diff mbox series

[2/4] coccinelle: platform_get_irq: handle 2-statement branches

Message ID 1574184500-29870-3-git-send-email-Julia.Lawall@lip6.fr
State New
Headers show
Series None | expand

Commit Message

Julia Lawall Nov. 19, 2019, 5:28 p.m. UTC
From: Masahiro Yamada <yamada.masahiro@socionext.com>


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 <Julia.Lawall@lip6.fr>


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

Comments

Markus Elfring Nov. 19, 2019, 9:33 p.m. UTC | #1
> From: Masahiro Yamada <yamada.masahiro@socionext.com>


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
Markus Elfring Nov. 19, 2019, 9:33 p.m. UTC | #2
> From: Masahiro Yamada <yamada.masahiro@socionext.com>


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
Julia Lawall Nov. 19, 2019, 9:36 p.m. UTC | #3
On Tue, 19 Nov 2019, Markus Elfring wrote:

> > From: Masahiro Yamada <yamada.masahiro@socionext.com>

>

> 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

>
Markus Elfring Nov. 20, 2019, 9:38 a.m. UTC | #4
> 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/1574197705-31132-3-git-send-email-Julia.Lawall@lip6.fr/


>> 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
diff mbox series

Patch

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 =