On Tue, Dec 27, 2022 at 10:07:36AM +0100, Sven Eckelmann wrote:
ecsv/pu: checkpatch ./net/batman-adv/multicast_forw.c
CHECK: Macro argument reuse 'num_dests' - possible side-effects? #25: FILE: ./net/batman-adv/multicast_forw.c:25: +#define batadv_mcast_forw_tracker_for_each_dest(dest, num_dests) \ + for (; num_dests; num_dests--, (dest) += ETH_ALEN) total: 0 errors, 0 warnings, 1 checks, 274 lines checked
For this I'm not quite sure how to best silence this. I tried the workaround of passing num_dests as a pointer and dereferencing it inside the macro:
#define batadv_mcast_forw_tracker_for_each_dest(dest, num_dests) \ for (; (*(num_dests)); (*(num_dests))--, (dest) += ETH_ALEN)
So just like you'd do if you would want intentional side-effects with a normal function. But seems like checkpatch does not recoginze it.
Also all the other for_each macros in the kernel code have side-effects, as far as I know?
Or would you have another idea?