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 | |
parent | 406089d01562f1e2bf9f089fd7637009ebaad589 (diff) |
Patched in Tegra support.
Diffstat (limited to 'scripts/coccinelle')
27 files changed, 76 insertions, 1849 deletions
diff --git a/scripts/coccinelle/api/d_find_alias.cocci b/scripts/coccinelle/api/d_find_alias.cocci deleted file mode 100644 index a9694a8d3e5..00000000000 --- a/scripts/coccinelle/api/d_find_alias.cocci +++ /dev/null | |||
@@ -1,80 +0,0 @@ | |||
1 | /// Make sure calls to d_find_alias() have a corresponding call to dput(). | ||
2 | // | ||
3 | // Keywords: d_find_alias, dput | ||
4 | // | ||
5 | // Confidence: Moderate | ||
6 | // URL: http://coccinelle.lip6.fr/ | ||
7 | // Options: -include_headers | ||
8 | |||
9 | virtual context | ||
10 | virtual org | ||
11 | virtual patch | ||
12 | virtual report | ||
13 | |||
14 | @r exists@ | ||
15 | local idexpression struct dentry *dent; | ||
16 | expression E, E1; | ||
17 | statement S1, S2; | ||
18 | position p1, p2; | ||
19 | @@ | ||
20 | ( | ||
21 | if (!(dent@p1 = d_find_alias(...))) S1 | ||
22 | | | ||
23 | dent@p1 = d_find_alias(...) | ||
24 | ) | ||
25 | |||
26 | <...when != dput(dent) | ||
27 | when != if (...) { <+... dput(dent) ...+> } | ||
28 | when != true !dent || ... | ||
29 | when != dent = E | ||
30 | when != E = dent | ||
31 | if (!dent || ...) S2 | ||
32 | ...> | ||
33 | ( | ||
34 | return <+...dent...+>; | ||
35 | | | ||
36 | return @p2 ...; | ||
37 | | | ||
38 | dent@p2 = E1; | ||
39 | | | ||
40 | E1 = dent; | ||
41 | ) | ||
42 | |||
43 | @depends on context@ | ||
44 | local idexpression struct dentry *r.dent; | ||
45 | position r.p1,r.p2; | ||
46 | @@ | ||
47 | * dent@p1 = ... | ||
48 | ... | ||
49 | ( | ||
50 | * return@p2 ...; | ||
51 | | | ||
52 | * dent@p2 | ||
53 | ) | ||
54 | |||
55 | |||
56 | @script:python depends on org@ | ||
57 | p1 << r.p1; | ||
58 | p2 << r.p2; | ||
59 | @@ | ||
60 | cocci.print_main("Missing call to dput()",p1) | ||
61 | cocci.print_secs("",p2) | ||
62 | |||
63 | @depends on patch@ | ||
64 | local idexpression struct dentry *r.dent; | ||
65 | position r.p2; | ||
66 | @@ | ||
67 | ( | ||
68 | + dput(dent); | ||
69 | return @p2 ...; | ||
70 | | | ||
71 | + dput(dent); | ||
72 | dent@p2 = ...; | ||
73 | ) | ||
74 | |||
75 | @script:python depends on report@ | ||
76 | p1 << r.p1; | ||
77 | p2 << r.p2; | ||
78 | @@ | ||
79 | msg = "Missing call to dput() at line %s." | ||
80 | coccilib.report.print_report(p1[0], msg % (p2[0].line)) | ||
diff --git a/scripts/coccinelle/api/devm_request_and_ioremap.cocci b/scripts/coccinelle/api/devm_request_and_ioremap.cocci deleted file mode 100644 index 46beb81406a..00000000000 --- a/scripts/coccinelle/api/devm_request_and_ioremap.cocci +++ /dev/null | |||
@@ -1,105 +0,0 @@ | |||
1 | /// Reimplement a call to devm_request_mem_region followed by a call to ioremap | ||
2 | /// or ioremap_nocache by a call to devm_request_and_ioremap. | ||
3 | /// Devm_request_and_ioremap was introduced in | ||
4 | /// 72f8c0bfa0de64c68ee59f40eb9b2683bffffbb0. It makes the code much more | ||
5 | /// concise. | ||
6 | /// | ||
7 | /// | ||
8 | // Confidence: High | ||
9 | // Copyright: (C) 2011 Julia Lawall, INRIA/LIP6. GPLv2. | ||
10 | // Copyright: (C) 2011 Gilles Muller, INRIA/LiP6. GPLv2. | ||
11 | // URL: http://coccinelle.lip6.fr/ | ||
12 | // Comments: | ||
13 | // Options: -no_includes -include_headers | ||
14 | |||
15 | virtual patch | ||
16 | virtual org | ||
17 | virtual report | ||
18 | virtual context | ||
19 | |||
20 | @nm@ | ||
21 | expression myname; | ||
22 | identifier i; | ||
23 | @@ | ||
24 | |||
25 | struct platform_driver i = { .driver = { .name = myname } }; | ||
26 | |||
27 | @depends on patch@ | ||
28 | expression dev,res,size; | ||
29 | @@ | ||
30 | |||
31 | -if (!devm_request_mem_region(dev, res->start, size, | ||
32 | - \(res->name\|dev_name(dev)\))) { | ||
33 | - ... | ||
34 | - return ...; | ||
35 | -} | ||
36 | ... when != res->start | ||
37 | ( | ||
38 | -devm_ioremap(dev,res->start,size) | ||
39 | +devm_request_and_ioremap(dev,res) | ||
40 | | | ||
41 | -devm_ioremap_nocache(dev,res->start,size) | ||
42 | +devm_request_and_ioremap(dev,res) | ||
43 | ) | ||
44 | ... when any | ||
45 | when != res->start | ||
46 | |||
47 | // this rule is separate from the previous one, because a single file can | ||
48 | // have multiple values of myname | ||
49 | @depends on patch@ | ||
50 | expression dev,res,size; | ||
51 | expression nm.myname; | ||
52 | @@ | ||
53 | |||
54 | -if (!devm_request_mem_region(dev, res->start, size,myname)) { | ||
55 | - ... | ||
56 | - return ...; | ||
57 | -} | ||
58 | ... when != res->start | ||
59 | ( | ||
60 | -devm_ioremap(dev,res->start,size) | ||
61 | +devm_request_and_ioremap(dev,res) | ||
62 | | | ||
63 | -devm_ioremap_nocache(dev,res->start,size) | ||
64 | +devm_request_and_ioremap(dev,res) | ||
65 | ) | ||
66 | ... when any | ||
67 | when != res->start | ||
68 | |||
69 | |||
70 | @pb depends on org || report || context@ | ||
71 | expression dev,res,size; | ||
72 | expression nm.myname; | ||
73 | position p1,p2; | ||
74 | @@ | ||
75 | |||
76 | *if | ||
77 | (!devm_request_mem_region@p1(dev, res->start, size, | ||
78 | \(res->name\|dev_name(dev)\|myname\))) { | ||
79 | ... | ||
80 | return ...; | ||
81 | } | ||
82 | ... when != res->start | ||
83 | ( | ||
84 | *devm_ioremap@p2(dev,res->start,size) | ||
85 | | | ||
86 | *devm_ioremap_nocache@p2(dev,res->start,size) | ||
87 | ) | ||
88 | ... when any | ||
89 | when != res->start | ||
90 | |||
91 | @script:python depends on org@ | ||
92 | p1 << pb.p1; | ||
93 | p2 << pb.p2; | ||
94 | @@ | ||
95 | |||
96 | cocci.print_main("INFO: replace by devm_request_and_ioremap",p1) | ||
97 | cocci.print_secs("",p2) | ||
98 | |||
99 | @script:python depends on report@ | ||
100 | p1 << pb.p1; | ||
101 | p2 << pb.p2; | ||
102 | @@ | ||
103 | |||
104 | msg = "INFO: devm_request_mem_region followed by ioremap on line %s can be replaced by devm_request_and_ioremap" % (p2[0].line) | ||
105 | coccilib.report.print_report(p1[0],msg) | ||
diff --git a/scripts/coccinelle/api/kstrdup.cocci b/scripts/coccinelle/api/kstrdup.cocci index 07a74b2c619..e0805ad08d3 100644 --- a/scripts/coccinelle/api/kstrdup.cocci +++ b/scripts/coccinelle/api/kstrdup.cocci | |||
@@ -1,19 +1,16 @@ | |||
1 | /// Use kstrdup rather than duplicating its implementation | 1 | /// Use kstrdup rather than duplicating its implementation |
2 | /// | 2 | /// |
3 | // Confidence: High | 3 | // Confidence: High |
4 | // Copyright: (C) 2010-2012 Nicolas Palix. GPLv2. | 4 | // Copyright: (C) 2010 Nicolas Palix, DIKU. GPLv2. |
5 | // Copyright: (C) 2010-2012 Julia Lawall, INRIA/LIP6. GPLv2. | 5 | // Copyright: (C) 2010 Julia Lawall, DIKU. GPLv2. |
6 | // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6. GPLv2. | 6 | // Copyright: (C) 2010 Gilles Muller, INRIA/LiP6. GPLv2. |
7 | // URL: http://coccinelle.lip6.fr/ | 7 | // URL: http://coccinelle.lip6.fr/ |
8 | // Comments: | 8 | // Comments: |
9 | // Options: -no_includes -include_headers | 9 | // Options: -no_includes -include_headers |
10 | 10 | ||
11 | virtual patch | 11 | virtual patch |
12 | virtual context | ||
13 | virtual org | ||
14 | virtual report | ||
15 | 12 | ||
16 | @depends on patch@ | 13 | @@ |
17 | expression from,to; | 14 | expression from,to; |
18 | expression flag,E1,E2; | 15 | expression flag,E1,E2; |
19 | statement S; | 16 | statement S; |
@@ -26,7 +23,7 @@ statement S; | |||
26 | ... when != \(from = E2 \| to = E2 \) | 23 | ... when != \(from = E2 \| to = E2 \) |
27 | - strcpy(to, from); | 24 | - strcpy(to, from); |
28 | 25 | ||
29 | @depends on patch@ | 26 | @@ |
30 | expression x,from,to; | 27 | expression x,from,to; |
31 | expression flag,E1,E2,E3; | 28 | expression flag,E1,E2,E3; |
32 | statement S; | 29 | statement S; |
@@ -40,65 +37,3 @@ statement S; | |||
40 | if (to==NULL || ...) S | 37 | if (to==NULL || ...) S |
41 | ... when != \(x = E3 \| from = E3 \| to = E3 \) | 38 | ... when != \(x = E3 \| from = E3 \| to = E3 \) |
42 | - memcpy(to, from, x); | 39 | - memcpy(to, from, x); |
43 | |||
44 | // --------------------------------------------------------------------- | ||
45 | |||
46 | @r1 depends on !patch exists@ | ||
47 | expression from,to; | ||
48 | expression flag,E1,E2; | ||
49 | statement S; | ||
50 | position p1,p2; | ||
51 | @@ | ||
52 | |||
53 | * to = kmalloc@p1(strlen(from) + 1,flag); | ||
54 | ... when != \(from = E1 \| to = E1 \) | ||
55 | if (to==NULL || ...) S | ||
56 | ... when != \(from = E2 \| to = E2 \) | ||
57 | * strcpy@p2(to, from); | ||
58 | |||
59 | @r2 depends on !patch exists@ | ||
60 | expression x,from,to; | ||
61 | expression flag,E1,E2,E3; | ||
62 | statement S; | ||
63 | position p1,p2; | ||
64 | @@ | ||
65 | |||
66 | * x = strlen(from) + 1; | ||
67 | ... when != \( x = E1 \| from = E1 \) | ||
68 | * to = \(kmalloc@p1\|kzalloc@p2\)(x,flag); | ||
69 | ... when != \(x = E2 \| from = E2 \| to = E2 \) | ||
70 | if (to==NULL || ...) S | ||
71 | ... when != \(x = E3 \| from = E3 \| to = E3 \) | ||
72 | * memcpy@p2(to, from, x); | ||
73 | |||
74 | @script:python depends on org@ | ||
75 | p1 << r1.p1; | ||
76 | p2 << r1.p2; | ||
77 | @@ | ||
78 | |||
79 | cocci.print_main("WARNING opportunity for kstrdep",p1) | ||
80 | cocci.print_secs("strcpy",p2) | ||
81 | |||
82 | @script:python depends on org@ | ||
83 | p1 << r2.p1; | ||
84 | p2 << r2.p2; | ||
85 | @@ | ||
86 | |||
87 | cocci.print_main("WARNING opportunity for kstrdep",p1) | ||
88 | cocci.print_secs("memcpy",p2) | ||
89 | |||
90 | @script:python depends on report@ | ||
91 | p1 << r1.p1; | ||
92 | p2 << r1.p2; | ||
93 | @@ | ||
94 | |||
95 | msg = "WARNING opportunity for kstrdep (strcpy on line %s)" % (p2[0].line) | ||
96 | coccilib.report.print_report(p1[0], msg) | ||
97 | |||
98 | @script:python depends on report@ | ||
99 | p1 << r2.p1; | ||
100 | p2 << r2.p2; | ||
101 | @@ | ||
102 | |||
103 | msg = "WARNING opportunity for kstrdep (memcpy on line %s)" % (p2[0].line) | ||
104 | coccilib.report.print_report(p1[0], msg) | ||
diff --git a/scripts/coccinelle/api/memdup.cocci b/scripts/coccinelle/api/memdup.cocci index 4dceab6d54d..b5d722077dc 100644 --- a/scripts/coccinelle/api/memdup.cocci +++ b/scripts/coccinelle/api/memdup.cocci | |||
@@ -1,17 +1,14 @@ | |||
1 | /// Use kmemdup rather than duplicating its implementation | 1 | /// Use kmemdup rather than duplicating its implementation |
2 | /// | 2 | /// |
3 | // Confidence: High | 3 | // Confidence: High |
4 | // Copyright: (C) 2010-2012 Nicolas Palix. GPLv2. | 4 | // Copyright: (C) 2010 Nicolas Palix, DIKU. GPLv2. |
5 | // Copyright: (C) 2010-2012 Julia Lawall, INRIA/LIP6. GPLv2. | 5 | // Copyright: (C) 2010 Julia Lawall, DIKU. GPLv2. |
6 | // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6. GPLv2. | 6 | // Copyright: (C) 2010 Gilles Muller, INRIA/LiP6. GPLv2. |
7 | // URL: http://coccinelle.lip6.fr/ | 7 | // URL: http://coccinelle.lip6.fr/ |
8 | // Comments: | 8 | // Comments: |
9 | // Options: -no_includes -include_headers | 9 | // Options: -no_includes -include_headers |
10 | 10 | ||
11 | virtual patch | 11 | virtual patch |
12 | virtual context | ||
13 | virtual org | ||
14 | virtual report | ||
15 | 12 | ||
16 | @r1@ | 13 | @r1@ |
17 | expression from,to; | 14 | expression from,to; |
@@ -31,7 +28,7 @@ position p; | |||
31 | ... when != \( x = E1 \| from = E1 \) | 28 | ... when != \( x = E1 \| from = E1 \) |
32 | to = \(kmalloc@p\|kzalloc@p\)(x,flag); | 29 | to = \(kmalloc@p\|kzalloc@p\)(x,flag); |
33 | 30 | ||
34 | @depends on patch@ | 31 | @@ |
35 | expression from,to,size,flag; | 32 | expression from,to,size,flag; |
36 | position p != {r1.p,r2.p}; | 33 | position p != {r1.p,r2.p}; |
37 | statement S; | 34 | statement S; |
@@ -41,26 +38,3 @@ statement S; | |||
41 | + to = kmemdup(from,size,flag); | 38 | + to = kmemdup(from,size,flag); |
42 | if (to==NULL || ...) S | 39 | if (to==NULL || ...) S |
43 | - memcpy(to, from, size); | 40 | - memcpy(to, from, size); |
44 | |||
45 | @r depends on !patch@ | ||
46 | expression from,to,size,flag; | ||
47 | position p != {r1.p,r2.p}; | ||
48 | statement S; | ||
49 | @@ | ||
50 | |||
51 | * to = \(kmalloc@p\|kzalloc@p\)(size,flag); | ||
52 | to = kmemdup(from,size,flag); | ||
53 | if (to==NULL || ...) S | ||
54 | * memcpy(to, from, size); | ||
55 | |||
56 | @script:python depends on org@ | ||
57 | p << r.p; | ||
58 | @@ | ||
59 | |||
60 | coccilib.org.print_todo(p[0], "WARNING opportunity for kmemdep") | ||
61 | |||
62 | @script:python depends on report@ | ||
63 | p << r.p; | ||
64 | @@ | ||
65 | |||
66 | coccilib.report.print_report(p[0], "WARNING opportunity for kmemdep") | ||
diff --git a/scripts/coccinelle/api/memdup_user.cocci b/scripts/coccinelle/api/memdup_user.cocci index 2b131a8a130..72ce012e878 100644 --- a/scripts/coccinelle/api/memdup_user.cocci +++ b/scripts/coccinelle/api/memdup_user.cocci | |||
@@ -1,25 +1,23 @@ | |||
1 | /// Use memdup_user rather than duplicating its implementation | 1 | /// Use kmemdup_user rather than duplicating its implementation |
2 | /// This is a little bit restricted to reduce false positives | 2 | /// This is a little bit restricted to reduce false positives |
3 | /// | 3 | /// |
4 | // Confidence: High | 4 | // Confidence: High |
5 | // Copyright: (C) 2010-2012 Nicolas Palix. GPLv2. | 5 | // Copyright: (C) 2010 Nicolas Palix, DIKU. GPLv2. |
6 | // Copyright: (C) 2010-2012 Julia Lawall, INRIA/LIP6. GPLv2. | 6 | // Copyright: (C) 2010 Julia Lawall, DIKU. GPLv2. |
7 | // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6. GPLv2. | 7 | // Copyright: (C) 2010 Gilles Muller, INRIA/LiP6. GPLv2. |
8 | // URL: http://coccinelle.lip6.fr/ | 8 | // URL: http://coccinelle.lip6.fr/ |
9 | // Comments: | 9 | // Comments: |
10 | // Options: -no_includes -include_headers | 10 | // Options: -no_includes -include_headers |
11 | 11 | ||
12 | virtual patch | 12 | virtual patch |
13 | virtual context | ||
14 | virtual org | ||
15 | virtual report | ||
16 | 13 | ||
17 | @depends on patch@ | 14 | @@ |
18 | expression from,to,size,flag; | 15 | expression from,to,size,flag; |
16 | position p; | ||
19 | identifier l1,l2; | 17 | identifier l1,l2; |
20 | @@ | 18 | @@ |
21 | 19 | ||
22 | - to = \(kmalloc\|kzalloc\)(size,flag); | 20 | - to = \(kmalloc@p\|kzalloc@p\)(size,flag); |
23 | + to = memdup_user(from,size); | 21 | + to = memdup_user(from,size); |
24 | if ( | 22 | if ( |
25 | - to==NULL | 23 | - to==NULL |
@@ -35,26 +33,3 @@ identifier l1,l2; | |||
35 | - -EFAULT | 33 | - -EFAULT |
36 | - ...+> | 34 | - ...+> |
37 | - } | 35 | - } |
38 | |||
39 | @r depends on !patch@ | ||
40 | expression from,to,size,flag; | ||
41 | position p; | ||
42 | statement S1,S2; | ||
43 | @@ | ||
44 | |||
45 | * to = \(kmalloc@p\|kzalloc@p\)(size,flag); | ||
46 | if (to==NULL || ...) S1 | ||
47 | if (copy_from_user(to, from, size) != 0) | ||
48 | S2 | ||
49 | |||
50 | @script:python depends on org@ | ||
51 | p << r.p; | ||
52 | @@ | ||
53 | |||
54 | coccilib.org.print_todo(p[0], "WARNING opportunity for memdup_user") | ||
55 | |||
56 | @script:python depends on report@ | ||
57 | p << r.p; | ||
58 | @@ | ||
59 | |||
60 | coccilib.report.print_report(p[0], "WARNING opportunity for memdup_user") | ||
diff --git a/scripts/coccinelle/api/ptr_ret.cocci b/scripts/coccinelle/api/ptr_ret.cocci deleted file mode 100644 index 15f076fdecb..00000000000 --- a/scripts/coccinelle/api/ptr_ret.cocci +++ /dev/null | |||
@@ -1,96 +0,0 @@ | |||
1 | /// | ||
2 | /// Use PTR_RET rather than if(IS_ERR(...)) + PTR_ERR | ||
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 | // Options: -no_includes -include_headers | ||
9 | // | ||
10 | // Keywords: ERR_PTR, PTR_ERR, PTR_RET | ||
11 | // Version min: 2.6.39 | ||
12 | // | ||
13 | |||
14 | virtual context | ||
15 | virtual patch | ||
16 | virtual org | ||
17 | virtual report | ||
18 | |||
19 | @depends on patch@ | ||
20 | expression ptr; | ||
21 | @@ | ||
22 | |||
23 | - if (IS_ERR(ptr)) return PTR_ERR(ptr); else return 0; | ||
24 | + return PTR_RET(ptr); | ||
25 | |||
26 | @depends on patch@ | ||
27 | expression ptr; | ||
28 | @@ | ||
29 | |||
30 | - if (IS_ERR(ptr)) return PTR_ERR(ptr); return 0; | ||
31 | + return PTR_RET(ptr); | ||
32 | |||
33 | @depends on patch@ | ||
34 | expression ptr; | ||
35 | @@ | ||
36 | |||
37 | - (IS_ERR(ptr) ? PTR_ERR(ptr) : 0) | ||
38 | + PTR_RET(ptr) | ||
39 | |||
40 | @r1 depends on !patch@ | ||
41 | expression ptr; | ||
42 | position p1; | ||
43 | @@ | ||
44 | |||
45 | * if@p1 (IS_ERR(ptr)) return PTR_ERR(ptr); else return 0; | ||
46 | |||
47 | @r2 depends on !patch@ | ||
48 | expression ptr; | ||
49 | position p2; | ||
50 | @@ | ||
51 | |||
52 | * if@p2 (IS_ERR(ptr)) return PTR_ERR(ptr); return 0; | ||
53 | |||
54 | @r3 depends on !patch@ | ||
55 | expression ptr; | ||
56 | position p3; | ||
57 | @@ | ||
58 | |||
59 | * IS_ERR@p3(ptr) ? PTR_ERR(ptr) : 0 | ||
60 | |||
61 | @script:python depends on org@ | ||
62 | p << r1.p1; | ||
63 | @@ | ||
64 | |||
65 | coccilib.org.print_todo(p[0], "WARNING: PTR_RET can be used") | ||
66 | |||
67 | |||
68 | @script:python depends on org@ | ||
69 | p << r2.p2; | ||
70 | @@ | ||
71 | |||
72 | coccilib.org.print_todo(p[0], "WARNING: PTR_RET can be used") | ||
73 | |||
74 | @script:python depends on org@ | ||
75 | p << r3.p3; | ||
76 | @@ | ||
77 | |||
78 | coccilib.org.print_todo(p[0], "WARNING: PTR_RET can be used") | ||
79 | |||
80 | @script:python depends on report@ | ||
81 | p << r1.p1; | ||
82 | @@ | ||
83 | |||
84 | coccilib.report.print_report(p[0], "WARNING: PTR_RET can be used") | ||
85 | |||
86 | @script:python depends on report@ | ||
87 | p << r2.p2; | ||
88 | @@ | ||
89 | |||
90 | coccilib.report.print_report(p[0], "WARNING: PTR_RET can be used") | ||
91 | |||
92 | @script:python depends on report@ | ||
93 | p << r3.p3; | ||
94 | @@ | ||
95 | |||
96 | coccilib.report.print_report(p[0], "WARNING: PTR_RET can be used") | ||
diff --git a/scripts/coccinelle/api/simple_open.cocci b/scripts/coccinelle/api/simple_open.cocci deleted file mode 100644 index 05962f7be15..00000000000 --- a/scripts/coccinelle/api/simple_open.cocci +++ /dev/null | |||
@@ -1,70 +0,0 @@ | |||
1 | /// This removes an open coded simple_open() function | ||
2 | /// and replaces file operations references to the function | ||
3 | /// with simple_open() instead. | ||
4 | /// | ||
5 | // Confidence: High | ||
6 | // Comments: | ||
7 | // Options: -no_includes -include_headers | ||
8 | |||
9 | virtual patch | ||
10 | virtual report | ||
11 | |||
12 | @ open depends on patch @ | ||
13 | identifier open_f != simple_open; | ||
14 | identifier i, f; | ||
15 | @@ | ||
16 | -int open_f(struct inode *i, struct file *f) | ||
17 | -{ | ||
18 | ( | ||
19 | -if (i->i_private) | ||
20 | -f->private_data = i->i_private; | ||
21 | | | ||
22 | -f->private_data = i->i_private; | ||
23 | ) | ||
24 | -return 0; | ||
25 | -} | ||
26 | |||
27 | @ has_open depends on open @ | ||
28 | identifier fops; | ||
29 | identifier open.open_f; | ||
30 | @@ | ||
31 | struct file_operations fops = { | ||
32 | ..., | ||
33 | -.open = open_f, | ||
34 | +.open = simple_open, | ||
35 | ... | ||
36 | }; | ||
37 | |||
38 | @ openr depends on report @ | ||
39 | identifier open_f != simple_open; | ||
40 | identifier i, f; | ||
41 | position p; | ||
42 | @@ | ||
43 | int open_f@p(struct inode *i, struct file *f) | ||
44 | { | ||
45 | ( | ||
46 | if (i->i_private) | ||
47 | f->private_data = i->i_private; | ||
48 | | | ||
49 | f->private_data = i->i_private; | ||
50 | ) | ||
51 | return 0; | ||
52 | } | ||
53 | |||
54 | @ has_openr depends on openr @ | ||
55 | identifier fops; | ||
56 | identifier openr.open_f; | ||
57 | position p; | ||
58 | @@ | ||
59 | struct file_operations fops = { | ||
60 | ..., | ||
61 | .open = open_f@p, | ||
62 | ... | ||
63 | }; | ||
64 | |||
65 | @script:python@ | ||
66 | pf << openr.p; | ||
67 | ps << has_openr.p; | ||
68 | @@ | ||
69 | |||
70 | coccilib.report.print_report(pf[0],"WARNING opportunity for simple_open, see also structure on line %s"%(ps[0].line)) | ||
diff --git a/scripts/coccinelle/free/clk_put.cocci b/scripts/coccinelle/free/clk_put.cocci deleted file mode 100644 index 46747adfd20..00000000000 --- a/scripts/coccinelle/free/clk_put.cocci +++ /dev/null | |||
@@ -1,67 +0,0 @@ | |||
1 | /// Find missing clk_puts. | ||
2 | /// | ||
3 | //# This only signals a missing clk_put when there is a clk_put later | ||
4 | //# in the same function. | ||
5 | //# False positives can be due to loops. | ||
6 | // | ||
7 | // Confidence: Moderate | ||
8 | // Copyright: (C) 2012 Julia Lawall, INRIA/LIP6. GPLv2. | ||
9 | // Copyright: (C) 2012 Gilles Muller, INRIA/LiP6. GPLv2. | ||
10 | // URL: http://coccinelle.lip6.fr/ | ||
11 | // Comments: | ||
12 | // Options: | ||
13 | |||
14 | virtual context | ||
15 | virtual org | ||
16 | virtual report | ||
17 | |||
18 | @clk@ | ||
19 | expression e; | ||
20 | statement S,S1; | ||
21 | int ret; | ||
22 | position p1,p2,p3; | ||
23 | @@ | ||
24 | |||
25 | e = clk_get@p1(...) | ||
26 | ... when != clk_put(e) | ||
27 | if (<+...e...+>) S | ||
28 | ... when any | ||
29 | when != clk_put(e) | ||
30 | when != if (...) { ... clk_put(e); ... } | ||
31 | ( | ||
32 | if (ret == 0) S1 | ||
33 | | | ||
34 | if (...) | ||
35 | { ... | ||
36 | return 0; } | ||
37 | | | ||
38 | if (...) | ||
39 | { ... | ||
40 | return <+...e...+>; } | ||
41 | | | ||
42 | *if@p2 (...) | ||
43 | { ... when != clk_put(e) | ||
44 | when forall | ||
45 | return@p3 ...; } | ||
46 | ) | ||
47 | ... when any | ||
48 | clk_put(e); | ||
49 | |||
50 | @script:python depends on org@ | ||
51 | p1 << clk.p1; | ||
52 | p2 << clk.p2; | ||
53 | p3 << clk.p3; | ||
54 | @@ | ||
55 | |||
56 | cocci.print_main("clk_get",p1) | ||
57 | cocci.print_secs("if",p2) | ||
58 | cocci.print_secs("needed clk_put",p3) | ||
59 | |||
60 | @script:python depends on report@ | ||
61 | p1 << clk.p1; | ||
62 | p2 << clk.p2; | ||
63 | p3 << clk.p3; | ||
64 | @@ | ||
65 | |||
66 | msg = "ERROR: missing clk_put; clk_get on line %s and execution via conditional on line %s" % (p1[0].line,p2[0].line) | ||
67 | coccilib.report.print_report(p3[0],msg) | ||
diff --git a/scripts/coccinelle/free/devm_free.cocci b/scripts/coccinelle/free/devm_free.cocci deleted file mode 100644 index 0a1e36146d7..00000000000 --- a/scripts/coccinelle/free/devm_free.cocci +++ /dev/null | |||
@@ -1,71 +0,0 @@ | |||
1 | /// Find uses of standard freeing functons on values allocated using devm_ | ||
2 | /// functions. Values allocated using the devm_functions are freed when | ||
3 | /// the device is detached, and thus the use of the standard freeing | ||
4 | /// function would cause a double free. | ||
5 | /// See Documentation/driver-model/devres.txt for more information. | ||
6 | /// | ||
7 | /// A difficulty of detecting this problem is that the standard freeing | ||
8 | /// function might be called from a different function than the one | ||
9 | /// containing the allocation function. It is thus necessary to make the | ||
10 | /// connection between the allocation function and the freeing function. | ||
11 | /// Here this is done using the specific argument text, which is prone to | ||
12 | /// false positives. There is no rule for the request_region and | ||
13 | /// request_mem_region variants because this heuristic seems to be a bit | ||
14 | /// less reliable in these cases. | ||
15 | /// | ||
16 | // Confidence: Moderate | ||
17 | // Copyright: (C) 2011 Julia Lawall, INRIA/LIP6. GPLv2. | ||
18 | // Copyright: (C) 2011 Gilles Muller, INRIA/LiP6. GPLv2. | ||
19 | // URL: http://coccinelle.lip6.fr/ | ||
20 | // Comments: | ||
21 | // Options: -no_includes -include_headers | ||
22 | |||
23 | virtual org | ||
24 | virtual report | ||
25 | virtual context | ||
26 | |||
27 | @r depends on context || org || report@ | ||
28 | expression x; | ||
29 | @@ | ||
30 | |||
31 | ( | ||
32 | x = devm_kzalloc(...) | ||
33 | | | ||
34 | x = devm_request_irq(...) | ||
35 | | | ||
36 | x = devm_ioremap(...) | ||
37 | | | ||
38 | x = devm_ioremap_nocache(...) | ||
39 | | | ||
40 | x = devm_ioport_map(...) | ||
41 | ) | ||
42 | |||
43 | @pb@ | ||
44 | expression r.x; | ||
45 | position p; | ||
46 | @@ | ||
47 | |||
48 | ( | ||
49 | * kfree@p(x) | ||
50 | | | ||
51 | * free_irq@p(x) | ||
52 | | | ||
53 | * iounmap@p(x) | ||
54 | | | ||
55 | * ioport_unmap@p(x) | ||
56 | ) | ||
57 | |||
58 | @script:python depends on org@ | ||
59 | p << pb.p; | ||
60 | @@ | ||
61 | |||
62 | msg="WARNING: invalid free of devm_ allocated data" | ||
63 | coccilib.org.print_todo(p[0], msg) | ||
64 | |||
65 | @script:python depends on report@ | ||
66 | p << pb.p; | ||
67 | @@ | ||
68 | |||
69 | msg="WARNING: invalid free of devm_ allocated data" | ||
70 | coccilib.report.print_report(p[0], msg) | ||
71 | |||
diff --git a/scripts/coccinelle/free/iounmap.cocci b/scripts/coccinelle/free/iounmap.cocci deleted file mode 100644 index 5384f4ba119..00000000000 --- a/scripts/coccinelle/free/iounmap.cocci +++ /dev/null | |||
@@ -1,67 +0,0 @@ | |||
1 | /// Find missing iounmaps. | ||
2 | /// | ||
3 | //# This only signals a missing iounmap when there is an iounmap later | ||
4 | //# in the same function. | ||
5 | //# False positives can be due to loops. | ||
6 | // | ||
7 | // Confidence: Moderate | ||
8 | // Copyright: (C) 2012 Julia Lawall, INRIA/LIP6. GPLv2. | ||
9 | // Copyright: (C) 2012 Gilles Muller, INRIA/LiP6. GPLv2. | ||
10 | // URL: http://coccinelle.lip6.fr/ | ||
11 | // Comments: | ||
12 | // Options: | ||
13 | |||
14 | virtual context | ||
15 | virtual org | ||
16 | virtual report | ||
17 | |||
18 | @iom@ | ||
19 | expression e; | ||
20 | statement S,S1; | ||
21 | int ret; | ||
22 | position p1,p2,p3; | ||
23 | @@ | ||
24 | |||
25 | e = \(ioremap@p1\|ioremap_nocache@p1\)(...) | ||
26 | ... when != iounmap(e) | ||
27 | if (<+...e...+>) S | ||
28 | ... when any | ||
29 | when != iounmap(e) | ||
30 | when != if (...) { ... iounmap(e); ... } | ||
31 | ( | ||
32 | if (ret == 0) S1 | ||
33 | | | ||
34 | if (...) | ||
35 | { ... | ||
36 | return 0; } | ||
37 | | | ||
38 | if (...) | ||
39 | { ... | ||
40 | return <+...e...+>; } | ||
41 | | | ||
42 | *if@p2 (...) | ||
43 | { ... when != iounmap(e) | ||
44 | when forall | ||
45 | return@p3 ...; } | ||
46 | ) | ||
47 | ... when any | ||
48 | iounmap(e); | ||
49 | |||
50 | @script:python depends on org@ | ||
51 | p1 << iom.p1; | ||
52 | p2 << iom.p2; | ||
53 | p3 << iom.p3; | ||
54 | @@ | ||
55 | |||
56 | cocci.print_main("ioremap",p1) | ||
57 | cocci.print_secs("if",p2) | ||
58 | cocci.print_secs("needed iounmap",p3) | ||
59 | |||
60 | @script:python depends on report@ | ||
61 | p1 << iom.p1; | ||
62 | p2 << iom.p2; | ||
63 | p3 << iom.p3; | ||
64 | @@ | ||
65 | |||
66 | msg = "ERROR: missing iounmap; ioremap on line %s and execution via conditional on line %s" % (p1[0].line,p2[0].line) | ||
67 | coccilib.report.print_report(p3[0],msg) | ||
diff --git a/scripts/coccinelle/free/kfree.cocci b/scripts/coccinelle/free/kfree.cocci index d9ae6d89c2f..f9f79d9245e 100644 --- a/scripts/coccinelle/free/kfree.cocci +++ b/scripts/coccinelle/free/kfree.cocci | |||
@@ -5,9 +5,9 @@ | |||
5 | //# SCTP_DBG_OBJCNT_DEC that do not actually evaluate their argument | 5 | //# SCTP_DBG_OBJCNT_DEC that do not actually evaluate their argument |
6 | /// | 6 | /// |
7 | // Confidence: Moderate | 7 | // Confidence: Moderate |
8 | // Copyright: (C) 2010-2012 Nicolas Palix. GPLv2. | 8 | // Copyright: (C) 2010 Nicolas Palix, DIKU. GPLv2. |
9 | // Copyright: (C) 2010-2012 Julia Lawall, INRIA/LIP6. GPLv2. | 9 | // Copyright: (C) 2010 Julia Lawall, DIKU. GPLv2. |
10 | // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6. GPLv2. | 10 | // Copyright: (C) 2010 Gilles Muller, INRIA/LiP6. GPLv2. |
11 | // URL: http://coccinelle.lip6.fr/ | 11 | // URL: http://coccinelle.lip6.fr/ |
12 | // Comments: | 12 | // Comments: |
13 | // Options: -no_includes -include_headers | 13 | // Options: -no_includes -include_headers |
@@ -23,7 +23,7 @@ position p1; | |||
23 | kfree@p1(E) | 23 | kfree@p1(E) |
24 | 24 | ||
25 | @print expression@ | 25 | @print expression@ |
26 | constant char [] c; | 26 | constant char *c; |
27 | expression free.E,E2; | 27 | expression free.E,E2; |
28 | type T; | 28 | type T; |
29 | position p; | 29 | position p; |
@@ -37,10 +37,6 @@ identifier f; | |||
37 | | | 37 | | |
38 | E@p != E2 | 38 | E@p != E2 |
39 | | | 39 | | |
40 | E2 == E@p | ||
41 | | | ||
42 | E2 != E@p | ||
43 | | | ||
44 | !E@p | 40 | !E@p |
45 | | | 41 | | |
46 | E@p || ... | 42 | E@p || ... |
@@ -117,5 +113,5 @@ p1 << free.p1; | |||
117 | p2 << r.p2; | 113 | p2 << r.p2; |
118 | @@ | 114 | @@ |
119 | 115 | ||
120 | msg = "ERROR: reference preceded by free on line %s" % (p1[0].line) | 116 | msg = "reference preceded by free on line %s" % (p1[0].line) |
121 | coccilib.report.print_report(p2[0],msg) | 117 | coccilib.report.print_report(p2[0],msg) |
diff --git a/scripts/coccinelle/iterators/fen.cocci b/scripts/coccinelle/iterators/fen.cocci index 0a40af828c4..77bc108c3f5 100644 --- a/scripts/coccinelle/iterators/fen.cocci +++ b/scripts/coccinelle/iterators/fen.cocci | |||
@@ -2,19 +2,16 @@ | |||
2 | /// is no point to call of_node_put on the final value. | 2 | /// is no point to call of_node_put on the final value. |
3 | /// | 3 | /// |
4 | // Confidence: High | 4 | // Confidence: High |
5 | // Copyright: (C) 2010-2012 Nicolas Palix. GPLv2. | 5 | // Copyright: (C) 2010 Nicolas Palix, DIKU. GPLv2. |
6 | // Copyright: (C) 2010-2012 Julia Lawall, INRIA/LIP6. GPLv2. | 6 | // Copyright: (C) 2010 Julia Lawall, DIKU. GPLv2. |
7 | // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6. GPLv2. | 7 | // Copyright: (C) 2010 Gilles Muller, INRIA/LiP6. GPLv2. |
8 | // URL: http://coccinelle.lip6.fr/ | 8 | // URL: http://coccinelle.lip6.fr/ |
9 | // Comments: | 9 | // Comments: |
10 | // Options: -no_includes -include_headers | 10 | // Options: -no_includes -include_headers |
11 | 11 | ||
12 | virtual patch | 12 | virtual patch |
13 | virtual context | ||
14 | virtual org | ||
15 | virtual report | ||
16 | 13 | ||
17 | @depends on patch@ | 14 | @@ |
18 | iterator name for_each_node_by_name; | 15 | iterator name for_each_node_by_name; |
19 | expression np,E; | 16 | expression np,E; |
20 | identifier l; | 17 | identifier l; |
@@ -27,7 +24,7 @@ for_each_node_by_name(np,...) { | |||
27 | ... when != np = E | 24 | ... when != np = E |
28 | - of_node_put(np); | 25 | - of_node_put(np); |
29 | 26 | ||
30 | @depends on patch@ | 27 | @@ |
31 | iterator name for_each_node_by_type; | 28 | iterator name for_each_node_by_type; |
32 | expression np,E; | 29 | expression np,E; |
33 | identifier l; | 30 | identifier l; |
@@ -40,7 +37,7 @@ for_each_node_by_type(np,...) { | |||
40 | ... when != np = E | 37 | ... when != np = E |
41 | - of_node_put(np); | 38 | - of_node_put(np); |
42 | 39 | ||
43 | @depends on patch@ | 40 | @@ |
44 | iterator name for_each_compatible_node; | 41 | iterator name for_each_compatible_node; |
45 | expression np,E; | 42 | expression np,E; |
46 | identifier l; | 43 | identifier l; |
@@ -53,7 +50,7 @@ for_each_compatible_node(np,...) { | |||
53 | ... when != np = E | 50 | ... when != np = E |
54 | - of_node_put(np); | 51 | - of_node_put(np); |
55 | 52 | ||
56 | @depends on patch@ | 53 | @@ |
57 | iterator name for_each_matching_node; | 54 | iterator name for_each_matching_node; |
58 | expression np,E; | 55 | expression np,E; |
59 | identifier l; | 56 | identifier l; |
@@ -65,59 +62,3 @@ for_each_matching_node(np,...) { | |||
65 | } | 62 | } |
66 | ... when != np = E | 63 | ... when != np = E |
67 | - of_node_put(np); | 64 | - of_node_put(np); |
68 | |||
69 | // ---------------------------------------------------------------------- | ||
70 | |||
71 | @r depends on !patch forall@ | ||
72 | //iterator name for_each_node_by_name; | ||
73 | //iterator name for_each_node_by_type; | ||
74 | //iterator name for_each_compatible_node; | ||
75 | //iterator name for_each_matching_node; | ||
76 | expression np,E; | ||
77 | identifier l; | ||
78 | position p1,p2; | ||
79 | @@ | ||
80 | |||
81 | ( | ||
82 | *for_each_node_by_name@p1(np,...) | ||
83 | { | ||
84 | ... when != break; | ||
85 | when != goto l; | ||
86 | } | ||
87 | | | ||
88 | *for_each_node_by_type@p1(np,...) | ||
89 | { | ||
90 | ... when != break; | ||
91 | when != goto l; | ||
92 | } | ||
93 | | | ||
94 | *for_each_compatible_node@p1(np,...) | ||
95 | { | ||
96 | ... when != break; | ||
97 | when != goto l; | ||
98 | } | ||
99 | | | ||
100 | *for_each_matching_node@p1(np,...) | ||
101 | { | ||
102 | ... when != break; | ||
103 | when != goto l; | ||
104 | } | ||
105 | ) | ||
106 | ... when != np = E | ||
107 | * of_node_put@p2(np); | ||
108 | |||
109 | @script:python depends on org@ | ||
110 | p1 << r.p1; | ||
111 | p2 << r.p2; | ||
112 | @@ | ||
113 | |||
114 | cocci.print_main("unneeded of_node_put",p2) | ||
115 | cocci.print_secs("iterator",p1) | ||
116 | |||
117 | @script:python depends on report@ | ||
118 | p1 << r.p1; | ||
119 | p2 << r.p2; | ||
120 | @@ | ||
121 | |||
122 | msg = "ERROR: of_node_put not needed after iterator on line %s" % (p1[0].line) | ||
123 | coccilib.report.print_report(p2[0], msg) | ||
diff --git a/scripts/coccinelle/iterators/itnull.cocci b/scripts/coccinelle/iterators/itnull.cocci index 259899f6838..baa4297a4ed 100644 --- a/scripts/coccinelle/iterators/itnull.cocci +++ b/scripts/coccinelle/iterators/itnull.cocci | |||
@@ -1,24 +1,20 @@ | |||
1 | /// Many iterators have the property that the first argument is always bound | 1 | /// Many iterators have the property that the first argument is always bound |
2 | /// to a real list element, never NULL. | 2 | /// to a real list element, never NULL. False positives arise for some |
3 | //# False positives arise for some iterators that do not have this property, | 3 | /// iterators that do not have this property, or in cases when the loop |
4 | //# or in cases when the loop cursor is reassigned. The latter should only | 4 | /// cursor is reassigned. The latter should only happen when the matched |
5 | //# happen when the matched code is on the way to a loop exit (break, goto, | 5 | /// code is on the way to a loop exit (break, goto, or return). |
6 | //# or return). | ||
7 | /// | 6 | /// |
8 | // Confidence: Moderate | 7 | // Confidence: Moderate |
9 | // Copyright: (C) 2010-2012 Nicolas Palix. GPLv2. | 8 | // Copyright: (C) 2010 Nicolas Palix, DIKU. GPLv2. |
10 | // Copyright: (C) 2010-2012 Julia Lawall, INRIA/LIP6. GPLv2. | 9 | // Copyright: (C) 2010 Julia Lawall, DIKU. GPLv2. |
11 | // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6. GPLv2. | 10 | // Copyright: (C) 2010 Gilles Muller, INRIA/LiP6. GPLv2. |
12 | // URL: http://coccinelle.lip6.fr/ | 11 | // URL: http://coccinelle.lip6.fr/ |
13 | // Comments: | 12 | // Comments: |
14 | // Options: -no_includes -include_headers | 13 | // Options: -no_includes -include_headers |
15 | 14 | ||
16 | virtual patch | 15 | virtual patch |
17 | virtual context | ||
18 | virtual org | ||
19 | virtual report | ||
20 | 16 | ||
21 | @depends on patch@ | 17 | @@ |
22 | iterator I; | 18 | iterator I; |
23 | expression x,E,E1,E2; | 19 | expression x,E,E1,E2; |
24 | statement S,S1,S2; | 20 | statement S,S1,S2; |
@@ -59,36 +55,4 @@ I(x,...) { <... | |||
59 | x != NULL | 55 | x != NULL |
60 | + ) | 56 | + ) |
61 | ) | 57 | ) |
62 | ...> } | 58 | ...> } \ No newline at end of file |
63 | |||
64 | @r depends on !patch exists@ | ||
65 | iterator I; | ||
66 | expression x,E; | ||
67 | position p1,p2; | ||
68 | @@ | ||
69 | |||
70 | *I@p1(x,...) | ||
71 | { ... when != x = E | ||
72 | ( | ||
73 | * x@p2 == NULL | ||
74 | | | ||
75 | * x@p2 != NULL | ||
76 | ) | ||
77 | ... when any | ||
78 | } | ||
79 | |||
80 | @script:python depends on org@ | ||
81 | p1 << r.p1; | ||
82 | p2 << r.p2; | ||
83 | @@ | ||
84 | |||
85 | cocci.print_main("iterator-bound variable",p1) | ||
86 | cocci.print_secs("useless NULL test",p2) | ||
87 | |||
88 | @script:python depends on report@ | ||
89 | p1 << r.p1; | ||
90 | p2 << r.p2; | ||
91 | @@ | ||
92 | |||
93 | msg = "ERROR: iterator variable bound on line %s cannot be NULL" % (p1[0].line) | ||
94 | coccilib.report.print_report(p2[0], msg) | ||
diff --git a/scripts/coccinelle/iterators/use_after_iter.cocci b/scripts/coccinelle/iterators/use_after_iter.cocci deleted file mode 100644 index 06284c57a95..00000000000 --- a/scripts/coccinelle/iterators/use_after_iter.cocci +++ /dev/null | |||
@@ -1,147 +0,0 @@ | |||
1 | /// If list_for_each_entry, etc complete a traversal of the list, the iterator | ||
2 | /// variable ends up pointing to an address at an offset from the list head, | ||
3 | /// and not a meaningful structure. Thus this value should not be used after | ||
4 | /// the end of the iterator. | ||
5 | //#False positives arise when there is a goto in the iterator and the | ||
6 | //#reported reference is at the label of this goto. Some flag tests | ||
7 | //#may also cause a report to be a false positive. | ||
8 | /// | ||
9 | // Confidence: Moderate | ||
10 | // Copyright: (C) 2012 Julia Lawall, INRIA/LIP6. GPLv2. | ||
11 | // Copyright: (C) 2012 Gilles Muller, INRIA/LIP6. GPLv2. | ||
12 | // URL: http://coccinelle.lip6.fr/ | ||
13 | // Comments: | ||
14 | // Options: -no_includes -include_headers | ||
15 | |||
16 | virtual context | ||
17 | virtual org | ||
18 | virtual report | ||
19 | |||
20 | @r exists@ | ||
21 | identifier c,member; | ||
22 | expression E,x; | ||
23 | iterator name list_for_each_entry; | ||
24 | iterator name list_for_each_entry_reverse; | ||
25 | iterator name list_for_each_entry_continue; | ||
26 | iterator name list_for_each_entry_continue_reverse; | ||
27 | iterator name list_for_each_entry_from; | ||
28 | iterator name list_for_each_entry_safe; | ||
29 | iterator name list_for_each_entry_safe_continue; | ||
30 | iterator name list_for_each_entry_safe_from; | ||
31 | iterator name list_for_each_entry_safe_reverse; | ||
32 | iterator name hlist_for_each_entry; | ||
33 | iterator name hlist_for_each_entry_continue; | ||
34 | iterator name hlist_for_each_entry_from; | ||
35 | iterator name hlist_for_each_entry_safe; | ||
36 | statement S; | ||
37 | position p1,p2; | ||
38 | @@ | ||
39 | |||
40 | ( | ||
41 | list_for_each_entry@p1(c,...,member) { ... when != break; | ||
42 | when forall | ||
43 | when strict | ||
44 | } | ||
45 | | | ||
46 | list_for_each_entry_reverse@p1(c,...,member) { ... when != break; | ||
47 | when forall | ||
48 | when strict | ||
49 | } | ||
50 | | | ||
51 | list_for_each_entry_continue@p1(c,...,member) { ... when != break; | ||
52 | when forall | ||
53 | when strict | ||
54 | } | ||
55 | | | ||
56 | list_for_each_entry_continue_reverse@p1(c,...,member) { ... when != break; | ||
57 | when forall | ||
58 | when strict | ||
59 | } | ||
60 | | | ||
61 | list_for_each_entry_from@p1(c,...,member) { ... when != break; | ||
62 | when forall | ||
63 | when strict | ||
64 | } | ||
65 | | | ||
66 | list_for_each_entry_safe@p1(c,...,member) { ... when != break; | ||
67 | when forall | ||
68 | when strict | ||
69 | } | ||
70 | | | ||
71 | list_for_each_entry_safe_continue@p1(c,...,member) { ... when != break; | ||
72 | when forall | ||
73 | when strict | ||
74 | } | ||
75 | | | ||
76 | list_for_each_entry_safe_from@p1(c,...,member) { ... when != break; | ||
77 | when forall | ||
78 | when strict | ||
79 | } | ||
80 | | | ||
81 | list_for_each_entry_safe_reverse@p1(c,...,member) { ... when != break; | ||
82 | when forall | ||
83 | when strict | ||
84 | } | ||
85 | ) | ||
86 | ... | ||
87 | ( | ||
88 | list_for_each_entry(c,...) S | ||
89 | | | ||
90 | list_for_each_entry_reverse(c,...) S | ||
91 | | | ||
92 | list_for_each_entry_continue(c,...) S | ||
93 | | | ||
94 | list_for_each_entry_continue_reverse(c,...) S | ||
95 | | | ||
96 | list_for_each_entry_from(c,...) S | ||
97 | | | ||
98 | list_for_each_entry_safe(c,...) S | ||
99 | | | ||
100 | list_for_each_entry_safe(x,c,...) S | ||
101 | | | ||
102 | list_for_each_entry_safe_continue(c,...) S | ||
103 | | | ||
104 | list_for_each_entry_safe_continue(x,c,...) S | ||
105 | | | ||
106 | list_for_each_entry_safe_from(c,...) S | ||
107 | | | ||
108 | list_for_each_entry_safe_from(x,c,...) S | ||
109 | | | ||
110 | list_for_each_entry_safe_reverse(c,...) S | ||
111 | | | ||
112 | list_for_each_entry_safe_reverse(x,c,...) S | ||
113 | | | ||
114 | hlist_for_each_entry(c,...) S | ||
115 | | | ||
116 | hlist_for_each_entry_continue(c,...) S | ||
117 | | | ||
118 | hlist_for_each_entry_from(c,...) S | ||
119 | | | ||
120 | hlist_for_each_entry_safe(c,...) S | ||
121 | | | ||
122 | list_remove_head(x,c,...) | ||
123 | | | ||
124 | sizeof(<+...c...+>) | ||
125 | | | ||
126 | &c->member | ||
127 | | | ||
128 | c = E | ||
129 | | | ||
130 | *c@p2 | ||
131 | ) | ||
132 | |||
133 | @script:python depends on org@ | ||
134 | p1 << r.p1; | ||
135 | p2 << r.p2; | ||
136 | @@ | ||
137 | |||
138 | cocci.print_main("invalid iterator index reference",p2) | ||
139 | cocci.print_secs("iterator",p1) | ||
140 | |||
141 | @script:python depends on report@ | ||
142 | p1 << r.p1; | ||
143 | p2 << r.p2; | ||
144 | @@ | ||
145 | |||
146 | msg = "ERROR: invalid reference to the index variable of the iterator on line %s" % (p1[0].line) | ||
147 | coccilib.report.print_report(p2[0], msg) | ||
diff --git a/scripts/coccinelle/locks/call_kern.cocci b/scripts/coccinelle/locks/call_kern.cocci index 8f10b49603c..00af5344a68 100644 --- a/scripts/coccinelle/locks/call_kern.cocci +++ b/scripts/coccinelle/locks/call_kern.cocci | |||
@@ -1,20 +1,17 @@ | |||
1 | /// Find functions that refer to GFP_KERNEL but are called with locks held. | 1 | /// Find functions that refer to GFP_KERNEL but are called with locks held. |
2 | //# The proposed change of converting the GFP_KERNEL is not necessarily the | 2 | /// The proposed change of converting the GFP_KERNEL is not necessarily the |
3 | //# correct one. It may be desired to unlock the lock, or to not call the | 3 | /// correct one. It may be desired to unlock the lock, or to not call the |
4 | //# function under the lock in the first place. | 4 | /// function under the lock in the first place. |
5 | /// | 5 | /// |
6 | // Confidence: Moderate | 6 | // Confidence: Moderate |
7 | // Copyright: (C) 2012 Nicolas Palix. GPLv2. | 7 | // Copyright: (C) 2010 Nicolas Palix, DIKU. GPLv2. |
8 | // Copyright: (C) 2012 Julia Lawall, INRIA/LIP6. GPLv2. | 8 | // Copyright: (C) 2010 Julia Lawall, DIKU. GPLv2. |
9 | // Copyright: (C) 2012 Gilles Muller, INRIA/LiP6. GPLv2. | 9 | // Copyright: (C) 2010 Gilles Muller, INRIA/LiP6. GPLv2. |
10 | // URL: http://coccinelle.lip6.fr/ | 10 | // URL: http://coccinelle.lip6.fr/ |
11 | // Comments: | 11 | // Comments: |
12 | // Options: -no_includes -include_headers | 12 | // Options: -no_includes -include_headers |
13 | 13 | ||
14 | virtual patch | 14 | virtual patch |
15 | virtual context | ||
16 | virtual org | ||
17 | virtual report | ||
18 | 15 | ||
19 | @gfp exists@ | 16 | @gfp exists@ |
20 | identifier fn; | 17 | identifier fn; |
@@ -35,29 +32,28 @@ fn(...) { | |||
35 | ... when any | 32 | ... when any |
36 | } | 33 | } |
37 | 34 | ||
38 | @locked exists@ | 35 | @locked@ |
39 | identifier gfp.fn; | 36 | identifier gfp.fn; |
40 | position p1,p2; | ||
41 | @@ | 37 | @@ |
42 | 38 | ||
43 | ( | 39 | ( |
44 | read_lock_irq@p1 | 40 | read_lock_irq |
45 | | | 41 | | |
46 | write_lock_irq@p1 | 42 | write_lock_irq |
47 | | | 43 | | |
48 | read_lock_irqsave@p1 | 44 | read_lock_irqsave |
49 | | | 45 | | |
50 | write_lock_irqsave@p1 | 46 | write_lock_irqsave |
51 | | | 47 | | |
52 | spin_lock@p1 | 48 | spin_lock |
53 | | | 49 | | |
54 | spin_trylock@p1 | 50 | spin_trylock |
55 | | | 51 | | |
56 | spin_lock_irq@p1 | 52 | spin_lock_irq |
57 | | | 53 | | |
58 | spin_lock_irqsave@p1 | 54 | spin_lock_irqsave |
59 | | | 55 | | |
60 | local_irq_disable@p1 | 56 | local_irq_disable |
61 | ) | 57 | ) |
62 | (...) | 58 | (...) |
63 | ... when != read_unlock_irq(...) | 59 | ... when != read_unlock_irq(...) |
@@ -68,38 +64,11 @@ local_irq_disable@p1 | |||
68 | when != spin_unlock_irq(...) | 64 | when != spin_unlock_irq(...) |
69 | when != spin_unlock_irqrestore(...) | 65 | when != spin_unlock_irqrestore(...) |
70 | when != local_irq_enable(...) | 66 | when != local_irq_enable(...) |
71 | fn@p2(...) | 67 | fn(...) |
72 | 68 | ||
73 | @depends on locked && patch@ | 69 | @depends on locked@ |
74 | position gfp.p; | 70 | position gfp.p; |
75 | @@ | 71 | @@ |
76 | 72 | ||
77 | - GFP_KERNEL@p | 73 | - GFP_KERNEL@p |
78 | + GFP_ATOMIC | 74 | + GFP_ATOMIC |
79 | |||
80 | @depends on locked && !patch@ | ||
81 | position gfp.p; | ||
82 | @@ | ||
83 | |||
84 | * GFP_KERNEL@p | ||
85 | |||
86 | @script:python depends on !patch && org@ | ||
87 | p << gfp.p; | ||
88 | fn << gfp.fn; | ||
89 | p1 << locked.p1; | ||
90 | p2 << locked.p2; | ||
91 | @@ | ||
92 | |||
93 | cocci.print_main("lock",p1) | ||
94 | cocci.print_secs("call",p2) | ||
95 | cocci.print_secs("GFP_KERNEL",p) | ||
96 | |||
97 | @script:python depends on !patch && report@ | ||
98 | p << gfp.p; | ||
99 | fn << gfp.fn; | ||
100 | p1 << locked.p1; | ||
101 | p2 << locked.p2; | ||
102 | @@ | ||
103 | |||
104 | msg = "ERROR: function %s called on line %s inside lock on line %s but uses GFP_KERNEL" % (fn,p2[0].line,p1[0].line) | ||
105 | coccilib.report.print_report(p[0], msg) | ||
diff --git a/scripts/coccinelle/locks/flags.cocci b/scripts/coccinelle/locks/flags.cocci index 1c4ffe6fd84..b4344d83809 100644 --- a/scripts/coccinelle/locks/flags.cocci +++ b/scripts/coccinelle/locks/flags.cocci | |||
@@ -1,9 +1,9 @@ | |||
1 | /// Find nested lock+irqsave functions that use the same flags variables | 1 | /// Find nested lock+irqsave functions that use the same flags variables |
2 | /// | 2 | /// |
3 | // Confidence: High | 3 | // Confidence: High |
4 | // Copyright: (C) 2010-2012 Nicolas Palix. GPLv2. | 4 | // Copyright: (C) 2010 Nicolas Palix, DIKU. GPLv2. |
5 | // Copyright: (C) 2010-2012 Julia Lawall, INRIA/LIP6. GPLv2. | 5 | // Copyright: (C) 2010 Julia Lawall, DIKU. GPLv2. |
6 | // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6. GPLv2. | 6 | // Copyright: (C) 2010 Gilles Muller, INRIA/LiP6. GPLv2. |
7 | // URL: http://coccinelle.lip6.fr/ | 7 | // URL: http://coccinelle.lip6.fr/ |
8 | // Comments: | 8 | // Comments: |
9 | // Options: -no_includes -include_headers | 9 | // Options: -no_includes -include_headers |
@@ -12,7 +12,7 @@ virtual context | |||
12 | virtual org | 12 | virtual org |
13 | virtual report | 13 | virtual report |
14 | 14 | ||
15 | @r exists@ | 15 | @r@ |
16 | expression lock1,lock2,flags; | 16 | expression lock1,lock2,flags; |
17 | position p1,p2; | 17 | position p1,p2; |
18 | @@ | 18 | @@ |
@@ -39,7 +39,7 @@ read_lock_irqsave@p2(lock2,flags) | |||
39 | write_lock_irqsave@p2(lock2,flags) | 39 | write_lock_irqsave@p2(lock2,flags) |
40 | ) | 40 | ) |
41 | 41 | ||
42 | @d exists@ | 42 | @d@ |
43 | expression f <= r.flags; | 43 | expression f <= r.flags; |
44 | expression lock1,lock2,flags; | 44 | expression lock1,lock2,flags; |
45 | position r.p1, r.p2; | 45 | position r.p1, r.p2; |
@@ -76,5 +76,5 @@ p1 << r.p1; | |||
76 | p2 << r.p2; | 76 | p2 << r.p2; |
77 | @@ | 77 | @@ |
78 | 78 | ||
79 | msg="ERROR: nested lock+irqsave that reuses flags from line %s." % (p1[0].line) | 79 | msg="ERROR: nested lock+irqsave that reuses flags from %s." % (p1[0].line) |
80 | coccilib.report.print_report(p2[0], msg) | 80 | coccilib.report.print_report(p2[0], msg) |
diff --git a/scripts/coccinelle/locks/mini_lock.cocci b/scripts/coccinelle/locks/mini_lock.cocci index 3267d7410bd..7641a292543 100644 --- a/scripts/coccinelle/locks/mini_lock.cocci +++ b/scripts/coccinelle/locks/mini_lock.cocci | |||
@@ -6,14 +6,13 @@ | |||
6 | /// function call that releases the lock. | 6 | /// function call that releases the lock. |
7 | /// | 7 | /// |
8 | // Confidence: Moderate | 8 | // Confidence: Moderate |
9 | // Copyright: (C) 2010-2012 Nicolas Palix. GPLv2. | 9 | // Copyright: (C) 2010 Nicolas Palix, DIKU. GPLv2. |
10 | // Copyright: (C) 2010-2012 Julia Lawall, INRIA/LIP6. GPLv2. | 10 | // Copyright: (C) 2010 Julia Lawall, DIKU. GPLv2. |
11 | // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6. GPLv2. | 11 | // Copyright: (C) 2010 Gilles Muller, INRIA/LiP6. GPLv2. |
12 | // URL: http://coccinelle.lip6.fr/ | 12 | // URL: http://coccinelle.lip6.fr/ |
13 | // Comments: | 13 | // Comments: |
14 | // Options: -no_includes -include_headers | 14 | // Options: -no_includes -include_headers |
15 | 15 | ||
16 | virtual context | ||
17 | virtual org | 16 | virtual org |
18 | virtual report | 17 | virtual report |
19 | 18 | ||
@@ -58,7 +57,7 @@ position r; | |||
58 | 57 | ||
59 | for(...;...;...) { <+... return@r ...; ...+> } | 58 | for(...;...;...) { <+... return@r ...; ...+> } |
60 | 59 | ||
61 | @err exists@ | 60 | @err@ |
62 | expression E1; | 61 | expression E1; |
63 | position prelocked.p; | 62 | position prelocked.p; |
64 | position up != prelocked.p1; | 63 | position up != prelocked.p1; |
@@ -66,14 +65,14 @@ position r!=looped.r; | |||
66 | identifier lock,unlock; | 65 | identifier lock,unlock; |
67 | @@ | 66 | @@ |
68 | 67 | ||
69 | *lock(E1@p,...); | 68 | lock(E1@p,...); |
70 | <+... when != E1 | 69 | <+... when != E1 |
71 | if (...) { | 70 | if (...) { |
72 | ... when != E1 | 71 | ... when != E1 |
73 | * return@r ...; | 72 | return@r ...; |
74 | } | 73 | } |
75 | ...+> | 74 | ...+> |
76 | *unlock@up(E1,...); | 75 | unlock@up(E1,...); |
77 | 76 | ||
78 | @script:python depends on org@ | 77 | @script:python depends on org@ |
79 | p << prelocked.p1; | 78 | p << prelocked.p1; |
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 | - } | ||
diff --git a/scripts/coccinelle/null/badzero.cocci b/scripts/coccinelle/null/badzero.cocci deleted file mode 100644 index d79baf7220e..00000000000 --- a/scripts/coccinelle/null/badzero.cocci +++ /dev/null | |||
@@ -1,237 +0,0 @@ | |||
1 | /// Compare pointer-typed values to NULL rather than 0 | ||
2 | /// | ||
3 | //# This makes an effort to choose between !x and x == NULL. !x is used | ||
4 | //# if it has previously been used with the function used to initialize x. | ||
5 | //# This relies on type information. More type information can be obtained | ||
6 | //# using the option -all_includes and the option -I to specify an | ||
7 | //# include path. | ||
8 | // | ||
9 | // Confidence: High | ||
10 | // Copyright: (C) 2012 Julia Lawall, INRIA/LIP6. GPLv2. | ||
11 | // Copyright: (C) 2012 Gilles Muller, INRIA/LiP6. GPLv2. | ||
12 | // URL: http://coccinelle.lip6.fr/ | ||
13 | // Comments: | ||
14 | // Options: | ||
15 | |||
16 | virtual patch | ||
17 | virtual context | ||
18 | virtual org | ||
19 | virtual report | ||
20 | |||
21 | @initialize:ocaml@ | ||
22 | let negtable = Hashtbl.create 101 | ||
23 | |||
24 | @depends on patch@ | ||
25 | expression *E; | ||
26 | identifier f; | ||
27 | @@ | ||
28 | |||
29 | ( | ||
30 | (E = f(...)) == | ||
31 | - 0 | ||
32 | + NULL | ||
33 | | | ||
34 | (E = f(...)) != | ||
35 | - 0 | ||
36 | + NULL | ||
37 | | | ||
38 | - 0 | ||
39 | + NULL | ||
40 | == (E = f(...)) | ||
41 | | | ||
42 | - 0 | ||
43 | + NULL | ||
44 | != (E = f(...)) | ||
45 | ) | ||
46 | |||
47 | |||
48 | @t1 depends on !patch@ | ||
49 | expression *E; | ||
50 | identifier f; | ||
51 | position p; | ||
52 | @@ | ||
53 | |||
54 | ( | ||
55 | (E = f(...)) == | ||
56 | * 0@p | ||
57 | | | ||
58 | (E = f(...)) != | ||
59 | * 0@p | ||
60 | | | ||
61 | * 0@p | ||
62 | == (E = f(...)) | ||
63 | | | ||
64 | * 0@p | ||
65 | != (E = f(...)) | ||
66 | ) | ||
67 | |||
68 | @script:python depends on org@ | ||
69 | p << t1.p; | ||
70 | @@ | ||
71 | |||
72 | coccilib.org.print_todo(p[0], "WARNING comparing pointer to 0") | ||
73 | |||
74 | @script:python depends on report@ | ||
75 | p << t1.p; | ||
76 | @@ | ||
77 | |||
78 | coccilib.report.print_report(p[0], "WARNING comparing pointer to 0") | ||
79 | |||
80 | // Tests of returned values | ||
81 | |||
82 | @s@ | ||
83 | identifier f; | ||
84 | expression E,E1; | ||
85 | @@ | ||
86 | |||
87 | E = f(...) | ||
88 | ... when != E = E1 | ||
89 | !E | ||
90 | |||
91 | @script:ocaml depends on s@ | ||
92 | f << s.f; | ||
93 | @@ | ||
94 | |||
95 | try let _ = Hashtbl.find negtable f in () | ||
96 | with Not_found -> Hashtbl.add negtable f () | ||
97 | |||
98 | @ r disable is_zero,isnt_zero exists @ | ||
99 | expression *E; | ||
100 | identifier f; | ||
101 | @@ | ||
102 | |||
103 | E = f(...) | ||
104 | ... | ||
105 | (E == 0 | ||
106 | |E != 0 | ||
107 | |0 == E | ||
108 | |0 != E | ||
109 | ) | ||
110 | |||
111 | @script:ocaml@ | ||
112 | f << r.f; | ||
113 | @@ | ||
114 | |||
115 | try let _ = Hashtbl.find negtable f in () | ||
116 | with Not_found -> include_match false | ||
117 | |||
118 | // This rule may lead to inconsistent path problems, if E is defined in two | ||
119 | // places | ||
120 | @ depends on patch disable is_zero,isnt_zero @ | ||
121 | expression *E; | ||
122 | expression E1; | ||
123 | identifier r.f; | ||
124 | @@ | ||
125 | |||
126 | E = f(...) | ||
127 | <... | ||
128 | ( | ||
129 | - E == 0 | ||
130 | + !E | ||
131 | | | ||
132 | - E != 0 | ||
133 | + E | ||
134 | | | ||
135 | - 0 == E | ||
136 | + !E | ||
137 | | | ||
138 | - 0 != E | ||
139 | + E | ||
140 | ) | ||
141 | ...> | ||
142 | ?E = E1 | ||
143 | |||
144 | @t2 depends on !patch disable is_zero,isnt_zero @ | ||
145 | expression *E; | ||
146 | expression E1; | ||
147 | identifier r.f; | ||
148 | position p1; | ||
149 | position p2; | ||
150 | @@ | ||
151 | |||
152 | E = f(...) | ||
153 | <... | ||
154 | ( | ||
155 | * E == 0@p1 | ||
156 | | | ||
157 | * E != 0@p2 | ||
158 | | | ||
159 | * 0@p1 == E | ||
160 | | | ||
161 | * 0@p1 != E | ||
162 | ) | ||
163 | ...> | ||
164 | ?E = E1 | ||
165 | |||
166 | @script:python depends on org@ | ||
167 | p << t2.p1; | ||
168 | @@ | ||
169 | |||
170 | coccilib.org.print_todo(p[0], "WARNING comparing pointer to 0, suggest !E") | ||
171 | |||
172 | @script:python depends on org@ | ||
173 | p << t2.p2; | ||
174 | @@ | ||
175 | |||
176 | coccilib.org.print_todo(p[0], "WARNING comparing pointer to 0") | ||
177 | |||
178 | @script:python depends on report@ | ||
179 | p << t2.p1; | ||
180 | @@ | ||
181 | |||
182 | coccilib.report.print_report(p[0], "WARNING comparing pointer to 0, suggest !E") | ||
183 | |||
184 | @script:python depends on report@ | ||
185 | p << t2.p2; | ||
186 | @@ | ||
187 | |||
188 | coccilib.report.print_report(p[0], "WARNING comparing pointer to 0") | ||
189 | |||
190 | @ depends on patch disable is_zero,isnt_zero @ | ||
191 | expression *E; | ||
192 | @@ | ||
193 | |||
194 | ( | ||
195 | E == | ||
196 | - 0 | ||
197 | + NULL | ||
198 | | | ||
199 | E != | ||
200 | - 0 | ||
201 | + NULL | ||
202 | | | ||
203 | - 0 | ||
204 | + NULL | ||
205 | == E | ||
206 | | | ||
207 | - 0 | ||
208 | + NULL | ||
209 | != E | ||
210 | ) | ||
211 | |||
212 | @ t3 depends on !patch disable is_zero,isnt_zero @ | ||
213 | expression *E; | ||
214 | position p; | ||
215 | @@ | ||
216 | |||
217 | ( | ||
218 | * E == 0@p | ||
219 | | | ||
220 | * E != 0@p | ||
221 | | | ||
222 | * 0@p == E | ||
223 | | | ||
224 | * 0@p != E | ||
225 | ) | ||
226 | |||
227 | @script:python depends on org@ | ||
228 | p << t3.p; | ||
229 | @@ | ||
230 | |||
231 | coccilib.org.print_todo(p[0], "WARNING comparing pointer to 0") | ||
232 | |||
233 | @script:python depends on report@ | ||
234 | p << t3.p; | ||
235 | @@ | ||
236 | |||
237 | coccilib.report.print_report(p[0], "WARNING comparing pointer to 0") | ||
diff --git a/scripts/coccinelle/null/eno.cocci b/scripts/coccinelle/null/eno.cocci index ed961a1f7d1..4c9c52b9c41 100644 --- a/scripts/coccinelle/null/eno.cocci +++ b/scripts/coccinelle/null/eno.cocci | |||
@@ -1,19 +1,16 @@ | |||
1 | /// The various basic memory allocation functions don't return ERR_PTR | 1 | /// The various basic memory allocation functions don't return ERR_PTR |
2 | /// | 2 | /// |
3 | // Confidence: High | 3 | // Confidence: High |
4 | // Copyright: (C) 2010-2012 Nicolas Palix. GPLv2. | 4 | // Copyright: (C) 2010 Nicolas Palix, DIKU. GPLv2. |
5 | // Copyright: (C) 2010-2012 Julia Lawall, INRIA/LIP6. GPLv2. | 5 | // Copyright: (C) 2010 Julia Lawall, DIKU. GPLv2. |
6 | // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6. GPLv2. | 6 | // Copyright: (C) 2010 Gilles Muller, INRIA/LiP6. GPLv2. |
7 | // URL: http://coccinelle.lip6.fr/ | 7 | // URL: http://coccinelle.lip6.fr/ |
8 | // Comments: | 8 | // Comments: |
9 | // Options: -no_includes -include_headers | 9 | // Options: -no_includes -include_headers |
10 | 10 | ||
11 | virtual patch | 11 | virtual patch |
12 | virtual context | ||
13 | virtual org | ||
14 | virtual report | ||
15 | 12 | ||
16 | @depends on patch@ | 13 | @@ |
17 | expression x,E; | 14 | expression x,E; |
18 | @@ | 15 | @@ |
19 | 16 | ||
@@ -21,28 +18,3 @@ x = \(kmalloc\|kzalloc\|kcalloc\|kmem_cache_alloc\|kmem_cache_zalloc\|kmem_cache | |||
21 | ... when != x = E | 18 | ... when != x = E |
22 | - IS_ERR(x) | 19 | - IS_ERR(x) |
23 | + !x | 20 | + !x |
24 | |||
25 | @r depends on !patch exists@ | ||
26 | expression x,E; | ||
27 | position p1,p2; | ||
28 | @@ | ||
29 | |||
30 | *x = \(kmalloc@p1\|kzalloc@p1\|kcalloc@p1\|kmem_cache_alloc@p1\|kmem_cache_zalloc@p1\|kmem_cache_alloc_node@p1\|kmalloc_node@p1\|kzalloc_node@p1\)(...) | ||
31 | ... when != x = E | ||
32 | * IS_ERR@p2(x) | ||
33 | |||
34 | @script:python depends on org@ | ||
35 | p1 << r.p1; | ||
36 | p2 << r.p2; | ||
37 | @@ | ||
38 | |||
39 | cocci.print_main("alloc call",p1) | ||
40 | cocci.print_secs("IS_ERR that should be NULL tests",p2) | ||
41 | |||
42 | @script:python depends on report@ | ||
43 | p1 << r.p1; | ||
44 | p2 << r.p2; | ||
45 | @@ | ||
46 | |||
47 | msg = "ERROR: allocation function on line %s returns NULL not ERR_PTR on failure" % (p1[0].line) | ||
48 | coccilib.report.print_report(p2[0], msg) | ||
diff --git a/scripts/coccinelle/tests/odd_ptr_err.cocci b/scripts/coccinelle/tests/odd_ptr_err.cocci deleted file mode 100644 index e8dd8a6b28a..00000000000 --- a/scripts/coccinelle/tests/odd_ptr_err.cocci +++ /dev/null | |||
@@ -1,65 +0,0 @@ | |||
1 | /// PTR_ERR should access the value just tested by IS_ERR | ||
2 | //# There can be false positives in the patch case, where it is the call | ||
3 | //# IS_ERR that is wrong. | ||
4 | /// | ||
5 | // Confidence: High | ||
6 | // Copyright: (C) 2012 Julia Lawall, INRIA. GPLv2. | ||
7 | // Copyright: (C) 2012 Gilles Muller, INRIA. GPLv2. | ||
8 | // URL: http://coccinelle.lip6.fr/ | ||
9 | // Comments: | ||
10 | // Options: -no_includes -include_headers | ||
11 | |||
12 | virtual patch | ||
13 | virtual context | ||
14 | virtual org | ||
15 | virtual report | ||
16 | |||
17 | @depends on patch@ | ||
18 | expression e,e1; | ||
19 | @@ | ||
20 | |||
21 | ( | ||
22 | if (IS_ERR(e)) { ... PTR_ERR(e) ... } | ||
23 | | | ||
24 | if (IS_ERR(e=e1)) { ... PTR_ERR(e) ... } | ||
25 | | | ||
26 | if (IS_ERR(e)) | ||
27 | { ... | ||
28 | PTR_ERR( | ||
29 | - e1 | ||
30 | + e | ||
31 | ) | ||
32 | ... } | ||
33 | ) | ||
34 | |||
35 | @r depends on !patch@ | ||
36 | expression e,e1; | ||
37 | position p1,p2; | ||
38 | @@ | ||
39 | |||
40 | ( | ||
41 | if (IS_ERR(e)) { ... PTR_ERR(e) ... } | ||
42 | | | ||
43 | if (IS_ERR(e=e1)) { ... PTR_ERR(e) ... } | ||
44 | | | ||
45 | *if (IS_ERR@p1(e)) | ||
46 | { ... | ||
47 | * PTR_ERR@p2(e1) | ||
48 | ... } | ||
49 | ) | ||
50 | |||
51 | @script:python depends on org@ | ||
52 | p1 << r.p1; | ||
53 | p2 << r.p2; | ||
54 | @@ | ||
55 | |||
56 | cocci.print_main("inconsistent IS_ERR and PTR_ERR",p1) | ||
57 | cocci.print_secs("PTR_ERR",p2) | ||
58 | |||
59 | @script:python depends on report@ | ||
60 | p1 << r.p1; | ||
61 | p2 << r.p2; | ||
62 | @@ | ||
63 | |||
64 | msg = "inconsistent IS_ERR and PTR_ERR, PTR_ERR on line %s" % (p2[0].line) | ||
65 | coccilib.report.print_report(p1[0],msg) | ||