summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Tardon <dtardon@redhat.com>2023-04-14 09:59:27 +0200
committerDavid Tardon <dtardon@redhat.com>2023-04-14 10:15:44 +0200
commit088d71f8edd616a839a6ebfd3ab0c58701678757 (patch)
tree9940b5f1d136299157eebbdc13be06f6fa92ea6c
parent13524b29a2833675518b5d5701344196429cb924 (diff)
downloadsystemd-088d71f8edd616a839a6ebfd3ab0c58701678757.tar.gz
tree-wide: use TAKE_STRUCT
-rw-r--r--src/locale/localed-util.c6
-rw-r--r--src/nspawn/nspawn.c3
-rw-r--r--src/resolve/resolved-etc-hosts.c3
-rw-r--r--src/shared/bootspec.c6
-rw-r--r--src/shared/cpu-set-util.c10
-rw-r--r--src/shared/install.c3
-rw-r--r--src/shared/numa-util.c3
-rw-r--r--src/tmpfiles/tmpfiles.c3
8 files changed, 12 insertions, 25 deletions
diff --git a/src/locale/localed-util.c b/src/locale/localed-util.c
index 5247d139eb..17d96aea1d 100644
--- a/src/locale/localed-util.c
+++ b/src/locale/localed-util.c
@@ -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) {
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
index bb3a04c9e4..6477cc43fa 100644
--- a/src/nspawn/nspawn.c
+++ b/src/nspawn/nspawn.c
@@ -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);
}
}
diff --git a/src/resolve/resolved-etc-hosts.c b/src/resolve/resolved-etc-hosts.c
index cf0e2be5fa..5eee9c57b2 100644
--- a/src/resolve/resolved-etc-hosts.c
+++ b/src/resolve/resolved-etc-hosts.c
@@ -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;
}
diff --git a/src/shared/bootspec.c b/src/shared/bootspec.c
index 7cc63e8848..a5ae2478fe 100644
--- a/src/shared/bootspec.c
+++ b/src/shared/bootspec.c
@@ -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;
}
diff --git a/src/shared/cpu-set-util.c b/src/shared/cpu-set-util.c
index 34c13cf969..580aa27c5c 100644
--- a/src/shared/cpu-set-util.c
+++ b/src/shared/cpu-set-util.c
@@ -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;
}
diff --git a/src/shared/install.c b/src/shared/install.c
index 964092456f..894ce90817 100644
--- a/src/shared/install.c
+++ b/src/shared/install.c
@@ -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;
}
diff --git a/src/shared/numa-util.c b/src/shared/numa-util.c
index 4f757f0b55..a954ea349e 100644
--- a/src/shared/numa-util.c
+++ b/src/shared/numa-util.c
@@ -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;
}
diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c
index 3adafcae83..2eb6e5ea33 100644
--- a/src/tmpfiles/tmpfiles.c
+++ b/src/tmpfiles/tmpfiles.c
@@ -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);