> I don't really understand the above, but it made me realize that actually > the following is sufficient: > > @@ > expression x; > @@ > > *&x || ... > > This forces &x to appear as a test expression. There can be 0 or more > occurrences of ||, so eg &x && y is also matched. That's indeed better because it allows to catch issues in tests that are not in if statements (such as loops). Is it ok to rename this file to test_addr.cocci in the next version of the patch to give it a more appropriated name? It also gives a better line indication for conditions split on several lines. I also noticed that with this change the semantic patch catches tests of addresses in if statements when likely/unlikely is used, for example if (likely(&a)). This was not the case with my previous patch nor with the current semantic patch version on master even though the isomorphism unlikely(E) <=> likely(E) => E is in the standard.iso file. I don't get this behavior change, do you have any idea why it didn't work? Thank you! Jérémy ________________________________________ From: Julia Lawall <julia.lawall@xxxxxxxx> Sent: Tuesday, June 7, 2022 21:39 To: Markus Elfring Cc: Jérémy LEFAURE; cocci@xxxxxxxx; kernel-janitors@xxxxxxxxxxxxxxx; Julia Lawall; Nicolas Palix Subject: Re: [PATCH v2] coccinelle: ifaddr: Find address test in more complex conditions On Tue, 7 Jun 2022, Markus Elfring wrote: > > > The test of an expression's address does not necessarily represent the > > whole condition, it may only be a part of it. > > This change aims at detecting an address test in more complex conditions. > > > > Signed-off-by: Jérémy Lefaure <jeremy.lefaure@xxxxxxxxxxx> > > --- > > v1 -> v2: Moved disjunction on the condition itself instead of being on the if statements > > > > scripts/coccinelle/misc/ifaddr.cocci | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/scripts/coccinelle/misc/ifaddr.cocci b/scripts/coccinelle/misc/ifaddr.cocci > > index fc92e8fcbfcb..14dbf3131a3f 100644 > > --- a/scripts/coccinelle/misc/ifaddr.cocci > > +++ b/scripts/coccinelle/misc/ifaddr.cocci > > @@ -18,7 +18,7 @@ statement S1,S2; > > position p; > > @@ > > > > -*if@p (&x) > > +*if@p ( \(&x || ... \| &x && ... \) ) > > S1 else S2 > > > > @script:python depends on org@ > > > Would you ever dare to adjust the specification another bit for such > a source code search approach according to the difference in the selection > of the operators “||” (disjunction) and “&&” (conjunction)? I don't really understand the above, but it made me realize that actually the following is sufficient: @@ expression x; @@ *&x || ... This forces &x to appear as a test expression. There can be 0 or more occurrences of ||, so eg &x && y is also matched. julia