diff options
author | Reuben Hawkins <reubenhwk@gmail.com> | 2011-05-20 07:01:38 -0700 |
---|---|---|
committer | Miklos Szeredi <mszeredi@suse.cz> | 2011-05-23 11:15:56 +0200 |
commit | 1193a39c0869a3608f22472735bcffdcccb6b2a5 (patch) | |
tree | 18f62331640b1d263ecc496f3c1eed1a4c16e037 /util | |
parent | d523ae8421eb506dbb8660e015c25fa9b16d0507 (diff) |
cleaning up warnings
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
Diffstat (limited to 'util')
-rw-r--r-- | util/fusermount.c | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/util/fusermount.c b/util/fusermount.c index 21e55f1..691e4fb 100644 --- a/util/fusermount.c +++ b/util/fusermount.c @@ -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); |