]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
common: Introduce for_each_link() macro
authorBenjamin Berg <benjamin.berg@intel.com>
Tue, 20 Feb 2024 13:18:11 +0000 (14:18 +0100)
committerJouni Malinen <j@w1.fi>
Sat, 2 Mar 2024 09:02:54 +0000 (11:02 +0200)
This is a simple macro iterating the given bitmask using the given
variable. Having the macro avoids the for loop-continuation making it
more readable overall.

Signed-off-by: Benjamin Berg <benjamin.berg@intel.com>
src/utils/common.h

index d4ffb998bae4826047d651438009d6393f1c427c..271b97dafc683196fc09c700ecb50de256b45b7f 100644 (file)
@@ -599,6 +599,10 @@ int str_starts(const char *str, const char *start);
 u8 rssi_to_rcpi(int rssi);
 char * get_param(const char *cmd, const char *param);
 
+#define for_each_link(__links, __i)                            \
+       for ((__i) = 0; (__i) < MAX_NUM_MLD_LINKS; (__i)++)    \
+               if ((__links) & BIT(__i))
+
 void forced_memzero(void *ptr, size_t len);
 
 /*