cocci.inria.fr archive mirror
 help / color / mirror / Atom feed
* [Cocci] [PATCH 0/4] improve platform_get_irq.cocci
@ 2019-11-19 17:28 Julia Lawall
  2019-11-19 17:28 ` [Cocci] [PATCH 1/4] coccinelle: platform_get_irq: simplify context case Julia Lawall
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Julia Lawall @ 2019-11-19 17:28 UTC (permalink / raw)
  To: linux-kernel, Masahiro Yamada
  Cc: Nicolas Palix, Gilles Muller, Michal Marek, kernel-janitors, cocci

Various cleanups in platform_get_irq.cocci to give more useful
patches and to give a few more results.
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* [Cocci] [PATCH 1/4] coccinelle: platform_get_irq: simplify context case
  2019-11-19 17:28 [Cocci] [PATCH 0/4] improve platform_get_irq.cocci Julia Lawall
@ 2019-11-19 17:28 ` Julia Lawall
  2019-11-19 17:28 ` [Cocci] [PATCH 2/4] coccinelle: platform_get_irq: handle 2-statement branches Julia Lawall
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 9+ messages in thread
From: Julia Lawall @ 2019-11-19 17:28 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Michal Marek, kernel-janitors, Nicolas Palix, linux-kernel,
	Gilles Muller, cocci

Simplify to just report on the first dev_err, whereever it occurs.

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 scripts/coccinelle/api/platform_get_irq.cocci |    9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/scripts/coccinelle/api/platform_get_irq.cocci b/scripts/coccinelle/api/platform_get_irq.cocci
index 06b6a95..c6ac755 100644
--- a/scripts/coccinelle/api/platform_get_irq.cocci
+++ b/scripts/coccinelle/api/platform_get_irq.cocci
@@ -23,16 +23,9 @@ platform_get_irq_byname
 
 if ( \( ret < 0 \| ret <= 0 \) )
 {
-(
-if (ret != -EPROBE_DEFER)
-{ ...
-*dev_err(...);
-... }
-|
 ...
 *dev_err(...);
-)
-...
+... when any
 }
 
 @depends on patch@

_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* [Cocci] [PATCH 2/4] coccinelle: platform_get_irq: handle 2-statement branches
  2019-11-19 17:28 [Cocci] [PATCH 0/4] improve platform_get_irq.cocci Julia Lawall
  2019-11-19 17:28 ` [Cocci] [PATCH 1/4] coccinelle: platform_get_irq: simplify context case Julia Lawall
@ 2019-11-19 17:28 ` Julia Lawall
  2019-11-19 21:33   ` Markus Elfring
  2019-11-19 21:33   ` [Cocci] [PATCH 2/4] " Markus Elfring
  2019-11-19 17:28 ` [Cocci] [PATCH 3/4] coccinelle: platform_get_irq: allow multiple dev_errs Julia Lawall
  2019-11-19 17:28 ` [Cocci] [PATCH 4/4] coccinelle: platform_get_irq: drop unneeded metavariable Julia Lawall
  3 siblings, 2 replies; 9+ messages in thread
From: Julia Lawall @ 2019-11-19 17:28 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Michal Marek, kernel-janitors, Nicolas Palix, linux-kernel,
	Gilles Muller, cocci

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(+)

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 =
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* [Cocci] [PATCH 3/4] coccinelle: platform_get_irq: allow multiple dev_errs
  2019-11-19 17:28 [Cocci] [PATCH 0/4] improve platform_get_irq.cocci Julia Lawall
  2019-11-19 17:28 ` [Cocci] [PATCH 1/4] coccinelle: platform_get_irq: simplify context case Julia Lawall
  2019-11-19 17:28 ` [Cocci] [PATCH 2/4] coccinelle: platform_get_irq: handle 2-statement branches Julia Lawall
@ 2019-11-19 17:28 ` Julia Lawall
  2019-11-19 17:28 ` [Cocci] [PATCH 4/4] coccinelle: platform_get_irq: drop unneeded metavariable Julia Lawall
  3 siblings, 0 replies; 9+ messages in thread
From: Julia Lawall @ 2019-11-19 17:28 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Michal Marek, kernel-janitors, Nicolas Palix, linux-kernel,
	Gilles Muller, cocci

Allow multiple calls to dev_err in the if branch under the
call to the platform_get_irq function.  Remove only the
first one.

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 scripts/coccinelle/api/platform_get_irq.cocci |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/coccinelle/api/platform_get_irq.cocci b/scripts/coccinelle/api/platform_get_irq.cocci
index 7ac32ee..e5d04fb 100644
--- a/scripts/coccinelle/api/platform_get_irq.cocci
+++ b/scripts/coccinelle/api/platform_get_irq.cocci
@@ -70,7 +70,7 @@ if ( \( ret < 0 \| ret <= 0 \) )
 ...
 -dev_err(...);
 )
-...
+... when any
 }
 
 @r depends on org || report@
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* [Cocci] [PATCH 4/4] coccinelle: platform_get_irq: drop unneeded metavariable
  2019-11-19 17:28 [Cocci] [PATCH 0/4] improve platform_get_irq.cocci Julia Lawall
                   ` (2 preceding siblings ...)
  2019-11-19 17:28 ` [Cocci] [PATCH 3/4] coccinelle: platform_get_irq: allow multiple dev_errs Julia Lawall
@ 2019-11-19 17:28 ` Julia Lawall
  3 siblings, 0 replies; 9+ messages in thread
From: Julia Lawall @ 2019-11-19 17:28 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Michal Marek, kernel-janitors, Nicolas Palix, linux-kernel,
	Gilles Muller, cocci

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

