From: Amitoj Kaur Chawla <amitoj1606@gmail.com>
To: Julia.Lawall@lip6.fr, Gilles.Muller@lip6.fr,
nicolas.palix@imag.fr, mmarek@suse.com, cocci@systeme.lip6.fr,
linux-kernel@vger.kernel.org
Subject: [PATCH] Coccinelle: Script to replace NULL test with IS_ERR test for devm_ioremap_resource
Date: Thu, 30 Jun 2016 00:03:47 +0530 [thread overview]
Message-ID: <20160629183347.GA17067@amitoj-Inspiron-3542> (raw)
This script detects cases which have incorrect error handling for
devm_ioremap_resource function, employing a NULL test instead of an
IS_ERR() test.
Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
---
.../coccinelle/null/devm_ioremap_resource.cocci | 37 ++++++++++++++++++++++
1 file changed, 37 insertions(+)
create mode 100644 scripts/coccinelle/null/devm_ioremap_resource.cocci
diff --git a/scripts/coccinelle/null/devm_ioremap_resource.cocci b/scripts/coccinelle/null/devm_ioremap_resource.cocci
new file mode 100644
index 0000000..bc87efa
--- /dev/null
+++ b/scripts/coccinelle/null/devm_ioremap_resource.cocci
@@ -0,0 +1,37 @@
+/// Correct error handling for devm_ioremap_resource
+///
+// Confidence: High
+// Copyright: (C) 2016 Amitoj Kaur Chawla
+// Keywords: devm,devm_ioremap_resource
+
+virtual context
+virtual org
+virtual report
+
+// ----------------------------------------------------------------------------
+
+@err depends on context || org || report@
+statement S;
+expression e;
+position j0;
+@@
+
+ e = devm_ioremap_resource(...);
+* if (!e@j0) S
+// ----------------------------------------------------------------------------
+
+@script:python err_org depends on org@
+j0 << err.j0;
+@@
+
+msg = "Incorrect error handling."
+coccilib.org.print_todo(j0[0], msg)
+
+// ----------------------------------------------------------------------------
+
+@script:python err_report depends on report@
+j0 << err.j0;
+@@
+
+msg = "Incorrect error handling."
+coccilib.report.print_report(j0[0], msg)
--
1.9.1
next reply other threads:[~2016-06-29 18:33 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-29 18:33 Amitoj Kaur Chawla [this message]
2016-06-29 19:23 ` [Cocci] " Wolfram Sang
2016-06-30 2:43 ` Amitoj Kaur Chawla
2016-06-30 7:14 ` Wolfram Sang
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=20160629183347.GA17067@amitoj-Inspiron-3542 \
--to=amitoj1606@gmail.com \
--cc=Gilles.Muller@lip6.fr \
--cc=Julia.Lawall@lip6.fr \
--cc=cocci@systeme.lip6.fr \
--cc=linux-kernel@vger.kernel.org \
--cc=mmarek@suse.com \
--cc=nicolas.palix@imag.fr \
/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®