diff options
Diffstat (limited to 'Documentation/coccinelle.txt')
-rw-r--r-- | Documentation/coccinelle.txt | 50 |
1 files changed, 39 insertions, 11 deletions
diff --git a/Documentation/coccinelle.txt b/Documentation/coccinelle.txt index cd2b02837066..4a276ea7001c 100644 --- a/Documentation/coccinelle.txt +++ b/Documentation/coccinelle.txt | |||
@@ -24,6 +24,9 @@ of many distributions, e.g. : | |||
24 | You can get the latest version released from the Coccinelle homepage at | 24 | You can get the latest version released from the Coccinelle homepage at |
25 | http://coccinelle.lip6.fr/ | 25 | http://coccinelle.lip6.fr/ |
26 | 26 | ||
27 | Information and tips about Coccinelle are also provided on the wiki | ||
28 | pages at http://cocci.ekstranet.diku.dk/wiki/doku.php | ||
29 | |||
27 | Once you have it, run the following command: | 30 | Once you have it, run the following command: |
28 | 31 | ||
29 | ./configure | 32 | ./configure |
@@ -41,20 +44,22 @@ A Coccinelle-specific target is defined in the top level | |||
41 | Makefile. This target is named 'coccicheck' and calls the 'coccicheck' | 44 | Makefile. This target is named 'coccicheck' and calls the 'coccicheck' |
42 | front-end in the 'scripts' directory. | 45 | front-end in the 'scripts' directory. |
43 | 46 | ||
44 | Four modes are defined: report, patch, context, and org. The mode to | 47 | Four modes are defined: patch, report, context, and org. The mode to |
45 | use is specified by setting the MODE variable with 'MODE=<mode>'. | 48 | use is specified by setting the MODE variable with 'MODE=<mode>'. |
46 | 49 | ||
50 | 'patch' proposes a fix, when possible. | ||
51 | |||
47 | 'report' generates a list in the following format: | 52 | 'report' generates a list in the following format: |
48 | file:line:column-column: message | 53 | file:line:column-column: message |
49 | 54 | ||
50 | 'patch' proposes a fix, when possible. | ||
51 | |||
52 | 'context' highlights lines of interest and their context in a | 55 | 'context' highlights lines of interest and their context in a |
53 | diff-like style.Lines of interest are indicated with '-'. | 56 | diff-like style.Lines of interest are indicated with '-'. |
54 | 57 | ||
55 | 'org' generates a report in the Org mode format of Emacs. | 58 | 'org' generates a report in the Org mode format of Emacs. |
56 | 59 | ||
57 | Note that not all semantic patches implement all modes. | 60 | Note that not all semantic patches implement all modes. For easy use |
61 | of Coccinelle, the default mode is "chain" which tries the previous | ||
62 | modes in the order above until one succeeds. | ||
58 | 63 | ||
59 | To make a report for every semantic patch, run the following command: | 64 | To make a report for every semantic patch, run the following command: |
60 | 65 | ||
@@ -68,9 +73,9 @@ To produce patches, run: | |||
68 | 73 | ||
69 | 74 | ||
70 | The coccicheck target applies every semantic patch available in the | 75 | The coccicheck target applies every semantic patch available in the |
71 | subdirectories of 'scripts/coccinelle' to the entire Linux kernel. | 76 | sub-directories of 'scripts/coccinelle' to the entire Linux kernel. |
72 | 77 | ||
73 | For each semantic patch, a changelog message is proposed. It gives a | 78 | For each semantic patch, a commit message is proposed. It gives a |
74 | description of the problem being checked by the semantic patch, and | 79 | description of the problem being checked by the semantic patch, and |
75 | includes a reference to Coccinelle. | 80 | includes a reference to Coccinelle. |
76 | 81 | ||
@@ -93,12 +98,35 @@ or | |||
93 | make coccicheck COCCI=<my_SP.cocci> MODE=report | 98 | make coccicheck COCCI=<my_SP.cocci> MODE=report |
94 | 99 | ||
95 | 100 | ||
101 | Using Coccinelle on (modified) files | ||
102 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
103 | |||
104 | To apply Coccinelle on a file basis, instead of a directory basis, the | ||
105 | following command may be used: | ||
106 | |||
107 | make C=1 CHECK="scripts/coccicheck" | ||
108 | |||
109 | To check only newly edited code, use the value 2 for the C flag, i.e. | ||
110 | |||
111 | make C=2 CHECK="scripts/coccicheck" | ||
112 | |||
113 | This runs every semantic patch in scripts/coccinelle by default. The | ||
114 | COCCI variable may additionally be used to only apply a single | ||
115 | semantic patch as shown in the previous section. | ||
116 | |||
117 | The "chain" mode is the default. You can select another one with the | ||
118 | MODE variable explained above. | ||
119 | |||
120 | In this mode, there is no information about semantic patches | ||
121 | displayed, and no commit message proposed. | ||
122 | |||
123 | |||
96 | Proposing new semantic patches | 124 | Proposing new semantic patches |
97 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 125 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
98 | 126 | ||
99 | New semantic patches can be proposed and submitted by kernel | 127 | New semantic patches can be proposed and submitted by kernel |
100 | developers. For sake of clarity, they should be organized in the | 128 | developers. For sake of clarity, they should be organized in the |
101 | subdirectories of 'scripts/coccinelle/'. | 129 | sub-directories of 'scripts/coccinelle/'. |
102 | 130 | ||
103 | 131 | ||
104 | Detailed description of the 'report' mode | 132 | Detailed description of the 'report' mode |
@@ -111,7 +139,7 @@ Example: | |||
111 | 139 | ||
112 | Running | 140 | Running |
113 | 141 | ||
114 | make coccicheck MODE=report COCCI=scripts/coccinelle/err_cast.cocci | 142 | make coccicheck MODE=report COCCI=scripts/coccinelle/api/err_cast.cocci |
115 | 143 | ||
116 | will execute the following part of the SmPL script. | 144 | will execute the following part of the SmPL script. |
117 | 145 | ||
@@ -149,7 +177,7 @@ identified. | |||
149 | Example: | 177 | Example: |
150 | 178 | ||
151 | Running | 179 | Running |
152 | make coccicheck MODE=patch COCCI=scripts/coccinelle/err_cast.cocci | 180 | make coccicheck MODE=patch COCCI=scripts/coccinelle/api/err_cast.cocci |
153 | 181 | ||
154 | will execute the following part of the SmPL script. | 182 | will execute the following part of the SmPL script. |
155 | 183 | ||
@@ -193,7 +221,7 @@ NOTE: The diff-like output generated is NOT an applicable patch. The | |||
193 | Example: | 221 | Example: |
194 | 222 | ||
195 | Running | 223 | Running |
196 | make coccicheck MODE=context COCCI=scripts/coccinelle/err_cast.cocci | 224 | make coccicheck MODE=context COCCI=scripts/coccinelle/api/err_cast.cocci |
197 | 225 | ||
198 | will execute the following part of the SmPL script. | 226 | will execute the following part of the SmPL script. |
199 | 227 | ||
@@ -228,7 +256,7 @@ diff -u -p /home/user/linux/crypto/ctr.c /tmp/nothing | |||
228 | Example: | 256 | Example: |
229 | 257 | ||
230 | Running | 258 | Running |
231 | make coccicheck MODE=org COCCI=scripts/coccinelle/err_cast.cocci | 259 | make coccicheck MODE=org COCCI=scripts/coccinelle/api/err_cast.cocci |
232 | 260 | ||
233 | will execute the following part of the SmPL script. | 261 | will execute the following part of the SmPL script. |
234 | 262 | ||