Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1433960

[PATCH] Coccinelle: Script to replace NULL test with IS_ERR test for devm_ioremap_resource

From Amitoj Kaur Chawla <amitoj1606@gmail.com>
Newsgroups linux.kernel
Subject [PATCH] Coccinelle: Script to replace NULL test with IS_ERR test for devm_ioremap_resource
Date 2016-06-29 20:40 +0200
Message-ID <rPsyZ-7FB-5@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View 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

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH] Coccinelle: Script to replace NULL test with IS_ERR test for  devm_ioremap_resource Amitoj Kaur Chawla <amitoj1606@gmail.com> - 2016-06-29 20:40 +0200
  Re: [Cocci] [PATCH] Coccinelle: Script to replace NULL test with  IS_ERR test for devm_ioremap_resource Wolfram Sang <wsa@the-dreams.de> - 2016-06-29 21:30 +0200
    Re: [Cocci] [PATCH] Coccinelle: Script to replace NULL test with  IS_ERR test for devm_ioremap_resource Amitoj Kaur Chawla <amitoj1606@gmail.com> - 2016-06-30 04:50 +0200
      Re: [Cocci] [PATCH] Coccinelle: Script to replace NULL test with  IS_ERR test for devm_ioremap_resource Wolfram Sang <wsa@the-dreams.de> - 2016-06-30 09:20 +0200

csiph-web