]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
cpu-set-util: rename cpu_set_reset() -> cpu_set_done()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 20 Jun 2025 22:08:12 +0000 (07:08 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 23 Jun 2025 15:20:20 +0000 (00:20 +0900)
This also introduces cpu_set_done_and_replace().

No functional change, just refactoring.

21 files changed:
src/core/cgroup.c
src/core/dbus-cgroup.c
src/core/dbus-execute.c
src/core/dbus-unit.c
src/core/exec-invoke.c
src/core/execute.c
src/core/load-fragment.c
src/core/main.c
src/core/varlink-cgroup.c
src/nspawn/nspawn-oci.c
src/nspawn/nspawn-settings.c
src/nspawn/nspawn.c
src/shared/bus-unit-util.c
src/shared/cpu-set-util.c
src/shared/cpu-set-util.h
src/shared/numa-util.c
src/shared/numa-util.h
src/systemctl/systemctl-show.c
src/test/test-cpu-set-util.c
src/test/test-execute.c
src/udev/net/link-config.c

index dd6b065c44963c1e239196bc6f2f4a70953320bf..7822360009c330091dc9b446ac87401841b81fc8 100644 (file)
@@ -267,10 +267,10 @@ void cgroup_context_done(CGroupContext *c) {
 
         c->restrict_network_interfaces = set_free(c->restrict_network_interfaces);
 
-        cpu_set_reset(&c->cpuset_cpus);
-        cpu_set_reset(&c->startup_cpuset_cpus);
-        cpu_set_reset(&c->cpuset_mems);
-        cpu_set_reset(&c->startup_cpuset_mems);
+        cpu_set_done(&c->cpuset_cpus);
+        cpu_set_done(&c->startup_cpuset_cpus);
+        cpu_set_done(&c->cpuset_mems);
+        cpu_set_done(&c->startup_cpuset_mems);
 
         c->delegate_subgroup = mfree(c->delegate_subgroup);
 
index b8ca90bb21fee6d6dc5467d61c57537acfba7e58..9fe0332135d5b9005ead176618a34f1aea28de26 100644 (file)
@@ -1241,7 +1241,7 @@ int bus_cgroup_set_property(
         } else if (STR_IN_SET(name, "AllowedCPUs", "StartupAllowedCPUs", "AllowedMemoryNodes", "StartupAllowedMemoryNodes")) {
                 const void *a;
                 size_t n;
-                _cleanup_(cpu_set_reset) CPUSet new_set = {};
+                _cleanup_(cpu_set_done) CPUSet new_set = {};
 
                 r = sd_bus_message_read_array(message, 'y', &a, &n);
                 if (r < 0)
@@ -1267,12 +1267,10 @@ int bus_cgroup_set_property(
                                 set = &c->cpuset_mems;
                         else if (streq(name, "StartupAllowedMemoryNodes"))
                                 set = &c->startup_cpuset_mems;
+                        else
+                                assert_not_reached();
 
-                        assert(set);
-
-                        cpu_set_reset(set);
-                        *set = new_set;
-                        new_set = (CPUSet) {};
+                        cpu_set_done_and_replace(*set, new_set);
 
                         unit_invalidate_cgroup(u, CGROUP_MASK_CPUSET);
                         unit_write_settingf(u, flags, name, "%s=\n%s=%s", name, name, setstr);
index e277849948a5052b6ad81ba4801cfad81f4e15b1..8ad3ebc5fac8b76c1782fac7ea63d9ad2b43007f 100644 (file)
@@ -115,7 +115,7 @@ static int property_get_cpu_affinity(
                 sd_bus_error *error) {
 
         ExecContext *c = ASSERT_PTR(userdata);
-        _cleanup_(cpu_set_reset) CPUSet s = {};
+        _cleanup_(cpu_set_done) CPUSet s = {};
         _cleanup_free_ uint8_t *array = NULL;
         size_t allocated;
 
@@ -2876,10 +2876,9 @@ int bus_exec_context_set_transient_property(
         }
 #endif
         if (STR_IN_SET(name, "CPUAffinity", "NUMAMask")) {
+                _cleanup_(cpu_set_done) CPUSet set = {};
                 const void *a;
                 size_t n;
-                bool affinity = streq(name, "CPUAffinity");
-                _cleanup_(cpu_set_reset) CPUSet set = {};
 
                 r = sd_bus_message_read_array(message, 'y', &a, &n);
                 if (r < 0)
@@ -2890,8 +2889,10 @@ int bus_exec_context_set_transient_property(
                         return r;
 
                 if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
+                        CPUSet *cpuset = streq(name, "CPUAffinity") ? &c->cpu_set : &c->numa_policy.nodes;
+
                         if (n == 0) {
-                                cpu_set_reset(affinity ? &c->cpu_set : &c->numa_policy.nodes);
+                                cpu_set_done(cpuset);
                                 unit_write_settingf(u, flags, name, "%s=", name);
                         } else {
                                 _cleanup_free_ char *str = NULL;
@@ -2903,7 +2904,7 @@ int bus_exec_context_set_transient_property(
                                 /* We forego any optimizations here, and always create the structure using
                                  * cpu_set_add_set(), because we don't want to care if the existing size we
                                  * got over dbus is appropriate. */
-                                r = cpu_set_add_set(affinity ? &c->cpu_set : &c->numa_policy.nodes, &set);
+                                r = cpu_set_add_set(cpuset, &set);
                                 if (r < 0)
                                         return r;
 
index 8d8169df55e599ca28b08c3946ebffe1ca815019..68837e8ee9189d064633710eb1f13c12008c87a3 100644 (file)
@@ -1154,7 +1154,7 @@ static int property_get_cpuset_cpus(
                 sd_bus_error *error) {
 
         Unit *u = ASSERT_PTR(userdata);
-        _cleanup_(cpu_set_reset) CPUSet cpus = {};
+        _cleanup_(cpu_set_done) CPUSet cpus = {};
         _cleanup_free_ uint8_t *array = NULL;
         size_t allocated;
 
@@ -1176,7 +1176,7 @@ static int property_get_cpuset_mems(
                 sd_bus_error *error) {
 
         Unit *u = ASSERT_PTR(userdata);
-        _cleanup_(cpu_set_reset) CPUSet mems = {};
+        _cleanup_(cpu_set_done) CPUSet mems = {};
         _cleanup_free_ uint8_t *array = NULL;
         size_t allocated;
 
index dbba429560513e53e5cd7616b0a4158afd7acfbf..4660fe3ef1540c2412f5427a0bca996cd2ecf445 100644 (file)
@@ -3990,7 +3990,7 @@ static int exec_context_cpu_affinity_from_numa(const ExecContext *c, CPUSet *ret
                 return 0;
         }
 
-        _cleanup_(cpu_set_reset) CPUSet s = {};
+        _cleanup_(cpu_set_done) CPUSet s = {};
         r = numa_to_cpu_set(&c->numa_policy, &s);
         if (r < 0)
                 return r;
@@ -5107,7 +5107,7 @@ int exec_invoke(
         }
 
         if (context->cpu_affinity_from_numa || context->cpu_set.set) {
-                _cleanup_(cpu_set_reset) CPUSet converted_cpu_set = {};
+                _cleanup_(cpu_set_done) CPUSet converted_cpu_set = {};
                 const CPUSet *cpu_set;
 
                 if (context->cpu_affinity_from_numa) {
index 1fdb3190427944f16043dc97e5c42e74657dd18f..9157288352ec0db1b050b85d691cc3a173894d99 100644 (file)
@@ -720,7 +720,7 @@ void exec_context_done(ExecContext *c) {
         c->n_temporary_filesystems = 0;
         c->mount_images = mount_image_free_many(c->mount_images, &c->n_mount_images);
 
-        cpu_set_reset(&c->cpu_set);
+        cpu_set_done(&c->cpu_set);
         numa_policy_reset(&c->numa_policy);
 
         c->utmp_id = mfree(c->utmp_id);
index aae9cb1d2ab8f735e9a2d48eccb3a358ad625511..fb8c786d24727595c49bb68a827c99169805fae3 100644 (file)
@@ -1834,7 +1834,7 @@ int config_parse_exec_cpu_affinity(
 
         if (streq(rvalue, "numa")) {
                 c->cpu_affinity_from_numa = true;
-                cpu_set_reset(&c->cpu_set);
+                cpu_set_done(&c->cpu_set);
 
                 return 0;
         }
index d63814db1a70354185b4f0a59ea809111ebb830f..22d4acfa07f57e463c5cd413cddf621aa5dd1749 100644 (file)
@@ -2787,7 +2787,7 @@ static void reset_arguments(void) {
         arg_machine_id = (sd_id128_t) {};
         arg_cad_burst_action = EMERGENCY_ACTION_REBOOT_FORCE;
 
-        cpu_set_reset(&arg_cpu_affinity);
+        cpu_set_done(&arg_cpu_affinity);
         numa_policy_reset(&arg_numa_policy);
 
         arg_random_seed = mfree(arg_random_seed);
index ec401054597885e477854f1beb28461d788f3125..7d8392bcea8c0918bb0cc1d9cc9564e55a2db562 100644 (file)
@@ -455,7 +455,7 @@ empty:
 
 static int effective_cpuset_build_json(sd_json_variant **ret, const char *name, void *userdata, const char *cpuset_name) {
         Unit *u = ASSERT_PTR(userdata);
-        _cleanup_(cpu_set_reset) CPUSet cpus = {};
+        _cleanup_(cpu_set_done) CPUSet cpus = {};
         int r;
 
         assert(ret);
index ef3a2e3119716a49e9e30a19f610d72324418b92..86c5dc2b04859873b70c76a08781f72de136eb5a 100644 (file)
@@ -1240,10 +1240,7 @@ static int oci_cgroup_cpu_cpus(const char *name, sd_json_variant *v, sd_json_dis
         if (r < 0)
                 return json_log(v, flags, r, "Failed to parse CPU set specification: %s", n);
 
-        cpu_set_reset(&data->cpu_set);
-        data->cpu_set = set;
-
-        return 0;
+        return cpu_set_done_and_replace(data->cpu_set, set);
 }
 
 static int oci_cgroup_cpu(const char *name, sd_json_variant *v, sd_json_dispatch_flags_t flags, void *userdata) {
@@ -1270,12 +1267,11 @@ static int oci_cgroup_cpu(const char *name, sd_json_variant *v, sd_json_dispatch
 
         r = oci_dispatch(v, table, flags, &data);
         if (r < 0) {
-                cpu_set_reset(&data.cpu_set);
+                cpu_set_done(&data.cpu_set);
                 return r;
         }
 
-        cpu_set_reset(&s->cpu_set);
-        s->cpu_set = data.cpu_set;
+        cpu_set_done_and_replace(s->cpu_set, data.cpu_set);
 
         if (data.weight != UINT64_MAX) {
                 r = settings_allocate_properties(s);
index 7c04bf6147cdac18625c3126da1d2517f89691c1..98b31d5d40cf5c603de16df2066f1958a620c396 100644 (file)
@@ -136,7 +136,7 @@ Settings* settings_free(Settings *s) {
         strv_free(s->syscall_deny_list);
         rlimit_free_all(s->rlimit);
         free(s->hostname);
-        cpu_set_reset(&s->cpu_set);
+        cpu_set_done(&s->cpu_set);
         strv_free(s->bind_user);
 
         strv_free(s->network_interfaces);
index 4edd092d3dee0979b81337ee0a9f230ab101aeaf..92e2c5ec20c7ca22280365033ce104fbe90fc6cb 100644 (file)
@@ -279,7 +279,7 @@ STATIC_DESTRUCTOR_REGISTER(arg_syscall_deny_list, strv_freep);
 STATIC_DESTRUCTOR_REGISTER(arg_seccomp, seccomp_releasep);
 #endif
 STATIC_DESTRUCTOR_REGISTER(arg_credentials, machine_credential_context_done);
-STATIC_DESTRUCTOR_REGISTER(arg_cpu_set, cpu_set_reset);
+STATIC_DESTRUCTOR_REGISTER(arg_cpu_set, cpu_set_done);
 STATIC_DESTRUCTOR_REGISTER(arg_sysctl, strv_freep);
 STATIC_DESTRUCTOR_REGISTER(arg_bind_user, strv_freep);
 STATIC_DESTRUCTOR_REGISTER(arg_settings_filename, freep);
@@ -1460,8 +1460,7 @@ static int parse_argv(int argc, char *argv[]) {
                         if (r < 0)
                                 return log_error_errno(r, "Failed to parse CPU affinity mask %s: %m", optarg);
 
-                        cpu_set_reset(&arg_cpu_set);
-                        arg_cpu_set = cpuset;
+                        cpu_set_done_and_replace(arg_cpu_set, cpuset);
                         arg_settings_mask |= SETTING_CPU_AFFINITY;
                         break;
                 }
@@ -4908,10 +4907,8 @@ static int merge_settings(Settings *settings, const char *path) {
 
                 if (!arg_settings_trusted)
                         log_warning("Ignoring CPUAffinity= setting, file '%s' is not trusted.", path);
-                else {
-                        cpu_set_reset(&arg_cpu_set);
-                        arg_cpu_set = TAKE_STRUCT(settings->cpu_set);
-                }
+                else
+                        cpu_set_done_and_replace(arg_cpu_set, settings->cpu_set);
         }
 
         if ((arg_settings_mask & SETTING_RESOLV_CONF) == 0 &&
index 4befd0a06c5595f81132c1822e6ffb7d9b95373e..1c6a863c01b2c47dc399240105d710017ba5cb4f 100644 (file)
@@ -615,7 +615,8 @@ static int bus_append_cgroup_property(sd_bus_message *m, const char *field, cons
                               "StartupAllowedCPUs",
                               "AllowedMemoryNodes",
                               "StartupAllowedMemoryNodes")) {
-                _cleanup_(cpu_set_reset) CPUSet cpuset = {};
+
+                _cleanup_(cpu_set_done) CPUSet cpuset = {};
                 _cleanup_free_ uint8_t *array = NULL;
                 size_t allocated;
 
@@ -1564,7 +1565,7 @@ static int bus_append_execute_property(sd_bus_message *m, const char *field, con
         }
 
         if (streq(field, "CPUAffinity")) {
-                _cleanup_(cpu_set_reset) CPUSet cpuset = {};
+                _cleanup_(cpu_set_done) CPUSet cpuset = {};
                 _cleanup_free_ uint8_t *array = NULL;
                 size_t allocated;
 
@@ -1599,7 +1600,7 @@ static int bus_append_execute_property(sd_bus_message *m, const char *field, con
         }
 
         if (streq(field, "NUMAMask")) {
-                _cleanup_(cpu_set_reset) CPUSet nodes = {};
+                _cleanup_(cpu_set_done) CPUSet nodes = {};
                 _cleanup_free_ uint8_t *array = NULL;
                 size_t allocated;
 
index 8bad1e8741aec4fdc83a170a34fed1c80f7e92e5..2e098b1bee250c22a6a9ad0f1611a2c3e10ec3f3 100644 (file)
@@ -117,11 +117,20 @@ char* cpu_set_to_mask_string(const CPUSet *c) {
         return TAKE_PTR(str) ?: strdup("0");
 }
 
+void cpu_set_done(CPUSet *c) {
+        assert(c);
+
+        if (c->set)
+                CPU_FREE(c->set);
+
+        *c = (CPUSet) {};
+}
+
 CPUSet* cpu_set_free(CPUSet *c) {
         if (!c)
                 return c;
 
-        cpu_set_reset(c);
+        cpu_set_done(c);
         return mfree(c);
 }
 
@@ -217,7 +226,7 @@ int parse_cpu_set_full(
                 unsigned line,
                 const char *lvalue) {
 
-        _cleanup_(cpu_set_reset) CPUSet c = {};
+        _cleanup_(cpu_set_done) CPUSet c = {};
         const char *p = ASSERT_PTR(rvalue);
 
         assert(cpu_set);
@@ -272,7 +281,7 @@ int parse_cpu_set_extend(
                 unsigned line,
                 const char *lvalue) {
 
-        _cleanup_(cpu_set_reset) CPUSet cpuset = {};
+        _cleanup_(cpu_set_done) CPUSet cpuset = {};
         int r;
 
         assert(old);
@@ -282,8 +291,8 @@ int parse_cpu_set_extend(
                 return r;
 
         if (!cpuset.set) {
-                /* An empty assignment resets the CPU list */
-                cpu_set_reset(old);
+                /* An empty assignment clears the CPU list */
+                cpu_set_done(old);
                 return 0;
         }
 
@@ -348,7 +357,7 @@ int cpu_set_to_dbus(const CPUSet *c, uint8_t **ret, size_t *ret_size) {
 }
 
 int cpu_set_from_dbus(const uint8_t *bits, size_t size, CPUSet *ret) {
-        _cleanup_(cpu_set_reset) CPUSet c = {};
+        _cleanup_(cpu_set_done) CPUSet c = {};
         int r;
 
         assert(bits || size == 0);
index 50535fdc2f316f5680cc79c0caec686cbda8d908..645e13cdf2d7c1080d2cd6fa7caca4cd120c4742 100644 (file)
@@ -11,12 +11,14 @@ typedef struct CPUSet {
         size_t allocated; /* in bytes */
 } CPUSet;
 
-static inline void cpu_set_reset(CPUSet *a) {
-        assert((a->allocated > 0) == !!a->set);
-        if (a->set)
-                CPU_FREE(a->set);
-        *a = (CPUSet) {};
-}
+void cpu_set_done(CPUSet *c);
+#define cpu_set_done_and_replace(a, b)                      \
+        ({                                                  \
+                CPUSet *_a = &(a), *_b = &(b);              \
+                cpu_set_done(_a);                           \
+                *_a = TAKE_STRUCT(*_b);                     \
+                0;                                          \
+        })
 
 CPUSet* cpu_set_free(CPUSet *c);
 DEFINE_TRIVIAL_CLEANUP_FUNC(CPUSet*, cpu_set_free);
index c06ad985d8c1446984a713e866cdcb2d67638297..8c18c582270ecd077cd200a5d42f8b85cb434f46 100644 (file)
@@ -91,17 +91,15 @@ int apply_numa_policy(const NUMAPolicy *policy) {
 }
 
 int numa_to_cpu_set(const NUMAPolicy *policy, CPUSet *ret) {
+        _cleanup_(cpu_set_done) CPUSet s = {};
         int r;
-        size_t i;
-        _cleanup_(cpu_set_reset) CPUSet s = {};
 
         assert(policy);
         assert(ret);
 
-        for (i = 0; i < policy->nodes.allocated * 8; i++) {
+        for (size_t i = 0; i < policy->nodes.allocated * 8; i++) {
                 _cleanup_free_ char *l = NULL;
                 char p[STRLEN("/sys/devices/system/node/node//cpulist") + DECIMAL_STR_MAX(size_t) + 1];
-                _cleanup_(cpu_set_reset) CPUSet part = {};
 
                 if (!CPU_ISSET_S(i, policy->nodes.allocated, policy->nodes.set))
                         continue;
@@ -112,6 +110,7 @@ int numa_to_cpu_set(const NUMAPolicy *policy, CPUSet *ret) {
                 if (r < 0)
                         return r;
 
+                _cleanup_(cpu_set_done) CPUSet part = {};
                 r = parse_cpu_set(l, &part);
                 if (r < 0)
                         return r;
index 065df9b9a40af193aea21d4fb5fce95231dfdb9a..571d0d1354f27c36b0f8d27f86426a803ae54c12 100644 (file)
@@ -23,7 +23,7 @@ static inline int numa_policy_get_type(const NUMAPolicy *p) {
 
 static inline void numa_policy_reset(NUMAPolicy *p) {
         assert(p);
-        cpu_set_reset(&p->nodes);
+        cpu_set_done(&p->nodes);
         p->type = -1;
 }
 
index f6eeeb29c9e394f50a146f22ddfded5ac0790af3..e906c08772e578d846808759d08e96c7bdb04e89 100644 (file)
@@ -1775,7 +1775,7 @@ static int print_property(const char *name, const char *expected_value, sd_bus_m
                                       "EffectiveCPUs", "EffectiveMemoryNodes")) {
 
                         _cleanup_free_ char *affinity = NULL;
-                        _cleanup_(cpu_set_reset) CPUSet set = {};
+                        _cleanup_(cpu_set_done) CPUSet set = {};
                         const void *a;
                         size_t n;
 
index 26189146664c792097f2081e24605fd80605232c..9254a3a1eca4363c8bc9205b905b555a5f26a96d 100644 (file)
@@ -41,14 +41,14 @@ TEST(parse_cpu_set) {
         /* empty */
         ASSERT_CPUSET_EMPTY(c);
         ASSERT_CPUSET_STRING(c, "", "", "0");
-        cpu_set_reset(&c);
+        cpu_set_done(&c);
 
         /* Single value */
         ASSERT_OK(parse_cpu_set("0", &c));
         ASSERT_CPUSET_COUNT(c, 1);
         ASSERT_CPUSET_ISSET(c, 0);
         ASSERT_CPUSET_STRING(c, "0", "0", "1");
-        cpu_set_reset(&c);
+        cpu_set_done(&c);
 
         /* Simple range (from CPUAffinity example) */
         ASSERT_OK(parse_cpu_set("1 2 4", &c));
@@ -57,7 +57,7 @@ TEST(parse_cpu_set) {
         ASSERT_CPUSET_ISSET(c, 2);
         ASSERT_CPUSET_ISSET(c, 4);
         ASSERT_CPUSET_STRING(c, "1 2 4", "1-2 4", "16");
-        cpu_set_reset(&c);
+        cpu_set_done(&c);
 
         /* A more interesting range */
         ASSERT_OK(parse_cpu_set("0 1 2 3 8 9 10 11", &c));
@@ -67,7 +67,7 @@ TEST(parse_cpu_set) {
         for (unsigned i = 8; i < 12; i++)
                 ASSERT_CPUSET_ISSET(c, i);
         ASSERT_CPUSET_STRING(c, "0 1 2 3 8 9 10 11", "0-3 8-11", "f0f");
-        cpu_set_reset(&c);
+        cpu_set_done(&c);
 
         /* Quoted strings */
         ASSERT_OK(parse_cpu_set("8 '9' 10 \"11\"", &c));
@@ -75,7 +75,7 @@ TEST(parse_cpu_set) {
         for (unsigned i = 8; i < 12; i++)
                 ASSERT_CPUSET_ISSET(c, i);
         ASSERT_CPUSET_STRING(c, "8 9 10 11", "8-11", "f00");
-        cpu_set_reset(&c);
+        cpu_set_done(&c);
 
         /* Use commas as separators */
         ASSERT_OK(parse_cpu_set("0,1,2,3 8,9,10,11", &c));
@@ -85,7 +85,7 @@ TEST(parse_cpu_set) {
         for (unsigned i = 8; i < 12; i++)
                 ASSERT_CPUSET_ISSET(c, i);
         ASSERT_CPUSET_STRING(c, "0 1 2 3 8 9 10 11", "0-3 8-11", "f0f");
-        cpu_set_reset(&c);
+        cpu_set_done(&c);
 
         /* Commas with spaces (and trailing comma, space) */
         ASSERT_OK(parse_cpu_set("0, 1, 2, 3, 4, 5, 6, 7, 63, ", &c));
@@ -94,7 +94,7 @@ TEST(parse_cpu_set) {
                 ASSERT_CPUSET_ISSET(c, i);
         ASSERT_CPUSET_ISSET(c, 63);
         ASSERT_CPUSET_STRING(c, "0 1 2 3 4 5 6 7 63", "0-7 63", "80000000,000000ff");
-        cpu_set_reset(&c);
+        cpu_set_done(&c);
 
         /* Ranges */
         ASSERT_OK(parse_cpu_set("0-3,8-11", &c));
@@ -104,7 +104,7 @@ TEST(parse_cpu_set) {
         for (unsigned i = 8; i < 12; i++)
                 ASSERT_CPUSET_ISSET(c, i);
         ASSERT_CPUSET_STRING(c, "0 1 2 3 8 9 10 11", "0-3 8-11", "f0f");
-        cpu_set_reset(&c);
+        cpu_set_done(&c);
 
         ASSERT_OK(parse_cpu_set("36-39,44-47", &c));
         ASSERT_CPUSET_COUNT(c, 8);
@@ -113,14 +113,14 @@ TEST(parse_cpu_set) {
         for (unsigned i = 44; i < 48; i++)
                 ASSERT_CPUSET_ISSET(c, i);
         ASSERT_CPUSET_STRING(c, "36 37 38 39 44 45 46 47", "36-39 44-47", "f0f0,00000000");
-        cpu_set_reset(&c);
+        cpu_set_done(&c);
 
         ASSERT_OK(parse_cpu_set("64-71", &c));
         ASSERT_CPUSET_COUNT(c, 8);
         for (unsigned i = 64; i < 72; i++)
                 ASSERT_CPUSET_ISSET(c, i);
         ASSERT_CPUSET_STRING(c, "64 65 66 67 68 69 70 71", "64-71", "ff,00000000,00000000");
-        cpu_set_reset(&c);
+        cpu_set_done(&c);
 
         /* Ranges with trailing comma, space */
         ASSERT_OK(parse_cpu_set("0-3  8-11, ", &c));
@@ -130,13 +130,13 @@ TEST(parse_cpu_set) {
         for (unsigned i = 8; i < 12; i++)
                 ASSERT_CPUSET_ISSET(c, i);
         ASSERT_CPUSET_STRING(c, "0 1 2 3 8 9 10 11", "0-3 8-11", "f0f");
-        cpu_set_reset(&c);
+        cpu_set_done(&c);
 
         /* Negative range (returns empty cpu_set) */
         ASSERT_OK(parse_cpu_set("3-0", &c));
         ASSERT_CPUSET_COUNT(c, 0);
         ASSERT_CPUSET_STRING(c, "", "", "0");
-        cpu_set_reset(&c);
+        cpu_set_done(&c);
 
         /* Overlapping ranges */
         ASSERT_OK(parse_cpu_set("0-7 4-11", &c));
@@ -144,7 +144,7 @@ TEST(parse_cpu_set) {
         for (unsigned i = 0; i < 12; i++)
                 ASSERT_CPUSET_ISSET(c, i);
         ASSERT_CPUSET_STRING(c, "0 1 2 3 4 5 6 7 8 9 10 11", "0-11", "fff");
-        cpu_set_reset(&c);
+        cpu_set_done(&c);
 
         /* Mix ranges and individual CPUs */
         ASSERT_OK(parse_cpu_set("0,2 4-11", &c));
@@ -154,7 +154,7 @@ TEST(parse_cpu_set) {
         for (unsigned i = 4; i < 12; i++)
                 ASSERT_CPUSET_ISSET(c, i);
         ASSERT_CPUSET_STRING(c, "0 2 4 5 6 7 8 9 10 11", "0 2 4-11", "ff5");
-        cpu_set_reset(&c);
+        cpu_set_done(&c);
 
         /* Garbage */
         ASSERT_ERROR(parse_cpu_set("0 1 2 3 garbage", &c), EINVAL);
@@ -185,7 +185,7 @@ TEST(parse_cpu_set) {
                 ASSERT_NOT_NULL(strextend_with_separator(&expected_mask, ",", i < 6 ? "ffffffff" : "00000000"));
 
         ASSERT_CPUSET_STRING(c, expected_str, "8000-8191", expected_mask);
-        cpu_set_reset(&c);
+        cpu_set_done(&c);
 }
 
 TEST(parse_cpu_set_extend) {
@@ -204,7 +204,7 @@ TEST(parse_cpu_set_extend) {
 }
 
 TEST(cpu_set_to_from_dbus) {
-        _cleanup_(cpu_set_reset) CPUSet c = {}, c2 = {};
+        _cleanup_(cpu_set_done) CPUSet c = {}, c2 = {};
 
         ASSERT_OK(parse_cpu_set("1 3 8 100-200", &c));
         ASSERT_CPUSET_COUNT(c, 104);
index 8d6b3443af697c3eeae8072f81a7cec011372010..335eb0d04cda3df1ee56fff124994b47bcb35281 100644 (file)
@@ -331,7 +331,7 @@ static void test_exec_bindpaths(Manager *m) {
 }
 
 static void test_exec_cpuaffinity(Manager *m) {
-        _cleanup_(cpu_set_reset) CPUSet c = {};
+        _cleanup_(cpu_set_done) CPUSet c = {};
 
         ASSERT_OK(cpu_set_realloc(&c, 8192)); /* just allocate the maximum possible size */
         ASSERT_OK_ERRNO(sched_getaffinity(0, c.allocated, c.set));
index b10e48a4ae7823eefd66a5b681e1b30c9367b1cf..52cb36d099ca5d013400fce34a0ac807bf018360 100644 (file)
@@ -1393,7 +1393,7 @@ int config_parse_rps_cpu_mask(
         }
 
         if (streq(rvalue, "disable"))
-                cpu_set_reset(mask);
+                cpu_set_done(mask);
 
         else if (streq(rvalue, "all")) {
                 r = cpu_set_add_all(mask);