Commit a1087ef6abedf0bfd60e5e3fddf33192cb2c1325

Authored by Julia Lawall
Committed by Michal Marek
1 parent 0a18a9386c

scripts/coccinelle: update for compatability with Coccinelle 0.2.4

For doubleinit.cocci, Coccinelle 0.2.4 requires a comma after ... in a
field list.  Coccinelle also now behaves gracefully when a definition is
provided for a virtual that doesn't exist, so there is no need for the
semantic patch code to check for this case.

Updated the documentation to reflect the fact that the best results will
now be obtained with Coccinelle version 0.2.4 or later.

Signed-off-by: Julia Lawall <julia@diku.dk>

Showing 3 changed files with 21 additions and 28 deletions Side-by-side Diff

Documentation/coccinelle.txt
... ... @@ -36,6 +36,10 @@
36 36  
37 37 sudo make install
38 38  
  39 +The semantic patches in the kernel will work best with Coccinelle version
  40 +0.2.4 or later. Using earlier versions may incur some parse errors in the
  41 +semantic patch code, but any results that are obtained should still be
  42 +correct.
39 43  
40 44 Using Coccinelle on the Linux kernel
41 45 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
scripts/coccinelle/misc/doubleinit.cocci
... ... @@ -7,7 +7,7 @@
7 7 // Copyright: (C) 2010 Julia Lawall, DIKU. GPLv2.
8 8 // Copyright: (C) 2010 Gilles Muller, INRIA/LiP6. GPLv2.
9 9 // URL: http://coccinelle.lip6.fr/
10   -// Comments:
  10 +// Comments: requires at least Coccinelle 0.2.4, lex or parse error otherwise
11 11 // Options: -no_includes -include_headers
12 12  
13 13 virtual org
... ... @@ -19,7 +19,7 @@
19 19 expression E;
20 20 @@
21 21  
22   -struct I s =@p0 { ... .fld@p = E, ...};
  22 +struct I s =@p0 { ..., .fld@p = E, ...};
23 23  
24 24 @s@
25 25 identifier I, s, r.fld;
... ... @@ -27,7 +27,7 @@
27 27 expression E;
28 28 @@
29 29  
30   -struct I s =@p0 { ... .fld@p = E, ...};
  30 +struct I s =@p0 { ..., .fld@p = E, ...};
31 31  
32 32 @script:python depends on org@
33 33 p0 << r.p0;
scripts/coccinelle/null/deref_null.cocci
... ... @@ -11,21 +11,10 @@
11 11 // Options:
12 12  
13 13 virtual context
14   -virtual patch
15 14 virtual org
16 15 virtual report
17 16  
18   -@initialize:python depends on !context && patch && !org && !report@
19   -
20   -import sys
21   -print >> sys.stderr, "This semantic patch does not support the 'patch' mode."
22   -
23   -@depends on patch@
24   -@@
25   -
26   -this_rule_should_never_matches();
27   -
28   -@ifm depends on !patch@
  17 +@ifm@
29 18 expression *E;
30 19 statement S1,S2;
31 20 position p1;
... ... @@ -35,7 +24,7 @@
35 24  
36 25 // The following two rules are separate, because both can match a single
37 26 // expression in different ways
38   -@pr1 depends on !patch expression@
  27 +@pr1 expression@
39 28 expression *ifm.E;
40 29 identifier f;
41 30 position p1;
... ... @@ -43,7 +32,7 @@
43 32  
44 33 (E != NULL && ...) ? <+...E->f@p1...+> : ...
45 34  
46   -@pr2 depends on !patch expression@
  35 +@pr2 expression@
47 36 expression *ifm.E;
48 37 identifier f;
49 38 position p2;
... ... @@ -59,7 +48,7 @@
59 48  
60 49 // For org and report modes
61 50  
62   -@r depends on !context && !patch && (org || report) exists@
  51 +@r depends on !context && (org || report) exists@
63 52 expression subE <= ifm.E;
64 53 expression *ifm.E;
65 54 expression E1,E2;
... ... @@ -99,7 +88,7 @@
99 88 }
100 89 else S3
101 90  
102   -@script:python depends on !context && !patch && !org && report@
  91 +@script:python depends on !context && !org && report@
103 92 p << r.p;
104 93 p1 << ifm.p1;
105 94 x << ifm.E;
... ... @@ -109,7 +98,7 @@
109 98 coccilib.report.print_report(p[0], msg)
110 99 cocci.include_match(False)
111 100  
112   -@script:python depends on !context && !patch && org && !report@
  101 +@script:python depends on !context && org && !report@
113 102 p << r.p;
114 103 p1 << ifm.p1;
115 104 x << ifm.E;
... ... @@ -120,7 +109,7 @@
120 109 cocci.print_main(msg_safe,p)
121 110 cocci.include_match(False)
122 111  
123   -@s depends on !context && !patch && (org || report) exists@
  112 +@s depends on !context && (org || report) exists@
124 113 expression subE <= ifm.E;
125 114 expression *ifm.E;
126 115 expression E1,E2;
... ... @@ -159,7 +148,7 @@
159 148 }
160 149 else S3
161 150  
162   -@script:python depends on !context && !patch && !org && report@
  151 +@script:python depends on !context && !org && report@
163 152 p << s.p;
164 153 p1 << ifm.p1;
165 154 x << ifm.E;
... ... @@ -168,7 +157,7 @@
168 157 msg="ERROR: %s is NULL but dereferenced." % (x)
169 158 coccilib.report.print_report(p[0], msg)
170 159  
171   -@script:python depends on !context && !patch && org && !report@
  160 +@script:python depends on !context && org && !report@
172 161 p << s.p;
173 162 p1 << ifm.p1;
174 163 x << ifm.E;
... ... @@ -180,7 +169,7 @@
180 169  
181 170 // For context mode
182 171  
183   -@depends on context && !patch && !org && !report exists@
  172 +@depends on context && !org && !report exists@
184 173 expression subE <= ifm.E;
185 174 expression *ifm.E;
186 175 expression E1,E2;
... ... @@ -223,7 +212,7 @@
223 212 // The following three rules are duplicates of ifm, pr1 and pr2 respectively.
224 213 // It is need because the previous rule as already made a "change".
225 214  
226   -@ifm1 depends on !patch@
  215 +@ifm1@
227 216 expression *E;
228 217 statement S1,S2;
229 218 position p1;
... ... @@ -231,7 +220,7 @@
231 220  
232 221 if@p1 ((E == NULL && ...) || ...) S1 else S2
233 222  
234   -@pr11 depends on !patch expression@
  223 +@pr11 expression@
235 224 expression *ifm1.E;
236 225 identifier f;
237 226 position p1;
... ... @@ -239,7 +228,7 @@
239 228  
240 229 (E != NULL && ...) ? <+...E->f@p1...+> : ...
241 230  
242   -@pr12 depends on !patch expression@
  231 +@pr12 expression@
243 232 expression *ifm1.E;
244 233 identifier f;
245 234 position p2;
... ... @@ -253,7 +242,7 @@
253 242 sizeof(<+...E->f@p2...+>)
254 243 )
255 244  
256   -@depends on context && !patch && !org && !report exists@
  245 +@depends on context && !org && !report exists@
257 246 expression subE <= ifm1.E;
258 247 expression *ifm1.E;
259 248 expression E1,E2;