public inbox for cocci@systeme.lip6.fr
 help / color / mirror / Atom feed
* [cocci] Deleting duplicate condition checks (with SmPL)?
@ 2025-07-13  7:21 Markus Elfring
  2025-07-14  7:26 ` Markus Elfring
  2025-07-14  9:54 ` Julia Lawall
  0 siblings, 2 replies; 7+ messages in thread
From: Markus Elfring @ 2025-07-13  7:21 UTC (permalink / raw)
  To: cocci; +Cc: Yue Haibing

Hello,

I noticed another contribution.

I got into the mood to construct another script for the semantic patch language.


// See also:
// [PATCH net-next] ipv6: mcast: Remove unnecessary null check in mld_del_delrec()
// https://lore.kernel.org/lkml/20250712092811.2992283-1-yuehaibing@huawei.com/
//
// https://elixir.bootlin.com/linux/v6.16-rc5/source/net/ipv6/mcast.c#L786-L813
@deletions@
expression x;
@@
 if (x)
 {
 <+...
-}
-if (x)
-{
 ...+>
 }


Questionable test result (by the software combination “Coccinelle 1.3.0” for example):
Markus_Elfring@Sonne:…/Projekte/Coccinelle/janitor> /usr/bin/spatch --parse-cocci delete_duplicate_condition_checks2.cocci
…
minus: parse error: 
  File "delete_duplicate_condition_checks2.cocci", line 12, column 1, charpos = 307
  around = '}',
  whole content = -}


The transformation approach is working as expected if the specification “... when any”
would be applied instead of the SmPL nest construct.
Which software improvements will become more desirable for such an use case?

Regards,
Markus

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

* Re: [cocci] Deleting duplicate condition checks (with SmPL)?
  2025-07-13  7:21 [cocci] Deleting duplicate condition checks (with SmPL)? Markus Elfring
@ 2025-07-14  7:26 ` Markus Elfring
  2025-07-14  9:57   ` Julia Lawall
  2025-07-14  9:54 ` Julia Lawall
  1 sibling, 1 reply; 7+ messages in thread
From: Markus Elfring @ 2025-07-14  7:26 UTC (permalink / raw)
  To: cocci; +Cc: Yue Haibing, Kuniyuki Iwashima

> Which software improvements will become more desirable for such an use case?

Will another script variant for the semantic patch language become helpful?


// See also:
// [PATCH net-next] ipv6: mcast: Remove unnecessary null check in mld_del_delrec()
// https://lore.kernel.org/netdev/CAAVpQUC-mV=SuNNhKbpy_1Mbh_sOs856+oNqDVJ4KcLjhDh2kw@mail.gmail.com/
// https://lkml.org/lkml/2025/7/12/336
//
// https://elixir.bootlin.com/linux/v6.16-rc5/source/net/ipv6/mcast.c#L786-L813
@adjustment disable braces0@
expression e;
identifier i;
@@
 void i(...)
 {
 ... when any
 if (
+    !
     e
    )
+   return;
-   {
    ... when any
-   }
-if (e)
-   {
    ... when any
-   }
 ... when any
 }


Would you be looking for further source code layout refinements then?

Regards,
Markus

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

* Re: [cocci] Deleting duplicate condition checks (with SmPL)?
  2025-07-13  7:21 [cocci] Deleting duplicate condition checks (with SmPL)? Markus Elfring
  2025-07-14  7:26 ` Markus Elfring
