#include "condition.h"
#include "conf-files.h"
#include "conf-parser.h"
-#include "cpu-set-util.h"
#include "creds-util.h"
#include "device-private.h"
#include "device-util.h"
free(config->alias);
free(config->wol_password_file);
erase_and_free(config->wol_password);
- cpu_set_free(config->rps_cpu_mask);
+ cpu_set_done(&config->rps_cpu_mask);
ordered_hashmap_free(config->sr_iov_by_section);
}
/* Skip if the config is not specified. */
- if (!config->rps_cpu_mask)
+ if (!config->rps_cpu_mask.set)
return 0;
- mask_str = cpu_set_to_mask_string(config->rps_cpu_mask);
+ mask_str = cpu_set_to_mask_string(&config->rps_cpu_mask);
if (!mask_str)
return log_oom();
void *data,
void *userdata) {
- _cleanup_(cpu_set_freep) CPUSet *allocated = NULL;
- CPUSet *mask, **rps_cpu_mask = ASSERT_PTR(data);
+ CPUSet *mask = ASSERT_PTR(data);
int r;
assert(filename);
assert(rvalue);
if (isempty(rvalue)) {
- *rps_cpu_mask = cpu_set_free(*rps_cpu_mask);
+ cpu_set_done(mask);
return 0;
}
- if (*rps_cpu_mask)
- mask = *rps_cpu_mask;
- else {
- allocated = new0(CPUSet, 1);
- if (!allocated)
+ if (streq(rvalue, "disable")) {
+ _cleanup_(cpu_set_done) CPUSet c = {};
+
+ r = cpu_set_realloc(&c, 1);
+ if (r < 0)
return log_oom();
- mask = allocated;
+ return cpu_set_done_and_replace(*mask, c);
}
- if (streq(rvalue, "disable"))
- cpu_set_done(mask);
+ if (streq(rvalue, "all")) {
+ _cleanup_(cpu_set_done) CPUSet c = {};
- else if (streq(rvalue, "all")) {
- r = cpu_set_add_all(mask);
+ r = cpu_set_add_all(&c);
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to create CPU affinity mask representing \"all\" cpus, ignoring: %m");
return 0;
}
- } else {
- r = parse_cpu_set_extend(rvalue, mask, /* warn= */ true, unit, filename, line, lvalue);
- if (r < 0)
- return 0;
+
+ return cpu_set_done_and_replace(*mask, c);
}
- if (allocated)
- *rps_cpu_mask = TAKE_PTR(allocated);
+ r = parse_cpu_set_extend(rvalue, mask, /* warn= */ true, unit, filename, line, lvalue);
+ if (r < 0)
+ return 0;
return 0;
}