Re: [cocci] [PATCH] coccinelle: ifaddr: Find address test in more complex conditions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Sat, 4 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>
> > ---
> >  scripts/coccinelle/misc/ifaddr.cocci | 8 ++++++++
> >  1 file changed, 8 insertions(+)
> >
> > diff --git a/scripts/coccinelle/misc/ifaddr.cocci b/scripts/coccinelle/misc/ifaddr.cocci
> > index fc92e8fcbfcb..387af44a1256 100644
> > --- a/scripts/coccinelle/misc/ifaddr.cocci
> > +++ b/scripts/coccinelle/misc/ifaddr.cocci
> > @@ -18,8 +18,16 @@ statement S1,S2;
> >  position p;
> >  @@
> >
> > +(
> >  *if@p (&x)
> >   S1 else S2
> > +|
> > +*if@p (&x || ...)
> > + S1 else S2
> > +|
> > +*if@p (&x && ...)
> > + S1 else S2
> > +)
> >
> >  @script:python depends on org@
> >  p << r.p;
>
>
> You would like to extend a check for an if statement.
> I suggest to specify the corresponding SmPL disjunction like the following.
>
> @r@
> expression x;
> statement S1,S2;
> position p;
> @@
>
> *if@p ( \(&x \| &x || ... \| &x && ... \) )
>  S1 else S2
>
>
> How do you think about to use such a SmPL code variant instead?


I don't think that the &x case is needed.  There is an isomorphism for ||
... that makes it cover the case where the || is not there as well.

julia

[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux