2019-11-19 18:06:49

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 0/4] improve platform_get_irq.cocci

Various cleanups in platform_get_irq.cocci to give more useful
patches and to give a few more results.


2019-11-19 18:08:34

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 2/4] coccinelle: platform_get_irq: handle 2-statement branches

From: Masahiro Yamada <[email protected]>

Treat separately the case where there is only one other
statement in the branch, to be able to remove the outer
{} as well.

Signed-off-by: Julia Lawall <[email protected]>

---
scripts/coccinelle/api/platform_get_irq.cocci | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)

diff --git a/scripts/coccinelle/api/platform_get_irq.cocci b/scripts/coccinelle/api/platform_get_irq.cocci
index c6ac755..7ac32ee 100644
--- a/scripts/coccinelle/api/platform_get_irq.cocci
+++ b/scripts/coccinelle/api/platform_get_irq.cocci
@@ -31,6 +31,25 @@ if ( \( ret < 0 \| ret <= 0 \) )
@depends on patch@
expression ret;
struct platform_device *E;
+statement S;
+@@
+
+ret =
+(
+platform_get_irq
+|
+platform_get_irq_byname
+)(E, ...);
+
+if ( \( ret < 0 \| ret <= 0 \) )
+-{
+-dev_err(...);
+S
+-}
+
+@depends on patch@
+expression ret;
+struct platform_device *E;
@@

ret =

2019-11-19 21:35:36

by Markus Elfring

[permalink] [raw]
Subject: Re: [PATCH 2/4] coccinelle: platform_get_irq: handle 2-statement branches

> From: Masahiro Yamada <[email protected]>

I wonder about this information.
Would you like to use the tag “Suggested-by” instead?



> +++ b/scripts/coccinelle/api/platform_get_irq.cocci
> @@ -31,6 +31,25 @@ if ( \( ret < 0 \| ret <= 0 \) )

> +ret =
> +(
> +platform_get_irq
> +|
> +platform_get_irq_byname
> +)(E, ...);
> +
> +if ( \( ret < 0 \| ret <= 0 \) )
> +-{
> +-dev_err(...);
> +S
> +-}

How do you think about to use the following SmPL code variant?

+ ret =
+(platform_get_irq
+|platform_get_irq_byname
+)(E, ...);
+
+ if ( \( ret < 0 \| ret <= 0 \) )
+-{
+-dev_err(...);
+ S
+-}

Regards,
Markus

2019-11-19 21:36:30

by Markus Elfring

[permalink] [raw]
Subject: Re: [PATCH 2/4] coccinelle: platform_get_irq: handle 2-statement branches

> From: Masahiro Yamada <[email protected]>

I wonder about this information.
Would you like to use the tag “Suggested-by” instead?



> +++ b/scripts/coccinelle/api/platform_get_irq.cocci
> @@ -31,6 +31,25 @@ if ( \( ret < 0 \| ret <= 0 \) )

> +ret =
> +(
> +platform_get_irq
> +|
> +platform_get_irq_byname
> +)(E, ...);
> +
> +if ( \( ret < 0 \| ret <= 0 \) )
> +-{
> +-dev_err(...);
> +S
> +-}

How do you think about to use the following SmPL code variant?

+ ret =
+(platform_get_irq
+|platform_get_irq_byname
+)(E, ...);
+
+ if ( \( ret < 0 \| ret <= 0 \) )
+-{
+-dev_err(...);
+ S
+-}

Regards,
Markus

2019-11-19 21:38:29

by Julia Lawall

[permalink] [raw]
Subject: Re: [PATCH 2/4] coccinelle: platform_get_irq: handle 2-statement branches



On Tue, 19 Nov 2019, Markus Elfring wrote:

> > From: Masahiro Yamada <[email protected]>
>
> I wonder about this information.
> Would you like to use the tag “Suggested-by” instead?

Sorry, I seem to have done something quite wrong on this patch. I will
fix it.

>
>
> …
> > +++ b/scripts/coccinelle/api/platform_get_irq.cocci
> > @@ -31,6 +31,25 @@ if ( \( ret < 0 \| ret <= 0 \) )
> …
> > +ret =
> > +(
> > +platform_get_irq
> > +|
> > +platform_get_irq_byname
> > +)(E, ...);
> > +
> > +if ( \( ret < 0 \| ret <= 0 \) )
> > +-{
> > +-dev_err(...);
> > +S
> > +-}
>
> How do you think about to use the following SmPL code variant?

And the benefit is what?

julia

> + ret =
> +(platform_get_irq
> +|platform_get_irq_byname
> +)(E, ...);
> +
> + if ( \( ret < 0 \| ret <= 0 \) )
> +-{
> +-dev_err(...);
> + S
> +-}
>
> Regards,
> Markus
>

2019-11-20 10:16:35

by Markus Elfring

[permalink] [raw]
Subject: Re: [2/4] coccinelle: platform_get_irq: handle 2-statement branches

> Sorry, I seem to have done something quite wrong on this patch.

Interesting …


> I will fix it.

Thanks.

Development will be continued:
https://lkml.org/lkml/2019/11/19/1681
https://lore.kernel.org/patchwork/patch/1156089/
https://lore.kernel.org/cocci/[email protected]/


>> How do you think about to use the following SmPL code variant?
>
> And the benefit is what?

>> + ret =
>> +(platform_get_irq
>> +|platform_get_irq_byname
>> +)(E, ...);
>> +
>> + if ( \( ret < 0 \| ret <= 0 \) )
>> +-{
>> +-dev_err(...);
>> + S
>> +-}

* I suggest to use a different coding style for the specification of
two function names in the SmPL disjunction.

* Would you like to avoid the mixing of code items in the first text column?

Regards,
Markus