summaryrefslogtreecommitdiff
path: root/src/shared/condition.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2019-03-18 17:42:56 +0100
committerLennart Poettering <lennart@poettering.net>2019-03-19 15:55:07 +0100
commit78d7652549b9733e978fe0686f6318bd7fd6e2f2 (patch)
tree8a29555a7560a9dd2c413651e2ca0085d27a3abb /src/shared/condition.c
parent20ee849d57e141e03a577554803da00d84b8f5ac (diff)
downloadsystemd-78d7652549b9733e978fe0686f6318bd7fd6e2f2.tar.gz
condition: use structured initialization
Diffstat (limited to 'src/shared/condition.c')
-rw-r--r--src/shared/condition.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/shared/condition.c b/src/shared/condition.c
index 12c685acd5..5853b4d61f 100644
--- a/src/shared/condition.c
+++ b/src/shared/condition.c
@@ -22,6 +22,7 @@
#include "cgroup-util.h"
#include "condition.h"
#include "efivars.h"
+#include "env-file.h"
#include "extract-word.h"
#include "fd-util.h"
#include "fileio.h"
@@ -31,7 +32,6 @@
#include "list.h"
#include "macro.h"
#include "mountpoint-util.h"
-#include "env-file.h"
#include "parse-util.h"
#include "path-util.h"
#include "proc-cmdline.h"
@@ -48,23 +48,25 @@
Condition* condition_new(ConditionType type, const char *parameter, bool trigger, bool negate) {
Condition *c;
- int r;
assert(type >= 0);
assert(type < _CONDITION_TYPE_MAX);
assert((!parameter) == (type == CONDITION_NULL));
- c = new0(Condition, 1);
+ c = new(Condition, 1);
if (!c)
return NULL;
- c->type = type;
- c->trigger = trigger;
- c->negate = negate;
+ *c = (Condition) {
+ .type = type,
+ .trigger = trigger,
+ .negate = negate,
+ };
- r = free_and_strdup(&c->parameter, parameter);
- if (r < 0) {
- return mfree(c);
+ if (parameter) {
+ c->parameter = strdup(parameter);
+ if (!c->parameter)
+ return mfree(c);
}
return c;