cleaning up warnings
authorReuben Hawkins <reubenhwk@gmail.com>
Fri, 20 May 2011 14:01:38 +0000 (07:01 -0700)
committerMiklos Szeredi <mszeredi@suse.cz>
Mon, 23 May 2011 09:15:56 +0000 (11:15 +0200)
fprintf(stderr, whatever); -> fprintf(stderr, "%s", whatever);
checking return values on chdir and lockf where we weren't already

modified:   example/cusexmp.c
modified:   example/fioclient.c
modified:   util/fusermount.c

example/cusexmp.c
example/fioclient.c
util/fusermount.c

index 48ccf8c3882ce08c53ff07620d7410bf85350c69..900c98588d836c8a1f5b74b7e6d375f8b3fa37ad 100644 (file)
@@ -247,7 +247,7 @@ static int cusexmp_process_arg(void *data, const char *arg, int key,
        switch (key) {
        case 0:
                param->is_help = 1;
-               fprintf(stderr, usage);
+               fprintf(stderr, "%s", usage);
                return fuse_opt_add_arg(outargs, "-ho");
        default:
                return 1;
index c056186f704494c7c3d94bb1277aeb615d199795..5f05525f25ced1405c54862992b756e584521a62 100644 (file)
@@ -117,6 +117,6 @@ int main(int argc, char **argv)
        }
 
  usage:
-       fprintf(stderr, usage);
+       fprintf(stderr, "%s", usage);
        return 1;
 }
index 21e55f1c8802023edf5189a81c5c5c285881f8c1..691e4fbda790e19ce1bdafbeae4e6659ab9c362b 100644 (file)
@@ -127,7 +127,13 @@ static int lock_umount(void)
 static void unlock_umount(int mtablock)
 {
        if (mtablock >= 0) {
-               lockf(mtablock, F_ULOCK, 0);
+               int res;
+
+               res = lockf(mtablock, F_ULOCK, 0);
+               if (res < 0) {
+                       fprintf(stderr, "%s: error releasing lock: %s\n",
+                               progname, strerror(errno));
+               }
                close(mtablock);
        }
 }
@@ -438,10 +444,15 @@ static int unmount_fuse_locked(const char *mnt, int quiet, int lazy)
        }
 
 out:
-       chdir("/");
        if (res == -1)
                return -1;
 
+       res = chdir("/");
+       if (res == -1) {
+               fprintf(stderr, "%s: failed to chdir to '/'\n", progname);
+               return -1;
+       }
+
        return fuse_mnt_remove_mount(progname, mnt);
 }
 
@@ -1074,13 +1085,18 @@ static int mount_fuse(const char *mnt, const char *opts)
        } else
                restore_privs();
 
-       chdir("/");
        if (mountpoint_fd != -1)
                close(mountpoint_fd);
 
        if (res == -1)
                goto fail_close_fd;
 
+       res = chdir("/");
+       if (res == -1) {
+               fprintf(stderr, "%s: failed to chdir to '/'\n", progname);
+               goto fail_close_fd;
+       }
+
        if (geteuid() == 0) {
                res = add_mount(source, mnt, type, mnt_opts);
                if (res == -1) {
@@ -1279,7 +1295,11 @@ int main(int argc, char *argv[])
           btw We don't want to use daemon() function here because
           it forks and messes with the file descriptors. */
        setsid();
-       chdir("/");
+       res = chdir("/");
+       if (res == -1) {
+               fprintf(stderr, "%s: failed to chdir to '/'\n", progname);
+               exit(1);
+       }
 
        sigfillset(&sigset);
        sigprocmask(SIG_BLOCK, &sigset, NULL);