]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tree-wide: use cpu_set_mfree()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 30 Nov 2017 14:23:16 +0000 (23:23 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 6 Dec 2017 01:32:38 +0000 (10:32 +0900)
src/core/execute.c
src/test/test-cpu-set-util.c

index 62f8ca7731af8a1840974e469230b49ae6736fd8..acd767cf77b43e00a3789d0d44495fe0afefed41 100644 (file)
@@ -66,6 +66,7 @@
 #include "cap-list.h"
 #include "capability-util.h"
 #include "chown-recursive.h"
+#include "cpu-set-util.h"
 #include "def.h"
 #include "env-util.h"
 #include "errno-list.h"
@@ -3628,8 +3629,7 @@ void exec_context_done(ExecContext *c) {
 
         bind_mount_free_many(c->bind_mounts, c->n_bind_mounts);
 
-        if (c->cpuset)
-                CPU_FREE(c->cpuset);
+        c->cpuset = cpu_set_mfree(c->cpuset);
 
         c->utmp_id = mfree(c->utmp_id);
         c->selinux_context = mfree(c->selinux_context);
index 8de7bbe0df9cadc856563d9f38925cde6266fbbc..1a7220d17a052d6de47dc7a51ae9c597f3ac0e81 100644 (file)
@@ -33,7 +33,7 @@ static void test_parse_cpu_set(void) {
         assert_se(CPU_ISSET_S(1, CPU_ALLOC_SIZE(ncpus), c));
         assert_se(CPU_ISSET_S(2, CPU_ALLOC_SIZE(ncpus), c));
         assert_se(CPU_COUNT_S(CPU_ALLOC_SIZE(ncpus), c) == 2);
-        c = mfree(c);
+        c = cpu_set_mfree(c);
 
         /* A more interesting range */
         ncpus = parse_cpu_set_and_warn("0 1 2 3 8 9 10 11", &c, NULL, "fake", 1, "CPUAffinity");
@@ -43,7 +43,7 @@ static void test_parse_cpu_set(void) {
                 assert_se(CPU_ISSET_S(cpu, CPU_ALLOC_SIZE(ncpus), c));
         for (cpu = 8; cpu < 12; cpu++)
                 assert_se(CPU_ISSET_S(cpu, CPU_ALLOC_SIZE(ncpus), c));
-        c = mfree(c);
+        c = cpu_set_mfree(c);
 
         /* Quoted strings */
         ncpus = parse_cpu_set_and_warn("8 '9' 10 \"11\"", &c, NULL, "fake", 1, "CPUAffinity");
@@ -51,7 +51,7 @@ static void test_parse_cpu_set(void) {
         assert_se(CPU_COUNT_S(CPU_ALLOC_SIZE(ncpus), c) == 4);
         for (cpu = 8; cpu < 12; cpu++)
                 assert_se(CPU_ISSET_S(cpu, CPU_ALLOC_SIZE(ncpus), c));
-        c = mfree(c);
+        c = cpu_set_mfree(c);
 
         /* Use commas as separators */
         ncpus = parse_cpu_set_and_warn("0,1,2,3 8,9,10,11", &c, NULL, "fake", 1, "CPUAffinity");
@@ -61,7 +61,7 @@ static void test_parse_cpu_set(void) {
                 assert_se(CPU_ISSET_S(cpu, CPU_ALLOC_SIZE(ncpus), c));
         for (cpu = 8; cpu < 12; cpu++)
                 assert_se(CPU_ISSET_S(cpu, CPU_ALLOC_SIZE(ncpus), c));
-        c = mfree(c);
+        c = cpu_set_mfree(c);
 
         /* Commas with spaces (and trailing comma, space) */
         ncpus = parse_cpu_set_and_warn("0, 1, 2, 3, 4, 5, 6, 7, ", &c, NULL, "fake", 1, "CPUAffinity");
@@ -69,7 +69,7 @@ static void test_parse_cpu_set(void) {
         assert_se(CPU_COUNT_S(CPU_ALLOC_SIZE(ncpus), c) == 8);
         for (cpu = 0; cpu < 8; cpu++)
                 assert_se(CPU_ISSET_S(cpu, CPU_ALLOC_SIZE(ncpus), c));
-        c = mfree(c);
+        c = cpu_set_mfree(c);
 
         /* Ranges */
         ncpus = parse_cpu_set_and_warn("0-3,8-11", &c, NULL, "fake", 1, "CPUAffinity");
@@ -79,7 +79,7 @@ static void test_parse_cpu_set(void) {
                 assert_se(CPU_ISSET_S(cpu, CPU_ALLOC_SIZE(ncpus), c));
         for (cpu = 8; cpu < 12; cpu++)
                 assert_se(CPU_ISSET_S(cpu, CPU_ALLOC_SIZE(ncpus), c));
-        c = mfree(c);
+        c = cpu_set_mfree(c);
 
         /* Ranges with trailing comma, space */
         ncpus = parse_cpu_set_and_warn("0-3  8-11, ", &c, NULL, "fake", 1, "CPUAffinity");
@@ -89,13 +89,13 @@ static void test_parse_cpu_set(void) {
                 assert_se(CPU_ISSET_S(cpu, CPU_ALLOC_SIZE(ncpus), c));
         for (cpu = 8; cpu < 12; cpu++)
                 assert_se(CPU_ISSET_S(cpu, CPU_ALLOC_SIZE(ncpus), c));
-        c = mfree(c);
+        c = cpu_set_mfree(c);
 
         /* Negative range (returns empty cpu_set) */
         ncpus = parse_cpu_set_and_warn("3-0", &c, NULL, "fake", 1, "CPUAffinity");
         assert_se(ncpus >= 1024);
         assert_se(CPU_COUNT_S(CPU_ALLOC_SIZE(ncpus), c) == 0);
-        c = mfree(c);
+        c = cpu_set_mfree(c);
 
         /* Overlapping ranges */
         ncpus = parse_cpu_set_and_warn("0-7 4-11", &c, NULL, "fake", 1, "CPUAffinity");
@@ -103,7 +103,7 @@ static void test_parse_cpu_set(void) {
         assert_se(CPU_COUNT_S(CPU_ALLOC_SIZE(ncpus), c) == 12);
         for (cpu = 0; cpu < 12; cpu++)
                 assert_se(CPU_ISSET_S(cpu, CPU_ALLOC_SIZE(ncpus), c));
-        c = mfree(c);
+        c = cpu_set_mfree(c);
 
         /* Mix ranges and individual CPUs */
         ncpus = parse_cpu_set_and_warn("0,1 4-11", &c, NULL, "fake", 1, "CPUAffinity");
@@ -113,7 +113,7 @@ static void test_parse_cpu_set(void) {
         assert_se(CPU_ISSET_S(1, CPU_ALLOC_SIZE(ncpus), c));
         for (cpu = 4; cpu < 12; cpu++)
                 assert_se(CPU_ISSET_S(cpu, CPU_ALLOC_SIZE(ncpus), c));
-        c = mfree(c);
+        c = cpu_set_mfree(c);
 
         /* Garbage */
         ncpus = parse_cpu_set_and_warn("0 1 2 3 garbage", &c, NULL, "fake", 1, "CPUAffinity");