Skip to contentSkip to conversation

coccinelle: misc: Semantic patch to find attempts at comparing struct clk pointers

PATCH New Quentin Lambert 1 participant 1 message Feb 6, 2015 Coccinelle/Semantic Patches (SmPL)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 coccinelle: misc: Semantic patch to find attempts at comparing struct clk pointers

This semantic patches find instances where struct clk pointers are compared.

This was proposed by Stephen Boyd.

---

This patch was discussed in this thread:
https://lkml.org/lkml/2015/2/2/629

 scripts/coccinelle/misc/structclk.cocci | 44 +++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)
 create mode 100644 scripts/coccinelle/misc/structclk.cocci
scripts/coccinelle/misc/structclk.cocci new file +44 -0
new file mode 100644
index 0000000..0307d34
@@ -0,0 +1,44 @@
+/// Find any attempt to compare struct clk pointers.
+///
+// Confidence: High
+// Copyright: (C) 2015 Quentin Lambert, INRIA/LiP6. GPLv2
+// URL: http://coccinelle.lip6.fr/
+// Options: --recursive-includes --relax-include-path
+// Options: --include-headers-for-types
+
+virtual context
+virtual org
+virtual report
+
+
+// ----------------------------------------------------------------------------
+
+@comparison depends on context || org || report@
+struct clk *x1, x2;
+position j0;
+@@
+
+(
+*  x1@j0 == x2
+|
+*  x1@j0 != x2
+)
+
+// ----------------------------------------------------------------------------
+
+@script:python comparison_org depends on org@
+j0 << comparison.j0;
+@@
+
+msg = "WARNING trying to compare struct clk pointers."
+coccilib.org.print_todo(j0[0], msg)
+
+// ----------------------------------------------------------------------------
+
+@script:python comparison_report depends on report@
+j0 << comparison.j0;
+@@
+
+msg = "WARNING trying to compare struct clk pointers."
+coccilib.report.print_report(j0[0], msg)
+
Signature · 1 line
1.9.1