Coccinelle archive on lore.kernel.org
 help / color / Atom feed
* [Cocci] [PATCH 0/4 v2] improve platform_get_irq.cocci
@ 2019-11-19 21:08 Julia Lawall
  2019-11-19 21:08 ` [Cocci] [PATCH 1/4 v2] coccinelle: platform_get_irq: simplify context case Julia Lawall
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Julia Lawall @ 2019-11-19 21:08 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.

v2: fix some interchanged From's and To's
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* [Cocci] [PATCH 1/4 v2] coccinelle: platform_get_irq: simplify context case
  2019-11-19 21:08 [Cocci] [PATCH 0/4 v2] improve platform_get_irq.cocci Julia Lawall
@ 2019-11-19 21:08 ` Julia Lawall
  2019-11-20 14:33   ` Markus Elfring
  2019-11-19 21:08 ` [Cocci] [PATCH 2/4 v2] coccinelle: platform_get_irq: handle 2-statement branches Julia Lawall
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 6+ messages in thread
From: Julia Lawall @ 2019-11-19 21:08 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>

---
v2: no change

 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	[flat|nested] 6+ messages in thread

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

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>

---
v2: fix From and To (very sorry for the mistake)

 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	[flat|nested] 6+ messages in thread

* [Cocci] [PATCH 3/4 v2] coccinelle: platform_get_irq: allow multiple dev_errs
  2019-11-19 21:08 [Cocci] [PATCH 0/4 v2] improve platform_get_irq.cocci Julia Lawall
  2019-11-19 21:08 ` [Cocci] [PATCH 1/4 v2] coccinelle: platform_get_irq: simplify context case Julia Lawall
  2019-11-19 21:08 ` [Cocci] [PATCH 2/4 v2] coccinelle: platform_get_irq: handle 2-statement branches Julia Lawall
@ 2019-11-19 21:08 ` Julia Lawall
  2019-11-19 21:08 ` [Cocci] [PATCH 4/4 v2] coccinelle: platform_get_irq: drop unneeded metavariable Julia Lawall
  3 siblings, 0 replies; 6+ messages in thread
From: Julia Lawall @ 2019-11-19 21:08 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>

---
v2: no change

 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	[flat|nested] 6+ messages in thread

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

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>

---
v2: fix From and To (very sorry for the mistake)

 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	[flat|nested] 6+ messages in thread

* Re: [Cocci] [PATCH 1/4 v2] coccinelle: platform_get_irq: simplify context case
  2019-11-19 21:08 ` [Cocci] [PATCH 1/4 v2] coccinelle: platform_get_irq: simplify context case Julia Lawall
@ 2019-11-20 14:33   ` Markus Elfring
  0 siblings, 0 replies; 6+ messages in thread
From: Markus Elfring @ 2019-11-20 14:33 UTC (permalink / raw)
  To: Julia Lawall, cocci
  Cc: Michal Marek, kernel-janitors, Nicolas Palix, linux-kernel

>  if ( \( ret < 0 \| ret <= 0 \) )

Can it make sense to specify the comparison by a constraint for
a metavariable of the type “binary operator” instead of a SmPL disjunction?

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

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

end of thread, back to index

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

Coccinelle archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/cocci/0 cocci/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 cocci cocci/ https://lore.kernel.org/cocci \
		cocci@systeme.lip6.fr
	public-inbox-index cocci

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/fr.lip6.systeme.cocci


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git