tree-wide: use TAKE_STRUCT

This commit is contained in:
David Tardon
2023-04-14 09:59:27 +02:00
parent 13524b29a2
commit 088d71f8ed
8 changed files with 12 additions and 25 deletions

View File

@@ -71,8 +71,7 @@ void x11_context_replace(X11Context *dest, X11Context *src) {
assert(src);
x11_context_clear(dest);
*dest = *src;
*src = (X11Context) {};
*dest = TAKE_STRUCT(*src);
}
bool x11_context_isempty(const X11Context *xc) {
@@ -196,8 +195,7 @@ void vc_context_replace(VCContext *dest, VCContext *src) {
assert(src);
vc_context_clear(dest);
*dest = *src;
*src = (VCContext) {};
*dest = TAKE_STRUCT(*src);
}
bool vc_context_isempty(const VCContext *vc) {

View File

@@ -4578,8 +4578,7 @@ static int merge_settings(Settings *settings, const char *path) {
log_warning("Ignoring CPUAffinity= setting, file '%s' is not trusted.", path);
else {
cpu_set_reset(&arg_cpu_set);
arg_cpu_set = settings->cpu_set;
settings->cpu_set = (CPUSet) {};
arg_cpu_set = TAKE_STRUCT(settings->cpu_set);
}
}

View File

@@ -313,8 +313,7 @@ int etc_hosts_parse(EtcHosts *hosts, FILE *f) {
strip_localhost(&t);
etc_hosts_clear(hosts);
*hosts = t;
t = (EtcHosts) {}; /* prevent cleanup */
*hosts = TAKE_STRUCT(t);
return 0;
}

View File

@@ -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;
}

View File

@@ -181,9 +181,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;
}
@@ -211,8 +209,7 @@ int parse_cpu_set_extend(
}
if (!old->set) {
*old = cpuset;
cpuset = (CPUSet) {};
*old = TAKE_STRUCT(cpuset);
return 1;
}
@@ -286,7 +283,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;
}

View File

@@ -3305,8 +3305,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;
}

View File

@@ -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;
}

View File

@@ -3637,8 +3637,7 @@ static int parse_line(
if (!GREEDY_REALLOC(existing->items, existing->n_items + 1))
return log_oom();
existing->items[existing->n_items++] = i;
i = (struct Item) {};
existing->items[existing->n_items++] = TAKE_STRUCT(i);
/* Sort item array, to enforce stable ordering of application */
typesafe_qsort(existing->items, existing->n_items, item_compare);