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 15:44:24 +0200 |
commit | a5648b809457d120500b2acb18b31e2168a4817a (patch) | |
tree | 59846b7791dce151e858a889f1281bad28c55ffe /src/delta/delta.c | |
parent | test-socket-util: avoid writing past the defined buffer (diff) | |
download | systemd-a5648b809457d120500b2acb18b31e2168a4817a.tar.xz systemd-a5648b809457d120500b2acb18b31e2168a4817a.zip |
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/delta/delta.c')
-rw-r--r-- | src/delta/delta.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/delta/delta.c b/src/delta/delta.c index bc11aa828a..cd33850b96 100644 --- a/src/delta/delta.c +++ b/src/delta/delta.c @@ -73,11 +73,11 @@ static int equivalent(const char *a, const char *b) { _cleanup_free_ char *x = NULL, *y = NULL; int r; - r = chase_symlinks(a, NULL, CHASE_TRAIL_SLASH, &x); + r = chase_symlinks(a, NULL, CHASE_TRAIL_SLASH, &x, NULL); if (r < 0) return r; - r = chase_symlinks(b, NULL, CHASE_TRAIL_SLASH, &y); + r = chase_symlinks(b, NULL, CHASE_TRAIL_SLASH, &y, NULL); if (r < 0) return r; @@ -378,7 +378,7 @@ static int should_skip_path(const char *prefix, const char *suffix) { dirname = prefix_roota(prefix, suffix); - if (chase_symlinks(dirname, NULL, 0, &target) < 0) + if (chase_symlinks(dirname, NULL, 0, &target, NULL) < 0) return false; NULSTR_FOREACH(p, prefixes) { |