From b205e59ad49aa0ea69496c43ffbc467299e85d21 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 14 Dec 2022 17:52:31 +0900 Subject: [PATCH] mountpoint-util: rename mount_propagation_flags_to_string() and friends as singular --- src/basic/mountpoint-util.c | 4 ++-- src/basic/mountpoint-util.h | 4 ++-- src/core/dbus-execute.c | 6 +++--- src/core/load-fragment.c | 2 +- src/shared/bus-print-properties.c | 2 +- src/shared/bus-unit-util.c | 4 ++-- src/test/test-mountpoint-util.c | 22 +++++++++++----------- 7 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/basic/mountpoint-util.c b/src/basic/mountpoint-util.c index 09fbdcfebec..0c9fc0a3505 100644 --- a/src/basic/mountpoint-util.c +++ b/src/basic/mountpoint-util.c @@ -568,7 +568,7 @@ int mount_nofollow( return mount_fd(source, fd, filesystemtype, mountflags, data); } -const char *mount_propagation_flags_to_string(unsigned long flags) { +const char *mount_propagation_flag_to_string(unsigned long flags) { switch (flags & (MS_SHARED|MS_SLAVE|MS_PRIVATE)) { case 0: @@ -584,7 +584,7 @@ const char *mount_propagation_flags_to_string(unsigned long flags) { return NULL; } -int mount_propagation_flags_from_string(const char *name, unsigned long *ret) { +int mount_propagation_flag_from_string(const char *name, unsigned long *ret) { if (isempty(name)) *ret = 0; diff --git a/src/basic/mountpoint-util.h b/src/basic/mountpoint-util.h index da5d852ff3e..c7b24584da2 100644 --- a/src/basic/mountpoint-util.h +++ b/src/basic/mountpoint-util.h @@ -55,5 +55,5 @@ int dev_is_devtmpfs(void); int mount_fd(const char *source, int target_fd, const char *filesystemtype, unsigned long mountflags, const void *data); int mount_nofollow(const char *source, const char *target, const char *filesystemtype, unsigned long mountflags, const void *data); -const char *mount_propagation_flags_to_string(unsigned long flags); -int mount_propagation_flags_from_string(const char *name, unsigned long *ret); +const char *mount_propagation_flag_to_string(unsigned long flags); +int mount_propagation_flag_from_string(const char *name, unsigned long *ret); diff --git a/src/core/dbus-execute.c b/src/core/dbus-execute.c index c5a51bf5cd8..4b41cfe778c 100644 --- a/src/core/dbus-execute.c +++ b/src/core/dbus-execute.c @@ -1599,11 +1599,11 @@ static int parse_personality(const char *s, unsigned long *p) { return 0; } -static const char* mount_propagation_flags_to_string_with_check(unsigned long n) { +static const char* mount_propagation_flag_to_string_with_check(unsigned long n) { if (!IN_SET(n, 0, MS_SHARED, MS_PRIVATE, MS_SLAVE)) return NULL; - return mount_propagation_flags_to_string(n); + return mount_propagation_flag_to_string(n); } static BUS_DEFINE_SET_TRANSIENT(nsec, "t", uint64_t, nsec_t, NSEC_FMT); @@ -1624,7 +1624,7 @@ static BUS_DEFINE_SET_TRANSIENT_PARSE_PTR(personality, unsigned long, parse_pers static BUS_DEFINE_SET_TRANSIENT_TO_STRING_ALLOC(secure_bits, "i", int32_t, int, "%" PRIi32, secure_bits_to_string_alloc_with_check); static BUS_DEFINE_SET_TRANSIENT_TO_STRING_ALLOC(capability, "t", uint64_t, uint64_t, "%" PRIu64, capability_set_to_string_alloc); static BUS_DEFINE_SET_TRANSIENT_TO_STRING_ALLOC(namespace_flag, "t", uint64_t, unsigned long, "%" PRIu64, namespace_flags_to_string); -static BUS_DEFINE_SET_TRANSIENT_TO_STRING(mount_flags, "t", uint64_t, unsigned long, "%" PRIu64, mount_propagation_flags_to_string_with_check); +static BUS_DEFINE_SET_TRANSIENT_TO_STRING(mount_flags, "t", uint64_t, unsigned long, "%" PRIu64, mount_propagation_flag_to_string_with_check); int bus_exec_context_set_transient_property( Unit *u, diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c index 734a5941cc1..ac8c64fe3b9 100644 --- a/src/core/load-fragment.c +++ b/src/core/load-fragment.c @@ -149,7 +149,7 @@ DEFINE_CONFIG_PARSE_PTR(config_parse_blockio_weight, cg_blkio_weight_parse, uint DEFINE_CONFIG_PARSE_PTR(config_parse_cg_weight, cg_weight_parse, uint64_t, "Invalid weight"); DEFINE_CONFIG_PARSE_PTR(config_parse_cg_cpu_weight, cg_cpu_weight_parse, uint64_t, "Invalid CPU weight"); static DEFINE_CONFIG_PARSE_PTR(config_parse_cpu_shares_internal, cg_cpu_shares_parse, uint64_t, "Invalid CPU shares"); -DEFINE_CONFIG_PARSE_PTR(config_parse_exec_mount_flags, mount_propagation_flags_from_string, unsigned long, "Failed to parse mount flag"); +DEFINE_CONFIG_PARSE_PTR(config_parse_exec_mount_flags, mount_propagation_flag_from_string, unsigned long, "Failed to parse mount flag"); DEFINE_CONFIG_PARSE_ENUM_WITH_DEFAULT(config_parse_numa_policy, mpol, int, -1, "Invalid NUMA policy type"); DEFINE_CONFIG_PARSE_ENUM(config_parse_status_unit_format, status_unit_format, StatusUnitFormat, "Failed to parse status unit format"); DEFINE_CONFIG_PARSE_ENUM_FULL(config_parse_socket_timestamping, socket_timestamping_from_string_harder, SocketTimestamping, "Failed to parse timestamping precision"); diff --git a/src/shared/bus-print-properties.c b/src/shared/bus-print-properties.c index b0267427fa1..9369866fa1a 100644 --- a/src/shared/bus-print-properties.c +++ b/src/shared/bus-print-properties.c @@ -136,7 +136,7 @@ static int bus_print_property(const char *name, const char *expected_value, sd_b } else if (streq(name, "MountFlags")) { const char *result; - result = mount_propagation_flags_to_string(u); + result = mount_propagation_flag_to_string(u); if (!result) return -EINVAL; diff --git a/src/shared/bus-unit-util.c b/src/shared/bus-unit-util.c index 6b6383b60b7..7d136df2d92 100644 --- a/src/shared/bus-unit-util.c +++ b/src/shared/bus-unit-util.c @@ -131,7 +131,7 @@ DEFINE_BUS_APPEND_PARSE_PTR("t", uint64_t, uint64_t, cg_blkio_weight_parse); DEFINE_BUS_APPEND_PARSE_PTR("t", uint64_t, uint64_t, cg_cpu_shares_parse); DEFINE_BUS_APPEND_PARSE_PTR("t", uint64_t, uint64_t, cg_weight_parse); DEFINE_BUS_APPEND_PARSE_PTR("t", uint64_t, uint64_t, cg_cpu_weight_parse); -DEFINE_BUS_APPEND_PARSE_PTR("t", uint64_t, unsigned long, mount_propagation_flags_from_string); +DEFINE_BUS_APPEND_PARSE_PTR("t", uint64_t, unsigned long, mount_propagation_flag_from_string); DEFINE_BUS_APPEND_PARSE_PTR("t", uint64_t, uint64_t, safe_atou64); DEFINE_BUS_APPEND_PARSE_PTR("u", uint32_t, mode_t, parse_mode); DEFINE_BUS_APPEND_PARSE_PTR("u", uint32_t, unsigned, safe_atou); @@ -1035,7 +1035,7 @@ static int bus_append_execute_property(sd_bus_message *m, const char *field, con return bus_append_safe_atou(m, field, eq); if (streq(field, "MountFlags")) - return bus_append_mount_propagation_flags_from_string(m, field, eq); + return bus_append_mount_propagation_flag_from_string(m, field, eq); if (STR_IN_SET(field, "Environment", "UnsetEnvironment", diff --git a/src/test/test-mountpoint-util.c b/src/test/test-mountpoint-util.c index ccf18ecd9c5..c4a87d253e9 100644 --- a/src/test/test-mountpoint-util.c +++ b/src/test/test-mountpoint-util.c @@ -17,19 +17,19 @@ #include "tests.h" #include "tmpfile-util.h" -static void test_mount_propagation_flags_one(const char *name, int ret, unsigned long expected) { +static void test_mount_propagation_flag_one(const char *name, int ret, unsigned long expected) { unsigned long flags; log_info("/* %s(%s) */", __func__, strnull(name)); - assert_se(mount_propagation_flags_from_string(name, &flags) == ret); + assert_se(mount_propagation_flag_from_string(name, &flags) == ret); if (ret >= 0) { const char *c; assert_se(flags == expected); - c = mount_propagation_flags_to_string(flags); + c = mount_propagation_flag_to_string(flags); if (isempty(name)) assert_se(isempty(c)); else @@ -37,14 +37,14 @@ static void test_mount_propagation_flags_one(const char *name, int ret, unsigned } } -TEST(mount_propagation_flags) { - test_mount_propagation_flags_one("shared", 0, MS_SHARED); - test_mount_propagation_flags_one("slave", 0, MS_SLAVE); - test_mount_propagation_flags_one("private", 0, MS_PRIVATE); - test_mount_propagation_flags_one(NULL, 0, 0); - test_mount_propagation_flags_one("", 0, 0); - test_mount_propagation_flags_one("xxxx", -EINVAL, 0); - test_mount_propagation_flags_one(" ", -EINVAL, 0); +TEST(mount_propagation_flag) { + test_mount_propagation_flag_one("shared", 0, MS_SHARED); + test_mount_propagation_flag_one("slave", 0, MS_SLAVE); + test_mount_propagation_flag_one("private", 0, MS_PRIVATE); + test_mount_propagation_flag_one(NULL, 0, 0); + test_mount_propagation_flag_one("", 0, 0); + test_mount_propagation_flag_one("xxxx", -EINVAL, 0); + test_mount_propagation_flag_one(" ", -EINVAL, 0); } TEST(mnt_id) { -- 2.47.3