From: Yu Watanabe Date: Fri, 20 Jun 2025 22:08:12 +0000 (+0900) Subject: cpu-set-util: rename cpu_set_reset() -> cpu_set_done() X-Git-Tag: v258-rc1~238^2~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=296fe3d5115a3223d7ee92ed9314d7ceb31ca557;p=thirdparty%2Fsystemd.git cpu-set-util: rename cpu_set_reset() -> cpu_set_done() This also introduces cpu_set_done_and_replace(). No functional change, just refactoring. --- diff --git a/src/core/cgroup.c b/src/core/cgroup.c index dd6b065c449..7822360009c 100644 --- a/src/core/cgroup.c +++ b/src/core/cgroup.c @@ -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); diff --git a/src/core/dbus-cgroup.c b/src/core/dbus-cgroup.c index b8ca90bb21f..9fe0332135d 100644 --- a/src/core/dbus-cgroup.c +++ b/src/core/dbus-cgroup.c @@ -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); diff --git a/src/core/dbus-execute.c b/src/core/dbus-execute.c index e277849948a..8ad3ebc5fac 100644 --- a/src/core/dbus-execute.c +++ b/src/core/dbus-execute.c @@ -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; diff --git a/src/core/dbus-unit.c b/src/core/dbus-unit.c index 8d8169df55e..68837e8ee91 100644 --- a/src/core/dbus-unit.c +++ b/src/core/dbus-unit.c @@ -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; diff --git a/src/core/exec-invoke.c b/src/core/exec-invoke.c index dbba4295605..4660fe3ef15 100644 --- a/src/core/exec-invoke.c +++ b/src/core/exec-invoke.c @@ -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) { diff --git a/src/core/execute.c b/src/core/execute.c index 1fdb3190427..9157288352e 100644 --- a/src/core/execute.c +++ b/src/core/execute.c @@ -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); diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c index aae9cb1d2ab..fb8c786d247 100644 --- a/src/core/load-fragment.c +++ b/src/core/load-fragment.c @@ -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; } diff --git a/src/core/main.c b/src/core/main.c index d63814db1a7..22d4acfa07f 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -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); diff --git a/src/core/varlink-cgroup.c b/src/core/varlink-cgroup.c index ec401054597..7d8392bcea8 100644 --- a/src/core/varlink-cgroup.c +++ b/src/core/varlink-cgroup.c @@ -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); diff --git a/src/nspawn/nspawn-oci.c b/src/nspawn/nspawn-oci.c index ef3a2e31197..86c5dc2b048 100644 --- a/src/nspawn/nspawn-oci.c +++ b/src/nspawn/nspawn-oci.c @@ -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); diff --git a/src/nspawn/nspawn-settings.c b/src/nspawn/nspawn-settings.c index 7c04bf6147c..98b31d5d40c 100644 --- a/src/nspawn/nspawn-settings.c +++ b/src/nspawn/nspawn-settings.c @@ -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); diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c index 4edd092d3de..92e2c5ec20c 100644 --- a/src/nspawn/nspawn.c +++ b/src/nspawn/nspawn.c @@ -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 && diff --git a/src/shared/bus-unit-util.c b/src/shared/bus-unit-util.c index 4befd0a06c5..1c6a863c01b 100644 --- a/src/shared/bus-unit-util.c +++ b/src/shared/bus-unit-util.c @@ -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; diff --git a/src/shared/cpu-set-util.c b/src/shared/cpu-set-util.c index 8bad1e8741a..2e098b1bee2 100644 --- a/src/shared/cpu-set-util.c +++ b/src/shared/cpu-set-util.c @@ -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); diff --git a/src/shared/cpu-set-util.h b/src/shared/cpu-set-util.h index 50535fdc2f3..645e13cdf2d 100644 --- a/src/shared/cpu-set-util.h +++ b/src/shared/cpu-set-util.h @@ -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); diff --git a/src/shared/numa-util.c b/src/shared/numa-util.c index c06ad985d8c..8c18c582270 100644 --- a/src/shared/numa-util.c +++ b/src/shared/numa-util.c @@ -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; diff --git a/src/shared/numa-util.h b/src/shared/numa-util.h index 065df9b9a40..571d0d1354f 100644 --- a/src/shared/numa-util.h +++ b/src/shared/numa-util.h @@ -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; } diff --git a/src/systemctl/systemctl-show.c b/src/systemctl/systemctl-show.c index f6eeeb29c9e..e906c08772e 100644 --- a/src/systemctl/systemctl-show.c +++ b/src/systemctl/systemctl-show.c @@ -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; diff --git a/src/test/test-cpu-set-util.c b/src/test/test-cpu-set-util.c index 26189146664..9254a3a1eca 100644 --- a/src/test/test-cpu-set-util.c +++ b/src/test/test-cpu-set-util.c @@ -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); diff --git a/src/test/test-execute.c b/src/test/test-execute.c index 8d6b3443af6..335eb0d04cd 100644 --- a/src/test/test-execute.c +++ b/src/test/test-execute.c @@ -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)); diff --git a/src/udev/net/link-config.c b/src/udev/net/link-config.c index b10e48a4ae7..52cb36d099c 100644 --- a/src/udev/net/link-config.c +++ b/src/udev/net/link-config.c @@ -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);