chiark / gitweb /
udevd: fix termination of rule execution
[elogind.git] / udev / udev-rules.c
index 665ad71e80f3289a1234930e1ab0b06fa4c48503..77029f7bec024e2ec9d90164520816b202cc59e4 100644 (file)
@@ -1808,11 +1808,10 @@ static int match_attr(struct udev_rules *rules, struct udev_device *dev, struct
                const char *val;
 
                val = udev_device_get_sysattr_value(dev, key_name);
-               if (val != NULL)
-                       util_strlcpy(value, val, sizeof(value));
+               if (val == NULL)
+                       return -1;
+               util_strlcpy(value, val, sizeof(value));
        }
-       if (value[0] == '\0')
-               return -1;
 
        /* strip trailing whitespace of value, if not asked to match for it */
        len = strlen(key_value);
@@ -2320,7 +2319,7 @@ int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event
                        continue;
                case TK_A_LAST_RULE:
                case TK_END:
-                       break;
+                       return 0;
 
                case TK_M_PARENTS_MAX:
                case TK_M_MAX:
@@ -2335,9 +2334,8 @@ int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event
                /* fast-forward to next rule */
                idx = rule->rule.next_rule;
                if (idx == 0)
-                       break;
+                       return 0;
                dbg(rules->udev, "forward to rule: %u\n", idx);
                cur = &rules->tokens[idx];
        }
-       return 0;
 }