b.a.t.m.a.n.lists.open-mesh.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] build_test: don't warn about "Macro argument reuse" in multicast_forw.c
@ 2022-12-27 17:45 Linus Lüssing
  0 siblings, 0 replies; only message in thread
From: Linus Lüssing @ 2022-12-27 17:45 UTC (permalink / raw)
  To: b.a.t.m.a.n; +Cc: Linus Lüssing

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
 
-- 
2.39.0

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2022-12-27 17:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-27 17:45 [PATCH] build_test: don't warn about "Macro argument reuse" in multicast_forw.c Linus Lüssing

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).