diff options
author | Lennart Poettering <lennart@poettering.net> | 2010-11-10 22:28:19 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2010-11-10 22:39:18 +0100 |
commit | d257ddef22ff1a1b98e6172799819e6511b1bcfb (patch) | |
tree | bc6b6acdc1e7fa353e2f53d5555aad63829c24c1 /src/condition.c | |
parent | 06cdd2484c5d0b7792168a7c2d99311e35b0fb8e (diff) |
unit: add ConditionNull= condition
Diffstat (limited to 'src/condition.c')
-rw-r--r-- | src/condition.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/condition.c b/src/condition.c index 1e69b610ff..4bbd4dbafa 100644 --- a/src/condition.c +++ b/src/condition.c @@ -34,10 +34,11 @@ Condition* condition_new(ConditionType type, const char *parameter, bool negate) c->type = type; c->negate = negate; - if (!(c->parameter = strdup(parameter))) { - free(c); - return NULL; - } + if (parameter) + if (!(c->parameter = strdup(parameter))) { + free(c); + return NULL; + } return c; } @@ -108,6 +109,9 @@ bool condition_test(Condition *c) { case CONDITION_KERNEL_COMMAND_LINE: return !!test_kernel_command_line(c->parameter) == !c->negate; + case CONDITION_NULL: + return !c->negate; + default: assert_not_reached("Invalid condition type."); } @@ -152,7 +156,8 @@ void condition_dump_list(Condition *first, FILE *f, const char *prefix) { static const char* const condition_type_table[_CONDITION_TYPE_MAX] = { [CONDITION_KERNEL_COMMAND_LINE] = "ConditionKernelCommandLine", - [CONDITION_PATH_EXISTS] = "ConditionPathExists" + [CONDITION_PATH_EXISTS] = "ConditionPathExists", + [CONDITION_NULL] = "ConditionNull" }; DEFINE_STRING_TABLE_LOOKUP(condition_type, ConditionType); |