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


Groups > linux.kernel > #1433960 > unrolled thread

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

Started byAmitoj Kaur Chawla <amitoj1606@gmail.com>
First post2016-06-29 20:40 +0200
Last post2016-06-30 09:20 +0200
Articles 4 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [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

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

FromAmitoj Kaur Chawla <amitoj1606@gmail.com>
Date2016-06-29 20:40 +0200
Subject[PATCH] Coccinelle: Script to replace NULL test with IS_ERR test for devm_ioremap_resource
Message-ID<rPsyZ-7FB-5@gated-at.bofh.it>
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

[toc] | [next] | [standalone]


#1434006 — Re: [Cocci] [PATCH] Coccinelle: Script to replace NULL test with IS_ERR test for devm_ioremap_resource

FromWolfram Sang <wsa@the-dreams.de>
Date2016-06-29 21:30 +0200
SubjectRe: [Cocci] [PATCH] Coccinelle: Script to replace NULL test with IS_ERR test for devm_ioremap_resource
Message-ID<rPtlo-8bY-13@gated-at.bofh.it>
In reply to#1433960

[Multipart message — attachments visible in raw view] — view raw

On Thu, Jun 30, 2016 at 12:03:47AM +0530, Amitoj Kaur Chawla wrote:
> 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>

Why don't we fix the code at the same time?

And it should not be restricted to devm_ioremap_resource() but
extensible so other functions could be added later?

(Surprised to see that we don't have such a script yet)

[toc] | [prev] | [next] | [standalone]


#1434184 — Re: [Cocci] [PATCH] Coccinelle: Script to replace NULL test with IS_ERR test for devm_ioremap_resource

FromAmitoj Kaur Chawla <amitoj1606@gmail.com>
Date2016-06-30 04:50 +0200
SubjectRe: [Cocci] [PATCH] Coccinelle: Script to replace NULL test with IS_ERR test for devm_ioremap_resource
Message-ID<rPAdb-3Uz-1@gated-at.bofh.it>
In reply to#1434006
On Thu, Jun 30, 2016 at 12:53 AM, Wolfram Sang <wsa@the-dreams.de> wrote:
> On Thu, Jun 30, 2016 at 12:03:47AM +0530, Amitoj Kaur Chawla wrote:
>> 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>
>
> Why don't we fix the code at the same time?
>

Thank you for your suggestion. I will fix this up and resend.

> And it should not be restricted to devm_ioremap_resource() but
> extensible so other functions could be added later?
>
> (Surprised to see that we don't have such a script yet)
>

I am working on a more general solution, extending to other functions.

Amitoj

[toc] | [prev] | [next] | [standalone]


#1434279 — Re: [Cocci] [PATCH] Coccinelle: Script to replace NULL test with IS_ERR test for devm_ioremap_resource

FromWolfram Sang <wsa@the-dreams.de>
Date2016-06-30 09:20 +0200
SubjectRe: [Cocci] [PATCH] Coccinelle: Script to replace NULL test with IS_ERR test for devm_ioremap_resource
Message-ID<rPEqu-6Dg-9@gated-at.bofh.it>
In reply to#1434184

[Multipart message — attachments visible in raw view] — view raw

> I am working on a more general solution, extending to other functions.

Sounds good, thanks!

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web