} UnitCondition;
static void unit_condition_free(UnitCondition *c) {
- assert(c);
+ if (!c)
+ return;
free(c->name);
free(c->param);
free(c);
}
+DEFINE_TRIVIAL_CLEANUP_FUNC(UnitCondition*, unit_condition_free);
+
typedef struct UnitStatusInfo {
const char *id;
const char *load_state;
return bus_log_parse_error(r);
while ((r = sd_bus_message_read(m, "(sbbsi)", &cond, &trigger, &negate, ¶m, &state)) > 0) {
- UnitCondition *c;
+ _cleanup_(unit_condition_freep) UnitCondition *c = NULL;
log_debug("%s trigger=%d negate=%d %s →%d", cond, trigger, negate, param, state);
return log_oom();
c->name = strdup(cond);
- if (!c->name) {
- free(c);
- return log_oom();
- }
-
c->param = strdup(param);
- if (!c->param) {
- free(c->name);
- free(c);
+ if (!c->name || !c->param)
return log_oom();
- }
c->trigger = trigger;
c->negate = negate;
c->tristate = state;
LIST_PREPEND(conditions, i->conditions, c);
+ c = NULL;
}
if (r < 0)
return bus_log_parse_error(r);