Merge pull request #27266 from dtardon/take-struct
Use TAKE_STRUCT() to copy and reset structs
This commit is contained in:
@@ -389,8 +389,7 @@ static int boot_entry_load_type1(
|
||||
return log_syntax(NULL, LOG_ERR, tmp.path, line, r, "Error while parsing: %m");
|
||||
}
|
||||
|
||||
*entry = tmp;
|
||||
tmp = (BootEntry) {};
|
||||
*entry = TAKE_STRUCT(tmp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -744,8 +743,7 @@ static int boot_entry_load_unified(
|
||||
return log_oom();
|
||||
}
|
||||
|
||||
*ret = tmp;
|
||||
tmp = (BootEntry) {};
|
||||
*ret = TAKE_STRUCT(tmp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -145,6 +145,8 @@ int parse_cpu_set_full(
|
||||
_cleanup_(cpu_set_reset) CPUSet c = {};
|
||||
const char *p = ASSERT_PTR(rvalue);
|
||||
|
||||
assert(cpu_set);
|
||||
|
||||
for (;;) {
|
||||
_cleanup_free_ char *word = NULL;
|
||||
unsigned cpu_lower, cpu_upper;
|
||||
@@ -181,9 +183,7 @@ int parse_cpu_set_full(
|
||||
}
|
||||
}
|
||||
|
||||
/* On success, transfer ownership to the output variable */
|
||||
*cpu_set = c;
|
||||
c = (CPUSet) {};
|
||||
*cpu_set = TAKE_STRUCT(c);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -200,6 +200,8 @@ int parse_cpu_set_extend(
|
||||
_cleanup_(cpu_set_reset) CPUSet cpuset = {};
|
||||
int r;
|
||||
|
||||
assert(old);
|
||||
|
||||
r = parse_cpu_set_full(rvalue, &cpuset, true, unit, filename, line, lvalue);
|
||||
if (r < 0)
|
||||
return r;
|
||||
@@ -211,8 +213,7 @@ int parse_cpu_set_extend(
|
||||
}
|
||||
|
||||
if (!old->set) {
|
||||
*old = cpuset;
|
||||
cpuset = (CPUSet) {};
|
||||
*old = TAKE_STRUCT(cpuset);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -286,7 +287,6 @@ int cpu_set_from_dbus(const uint8_t *bits, size_t size, CPUSet *set) {
|
||||
return r;
|
||||
}
|
||||
|
||||
*set = s;
|
||||
s = (CPUSet) {};
|
||||
*set = TAKE_STRUCT(s);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -3310,8 +3310,7 @@ static int read_presets(RuntimeScope scope, const char *root_dir, UnitFilePreset
|
||||
}
|
||||
|
||||
ps.initialized = true;
|
||||
*presets = ps;
|
||||
ps = (UnitFilePresets){};
|
||||
*presets = TAKE_STRUCT(ps);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -120,8 +120,7 @@ int numa_to_cpu_set(const NUMAPolicy *policy, CPUSet *ret) {
|
||||
return r;
|
||||
}
|
||||
|
||||
*ret = s;
|
||||
s = (CPUSet) {};
|
||||
*ret = TAKE_STRUCT(s);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user