lkml.org 
[lkml]   [2015]   [Jan]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 3/3 RFC] Coccinelle: incorrect use of multiple init_completion
Date
Reviewed-by: Andreas Platschek <platschek@ict.tuwien.ac.at>
Signed-off-by: Nicholas Mc Guire <der.herr@hofr.at>
---
scripts/coccinelle/api/false_init_compltion.cocci | 74 +++++++++++++++++++++
1 file changed, 74 insertions(+)
create mode 100644 scripts/coccinelle/api/false_init_compltion.cocci

diff --git a/scripts/coccinelle/api/false_init_compltion.cocci b/scripts/coccinelle/api/false_init_compltion.cocci
new file mode 100644
index 0000000..a97dfcf
--- /dev/null
+++ b/scripts/coccinelle/api/false_init_compltion.cocci
@@ -0,0 +1,74 @@
+/* check for incorrect use of multiple init_completion on the
+ * same struct completion and switch the reinitializations to use
+ * reinit_completion()
+ *
+ * Options: --no-includes --include-headers
+ */
+virtual context
+virtual patch
+virtual org
+virtual report
+
+/* mark first call to init_completion */
+@c@
+expression cmp;
+position p;
+@@
+
+ init_completion@p(cmp)
+
+/* flag incorrect reinitializations */
+@d depends on patch && !(context || org || report)@
+expression E,c.cmp;
+identifier f;
+position c.p,p1;
+@@
+
+ init_completion@p(cmp)
+ <+...
+(
+ E = cmp
+|
+ E = &cmp
+|
+ f(..., cmp,...)
+|
+ f(..., &cmp,...)
+)
+ ...+>
+- init_completion@p1(cmp)
++ reinit_completion1(cmp)
+
+@dp depends on !patch && (context || org || report)@
+identifier f;
+expression E,c.cmp;
+position c.p,p1;
+@@
+
+ init_completion@p(cmp)
+ <+...
+(
+ E = cmp
+|
+ E = &cmp
+|
+ f(..., cmp,...)
+|
+ f(..., &cmp,...)
+)
+ ...+>
+ init_completion@p1(cmp)
+
+@script:python depends on org@
+p << dp.p1;
+@@
+
+msg="WARNING: possible reinit by init_completion"
+coccilib.org.print_todo(p[0], msg)
+
+@script:python depends on report@
+p << dp.p1;
+@@
+
+msg="WARNING: possible reinit by init_completion"
+coccilib.report.print_report(p[0], msg)
--
1.7.10.4


\
 
 \ /
  Last update: 2015-01-02 11:21    [W:0.056 / U:0.016 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site