diff options
author | Lennart Poettering <lennart@poettering.net> | 2019-03-22 20:07:26 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2019-03-25 15:25:57 +0100 |
commit | 3bfa8668b0ebc8d2154a23a4d1e2ef5749a6c1e6 (patch) | |
tree | 942f9677802daa7c0bcb5e8637361a43dccdc26e /src/systemctl | |
parent | 2f50e59f2b8e5ccaf9baa9962d998e396ec35350 (diff) | |
download | systemd-3bfa8668b0ebc8d2154a23a4d1e2ef5749a6c1e6.tar.gz |
systemctl: use structured initialization
Diffstat (limited to 'src/systemctl')
-rw-r--r-- | src/systemctl/systemctl.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index c5bb1f127a..bca05d461e 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -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, ¶m, &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; |