ubusd: simplify/fix avl loop in ubusd_acl_check()
authorFelix Fietkau <nbd@openwrt.org>
Wed, 9 Dec 2015 18:36:49 +0000 (19:36 +0100)
committerFelix Fietkau <nbd@openwrt.org>
Wed, 9 Dec 2015 18:36:49 +0000 (19:36 +0100)
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
ubusd_acl.c

index dbfa83ad4b94b4d547d155154d83095ce28ac447..9f0f0fccd79197a98bf113f746a9b5862d727af6 100644 (file)
@@ -105,16 +105,14 @@ ubusd_acl_check(struct ubus_client *cl, const char *obj,
                return 0;
 
        acl = avl_find_ge_element(&ubusd_acls, obj, acl, avl);
-       while (acl) {
+       avl_for_element_to_last(&ubusd_acls, acl, acl, avl) {
                int diff = ubusd_acl_match_path(obj, acl->avl.key, NULL);
 
                if (diff)
                        break;
 
-               if (ubusd_acl_match_cred(cl, acl)) {
-                       acl = avl_next_element(acl, avl);
+               if (ubusd_acl_match_cred(cl, acl))
                        continue;
-               }
 
                switch (type) {
                case UBUS_ACL_PUBLISH:
@@ -135,7 +133,6 @@ ubusd_acl_check(struct ubus_client *cl, const char *obj,
                                                        return 0;
                        break;
                }
-               acl = avl_next_element(acl, avl);
        }
 
        return -1;