Having E as a metavariable adds the requirement to verify its type.
This seems like an unnecessary constraint, so drop it.
There is currently no impact on the set of results.

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 scripts/coccinelle/api/platform_get_irq.cocci |   12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/scripts/coccinelle/api/platform_get_irq.cocci b/scripts/coccinelle/api/platform_get_irq.cocci
index e5d04fb..17e5895 100644
--- a/scripts/coccinelle/api/platform_get_irq.cocci
+++ b/scripts/coccinelle/api/platform_get_irq.cocci
@@ -11,7 +11,6 @@ virtual report
 
 @depends on context@
 expression ret;
-struct platform_device *E;
 @@
 
 ret =
@@ -19,7 +18,7 @@ ret =
 platform_get_irq
 |
 platform_get_irq_byname
-)(E, ...);
+)(...);
 
 if ( \( ret < 0 \| ret <= 0 \) )
 {
@@ -30,7 +29,6 @@ if ( \( ret < 0 \| ret <= 0 \) )
 
 @depends on patch@
 expression ret;
-struct platform_device *E;
 statement S;
 @@
 
@@ -39,7 +37,7 @@ ret =
 platform_get_irq
 |
 platform_get_irq_byname
-)(E, ...);
+)(...);
 
 if ( \( ret < 0 \| ret <= 0 \) )
 -{
@@ -49,7 +47,6 @@ S
 
 @depends on patch@
 expression ret;
-struct platform_device *E;
 @@
 
 ret =
@@ -57,7 +54,7 @@ ret =
 platform_get_irq
 |
 platform_get_irq_byname
-)(E, ...);
+)(...);
 
 if ( \( ret < 0 \| ret <= 0 \) )
 {
@@ -76,7 +73,6 @@ if ( \( ret < 0 \| ret <= 0 \) )
 @r depends on org || report@
 position p1;
 expression ret;
-struct platform_device *E;
 @@
 
 ret =
@@ -84,7 +80,7 @@ ret =
 platform_get_irq
 |
 platform_get_irq_byname
-)(E, ...);
+)(...);
 
 if ( \( ret < 0 \| ret <= 0 \) )
 {
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* Re: [Cocci] [PATCH 2/4] coccinelle: platform_get_irq: handle 2-statement branches
  2019-11-19 17:28 ` [Cocci] [PATCH 2/4] coccinelle: platform_get_irq: handle 2-statement branches Julia Lawall
@ 2019-11-19 21:33   ` Markus Elfring
  2019-11-19 21:36     ` Julia Lawall
  2019-11-19 21:33   ` [Cocci] [PATCH 2/4] " Markus Elfring
  1 sibling, 1 reply; 9+ messages in thread
From: Markus Elfring @ 2019-11-19 21:33 UTC (permalink / raw)
  To: Julia Lawall, cocci
  Cc: Michal Marek, kernel-janitors, Nicolas Palix, linux-kernel

> 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
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* Re: [Cocci] [PATCH 2/4] coccinelle: platform_get_irq: handle 2-statement branches
  2019-11-19 17:28 ` [Cocci] [PATCH 2/4] coccinelle: platform_get_irq: handle 2-statement branches Julia Lawall
  2019-11-19 21:33   ` Markus Elfring
@ 2019-11-19 21:33   ` Markus Elfring
  1 sibling, 0 replies; 9+ messages in thread
From: Markus Elfring @ 2019-11-19 21:33 UTC (permalink / raw)
  To: Julia Lawall, cocci
  Cc: Michal Marek, kernel-janitors, Nicolas Palix, linux-kernel

> 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
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* Re: [Cocci] [PATCH 2/4] coccinelle: platform_get_irq: handle 2-statement branches
  2019-11-19 21:33   ` Markus Elfring
@ 2019-11-19 21:36     ` Julia Lawall
  2019-11-20  9:38       ` [Cocci] [2/4] " Markus Elfring
  0 siblings, 1 reply; 9+ messages in thread
From: Julia Lawall @ 2019-11-19 21:36 UTC (permalink / raw)
  To: Markus Elfring
  Cc: Michal Marek, Nicolas Palix, kernel-janitors, linux-kernel, cocci

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



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
>

[-- Attachment #2: Type: text/plain, Size: 136 bytes --]

_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* Re: [Cocci] [2/4] coccinelle: platform_get_irq: handle 2-statement branches
  2019-11-19 21:36     ` Julia Lawall
@ 2019-11-20  9:38       ` Markus Elfring
  0 siblings, 0 replies; 9+ messages in thread
From: Markus Elfring @ 2019-11-20  9:38 UTC (permalink / raw)
  To: Julia Lawall, cocci
  Cc: Michal Marek, kernel-janitors, Nicolas Palix, linux-kernel

> 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
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

end of thread, other threads:[~2019-11-20  9:39 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-19 17:28 [Cocci] [PATCH 0/4] improve platform_get_irq.cocci Julia Lawall
2019-11-19 17:28 ` [Cocci] [PATCH 1/4] coccinelle: platform_get_irq: simplify context case Julia Lawall
2019-11-19 17:28 ` [Cocci] [PATCH 2/4] coccinelle: platform_get_irq: handle 2-statement branches Julia Lawall
2019-11-19 21:33   ` Markus Elfring
2019-11-19 21:36     ` Julia Lawall
2019-11-20  9:38       ` [Cocci] [2/4] " Markus Elfring
2019-11-19 21:33   ` [Cocci] [PATCH 2/4] " Markus Elfring
2019-11-19 17:28 ` [Cocci] [PATCH 3/4] coccinelle: platform_get_irq: allow multiple dev_errs Julia Lawall
2019-11-19 17:28 ` [Cocci] [PATCH 4/4] coccinelle: platform_get_irq: drop unneeded metavariable Julia Lawall

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).