All of lore.kernel.org
 help / color / mirror / Atom feed
* [cocci] [PATCH] coccinelle: ifaddr: Find address test in more complex conditions
@ 2022-05-30 15:40 Jérémy LEFAURE
  2022-06-04 14:02 ` Markus Elfring
  0 siblings, 1 reply; 6+ messages in thread
From: Jérémy LEFAURE @ 2022-05-30 15:40 UTC (permalink / raw)
  To: Julia Lawall, Nicolas Palix; +Cc: cocci

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@netatmo.com>
---
 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;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [cocci] [PATCH] coccinelle: ifaddr: Find address test in more complex conditions
  2022-05-30 15:40 [cocci] [PATCH] coccinelle: ifaddr: Find address test in more complex conditions Jérémy LEFAURE
@ 2022-06-04 14:02 ` Markus Elfring
  2022-06-04 14:11   ` Julia Lawall
  2022-06-07  8:18   ` [cocci] [PATCH] " Jérémy LEFAURE
  0 siblings, 2 replies; 6+ messages in thread
From: Markus Elfring @ 2022-06-04 14:02 UTC (permalink / raw)
  To: Jérémy Lefaure, cocci, kernel-janitors
  Cc: Julia Lawall, Nicolas Palix


> 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@netatmo.com>
> ---
>  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?

Regards,
Markus


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [cocci] [PATCH] coccinelle: ifaddr: Find address test in more complex conditions
  2022-06-04 14:02 ` Markus Elfring
@ 2022-06-04 14:11   ` Julia Lawall
  2022-06-04 14:32     ` [cocci] " Markus Elfring
  2022-06-07  8:18   ` [cocci] [PATCH] " Jérémy LEFAURE
  1 sibling, 1 reply; 6+ messages in thread
From: Julia Lawall @ 2022-06-04 14:11 UTC (permalink / raw)
  To: Markus Elfring
  Cc: Jérémy Lefaure, cocci, kernel-janitors, Nicolas Palix

[-- Attachment #1: Type: text/plain, Size: 1402 bytes --]



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@netatmo.com>
> > ---
> >  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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [cocci] coccinelle: ifaddr: Find address test in more complex conditions
  2022-06-04 14:11   ` Julia Lawall
@ 2022-06-04 14:32     ` Markus Elfring
  2022-06-04 14:50       ` Julia Lawall
  0 siblings, 1 reply; 6+ messages in thread
From: Markus Elfring @ 2022-06-04 14:32 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Jérémy Lefaure, cocci, kernel-janitors, Nicolas Palix

>> *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.


Do you refer to an isomorphism which is built into the Coccinelle software
(instead of being explicitly specified in the file “standard.iso”)?

Regards,
Markus


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [cocci] coccinelle: ifaddr: Find address test in more complex conditions
  2022-06-04 14:32     ` [cocci] " Markus Elfring
@ 2022-06-04 14:50       ` Julia Lawall
  0 siblings, 0 replies; 6+ messages in thread
From: Julia Lawall @ 2022-06-04 14:50 UTC (permalink / raw)
  To: Markus Elfring
  Cc: Julia Lawall, Jérémy Lefaure, cocci, kernel-janitors,
	Nicolas Palix

[-- Attachment #1: Type: text/plain, Size: 529 bytes --]



On Sat, 4 Jun 2022, Markus Elfring wrote:

> >> *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.
>
>
> Do you refer to an isomorphism which is built into the Coccinelle software
> (instead of being explicitly specified in the file “standard.iso”)?

Yes, that is correct.

julia

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [cocci] [PATCH] coccinelle: ifaddr: Find address test in more complex conditions
  2022-06-04 14:02 ` Markus Elfring
  2022-06-04 14:11   ` Julia Lawall
@ 2022-06-07  8:18   ` Jérémy LEFAURE
  1 sibling, 0 replies; 6+ messages in thread
From: Jérémy LEFAURE @ 2022-06-07  8:18 UTC (permalink / raw)
  To: Markus Elfring; +Cc: Julia Lawall, Nicolas Palix, cocci, kernel-janitors

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

Thank you for your suggestion, it looks like a better solution.
I'll send a v2 with this suggestion (without the &x case).

Jérémy

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-06-07  8:18 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-30 15:40 [cocci] [PATCH] coccinelle: ifaddr: Find address test in more complex conditions Jérémy LEFAURE
2022-06-04 14:02 ` Markus Elfring
2022-06-04 14:11   ` Julia Lawall
2022-06-04 14:32     ` [cocci] " Markus Elfring
2022-06-04 14:50       ` Julia Lawall
2022-06-07  8:18   ` [cocci] [PATCH] " Jérémy LEFAURE

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.