]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tree-wide: use TAKE_STRUCT
authorDavid Tardon <dtardon@redhat.com>
Fri, 14 Apr 2023 07:59:27 +0000 (09:59 +0200)
committerDavid Tardon <dtardon@redhat.com>
Fri, 14 Apr 2023 08:15:44 +0000 (10:15 +0200)
src/locale/localed-util.c
src/nspawn/nspawn.c
src/resolve/resolved-etc-hosts.c
src/shared/bootspec.c
src/shared/cpu-set-util.c
src/shared/install.c
src/shared/numa-util.c
src/tmpfiles/tmpfiles.c

index 5247d139eb7ea9d64766bbad68a7b697ecbecc1a..17d96aea1d15734698f6e695ab283e6e9d5a33c6 100644 (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) {
index bb3a04c9e4a9d8928bcc69e12bb22f14521f1874..6477cc43fa9b98417702aa1b9b17b7c3ebe8db3f 100644 (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);
                 }
         }
 
index cf0e2be5fa0b86aff1c7a5829d6e1f3a6227f4aa..5eee9c57b2b34d45d5d7117f8a04e1464e2d632c 100644 (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;
 }
 
index 7cc63e88486dabae79833b553bec9c85b7d99cbe..a5ae2478fe85fd853abc6a3bd7b8ee60cf741823 100644 (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;
 }
 
index 34c13cf9692d9644fc30f16d38d686cbb208ce6f..580aa27c5c72a8301d750f2812273a32f684df75 100644 (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;
 }
index 964092456f4a0ea820238331fc123c97c15f4a12..894ce908173da28ab989f5f7c423125dc944aef8 100644 (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;
 }
index 4f757f0b55d8feb9c6f6257daca4bef30ff9f1ca..a954ea349ee065c633395ee7536f84972cacfd01 100644 (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;
 }
index 3adafcae83f9fd152a619f80a29fff86e7402149..2eb6e5ea3361ed0aeccaa67c6fbda9f3639e74c9 100644 (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);