@ 2025-07-14  9:54 ` Julia Lawall
  1 sibling, 0 replies; 7+ messages in thread
From: Julia Lawall @ 2025-07-14  9:54 UTC (permalink / raw)
  To: Markus Elfring; +Cc: cocci, Yue Haibing


Sent from my iPhone

> On 13 Jul 2025, at 03:21, Markus Elfring <Markus.Elfring@web.de> wrote:
> 
> Hello,
> 
> I noticed another contribution.
> 
> I got into the mood to construct another script for the semantic patch language.
> 
> 
> // See also:
> // [PATCH net-next] ipv6: mcast: Remove unnecessary null check in mld_del_delrec()
> // https://lore.kernel.org/lkml/20250712092811.2992283-1-yuehaibing@huawei.com/
> //
> // https://elixir.bootlin.com/linux/v6.16-rc5/source/net/ipv6/mcast.c#L786-L813
> @deletions@
> expression x;
> @@
> if (x)
> {
> <+...
> -}
> -if (x)
> -{
> ...+>
> }
> 
> 

It expects a real statement inside <+… …+>

> Questionable test result (by the software combination “Coccinelle 1.3.0” for example):
> Markus_Elfring@Sonne:…/Projekte/Coccinelle/janitor> /usr/bin/spatch --parse-cocci delete_duplicate_condition_checks2.cocci
> …
> minus: parse error:
>  File "delete_duplicate_condition_checks2.cocci", line 12, column 1, charpos = 307
>  around = '}',
>  whole content = -}
> 
> 
> The transformation approach is working as expected if the specification “... when any”
> would be applied instead of the SmPL nest construct.
> Which software improvements will become more desirable for such an use case?
> 
> Regards,
> Markus


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

* Re: [cocci] Deleting duplicate condition checks (with SmPL)?
  2025-07-14  7:26 ` Markus Elfring
@ 2025-07-14  9:57   ` Julia Lawall
  2025-07-14 11:13     ` Markus Elfring
  0 siblings, 1 reply; 7+ messages in thread
From: Julia Lawall @ 2025-07-14  9:57 UTC (permalink / raw)
  To: Markus Elfring; +Cc: cocci, Yue Haibing, Kuniyuki Iwashima



> On 14 Jul 2025, at 03:27, Markus Elfring <Markus.Elfring@web.de> wrote:
> 
> 
>> 
>> Which software improvements will become more desirable for such an use case?
> 
> Will another script variant for the semantic patch language become helpful?
> 
> 
> // See also:
> // [PATCH net-next] ipv6: mcast: Remove unnecessary null check in mld_del_delrec()
> // https://lore.kernel.org/netdev/CAAVpQUC-mV=SuNNhKbpy_1Mbh_sOs856+oNqDVJ4KcLjhDh2kw@mail.gmail.com/
> // https://lkml.org/lkml/2025/7/12/336
> //
> // https://elixir.bootlin.com/linux/v6.16-rc5/source/net/ipv6/mcast.c#L786-L813
> @adjustment disable braces0@
> expression e;
> identifier i;
> @@
> void i(...)
> {
> ... when any
> if (
> +    !
>     e
>    )
> +   return;
> -   {
>    ... when any

I have no idea what is the question here, but the above when any is useless. Braces always match up properly.

> -   }
> -if (e)
> -   {
>    ... when any
> -   }
> ... when any
> }
> 
> 
> Would you be looking for further source code layout refinements then?
> 
> Regards,
> Markus


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

* Re: [cocci] Deleting duplicate condition checks (with SmPL)?
  2025-07-14  9:57   ` Julia Lawall
@ 2025-07-14 11:13     ` Markus Elfring
  2025-07-14 11:28       ` Julia Lawall
  0 siblings, 1 reply; 7+ messages in thread
From: Markus Elfring @ 2025-07-14 11:13 UTC (permalink / raw)
  To: Julia Lawall, cocci; +Cc: Yue Haibing, Kuniyuki Iwashima

>> // https://elixir.bootlin.com/linux/v6.16-rc5/source/net/ipv6/mcast.c#L786-L813
>> @adjustment disable braces0@
>> expression e;
>> identifier i;
>> @@
>> void i(...)
>> {
>> ... when any
>> if (
>> +    !
>>     e
>>    )
>> +   return;
>> -   {
>>    ... when any
> 
> I have no idea what is the question here,

Would you find any details improvable in the generated diff output?

Markus_Elfring@Sonne:…/Projekte/Linux/next-analyses> time /usr/bin/spatch …/Projekte/Coccinelle/janitor/delete_duplicate_condition_checks4.cocci net/ipv6/mcast.c
…
@@ -789,34 +789,31 @@ static void mld_del_delrec(struct inet6_
…


Examples:
* Coding style preferences?
…
+       if (!pmc)
+               return;
+       if (pmc_prev)
…

* Indentation?
…
+               for_each_psf_mclock(im, psf)
+                       psf->sf_crcount = idev->mc_qrv;
+} else {
+               im->mca_crcount = idev->mc_qrv;
        }
…


> but the above when any is useless. Braces always match up properly.

Will such information become relevant for a better software documentation?

Regards,
Markus

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

* Re: [cocci] Deleting duplicate condition checks (with SmPL)?
  2025-07-14 11:13     ` Markus Elfring
