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


Groups > linux.kernel > #1298267

[PATCH v2] coccinelle: api: check for propagation of error from platform_get_irq

From Julia Lawall <julia.lawall@lip6.fr>
Newsgroups linux.kernel
Subject [PATCH v2] coccinelle: api: check for propagation of error from platform_get_irq
Date 2015-12-26 22:00 +0100
Message-ID <qK46u-5K2-7@gated-at.bofh.it> (permalink)
References <qK2R4-50U-3@gated-at.bofh.it> <qK3aq-598-11@gated-at.bofh.it> <qK3k5-5rM-15@gated-at.bofh.it> <qK3Ds-5yA-5@gated-at.bofh.it> <qK3Ds-5yA-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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

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

---

v2: Check for the direct return case also.  Added some mailing lists of
common offenders.

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..44680d0
--- /dev/null
+++ b/scripts/coccinelle/api/platform_get_irq_return.cocci
@@ -0,0 +1,58 @@
+/// 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;
+statement S;
+expression e, ret;
+position j0, j1;
+@@
+
+* e@j0 = platform_get_irq(...);
+(
+if@j1 (...) {
+  ...
+  return -C;
+} else S
+|
+if@j1 (...) {
+  ...
+  ret = -C;
+  ...
+  return ret;
+} else S
+)
+
+// ----------------------------------------------------------------------------
+
+@script:python r_org depends on org@
+j0 << r.j0;
+j1 << r.j1;
+@@
+
+msg = "Propagate return value of platform_get_irq."
+coccilib.org.print_todo(j0[0], msg)
+coccilib.org.print_link(j1[0], "")
+
+// ----------------------------------------------------------------------------
+
+@script:python r_report depends on report@
+j0 << r.j0;
+j1 << r.j1;
+@@
+
+msg = "Propagate return value of platform_get_irq around line %s." % (j1[0].line)
+coccilib.report.print_report(j0[0], msg)
+
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

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


Thread

[PATCH] coccinelle: api: check for propagation of error from platform_get_irq Julia Lawall <Julia.Lawall@lip6.fr> - 2015-12-26 20:40 +0100
  Re: [PATCH] coccinelle: api: check for propagation of error from  platform_get_irq Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> - 2015-12-26 21:00 +0100
    Re: [PATCH] coccinelle: api: check for propagation of error from  platform_get_irq Julia Lawall <julia.lawall@lip6.fr> - 2015-12-26 21:10 +0100
      Re: [PATCH] coccinelle: api: check for propagation of error from  platform_get_irq Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> - 2015-12-26 21:30 +0100
        Re: [PATCH] coccinelle: api: check for propagation of error from  platform_get_irq Julia Lawall <julia.lawall@lip6.fr> - 2015-12-26 21:40 +0100
        [PATCH v2] coccinelle: api: check for propagation of error from  platform_get_irq Julia Lawall <julia.lawall@lip6.fr> - 2015-12-26 22:00 +0100
          Re: [PATCH v2] coccinelle: api: check for propagation of error from  platform_get_irq Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> - 2015-12-26 23:30 +0100
            Re: [PATCH v2] coccinelle: api: check for propagation of error from  platform_get_irq Julia Lawall <julia.lawall@lip6.fr> - 2015-12-26 23:40 +0100
              Re: [PATCH v2] coccinelle: api: check for propagation of error from  platform_get_irq Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> - 2015-12-26 23:40 +0100
                Re: [PATCH v2] coccinelle: api: check for propagation of error from  platform_get_irq Julia Lawall <julia.lawall@lip6.fr> - 2015-12-27 07:20 +0100
                Re: [PATCH v2] coccinelle: api: check for propagation of error from  platform_get_irq Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> - 2015-12-27 12:20 +0100
          Re: [Cocci] [PATCH v2] coccinelle: api: check for propagation of  error from platform_get_irq SF Markus Elfring <elfring@users.sourceforge.net> - 2015-12-27 09:00 +0100
            Re: [Cocci] [PATCH v2] coccinelle: api: check for propagation of  error from platform_get_irq Julia Lawall <julia.lawall@lip6.fr> - 2015-12-27 12:50 +0100
              Re: [Cocci] [PATCH v2] coccinelle: api: check for propagation of  error from platform_get_irq SF Markus Elfring <elfring@users.sourceforge.net> - 2015-12-28 03:50 +0100
      Re: [PATCH] coccinelle: api: check for propagation of error from  platform_get_irq Julia Lawall <julia.lawall@lip6.fr> - 2015-12-26 21:30 +0100

csiph-web