diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2019-10-24 10:33:20 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2019-10-24 10:33:20 +0200 |
commit | 7abeefa9f9e55592db14f3fdafc01ea8f90311e4 (patch) | |
tree | f91422895ffeda469dabd808cd4155d76638cc81 /src/shared/switch-root.c | |
parent | 235ecb6d75f00384b3f42f449c769340e13fbd0b (diff) | |
download | systemd-chase-symlinks-rework.tar.gz |
basic/fs-util: change CHASE_OPEN flag into a separate output parameterchase-symlinks-rework
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/shared/switch-root.c')
-rw-r--r-- | src/shared/switch-root.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/shared/switch-root.c b/src/shared/switch-root.c index f721aff760..a807826378 100644 --- a/src/shared/switch-root.c +++ b/src/shared/switch-root.c @@ -52,7 +52,7 @@ int switch_root(const char *new_root, } /* Determine where we shall place the old root after the transition */ - r = chase_symlinks(old_root_after, new_root, CHASE_PREFIX_ROOT|CHASE_NONEXISTENT, &resolved_old_root_after); + r = chase_symlinks(old_root_after, new_root, CHASE_PREFIX_ROOT|CHASE_NONEXISTENT, &resolved_old_root_after, NULL); if (r < 0) return log_error_errno(r, "Failed to resolve %s/%s: %m", new_root, old_root_after); if (r == 0) /* Doesn't exist yet. Let's create it */ @@ -68,7 +68,7 @@ int switch_root(const char *new_root, FOREACH_STRING(i, "/sys", "/dev", "/run", "/proc") { _cleanup_free_ char *chased = NULL; - r = chase_symlinks(i, new_root, CHASE_PREFIX_ROOT|CHASE_NONEXISTENT, &chased); + r = chase_symlinks(i, new_root, CHASE_PREFIX_ROOT|CHASE_NONEXISTENT, &chased, NULL); if (r < 0) return log_error_errno(r, "Failed to resolve %s/%s: %m", new_root, i); if (r > 0) { |