kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] coccinelle: api: check for propagation of error from platform_get_irq
@ 2015-12-26 19:24 Julia Lawall
  2015-12-26 19:59 ` Sergei Shtylyov
  0 siblings, 1 reply; 15+ messages in thread
From: Julia Lawall @ 2015-12-26 19:24 UTC (permalink / raw)
  To: cocci

The error return value of platform_get_irq seems to often get dropped.

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 scripts/coccinelle/api/platform_get_irq_return.cocci |   53 ++++++++++
 1 file changed, 53 insertions(+)

diff --git a/scripts/coccinelle/api/platform_get_irq_return.cocci b/scripts/coccinelle/api/platform_get_irq_return.cocci
new file mode 100644
index 0000000..96fc560
--- /dev/null
+++ b/scripts/coccinelle/api/platform_get_irq_return.cocci
@@ -0,0 +1,53 @@
+/// Propagate the return value of platform_get_irq.
+//# Sometimes the return value of platform_get_irq is tested using <= 0, but 0
+//# might not be an appropriate return value in an error case.
+///
+// Confidence: Moderate
+// Copyright: (C) 2015 Julia Lawall, Inria. GPLv2.
+// URL: http://coccinelle.lip6.fr/
+// Options: --no-includes --include-headers
+
+virtual context
+virtual org
+virtual report
+
+// ----------------------------------------------------------------------------
+
+@r depends on context || org || report@
+constant C;
+expression e, ret;
+position j0, j1, j2;
+@@
+
+* e@j0 = platform_get_irq(...);
+if (...) {
+  ...
+  ret@j1 = -C;
+  ...
+  return ret@j2;
+}
+
+// ----------------------------------------------------------------------------
+
+@script:python r_org depends on org@
+j0 << r.j0;
+j1 << r.j1;
+j2 << r.j2;
+@@
+
+msg = "Propagate return value of platform_get_irq."
+coccilib.org.print_todo(j0[0], msg)
+coccilib.org.print_link(j1[0], "")
+coccilib.org.print_link(j2[0], "")
+
+// ----------------------------------------------------------------------------
+
+@script:python r_report depends on report@
+j0 << r.j0;
+j1 << r.j1;
+j2 << r.j2;
+@@
+
+msg = "Propagate return value of platform_get_irq around lines %s,%s." % (j1[0].line,j2[0].line)
+coccilib.report.print_report(j0[0], msg)
+


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

end of thread, other threads:[~2015-12-27 16:24 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-26 19:24 [PATCH] coccinelle: api: check for propagation of error from platform_get_irq Julia Lawall
2015-12-26 19:59 ` Sergei Shtylyov
2015-12-26 20:08   ` Julia Lawall
2015-12-26 20:24     ` Julia Lawall
2015-12-26 20:29       ` Sergei Shtylyov
2015-12-26 20:38         ` Julia Lawall
2015-12-26 20:58         ` [PATCH v2] " Julia Lawall
2015-12-26 22:26           ` Sergei Shtylyov
2015-12-26 22:32             ` Julia Lawall
2015-12-26 22:36               ` Sergei Shtylyov
2015-12-27  6:13                 ` Julia Lawall
2015-12-27 11:18                   ` Sergei Shtylyov
2015-12-27  7:58           ` [Cocci] " SF Markus Elfring
2015-12-27 11:41             ` Julia Lawall
2015-12-27 16:24               ` SF Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).