trigger: make trigger_match() bool and make return value less confusing
authorFelix Fietkau <nbd@openwrt.org>
Tue, 2 Jun 2015 14:27:56 +0000 (16:27 +0200)
committerFelix Fietkau <nbd@openwrt.org>
Thu, 4 Jun 2015 20:05:00 +0000 (22:05 +0200)
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
service/trigger.c

index a8533b3bce298a9479b334552582111756df4ba3..97a06bb57d1a4bcf4769c4c81831d35b4456a3be 100644 (file)
@@ -323,12 +323,12 @@ void trigger_init(void)
        q.max_running_tasks = 1;
 }
 
-static int trigger_match(const char *event, const char *match)
+static bool trigger_match(const char *event, const char *match)
 {
        char *wildcard = strstr(match, ".*");
        if (wildcard)
-               return strncmp(event, match, wildcard - match);
-       return strcmp(event, match);
+               return !strncmp(event, match, wildcard - match);
+       return !strcmp(event, match);
 }
 
 void trigger_event(const char *type, struct blob_attr *data)
@@ -338,7 +338,7 @@ void trigger_event(const char *type, struct blob_attr *data)
        list_for_each_entry(t, &triggers, list) {
                if (t->remove)
                        continue;
-               if (!trigger_match(type, t->type)) {
+               if (trigger_match(type, t->type)) {
                        if (t->timeout) {
                                free(t->data);
                                t->data = blob_memdup(data);