aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/coccinelle
diff options
context:
space:
mode:
authorPeter Senna Tschudin <peter.senna@gmail.com>2012-12-08 12:34:34 -0500
committerMichal Marek <mmarek@suse.cz>2013-01-24 06:10:38 -0500
commit7320bfa7cfe31e9ee95a40ab8e52648066284141 (patch)
tree6ecc0024f3b07746848ddfe5dbfdd7299bbace49 /scripts/coccinelle
parent9f14b4201239a9779d52bdd6137583d452b38ec3 (diff)
scripts/coccinelle/misc/semicolon.cocci: Add unneeded semicolon test
This semantic patch looks for semicolons that can be removed without changing the semantics of the code. The confidence is moderate because there are some false positives on cases like: b/drivers/mmc/host/cb710-mmc.c:589 break; case MMC_POWER_UP: default: - /* ignore */; } There are 37 patches accepted reported by this semantic patch and more than 300 fixes to be applied. Signed-off-by: Peter Senna Tschudin <peter.senna@gmail.com> Signed-off-by: Michal Marek <mmarek@suse.cz>
Diffstat (limited to 'scripts/coccinelle')
-rw-r--r--scripts/coccinelle/misc/semicolon.cocci83
1 files changed, 83 insertions, 0 deletions
diff --git a/scripts/coccinelle/misc/semicolon.cocci b/scripts/coccinelle/misc/semicolon.cocci
new file mode 100644
index 000000000000..a47eba2edc9e
--- /dev/null
+++ b/scripts/coccinelle/misc/semicolon.cocci
@@ -0,0 +1,83 @@
1///
2/// Removes unneeded semicolon.
3///
4// Confidence: Moderate
5// Copyright: (C) 2012 Peter Senna Tschudin, INRIA/LIP6. GPLv2.
6// URL: http://coccinelle.lip6.fr/
7// Comments: Some false positives on empty default cases in switch statements.
8// Options: --no-includes --include-headers
9
10virtual patch
11virtual report
12virtual context
13virtual org
14
15@r_default@
16position p;
17@@
18switch (...)
19{
20default: ...;@p
21}
22
23@r_case@
24position p;
25@@
26(
27switch (...)
28{
29case ...:;@p
30}
31|
32switch (...)
33{
34case ...:...
35case ...:;@p
36}
37|
38switch (...)
39{
40case ...:...
41case ...:
42case ...:;@p
43}
44)
45
46@r1@
47statement S;
48position p1;
49position p != {r_default.p, r_case.p};
50identifier label;
51@@
52(
53label:;
54|
55S@p1;@p
56)
57
58@script:python@
59p << r1.p;
60p1 << r1.p1;
61@@
62if p[0].line != p1[0].line_end:
63 cocci.include_match(False)
64
65@depends on patch@
66position r1.p;
67@@
68-;@p
69
70@script:python depends on report@
71p << r1.p;
72@@
73coccilib.report.print_report(p[0],"Unneeded semicolon")
74
75@depends on context@
76position r1.p;
77@@
78*;@p
79
80@script:python depends on org@
81p << r1.p;
82@@
83cocci.print_main("Unneeded semicolon",p)