]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
common: Use for_each_element() in ieee802_11_ie_count()
authorJohannes Berg <johannes.berg@intel.com>
Fri, 8 Feb 2019 16:57:49 +0000 (17:57 +0100)
committerJouni Malinen <j@w1.fi>
Mon, 11 Feb 2019 11:37:22 +0000 (13:37 +0200)
Simple cleanup using the new macros.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
src/common/ieee802_11_common.c

index 871536f593cf5457a7fdea32cb25e62242cb66a6..b38f2f106b384fb29d52fa01b595308207d5c3dc 100644 (file)
@@ -543,21 +543,14 @@ ParseRes ieee802_11_parse_elems(const u8 *start, size_t len,
 
 int ieee802_11_ie_count(const u8 *ies, size_t ies_len)
 {
+       const struct element *elem;
        int count = 0;
-       const u8 *pos, *end;
 
        if (ies == NULL)
                return 0;
 
-       pos = ies;
-       end = ies + ies_len;
-
-       while (end - pos >= 2) {
-               if (2 + pos[1] > end - pos)
-                       break;
+       for_each_element(elem, ies, ies_len)
                count++;
-               pos += 2 + pos[1];
-       }
 
        return count;
 }