]> granicus.if.org Git - sudo/commitdiff
Quiet some compiler warnings
authorTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 16 May 2012 20:06:30 +0000 (16:06 -0400)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 16 May 2012 20:06:30 +0000 (16:06 -0400)
--HG--
branch : 1.7

ldap.c
parse.c
sudo_edit.c
sudoreplay.c
visudo.c

diff --git a/ldap.c b/ldap.c
index 35c13159b946b7f5e558618e36d723a46ef5a823..7ec35a91dc577608a91453b3548929ac50304eca 100644 (file)
--- a/ldap.c
+++ b/ldap.c
@@ -1667,24 +1667,19 @@ sudo_ldap_display_entry_short(ld, entry, lbuf)
     /* get the Option Values from the entry */
     bv = ldap_get_values_len(ld, entry, "sudoOption");
     if (bv != NULL) {
-       char *cp, *tag;
-
        for (p = bv; *p != NULL; p++) {
-           cp = (*p)->bv_val;
+           char *cp = (*p)->bv_val;
            if (*cp == '!')
                cp++;
-           tag = NULL;
            if (strcmp(cp, "authenticate") == 0)
-               tag = (*p)->bv_val[0] == '!' ?
-                   "NOPASSWD: " : "PASSWD: ";
+               lbuf_append(lbuf, (*p)->bv_val[0] == '!' ?
+                   "NOPASSWD: " : "PASSWD: ");
            else if (strcmp(cp, "noexec") == 0)
-               tag = (*p)->bv_val[0] == '!' ?
-                   "EXEC: " : "NOEXEC: ";
+               lbuf_append(lbuf, (*p)->bv_val[0] == '!' ?
+                   "EXEC: " : "NOEXEC: ");
            else if (strcmp(cp, "setenv") == 0)
-               tag = (*p)->bv_val[0] == '!' ?
-                   "NOSETENV: " : "SETENV: ";
-           if (tag != NULL)
-               lbuf_append(lbuf, tag);
+               lbuf_append(lbuf, (*p)->bv_val[0] == '!' ?
+                   "NOSETENV: " : "SETENV: ");
        }
        ldap_value_free_len(bv);
     }
diff --git a/parse.c b/parse.c
index 96b02ab7b744611bd308a398f4de4551978d8976..5cb78bb512dd4371c205f097247d9bfd29275d9b 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -480,10 +480,9 @@ sudo_file_display_defaults(nss, pw, lbuf)
            case DEFAULTS_CMND:
                continue;
        }
-       lbuf_append(lbuf, prefix);
        if (d->val != NULL) {
-           lbuf_append(lbuf, "%s%s", d->var, d->op == '+' ? "+=" :
-               d->op == '-' ? "-=" : "=");
+           lbuf_append(lbuf, "%s%s%s", prefix, d->var,
+               d->op == '+' ? "+=" : d->op == '-' ? "-=" : "=");
            if (strpbrk(d->val, " \t") != NULL) {
                lbuf_append(lbuf, "\"");
                lbuf_append_quoted(lbuf, "\"", "%s", d->val);
@@ -491,7 +490,8 @@ sudo_file_display_defaults(nss, pw, lbuf)
            } else
                lbuf_append_quoted(lbuf, SUDOERS_QUOTED, "%s", d->val);
        } else
-           lbuf_append(lbuf, "%s%s", d->op == FALSE ? "!" : "", d->var);
+           lbuf_append(lbuf, "%s%s%s", prefix,
+               d->op == FALSE ? "!" : "", d->var);
        prefix = ", ";
        nfound++;
     }
index f8666d9555b80a0d075d622b9c4325e682d649ec..b3b1896260f326f6080b9616ca2c4936e68f83aa 100644 (file)
@@ -81,7 +81,7 @@ sudo_edit(argc, argv, envp)
        char *ofile;
        struct timeval omtim;
        off_t osize;
-    } *tf;
+    } *tf = NULL;
 
     /* Determine user's editor. */
     editor = find_editor(&editor_argc, &editor_argv);
@@ -282,9 +282,11 @@ sudo_edit(argc, argv, envp)
     return rval;
 cleanup:
     /* Clean up temp files and return. */
-    for (i = 0; i < nfiles; i++) {
-       if (tf[i].tfile != NULL)
-           unlink(tf[i].tfile);
+    if (tf != NULL) {
+       for (i = 0; i < nfiles; i++) {
+           if (tf[i].tfile != NULL)
+               unlink(tf[i].tfile);
+       }
     }
     return 1;
 }
index 7d43faf90165e10b26f1e3140382691a1a4e3c1a..56a27cb0fe4468b78cf4a7b03a8015b335d319bb 100644 (file)
@@ -200,7 +200,7 @@ static void check_input __P((int, double *));
 static void delay __P((double));
 static void help __P((void)) __attribute__((__noreturn__));
 static void usage __P((int));
-static void *open_io_fd __P((char *pathbuf, int len, const char *suffix));
+static int open_io_fd __P((char *pathbuf, int len, const char *suffix, union io_fd *fdp));
 static int parse_timing __P((const char *buf, const char *decimal, int *idx, double *seconds, size_t *nbytes));
 
 #ifdef HAVE_REGCOMP
@@ -300,15 +300,14 @@ main(argc, argv)
     plen = snprintf(path, sizeof(path), "%s/%.2s/%.2s/%.2s/timing",
        session_dir, id, &id[2], &id[4]);
     if (plen <= 0 || plen >= sizeof(path))
-       errorx(1, "%s/%.2s/%.2s/%.2s/%.2s/timing: %s", session_dir,
+       errorx(1, "%s/%.2s/%.2s/%.2s/timing: %s", session_dir,
            id, &id[2], &id[4], strerror(ENAMETOOLONG));
     plen -= 7;
 
     /* Open files for replay, applying replay filter for the -f flag. */
     for (idx = 0; idx < IOFD_MAX; idx++) {
        if (ISSET(replay_filter, 1 << idx) || idx == IOFD_TIMING) {
-           io_fds[idx].v = open_io_fd(path, plen, io_fnames[idx]);
-           if (io_fds[idx].v == NULL)
+           if (open_io_fd(path, plen, io_fnames[idx], &io_fds[idx]) == -1)
                error(1, "unable to open %s", path);
        }
     }
@@ -442,19 +441,22 @@ delay(secs)
        error(1, "nanosleep: tv_sec %ld, tv_nsec %ld", ts.tv_sec, ts.tv_nsec);
 }
 
-static void *
-open_io_fd(path, len, suffix)
+static int
+open_io_fd(path, len, suffix, fdp)
     char *path;
     int len;
     const char *suffix;
+    union io_fd *fdp;
 {
     path[len] = '\0';
     strlcat(path, suffix, PATH_MAX);
 
 #ifdef HAVE_ZLIB_H
-    return gzopen(path, "r");
+    fdp->g = gzopen(path, "r");
+    return fdp->g ? 0 : -1;
 #else
-    return fopen(path, "r");
+    fdp->f = fopen(path, "r");
+    return fdp->f ? 0 : -1;
 #endif
 }
 
index bfdaf83c9b9a922f7ae115e6ad762ecf0f0f89cc..e19b9864a2409c962468cfdc5b5d68eda5550265 100644 (file)
--- a/visudo.c
+++ b/visudo.c
@@ -185,9 +185,8 @@ main(argc, argv)
                usage(1);
        }
     }
-    argc -= optind;
-    argv += optind;
-    if (argc)
+    /* There should be no other command line arguments. */
+    if (argc - optind != 0)
        usage(1);
 
     sudo_setpwent();