Use for_each_link() in most cases

This was done using the below semantic patch. There are a few more
places that were missed due to variable declarations or additional
checks in the for loop.

@@
iterator name for_each_link;
identifier max_links =~ "MAX_NUM_MLD_LINKS|MAX_NUM_MLO_LINKS";
expression links;
expression further_tests;
identifier i;
statement stmt;
@@
-for (i = 0; i < max_links; i++)
+for_each_link(links, i)
 {
(
-  if (!(links & BIT(i)))
-    continue;
   ...
|
-  if (!(links & BIT(i)) || further_tests)
+  if (further_tests)
     continue;
   ...
|
-  if (further_tests || !(links & BIT(i)))
+  if (further_tests)
     continue;
   ...
|
-  if (links & BIT(i))
     stmt
|
-  if (further_tests && (links & BIT(i)))
+  if (further_tests)
     stmt
|
-  if ((links & BIT(i)) && further_tests)
+  if (further_tests)
     stmt
)
 }

Signed-off-by: Benjamin Berg <benjamin.berg@intel.com>
This commit is contained in:
Benjamin Berg 2024-02-20 14:18:12 +01:00 committed by Jouni Malinen
parent c9f8fe0664
commit dbdf7ef679
13 changed files with 31 additions and 106 deletions

View file

@ -1520,10 +1520,7 @@ static bool wpas_beacon_rep_scan_match(struct wpa_supplicant *wpa_s,
if (!wpa_s->valid_links)
return ether_addr_equal(wpa_s->current_bss->bssid, bssid);
for (i = 0; i < MAX_NUM_MLD_LINKS; i++) {
if (!(wpa_s->valid_links & BIT(i)))
continue;
for_each_link(wpa_s->valid_links, i) {
if (ether_addr_equal(wpa_s->links[i].bssid, bssid))
return true;
}