Skip to contentSkip to conversation

ie: fix static analysis warning

PATCH New James Prestwood 1 participant 1 message May 14, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ie: fix static analysis warning

The supp_rates_iter was being used prior to the NULL check. This was fixed as well as some reordering to make the function consistent between supp_rates_iter and ext_supp_rates_iter.

---
 src/ie.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
src/ie.c +2 -6
index 0b471f1b..352ce469 100644
@@ -1673,11 +1673,6 @@ static int ie_parse_supported_rates(struct ie_tlv_iter *supp_rates_iter,
 	unsigned int len;
 	unsigned int i;
 
-	len = ie_tlv_iter_get_length(supp_rates_iter);
-
-	if (len == 0)
-		return -EINVAL;
-
 	/* Find highest rates possible with our RSSI */
 	for (i = 0; i < L_ARRAY_SIZE(rate_rssi_map); i++) {
 		const struct basic_rate_map *map = &rate_rssi_map[i];
@@ -1688,8 +1683,9 @@ static int ie_parse_supported_rates(struct ie_tlv_iter *supp_rates_iter,
 		max_rate = map->rate;
 	}
 
+	/* Find highest rate in Supported Rates IE */
 	if (supp_rates_iter) {
-		/* Find highest rate in Supported Rates IE */
+		len = ie_tlv_iter_get_length(supp_rates_iter);
 		rates = ie_tlv_iter_get_data(supp_rates_iter);
 
 		for (i = 0; i < len; i++) {
Signature · 1 line
2.31.1