X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fcondition.c;h=4bbd4dbafaecfe1f53b11133db75255dfd297e76;hb=9d3e691e709eb12ce48a3dec6e50537406d12ad2;hp=8c2db2d3e92ab42d0a5e344b39816cab7dabf118;hpb=52661efd21608dc7e0ac26b714a9254ed6180ddb;p=elogind.git diff --git a/src/condition.c b/src/condition.c index 8c2db2d3e..4bbd4dbaf 100644 --- a/src/condition.c +++ b/src/condition.c @@ -3,7 +3,7 @@ /*** This file is part of systemd. - Copyright 2010 ProFUSION embedded systems + Copyright 2010 Lennart Poettering systemd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -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);