From 04dc2db08a98d309675cabe0eb066c5f4f5ad02f Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 15 May 2023 11:53:07 +0200 Subject: mount-setup: minor modernization --- src/shared/mount-setup.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'src/shared') diff --git a/src/shared/mount-setup.c b/src/shared/mount-setup.c index e9cc57901c..edd37c193a 100644 --- a/src/shared/mount-setup.c +++ b/src/shared/mount-setup.c @@ -114,6 +114,8 @@ static const MountPoint mount_table[] = { NULL, MNT_NONE, }, }; +assert_cc(N_EARLY_MOUNT <= ELEMENTSOF(mount_table)); + bool mount_point_is_api(const char *path) { /* Checks if this mount point is considered "API", and hence * should be ignored */ @@ -211,27 +213,23 @@ static int mount_one(const MountPoint *p, bool relabel) { return 1; } -static int mount_points_setup(unsigned n, bool loaded_policy) { - unsigned i; - int r = 0; +static int mount_points_setup(size_t n, bool loaded_policy) { + int ret = 0, r; - for (i = 0; i < n; i ++) { - int j; + assert(n <= ELEMENTSOF(mount_table)); - j = mount_one(mount_table + i, loaded_policy); - if (j != 0 && r >= 0) - r = j; + FOREACH_ARRAY(mp, mount_table, n) { + r = mount_one(mp, loaded_policy); + if (r != 0 && ret >= 0) + ret = r; } - return r; + return ret; } int mount_setup_early(void) { - assert_cc(N_EARLY_MOUNT <= ELEMENTSOF(mount_table)); - - /* Do a minimal mount of /proc and friends to enable the most - * basic stuff, such as SELinux */ - return mount_points_setup(N_EARLY_MOUNT, false); + /* Do a minimal mount of /proc and friends to enable the most basic stuff, such as SELinux */ + return mount_points_setup(N_EARLY_MOUNT, /* loaded_policy= */ false); } static const char *join_with(const char *controller) { @@ -277,7 +275,7 @@ static int symlink_controller(const char *target, const char *alias) { p = strjoina("/sys/fs/cgroup/", target); r = mac_smack_copy(a, p); - if (r < 0 && r != -EOPNOTSUPP) + if (r < 0 && !ERRNO_IS_NOT_SUPPORTED(r)) return log_error_errno(r, "Failed to copy smack label from %s to %s: %m", p, a); #endif -- cgit v1.2.1