chiark / gitweb /
condition: minor modernizations
authorLennart Poettering <lennart@poettering.net>
Fri, 13 Jun 2014 10:39:58 +0000 (12:39 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 13 Jun 2014 11:26:32 +0000 (13:26 +0200)
src/core/condition.c
src/shared/condition-util.c

index 2468458..833bcdf 100644 (file)
@@ -27,7 +27,7 @@
 #include <sys/statvfs.h>
 #include <fnmatch.h>
 
-#include <systemd/sd-id128.h>
+#include "sd-id128.h"
 #include "util.h"
 #include "condition.h"
 #include "virt.h"
@@ -52,12 +52,13 @@ static bool condition_test_security(Condition *c) {
                 return use_ima() == !c->negate;
         if (streq(c->parameter, "smack"))
                 return use_smack() == !c->negate;
+
         return c->negate;
 }
 
 static bool condition_test_capability(Condition *c) {
+        _cleanup_fclose_ FILE *f = NULL;
         cap_value_t value;
-        FILE *f;
         char line[LINE_MAX];
         unsigned long long capabilities = -1;
 
@@ -86,8 +87,6 @@ static bool condition_test_capability(Condition *c) {
                 }
         }
 
-        fclose(f);
-
         return !!(capabilities & (1ULL << value)) == !c->negate;
 }
 
index 9961cb4..1c7d1f6 100644 (file)
@@ -177,10 +177,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);
@@ -199,10 +198,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) {