From: Johannes Berg Date: Fri, 8 Feb 2019 16:57:49 +0000 (+0100) Subject: common: Use for_each_element() in ieee802_11_ie_count() X-Git-Tag: hostap_2_8~379 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eb84238df6819fe38b52d8db3b529ec26cf978fa;p=thirdparty%2Fhostap.git common: Use for_each_element() in ieee802_11_ie_count() Simple cleanup using the new macros. Signed-off-by: Johannes Berg --- diff --git a/src/common/ieee802_11_common.c b/src/common/ieee802_11_common.c index 871536f59..b38f2f106 100644 --- a/src/common/ieee802_11_common.c +++ b/src/common/ieee802_11_common.c @@ -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; }