From: Lars-Peter Clausen <lars@metafoo.de>
To: Julia Lawall <julia@diku.dk>
Cc: cocci@diku.dk, linux-kernel@vger.kernel.org,
Lars-Peter Clausen <lars@metafoo.de>
Subject: [PATCH] scripts/coccinelle: ptr_ret: Add ternary operator version
Date: Tue, 21 Aug 2012 10:49:58 +0200 [thread overview]
Message-ID: <1345538998-24600-1-git-send-email-lars@metafoo.de> (raw)
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
next reply other threads:[~2012-08-21 8:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-21 8:49 Lars-Peter Clausen [this message]
2012-08-21 9:06 ` [Cocci] " Julia Lawall
2012-08-31 14:55 ` Michal Marek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1345538998-24600-1-git-send-email-lars@metafoo.de \
--to=lars@metafoo.de \
--cc=cocci@diku.dk \
--cc=julia@diku.dk \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®