diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2019-10-24 10:33:20 +0200 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2019-10-24 22:44:24 +0900 |
commit | a5648b809457d120500b2acb18b31e2168a4817a (patch) | |
tree | 59846b7791dce151e858a889f1281bad28c55ffe /src/mount | |
parent | 58ce85f6a17b6db03265e6a974120b18d1c0855a (diff) | |
download | systemd-a5648b809457d120500b2acb18b31e2168a4817a.tar.gz |
basic/fs-util: change CHASE_OPEN flag into a separate output parameter
chase_symlinks() would return negative on error, and either a non-negative status
or a non-negative fd when CHASE_OPEN was given. This made the interface quite
complicated, because dependning on the flags used, we would get two different
"types" of return object. Coverity was always confused by this, and flagged
every use of chase_symlinks() without CHASE_OPEN as a resource leak (because it
would this that an fd is returned). This patch uses a saparate output parameter,
so there is no confusion.
(I think it is OK to have functions which return either an error or an fd. It's
only returning *either* an fd or a non-fd that is confusing.)
Diffstat (limited to 'src/mount')
-rw-r--r-- | src/mount/mount-tool.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/mount/mount-tool.c b/src/mount/mount-tool.c index 457ba4ea16..9f0220a75e 100644 --- a/src/mount/mount-tool.c +++ b/src/mount/mount-tool.c @@ -360,7 +360,7 @@ static int parse_argv(int argc, char *argv[]) { if (!u) return log_oom(); - r = chase_symlinks(u, NULL, 0, &arg_mount_what); + r = chase_symlinks(u, NULL, 0, &arg_mount_what, NULL); if (r < 0) return log_error_errno(r, "Failed to make path %s absolute: %m", u); } else { @@ -377,7 +377,7 @@ static int parse_argv(int argc, char *argv[]) { if (argc > optind+1) { if (arg_transport == BUS_TRANSPORT_LOCAL) { - r = chase_symlinks(argv[optind+1], NULL, CHASE_NONEXISTENT, &arg_mount_where); + r = chase_symlinks(argv[optind+1], NULL, CHASE_NONEXISTENT, &arg_mount_where, NULL); if (r < 0) return log_error_errno(r, "Failed to make path %s absolute: %m", argv[optind+1]); } else { @@ -1004,7 +1004,7 @@ static int action_umount( if (!u) return log_oom(); - r = chase_symlinks(u, NULL, 0, &p); + r = chase_symlinks(u, NULL, 0, &p, NULL); if (r < 0) { r2 = log_error_errno(r, "Failed to make path %s absolute: %m", argv[i]); continue; |