@ 2025-07-14 11:28       ` Julia Lawall
  2025-07-14 11:33         ` Markus Elfring
  0 siblings, 1 reply; 7+ messages in thread
From: Julia Lawall @ 2025-07-14 11:28 UTC (permalink / raw)
  To: Markus Elfring; +Cc: cocci, Yue Haibing, Kuniyuki Iwashima

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



On Mon, 14 Jul 2025, Markus Elfring wrote:

> >> // https://elixir.bootlin.com/linux/v6.16-rc5/source/net/ipv6/mcast.c#L786-L813
> >> @adjustment disable braces0@
> >> expression e;
> >> identifier i;
> >> @@
> >> void i(...)
> >> {
> >> ... when any
> >> if (
> >> +    !
> >>     e
> >>    )
> >> +   return;
> >> -   {
> >>    ... when any
> >
> > I have no idea what is the question here,
>
> Would you find any details improvable in the generated diff output?
>
> Markus_Elfring@Sonne:…/Projekte/Linux/next-analyses> time /usr/bin/spatch …/Projekte/Coccinelle/janitor/delete_duplicate_condition_checks4.cocci net/ipv6/mcast.c
> …
> @@ -789,34 +789,31 @@ static void mld_del_delrec(struct inet6_
> …
>
>
> Examples:
> * Coding style preferences?
> …
> +       if (!pmc)
> +               return;
> +       if (pmc_prev)
> …
>
> * Indentation?
> …
> +               for_each_psf_mclock(im, psf)
> +                       psf->sf_crcount = idev->mc_qrv;
> +} else {
> +               im->mca_crcount = idev->mc_qrv;
>         }
> …
>

I still have no idea what the question is.  Please provide a single email
with both the semantic patch and a small C program thta illustrates
whatever you are concerned about.  This is the rule for all issues that
you want to raise.  Everything should be in one email and easily
reproducible,

julia


>
> > but the above when any is useless. Braces always match up properly.
>
> Will such information become relevant for a better software documentation?
>
> Regards,
> Markus
>

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

* Re: [cocci] Deleting duplicate condition checks (with SmPL)?
  2025-07-14 11:28       ` Julia Lawall
@ 2025-07-14 11:33         ` Markus Elfring
  0 siblings, 0 replies; 7+ messages in thread
From: Markus Elfring @ 2025-07-14 11:33 UTC (permalink / raw)
  To: Julia Lawall, cocci; +Cc: Yue Haibing, Kuniyuki Iwashima

> I still have no idea what the question is.

Can you reproduce my observations in your software test environment?

Regards,
Markus

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

end of thread, other threads:[~2025-07-14 11:34 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-13  7:21 [cocci] Deleting duplicate condition checks (with SmPL)? Markus Elfring
2025-07-14  7:26 ` Markus Elfring
2025-07-14  9:57   ` Julia Lawall
2025-07-14 11:13     ` Markus Elfring
2025-07-14 11:28       ` Julia Lawall
2025-07-14 11:33         ` Markus Elfring
2025-07-14  9:54 ` Julia Lawall

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox