diff options
author | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-17 16:15:55 -0500 |
---|---|---|
committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-17 16:15:55 -0500 |
commit | 8dea78da5cee153b8af9c07a2745f6c55057fe12 (patch) | |
tree | a8f4d49d63b1ecc92f2fddceba0655b2472c5bd9 /scripts/coccinelle/misc | |
parent | 406089d01562f1e2bf9f089fd7637009ebaad589 (diff) |
Patched in Tegra support.
Diffstat (limited to 'scripts/coccinelle/misc')
-rw-r--r-- | scripts/coccinelle/misc/boolinit.cocci | 178 | ||||
-rw-r--r-- | scripts/coccinelle/misc/cstptr.cocci | 41 | ||||
-rw-r--r-- | scripts/coccinelle/misc/doubleinit.cocci | 8 | ||||
-rw-r--r-- | scripts/coccinelle/misc/ifaddr.cocci | 35 | ||||
-rw-r--r-- | scripts/coccinelle/misc/irqf_oneshot.cocci | 65 | ||||
-rw-r--r-- | scripts/coccinelle/misc/noderef.cocci | 65 | ||||
-rw-r--r-- | scripts/coccinelle/misc/warn.cocci | 109 |
7 files changed, 4 insertions, 497 deletions
diff --git a/scripts/coccinelle/misc/boolinit.cocci b/scripts/coccinelle/misc/boolinit.cocci deleted file mode 100644 index 97ce41ce813..00000000000 --- a/scripts/coccinelle/misc/boolinit.cocci +++ /dev/null | |||
@@ -1,178 +0,0 @@ | |||
1 | /// Bool initializations should use true and false. Bool tests don't need | ||
2 | /// comparisons. Based on contributions from Joe Perches, Rusty Russell | ||
3 | /// and Bruce W Allan. | ||
4 | /// | ||
5 | // Confidence: High | ||
6 | // Copyright: (C) 2012 Julia Lawall, INRIA/LIP6. GPLv2. | ||
7 | // Copyright: (C) 2012 Gilles Muller, INRIA/LiP6. GPLv2. | ||
8 | // URL: http://coccinelle.lip6.fr/ | ||
9 | // Options: -include_headers | ||
10 | |||
11 | virtual patch | ||
12 | virtual context | ||
13 | virtual org | ||
14 | virtual report | ||
15 | |||
16 | @depends on patch@ | ||
17 | bool t; | ||
18 | symbol true; | ||
19 | symbol false; | ||
20 | @@ | ||
21 | |||
22 | ( | ||
23 | - t == true | ||
24 | + t | ||
25 | | | ||
26 | - true == t | ||
27 | + t | ||
28 | | | ||
29 | - t != true | ||
30 | + !t | ||
31 | | | ||
32 | - true != t | ||
33 | + !t | ||
34 | | | ||
35 | - t == false | ||
36 | + !t | ||
37 | | | ||
38 | - false == t | ||
39 | + !t | ||
40 | | | ||
41 | - t != false | ||
42 | + t | ||
43 | | | ||
44 | - false != t | ||
45 | + t | ||
46 | ) | ||
47 | |||
48 | @depends on patch disable is_zero, isnt_zero@ | ||
49 | bool t; | ||
50 | @@ | ||
51 | |||
52 | ( | ||
53 | - t == 1 | ||
54 | + t | ||
55 | | | ||
56 | - t != 1 | ||
57 | + !t | ||
58 | | | ||
59 | - t == 0 | ||
60 | + !t | ||
61 | | | ||
62 | - t != 0 | ||
63 | + t | ||
64 | ) | ||
65 | |||
66 | @depends on patch@ | ||
67 | bool b; | ||
68 | @@ | ||
69 | ( | ||
70 | b = | ||
71 | - 0 | ||
72 | + false | ||
73 | | | ||
74 | b = | ||
75 | - 1 | ||
76 | + true | ||
77 | ) | ||
78 | |||
79 | // --------------------------------------------------------------------- | ||
80 | |||
81 | @r1 depends on !patch@ | ||
82 | bool t; | ||
83 | position p; | ||
84 | @@ | ||
85 | |||
86 | ( | ||
87 | * t@p == true | ||
88 | | | ||
89 | * true == t@p | ||
90 | | | ||
91 | * t@p != true | ||
92 | | | ||
93 | * true != t@p | ||
94 | | | ||
95 | * t@p == false | ||
96 | | | ||
97 | * false == t@p | ||
98 | | | ||
99 | * t@p != false | ||
100 | | | ||
101 | * false != t@p | ||
102 | ) | ||
103 | |||
104 | @r2 depends on !patch disable is_zero, isnt_zero@ | ||
105 | bool t; | ||
106 | position p; | ||
107 | @@ | ||
108 | |||
109 | ( | ||
110 | * t@p == 1 | ||
111 | | | ||
112 | * t@p != 1 | ||
113 | | | ||
114 | * t@p == 0 | ||
115 | | | ||
116 | * t@p != 0 | ||
117 | ) | ||
118 | |||
119 | @r3 depends on !patch@ | ||
120 | bool b; | ||
121 | position p1,p2; | ||
122 | constant c; | ||
123 | @@ | ||
124 | ( | ||
125 | *b@p1 = 0 | ||
126 | | | ||
127 | *b@p1 = 1 | ||
128 | | | ||
129 | *b@p2 = c | ||
130 | ) | ||
131 | |||
132 | @script:python depends on org@ | ||
133 | p << r1.p; | ||
134 | @@ | ||
135 | |||
136 | cocci.print_main("WARNING: Comparison to bool",p) | ||
137 | |||
138 | @script:python depends on org@ | ||
139 | p << r2.p; | ||
140 | @@ | ||
141 | |||
142 | cocci.print_main("WARNING: Comparison of bool to 0/1",p) | ||
143 | |||
144 | @script:python depends on org@ | ||
145 | p1 << r3.p1; | ||
146 | @@ | ||
147 | |||
148 | cocci.print_main("WARNING: Assignment of bool to 0/1",p1) | ||
149 | |||
150 | @script:python depends on org@ | ||
151 | p2 << r3.p2; | ||
152 | @@ | ||
153 | |||
154 | cocci.print_main("ERROR: Assignment of bool to non-0/1 constant",p2) | ||
155 | |||
156 | @script:python depends on report@ | ||
157 | p << r1.p; | ||
158 | @@ | ||
159 | |||
160 | coccilib.report.print_report(p[0],"WARNING: Comparison to bool") | ||
161 | |||
162 | @script:python depends on report@ | ||
163 | p << r2.p; | ||
164 | @@ | ||
165 | |||
166 | coccilib.report.print_report(p[0],"WARNING: Comparison of bool to 0/1") | ||
167 | |||
168 | @script:python depends on report@ | ||
169 | p1 << r3.p1; | ||
170 | @@ | ||
171 | |||
172 | coccilib.report.print_report(p1[0],"WARNING: Assignment of bool to 0/1") | ||
173 | |||
174 | @script:python depends on report@ | ||
175 | p2 << r3.p2; | ||
176 | @@ | ||
177 | |||
178 | coccilib.report.print_report(p2[0],"ERROR: Assignment of bool to non-0/1 constant") | ||
diff --git a/scripts/coccinelle/misc/cstptr.cocci b/scripts/coccinelle/misc/cstptr.cocci deleted file mode 100644 index d4256448452..00000000000 --- a/scripts/coccinelle/misc/cstptr.cocci +++ /dev/null | |||
@@ -1,41 +0,0 @@ | |||
1 | /// PTR_ERR should be applied before its argument is reassigned, typically | ||
2 | /// to NULL | ||
3 | /// | ||
4 | // Confidence: High | ||
5 | // Copyright: (C) 2012 Julia Lawall, INRIA/LIP6. GPLv2. | ||
6 | // Copyright: (C) 2012 Gilles Muller, INRIA/LiP6. GPLv2. | ||
7 | // URL: http://coccinelle.lip6.fr/ | ||
8 | // Comments: | ||
9 | // Options: -no_includes -include_headers | ||
10 | |||
11 | virtual org | ||
12 | virtual report | ||
13 | virtual context | ||
14 | |||
15 | @r exists@ | ||
16 | expression e,e1; | ||
17 | constant c; | ||
18 | position p1,p2; | ||
19 | @@ | ||
20 | |||
21 | *e@p1 = c | ||
22 | ... when != e = e1 | ||
23 | when != &e | ||
24 | when != true IS_ERR(e) | ||
25 | *PTR_ERR@p2(e) | ||
26 | |||
27 | @script:python depends on org@ | ||
28 | p1 << r.p1; | ||
29 | p2 << r.p2; | ||
30 | @@ | ||
31 | |||
32 | cocci.print_main("PTR_ERR",p2) | ||
33 | cocci.print_secs("assignment",p1) | ||
34 | |||
35 | @script:python depends on report@ | ||
36 | p1 << r.p1; | ||
37 | p2 << r.p2; | ||
38 | @@ | ||
39 | |||
40 | msg = "ERROR: PTR_ERR applied after initialization to constant on line %s" % (p1[0].line) | ||
41 | coccilib.report.print_report(p2[0],msg) | ||
diff --git a/scripts/coccinelle/misc/doubleinit.cocci b/scripts/coccinelle/misc/doubleinit.cocci index cf74a00cf59..156b20adb35 100644 --- a/scripts/coccinelle/misc/doubleinit.cocci +++ b/scripts/coccinelle/misc/doubleinit.cocci | |||
@@ -3,9 +3,9 @@ | |||
3 | /// initialization. | 3 | /// initialization. |
4 | /// | 4 | /// |
5 | // Confidence: Low | 5 | // Confidence: Low |
6 | // Copyright: (C) 2010-2012 Nicolas Palix. GPLv2. | 6 | // Copyright: (C) 2010 Nicolas Palix, DIKU. GPLv2. |
7 | // Copyright: (C) 2010-2012 Julia Lawall, INRIA/LIP6. GPLv2. | 7 | // Copyright: (C) 2010 Julia Lawall, DIKU. GPLv2. |
8 | // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6. GPLv2. | 8 | // Copyright: (C) 2010 Gilles Muller, INRIA/LiP6. GPLv2. |
9 | // URL: http://coccinelle.lip6.fr/ | 9 | // URL: http://coccinelle.lip6.fr/ |
10 | // Comments: requires at least Coccinelle 0.2.4, lex or parse error otherwise | 10 | // Comments: requires at least Coccinelle 0.2.4, lex or parse error otherwise |
11 | // Options: -no_includes -include_headers | 11 | // Options: -no_includes -include_headers |
@@ -49,5 +49,5 @@ pr << r.p; | |||
49 | @@ | 49 | @@ |
50 | 50 | ||
51 | if int(ps[0].line) < int(pr[0].line) or (int(ps[0].line) == int(pr[0].line) and int(ps[0].column) < int(pr[0].column)): | 51 | if int(ps[0].line) < int(pr[0].line) or (int(ps[0].line) == int(pr[0].line) and int(ps[0].column) < int(pr[0].column)): |
52 | msg = "%s: first occurrence line %s, second occurrence line %s" % (fld,ps[0].line,pr[0].line) | 52 | msg = "%s: first occurrence %s, second occurrence %s" % (fld,ps[0].line,pr[0].line) |
53 | coccilib.report.print_report(p0[0],msg) | 53 | coccilib.report.print_report(p0[0],msg) |
diff --git a/scripts/coccinelle/misc/ifaddr.cocci b/scripts/coccinelle/misc/ifaddr.cocci deleted file mode 100644 index 3e4089a7700..00000000000 --- a/scripts/coccinelle/misc/ifaddr.cocci +++ /dev/null | |||
@@ -1,35 +0,0 @@ | |||
1 | /// the address of a variable or field is non-zero is likely always to bo | ||
2 | /// non-zero | ||
3 | /// | ||
4 | // Confidence: High | ||
5 | // Copyright: (C) 2012 Julia Lawall, INRIA/LIP6. GPLv2. | ||
6 | // Copyright: (C) 2012 Gilles Muller, INRIA/LiP6. GPLv2. | ||
7 | // URL: http://coccinelle.lip6.fr/ | ||
8 | // Comments: | ||
9 | // Options: -no_includes -include_headers | ||
10 | |||
11 | virtual org | ||
12 | virtual report | ||
13 | virtual context | ||
14 | |||
15 | @r@ | ||
16 | expression x; | ||
17 | statement S1,S2; | ||
18 | position p; | ||
19 | @@ | ||
20 | |||
21 | *if@p (&x) | ||
22 | S1 else S2 | ||
23 | |||
24 | @script:python depends on org@ | ||
25 | p << r.p; | ||
26 | @@ | ||
27 | |||
28 | cocci.print_main("test of a variable/field address",p) | ||
29 | |||
30 | @script:python depends on report@ | ||
31 | p << r.p; | ||
32 | @@ | ||
33 | |||
34 | msg = "ERROR: test of a variable/field address" | ||
35 | coccilib.report.print_report(p[0],msg) | ||
diff --git a/scripts/coccinelle/misc/irqf_oneshot.cocci b/scripts/coccinelle/misc/irqf_oneshot.cocci deleted file mode 100644 index 6cfde94be0e..00000000000 --- a/scripts/coccinelle/misc/irqf_oneshot.cocci +++ /dev/null | |||
@@ -1,65 +0,0 @@ | |||
1 | /// Make sure threaded IRQs without a primary handler are always request with | ||
2 | /// IRQF_ONESHOT | ||
3 | /// | ||
4 | // | ||
5 | // Confidence: Good | ||
6 | // Comments: | ||
7 | // Options: --no-includes | ||
8 | |||
9 | virtual patch | ||
10 | virtual context | ||
11 | virtual org | ||
12 | virtual report | ||
13 | |||
14 | @r1@ | ||
15 | expression irq; | ||
16 | expression thread_fn; | ||
17 | expression flags; | ||
18 | position p; | ||
19 | @@ | ||
20 | request_threaded_irq@p(irq, NULL, thread_fn, | ||
21 | ( | ||
22 | flags | IRQF_ONESHOT | ||
23 | | | ||
24 | IRQF_ONESHOT | ||
25 | ) | ||
26 | , ...) | ||
27 | |||
28 | @depends on patch@ | ||
29 | expression irq; | ||
30 | expression thread_fn; | ||
31 | expression flags; | ||
32 | position p != r1.p; | ||
33 | @@ | ||
34 | request_threaded_irq@p(irq, NULL, thread_fn, | ||
35 | ( | ||
36 | -0 | ||
37 | +IRQF_ONESHOT | ||
38 | | | ||
39 | -flags | ||
40 | +flags | IRQF_ONESHOT | ||
41 | ) | ||
42 | , ...) | ||
43 | |||
44 | @depends on context@ | ||
45 | position p != r1.p; | ||
46 | @@ | ||
47 | *request_threaded_irq@p(...) | ||
48 | |||
49 | @match depends on report || org@ | ||
50 | expression irq; | ||
51 | position p != r1.p; | ||
52 | @@ | ||
53 | request_threaded_irq@p(irq, NULL, ...) | ||
54 | |||
55 | @script:python depends on org@ | ||
56 | p << match.p; | ||
57 | @@ | ||
58 | msg = "ERROR: Threaded IRQ with no primary handler requested without IRQF_ONESHOT" | ||
59 | coccilib.org.print_todo(p[0],msg) | ||
60 | |||
61 | @script:python depends on report@ | ||
62 | p << match.p; | ||
63 | @@ | ||
64 | msg = "ERROR: Threaded IRQ with no primary handler requested without IRQF_ONESHOT" | ||
65 | coccilib.report.print_report(p[0],msg) | ||
diff --git a/scripts/coccinelle/misc/noderef.cocci b/scripts/coccinelle/misc/noderef.cocci deleted file mode 100644 index c1707214e60..00000000000 --- a/scripts/coccinelle/misc/noderef.cocci +++ /dev/null | |||
@@ -1,65 +0,0 @@ | |||
1 | /// sizeof when applied to a pointer typed expression gives the size of | ||
2 | /// the pointer | ||
3 | /// | ||
4 | // Confidence: High | ||
5 | // Copyright: (C) 2012 Julia Lawall, INRIA/LIP6. GPLv2. | ||
6 | // Copyright: (C) 2012 Gilles Muller, INRIA/LiP6. GPLv2. | ||
7 | // URL: http://coccinelle.lip6.fr/ | ||
8 | // Comments: | ||
9 | // Options: -no_includes -include_headers | ||
10 | |||
11 | virtual org | ||
12 | virtual report | ||
13 | virtual context | ||
14 | virtual patch | ||
15 | |||
16 | @depends on patch@ | ||
17 | expression *x; | ||
18 | expression f; | ||
19 | type T; | ||
20 | @@ | ||
21 | |||
22 | ( | ||
23 | x = <+... sizeof( | ||
24 | - x | ||
25 | + *x | ||
26 | ) ...+> | ||
27 | | | ||
28 | f(...,(T)(x),...,sizeof( | ||
29 | - x | ||
30 | + *x | ||
31 | ),...) | ||
32 | | | ||
33 | f(...,sizeof(x),...,(T)( | ||
34 | - x | ||
35 | + *x | ||
36 | ),...) | ||
37 | ) | ||
38 | |||
39 | @r depends on !patch@ | ||
40 | expression *x; | ||
41 | expression f; | ||
42 | position p; | ||
43 | type T; | ||
44 | @@ | ||
45 | |||
46 | ( | ||
47 | *x = <+... sizeof@p(x) ...+> | ||
48 | | | ||
49 | *f(...,(T)(x),...,sizeof@p(x),...) | ||
50 | | | ||
51 | *f(...,sizeof@p(x),...,(T)(x),...) | ||
52 | ) | ||
53 | |||
54 | @script:python depends on org@ | ||
55 | p << r.p; | ||
56 | @@ | ||
57 | |||
58 | cocci.print_main("application of sizeof to pointer",p) | ||
59 | |||
60 | @script:python depends on report@ | ||
61 | p << r.p; | ||
62 | @@ | ||
63 | |||
64 | msg = "ERROR: application of sizeof to pointer" | ||
65 | coccilib.report.print_report(p[0],msg) | ||
diff --git a/scripts/coccinelle/misc/warn.cocci b/scripts/coccinelle/misc/warn.cocci deleted file mode 100644 index fda8c3558e4..00000000000 --- a/scripts/coccinelle/misc/warn.cocci +++ /dev/null | |||
@@ -1,109 +0,0 @@ | |||
1 | /// Use WARN(1,...) rather than printk followed by WARN_ON(1) | ||
2 | /// | ||
3 | // Confidence: High | ||
4 | // Copyright: (C) 2012 Julia Lawall, INRIA/LIP6. GPLv2. | ||
5 | // Copyright: (C) 2012 Gilles Muller, INRIA/LiP6. GPLv2. | ||
6 | // URL: http://coccinelle.lip6.fr/ | ||
7 | // Comments: | ||
8 | // Options: -no_includes -include_headers | ||
9 | |||
10 | virtual patch | ||
11 | virtual context | ||
12 | virtual org | ||
13 | virtual report | ||
14 | |||
15 | @bad1@ | ||
16 | position p; | ||
17 | @@ | ||
18 | |||
19 | printk(...); | ||
20 | printk@p(...); | ||
21 | WARN_ON(1); | ||
22 | |||
23 | @r1 depends on context || report || org@ | ||
24 | position p != bad1.p; | ||
25 | @@ | ||
26 | |||
27 | printk@p(...); | ||
28 | *WARN_ON(1); | ||
29 | |||
30 | @script:python depends on org@ | ||
31 | p << r1.p; | ||
32 | @@ | ||
33 | |||
34 | cocci.print_main("printk + WARN_ON can be just WARN",p) | ||
35 | |||
36 | @script:python depends on report@ | ||
37 | p << r1.p; | ||
38 | @@ | ||
39 | |||
40 | msg = "SUGGESTION: printk + WARN_ON can be just WARN" | ||
41 | coccilib.report.print_report(p[0],msg) | ||
42 | |||
43 | @ok1 depends on patch@ | ||
44 | expression list es; | ||
45 | position p != bad1.p; | ||
46 | @@ | ||
47 | |||
48 | -printk@p( | ||
49 | +WARN(1, | ||
50 | es); | ||
51 | -WARN_ON(1); | ||
52 | |||
53 | @depends on patch@ | ||
54 | expression list ok1.es; | ||
55 | @@ | ||
56 | |||
57 | if (...) | ||
58 | - { | ||
59 | WARN(1,es); | ||
60 | - } | ||
61 | |||
62 | // -------------------------------------------------------------------- | ||
63 | |||
64 | @bad2@ | ||
65 | position p; | ||
66 | @@ | ||
67 | |||
68 | printk(...); | ||
69 | printk@p(...); | ||
70 | WARN_ON_ONCE(1); | ||
71 | |||
72 | @r2 depends on context || report || org@ | ||
73 | position p != bad1.p; | ||
74 | @@ | ||
75 | |||
76 | printk@p(...); | ||
77 | *WARN_ON_ONCE(1); | ||
78 | |||
79 | @script:python depends on org@ | ||
80 | p << r2.p; | ||
81 | @@ | ||
82 | |||
83 | cocci.print_main("printk + WARN_ON_ONCE can be just WARN_ONCE",p) | ||
84 | |||
85 | @script:python depends on report@ | ||
86 | p << r2.p; | ||
87 | @@ | ||
88 | |||
89 | msg = "SUGGESTION: printk + WARN_ON_ONCE can be just WARN_ONCE" | ||
90 | coccilib.report.print_report(p[0],msg) | ||
91 | |||
92 | @ok2 depends on patch@ | ||
93 | expression list es; | ||
94 | position p != bad2.p; | ||
95 | @@ | ||
96 | |||
97 | -printk@p( | ||
98 | +WARN_ONCE(1, | ||
99 | es); | ||
100 | -WARN_ON_ONCE(1); | ||
101 | |||
102 | @depends on patch@ | ||
103 | expression list ok2.es; | ||
104 | @@ | ||
105 | |||
106 | if (...) | ||
107 | - { | ||
108 | WARN_ONCE(1,es); | ||
109 | - } | ||