]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
systemctl: use structured initialization
authorLennart Poettering <lennart@poettering.net>
Fri, 22 Mar 2019 19:07:26 +0000 (20:07 +0100)
committerLennart Poettering <lennart@poettering.net>
Mon, 25 Mar 2019 14:25:57 +0000 (15:25 +0100)
src/systemctl/systemctl.c

index c5bb1f127a873e6c0876a511a47865f221dcf849..bca05d461eb9c711fa19ba3a7b484e922f190fe6 100644 (file)
@@ -4630,21 +4630,23 @@ static int map_conditions(sd_bus *bus, const char *member, sd_bus_message *m, sd
         while ((r = sd_bus_message_read(m, "(sbbsi)", &cond, &trigger, &negate, &param, &state)) > 0) {
                 _cleanup_(unit_condition_freep) UnitCondition *c = NULL;
 
-                c = new0(UnitCondition, 1);
+                c = new(UnitCondition, 1);
                 if (!c)
                         return -ENOMEM;
 
-                c->name = strdup(cond);
-                c->param = strdup(param);
+                *c = (UnitCondition) {
+                        .name = strdup(cond),
+                        .param = strdup(param),
+                        .trigger = trigger,
+                        .negate = negate,
+                        .tristate = state,
+                };
+
                 if (!c->name || !c->param)
                         return -ENOMEM;
 
-                c->trigger = trigger;
-                c->negate = negate;
-                c->tristate = state;
 
-                LIST_PREPEND(conditions, i->conditions, c);
-                c = NULL;
+                LIST_PREPEND(conditions, i->conditions, TAKE_PTR(c));
         }
         if (r < 0)
                 return r;