X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fshared%2Fcondition-util.c;h=ff4a8ecd15dfd69bfcc8a2220f514c115048d5d1;hb=7c63b23f499069b7bbdf5e74d3e7a622918341e9;hp=4aea3caf9d59422c35fe914a75bc578c12c15f8a;hpb=099524d7b0df690e3361ffc3fe3c6aed0558b4fc;p=elogind.git diff --git a/src/shared/condition-util.c b/src/shared/condition-util.c index 4aea3caf9..ff4a8ecd1 100644 --- a/src/shared/condition-util.c +++ b/src/shared/condition-util.c @@ -26,7 +26,7 @@ #include #include -#include +#include "systemd/sd-id128.h" #include "util.h" #include "condition-util.h" #include "virt.h" @@ -74,7 +74,8 @@ void condition_free_list(Condition *first) { } bool condition_test_kernel_command_line(Condition *c) { - char *line, *w, *state, *word = NULL; + char *line, *word = NULL; + const char *w, *state; bool equal; int r; size_t l, pl; @@ -113,6 +114,8 @@ bool condition_test_kernel_command_line(Condition *c) { } } + if (!isempty(state)) + log_warning("Trailing garbage and the end of kernel commandline, ignoring."); free(word); free(line); @@ -121,8 +124,7 @@ bool condition_test_kernel_command_line(Condition *c) { } bool condition_test_virtualization(Condition *c) { - int b; - Virtualization v; + int b, v; const char *id; assert(c); @@ -178,10 +180,9 @@ bool condition_test_architecture(Condition *c) { } bool condition_test_host(Condition *c) { + _cleanup_free_ char *h = NULL; sd_id128_t x, y; - char *h; int r; - bool b; assert(c); assert(c->parameter); @@ -200,10 +201,7 @@ bool condition_test_host(Condition *c) { if (!h) return c->negate; - b = fnmatch(c->parameter, h, FNM_CASEFOLD) == 0; - free(h); - - return b == !c->negate; + return (fnmatch(c->parameter, h, FNM_CASEFOLD) == 0) == !c->negate; } bool condition_test_ac_power(Condition *c) { @@ -261,6 +259,8 @@ static const char* const condition_type_table[_CONDITION_TYPE_MAX] = { [CONDITION_HOST] = "ConditionHost", [CONDITION_AC_POWER] = "ConditionACPower", [CONDITION_ARCHITECTURE] = "ConditionArchitecture", + [CONDITION_NEEDS_UPDATE] = "ConditionNeedsUpdate", + [CONDITION_FIRST_BOOT] = "ConditionFirstBoot", [CONDITION_NULL] = "ConditionNull" };