From: Sven Eckelmann <sven@narfation.org>
To: The list for a Better Approach To Mobile Ad-hoc Networking
<b.a.t.m.a.n@lists.open-mesh.org>
Cc: "Linus Lüssing" <linus.luessing@c0d3.blue>
Subject: Re: [PATCH v3 3/5] batman-adv: mcast: implement multicast packet reception and forwarding
Date: Tue, 27 Dec 2022 13:47:42 +0100 [thread overview]
Message-ID: <2126960.yKVeVyVuyW@sven-l14> (raw)
In-Reply-To: <Y6rd8cwPi8JqTbkN@sellars>
[-- Attachment #1: Type: text/plain, Size: 1898 bytes --]
On Tuesday, 27 December 2022 12:58:41 CET Linus Lüssing wrote:
> 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)
This doesn't make a lot of sense. The checkpatch output is about using the
same argument multiple times. It is explicitly talking about following
situation.
#define asd(b) \
do {
if (b)
printk("Foobar %d\n", b);
while (1)
....
asd(x++);
Which would then be transformed to following by the preprocessor:
do {
if (x++)
printk("Foobar %d\n", x++);
while (1)
So your x after the "call" of asd() would (sometimes) not be x+1 but x+2.
> 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?
Provide a patch for checkpatch or build_test.git (which would otherwise send
this output every day).
Kind regards,
Sven
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2022-12-27 12:47 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-26 20:42 [PATCH v3 0/5] Implementation of a Stateless Multicast Packet Type Linus Lüssing
2022-12-26 20:42 ` [PATCH v3 1/5] batman-adv: mcast: remove now redundant single ucast forwarding Linus Lüssing
2022-12-26 20:42 ` [PATCH v3 2/5] batman-adv: tvlv: prepare for tvlv enabled multicast packet type Linus Lüssing
2022-12-26 20:42 ` [PATCH v3 3/5] batman-adv: mcast: implement multicast packet reception and forwarding Linus Lüssing
2022-12-27 9:07 ` Sven Eckelmann
2022-12-27 11:58 ` Linus Lüssing
2022-12-27 12:47 ` Sven Eckelmann [this message]
2022-12-26 20:42 ` [PATCH v3 4/5] batman-adv: mcast: implement multicast packet generation Linus Lüssing
2022-12-27 9:34 ` Sven Eckelmann
2022-12-26 20:42 ` [PATCH v3 5/5] batman-adv: mcast: shrink tracker packet after scrubbing Linus Lüssing
2022-12-27 10:46 ` Sven Eckelmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2126960.yKVeVyVuyW@sven-l14 \
--to=sven@narfation.org \
--cc=b.a.t.m.a.n@lists.open-mesh.org \
--cc=linus.luessing@c0d3.blue \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).