linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] scripts/coccinelle: ptr_ret: Add ternary operator version
@ 2012-08-21  8:49 Lars-Peter Clausen
  2012-08-21  9:06 ` [Cocci] " Julia Lawall
  0 siblings, 1 reply; 3+ messages in thread
From: Lars-Peter Clausen @ 2012-08-21  8:49 UTC (permalink / raw)
  To: Julia Lawall; +Cc: cocci, linux-kernel, Lars-Peter Clausen

Add a ternary operator version of the open-coded PTR_RET().

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 scripts/coccinelle/api/ptr_ret.cocci |   26 ++++++++++++++++++++++++++
 1 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/scripts/coccinelle/api/ptr_ret.cocci b/scripts/coccinelle/api/ptr_ret.cocci
index cbfd08c..15f076f 100644
--- a/scripts/coccinelle/api/ptr_ret.cocci
+++ b/scripts/coccinelle/api/ptr_ret.cocci
@@ -30,6 +30,13 @@ expression ptr;
 - if (IS_ERR(ptr)) return PTR_ERR(ptr); return 0;
 + return PTR_RET(ptr);
 
+@depends on patch@
+expression ptr;
+@@
+
+- (IS_ERR(ptr) ? PTR_ERR(ptr) : 0)
++ PTR_RET(ptr)
+
 @r1 depends on !patch@
 expression ptr;
 position p1;
@@ -44,6 +51,13 @@ position p2;
 
 * if@p2 (IS_ERR(ptr)) return PTR_ERR(ptr); return 0;
 
+@r3 depends on !patch@
+expression ptr;
+position p3;
+@@
+
+* IS_ERR@p3(ptr) ? PTR_ERR(ptr) : 0
+
 @script:python depends on org@
 p << r1.p1;
 @@
@@ -57,6 +71,12 @@ p << r2.p2;
 
 coccilib.org.print_todo(p[0], "WARNING: PTR_RET can be used")
 
+@script:python depends on org@
+p << r3.p3;
+@@
+
+coccilib.org.print_todo(p[0], "WARNING: PTR_RET can be used")
+
 @script:python depends on report@
 p << r1.p1;
 @@
@@ -68,3 +88,9 @@ p << r2.p2;
 @@
 
 coccilib.report.print_report(p[0], "WARNING: PTR_RET can be used")
+
+@script:python depends on report@
+p << r3.p3;
+@@
+
+coccilib.report.print_report(p[0], "WARNING: PTR_RET can be used")
-- 
1.7.2.5


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

* Re: [Cocci] [PATCH] scripts/coccinelle: ptr_ret: Add ternary operator version
  2012-08-21  8:49 [PATCH] scripts/coccinelle: ptr_ret: Add ternary operator version Lars-Peter Clausen
@ 2012-08-21  9:06 ` Julia Lawall
  2012-08-31 14:55   ` Michal Marek
  0 siblings, 1 reply; 3+ messages in thread
From: Julia Lawall @ 2012-08-21  9:06 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: Julia Lawall, linux-kernel, cocci, Michal Marek



On Tue, 21 Aug 2012, Lars-Peter Clausen wrote:

> Add a ternary operator version of the open-coded PTR_RET().
>
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
> ---
>  scripts/coccinelle/api/ptr_ret.cocci |   26 ++++++++++++++++++++++++++
>  1 files changed, 26 insertions(+), 0 deletions(-)
>
> diff --git a/scripts/coccinelle/api/ptr_ret.cocci b/scripts/coccinelle/api/ptr_ret.cocci
> index cbfd08c..15f076f 100644
> --- a/scripts/coccinelle/api/ptr_ret.cocci
> +++ b/scripts/coccinelle/api/ptr_ret.cocci
> @@ -30,6 +30,13 @@ expression ptr;
>  - if (IS_ERR(ptr)) return PTR_ERR(ptr); return 0;
>  + return PTR_RET(ptr);
>
> +@depends on patch@
> +expression ptr;
> +@@
> +
> +- (IS_ERR(ptr) ? PTR_ERR(ptr) : 0)
> ++ PTR_RET(ptr)
> +
>  @r1 depends on !patch@
>  expression ptr;
>  position p1;
> @@ -44,6 +51,13 @@ position p2;
>
>  * if@p2 (IS_ERR(ptr)) return PTR_ERR(ptr); return 0;
>
> +@r3 depends on !patch@
> +expression ptr;
> +position p3;
> +@@
> +
> +* IS_ERR@p3(ptr) ? PTR_ERR(ptr) : 0
> +
>  @script:python depends on org@
>  p << r1.p1;
>  @@
> @@ -57,6 +71,12 @@ p << r2.p2;
>
>  coccilib.org.print_todo(p[0], "WARNING: PTR_RET can be used")
>
> +@script:python depends on org@
> +p << r3.p3;
> +@@
> +
> +coccilib.org.print_todo(p[0], "WARNING: PTR_RET can be used")
> +
>  @script:python depends on report@
>  p << r1.p1;
>  @@
> @@ -68,3 +88,9 @@ p << r2.p2;
>  @@
>
>  coccilib.report.print_report(p[0], "WARNING: PTR_RET can be used")
> +
> +@script:python depends on report@
> +p << r3.p3;
> +@@
> +
> +coccilib.report.print_report(p[0], "WARNING: PTR_RET can be used")

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

> --
> 1.7.2.5
>
> _______________________________________________
> Cocci mailing list
> Cocci@diku.dk
> http://lists.diku.dk/mailman/listinfo/cocci
> (Web access from inside DIKUs LAN only)
>

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

* Re: [Cocci] [PATCH] scripts/coccinelle: ptr_ret: Add ternary operator version
  2012-08-21  9:06 ` [Cocci] " Julia Lawall
@ 2012-08-31 14:55   ` Michal Marek
  0 siblings, 0 replies; 3+ messages in thread
From: Michal Marek @ 2012-08-31 14:55 UTC (permalink / raw)
  To: Julia Lawall; +Cc: Lars-Peter Clausen, Julia Lawall, linux-kernel, cocci

On Tue, Aug 21, 2012 at 11:06:35AM +0200, Julia Lawall wrote:
> 
> 
> On Tue, 21 Aug 2012, Lars-Peter Clausen wrote:
> 
> > Add a ternary operator version of the open-coded PTR_RET().
> >
> > Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
> 
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

Applied to kbuild.git#misc, thanks.

Michal

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

end of thread, other threads:[~2012-08-31 14:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-21  8:49 [PATCH] scripts/coccinelle: ptr_ret: Add ternary operator version Lars-Peter Clausen
2012-08-21  9:06 ` [Cocci] " Julia Lawall
2012-08-31 14:55   ` Michal Marek

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).