summaryrefslogtreecommitdiff
path: root/src/core/main.c
diff options
context:
space:
mode:
authorFilipe Brandenburger <filbranden@google.com>2015-08-30 20:46:27 -0700
committerFilipe Brandenburger <filbranden@google.com>2015-08-31 17:15:56 -0700
commit4b40bc38b495bb0c986e7accf5897b164ccfee4d (patch)
tree081ad5ca971ce4b49f8d86e75e70ad3c319b5a97 /src/core/main.c
parent4457c2279e032832bccd6ec0895105e3d6e192cc (diff)
util: Declare a cleanup routine for a cpu_set_t
Make use of it in config_parse_cpu_affinity2. Tested by tweaking the `CPUAffinity' setting in /etc/systemd/system.conf and reloading the daemon to confirm it is working as expected. No regressions observed in test cases.
Diffstat (limited to 'src/core/main.c')
-rw-r--r--src/core/main.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/src/core/main.c b/src/core/main.c
index 9c2b0c0897..539c57a7b8 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -433,7 +433,7 @@ static int config_parse_cpu_affinity2(
void *data,
void *userdata) {
- cpu_set_t *c = NULL;
+ _cleanup_cpu_free_ cpu_set_t *c = NULL;
unsigned ncpus = 0;
assert(filename);
@@ -460,7 +460,6 @@ static int config_parse_cpu_affinity2(
if (r < 0 || cpu >= ncpus) {
log_syntax(unit, LOG_ERR, filename, line, -r,
"Failed to parse CPU affinity '%s'", rvalue);
- CPU_FREE(c);
return -EBADMSG;
}
@@ -470,13 +469,10 @@ static int config_parse_cpu_affinity2(
log_syntax(unit, LOG_ERR, filename, line, EINVAL,
"Trailing garbage, ignoring.");
- if (c) {
+ if (c)
if (sched_setaffinity(0, CPU_ALLOC_SIZE(ncpus), c) < 0)
log_warning("Failed to set CPU affinity: %m");
- CPU_FREE(c);
- }
-
return 0;
}