It's tricky to avoid reusing an argument in a for-each like macro. This is to silence the following warning:
CHECK: Macro argument reuse 'num_dests' - possible side-effects? #789: FILE: net/batman-adv/multicast_forw.c:35: +#define batadv_mcast_forw_tracker_for_each_dest(dest, num_dests) \ + for (; num_dests; num_dests--, (dest) += ETH_ALEN)
CHECK: Macro argument reuse 'num_dests' - possible side-effects? #792: FILE: net/batman-adv/multicast_forw.c:38: +#define batadv_mcast_forw_tracker_for_each_dest_rev(dest, num_dests) \ + for (; num_dests; num_dests--, (dest) -= ETH_ALEN)
Later, once < 5.18 is out of our compat range we can rely on C99 syntax and use variable declarations inside a for loop, readd the check and rewrite the macro to something like this:
#define batadv_mcast_forw_tracker_for_each_dest(dest, num_dests) \ for (typeof(num_dests) __batadv_forw_num_dests = num_dests; \ *__batadv_forw_num_dests; \ (*__batadv_forw_num_dests)--, (dest) += ETH_ALEN)
Signed-off-by: Linus Lüssing linus.luessing@c0d3.blue --- checkstuff.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/checkstuff.sh b/checkstuff.sh index 207652ce4fbe..be49709dcb3b 100755 --- a/checkstuff.sh +++ b/checkstuff.sh @@ -191,7 +191,7 @@ test_checkpatch() continue fi
- if [ "${fname}" = "log.h" ]; then + if [ "${fname}" = "log.h" -o "${fname}" = "multicast_forw.c" ]; then cp_extra_params="${cp_extra_params} --ignore MACRO_ARG_REUSE" fi
b.a.t.m.a.n@lists.open-mesh.org