]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
exec-invoke: modernize exec_context_cpu_affinity_from_numa()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 20 Jun 2025 20:56:51 +0000 (05:56 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 23 Jun 2025 15:20:20 +0000 (00:20 +0900)
- always assign 'ret' on success,
- do not modify previous assignment of 'ret', and simply overwrite it.

No functional change, just refactoring.

src/core/exec-invoke.c

index 9e7af81f1ef1259af29f99e1fe77a7d2e7247468..dbba429560513e53e5cd7616b0a4158afd7acfbf 100644 (file)
@@ -3979,7 +3979,6 @@ static int compile_suggested_paths(const ExecContext *c, const ExecParameters *p
 }
 
 static int exec_context_cpu_affinity_from_numa(const ExecContext *c, CPUSet *ret) {
-        _cleanup_(cpu_set_reset) CPUSet s = {};
         int r;
 
         assert(c);
@@ -3987,16 +3986,17 @@ static int exec_context_cpu_affinity_from_numa(const ExecContext *c, CPUSet *ret
 
         if (!c->numa_policy.nodes.set) {
                 log_debug("Can't derive CPU affinity mask from NUMA mask because NUMA mask is not set, ignoring");
+                *ret = (CPUSet) {};
                 return 0;
         }
 
+        _cleanup_(cpu_set_reset) CPUSet s = {};
         r = numa_to_cpu_set(&c->numa_policy, &s);
         if (r < 0)
                 return r;
 
-        cpu_set_reset(ret);
-
-        return cpu_set_add_all(ret, &s);
+        *ret = TAKE_STRUCT(s);
+        return 0;
 }
 
 static int add_shifted_fd(int *fds, size_t fds_size, size_t *n_fds, int *fd) {