From 51bf9b1ac33657d0e2ce056f388cf20009b3adbf Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Tue, 22 Aug 2023 20:05:41 +0900 Subject: [PATCH] core/namespace: do not return 1 unnecessarily The caller of this function apply_mounts() -> apply_one_mount() only checks if the return value is negative or not. --- src/core/namespace.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/src/core/namespace.c b/src/core/namespace.c index 17fc416d981..2197287fd08 100644 --- a/src/core/namespace.c +++ b/src/core/namespace.c @@ -1051,11 +1051,7 @@ static int mount_bind_dev(const MountEntry *m) { if (r > 0) /* make this a NOP if /dev is already a mount point */ return 0; - r = mount_nofollow_verbose(LOG_DEBUG, "/dev", mount_entry_path(m), NULL, MS_BIND|MS_REC, NULL); - if (r < 0) - return r; - - return 1; + return mount_nofollow_verbose(LOG_DEBUG, "/dev", mount_entry_path(m), NULL, MS_BIND|MS_REC, NULL); } static int mount_bind_sysfs(const MountEntry *m) { @@ -1072,11 +1068,7 @@ static int mount_bind_sysfs(const MountEntry *m) { return 0; /* Bind mount the host's version so that we get all child mounts of it, too. */ - r = mount_nofollow_verbose(LOG_DEBUG, "/sys", mount_entry_path(m), NULL, MS_BIND|MS_REC, NULL); - if (r < 0) - return r; - - return 1; + return mount_nofollow_verbose(LOG_DEBUG, "/sys", mount_entry_path(m), NULL, MS_BIND|MS_REC, NULL); } static int mount_private_sysfs(const MountEntry *m) { @@ -1213,7 +1205,7 @@ static int mount_tmpfs(const MountEntry *m) { if (r < 0) return log_debug_errno(r, "Failed to fix label of '%s' as '%s': %m", entry_path, inner_path); - return 1; + return 0; } static int mount_run(const MountEntry *m) { @@ -1311,7 +1303,7 @@ static int mount_image( if (r < 0) return log_debug_errno(r, "Failed to mount image %s on %s: %m", mount_entry_source(m), mount_entry_path(m)); - return 1; + return 0; } static int mount_overlay(const MountEntry *m) { @@ -1327,10 +1319,8 @@ static int mount_overlay(const MountEntry *m) { r = mount_nofollow_verbose(LOG_DEBUG, "overlay", mount_entry_path(m), "overlay", MS_RDONLY, options); if (r == -ENOENT && m->ignore) return 0; - if (r < 0) - return r; - return 1; + return r; } static int follow_symlink( -- 2.47.3