All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Coccinelle: Script to replace NULL test with IS_ERR test for devm_ioremap_resource
@ 2016-06-29 18:33 ` Amitoj Kaur Chawla
  0 siblings, 0 replies; 8+ messages in thread
From: Amitoj Kaur Chawla @ 2016-06-29 18:33 UTC (permalink / raw)
  To: Julia.Lawall, Gilles.Muller, nicolas.palix, mmarek, cocci, linux-kernel

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

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

* [Cocci] [PATCH] Coccinelle: Script to replace NULL test with IS_ERR test for devm_ioremap_resource
@ 2016-06-29 18:33 ` Amitoj Kaur Chawla
  0 siblings, 0 replies; 8+ messages in thread
From: Amitoj Kaur Chawla @ 2016-06-29 18:33 UTC (permalink / raw)
  To: cocci

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
+
+// ----------------------------------------------------------------------------
+
+ at err depends on context || org || report@
+statement S;
+expression e;
+position j0;
+@@
+
+  e = devm_ioremap_resource(...);
+* if (!e at j0) S
+// ----------------------------------------------------------------------------
+
+ at 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

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

* Re: [Cocci] [PATCH] Coccinelle: Script to replace NULL test with IS_ERR test for devm_ioremap_resource
  2016-06-29 18:33 ` [Cocci] " Amitoj Kaur Chawla
@ 2016-06-29 19:23   ` Wolfram Sang
  -1 siblings, 0 replies; 8+ messages in thread
From: Wolfram Sang @ 2016-06-29 19:23 UTC (permalink / raw)
  To: Amitoj Kaur Chawla
  Cc: Julia.Lawall, Gilles.Muller, nicolas.palix, mmarek, cocci, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 518 bytes --]

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)


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* [Cocci] [PATCH] Coccinelle: Script to replace NULL test with IS_ERR test for devm_ioremap_resource
@ 2016-06-29 19:23   ` Wolfram Sang
  0 siblings, 0 replies; 8+ messages in thread
From: Wolfram Sang @ 2016-06-29 19:23 UTC (permalink / raw)
  To: cocci

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)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <https://systeme.lip6.fr/pipermail/cocci/attachments/20160629/fe60e990/attachment.asc>

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

* Re: [Cocci] [PATCH] Coccinelle: Script to replace NULL test with IS_ERR test for devm_ioremap_resource
  2016-06-29 19:23   ` Wolfram Sang
@ 2016-06-30  2:43     ` Amitoj Kaur Chawla
  -1 siblings, 0 replies; 8+ messages in thread
From: Amitoj Kaur Chawla @ 2016-06-30  2:43 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: Julia Lawall, Gilles.Muller, nicolas.palix, mmarek, cocci,
	Linux-Kernel@Vger. Kernel. Org

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

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

* [Cocci] [PATCH] Coccinelle: Script to replace NULL test with IS_ERR test for devm_ioremap_resource
@ 2016-06-30  2:43     ` Amitoj Kaur Chawla
  0 siblings, 0 replies; 8+ messages in thread
From: Amitoj Kaur Chawla @ 2016-06-30  2:43 UTC (permalink / raw)
  To: cocci

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

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

* Re: [Cocci] [PATCH] Coccinelle: Script to replace NULL test with IS_ERR test for devm_ioremap_resource
  2016-06-30  2:43     ` Amitoj Kaur Chawla
@ 2016-06-30  7:14       ` Wolfram Sang
  -1 siblings, 0 replies; 8+ messages in thread
From: Wolfram Sang @ 2016-06-30  7:14 UTC (permalink / raw)
  To: Amitoj Kaur Chawla
  Cc: Julia Lawall, Gilles.Muller, nicolas.palix, mmarek, cocci,
	Linux-Kernel@Vger. Kernel. Org

[-- Attachment #1: Type: text/plain, Size: 97 bytes --]


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

Sounds good, thanks!


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* [Cocci] [PATCH] Coccinelle: Script to replace NULL test with IS_ERR test for devm_ioremap_resource
@ 2016-06-30  7:14       ` Wolfram Sang
  0 siblings, 0 replies; 8+ messages in thread
From: Wolfram Sang @ 2016-06-30  7:14 UTC (permalink / raw)
  To: cocci


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

Sounds good, thanks!

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <https://systeme.lip6.fr/pipermail/cocci/attachments/20160630/d4549886/attachment.asc>

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

end of thread, other threads:[~2016-06-30  7:14 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-29 18:33 [PATCH] Coccinelle: Script to replace NULL test with IS_ERR test for devm_ioremap_resource Amitoj Kaur Chawla
2016-06-29 18:33 ` [Cocci] " Amitoj Kaur Chawla
2016-06-29 19:23 ` Wolfram Sang
2016-06-29 19:23   ` Wolfram Sang
2016-06-30  2:43   ` Amitoj Kaur Chawla
2016-06-30  2:43     ` Amitoj Kaur Chawla
2016-06-30  7:14     ` Wolfram Sang
2016-06-30  7:14       ` Wolfram Sang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.