aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/coccinelle.txt
diff options
context:
space:
mode:
Diffstat (limited to 'Documentation/coccinelle.txt')
-rw-r--r--Documentation/coccinelle.txt50
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. :
24You can get the latest version released from the Coccinelle homepage at 24You can get the latest version released from the Coccinelle homepage at
25http://coccinelle.lip6.fr/ 25http://coccinelle.lip6.fr/
26 26
27Information and tips about Coccinelle are also provided on the wiki
28pages at http://cocci.ekstranet.diku.dk/wiki/doku.php
29
27Once you have it, run the following command: 30Once 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
41Makefile. This target is named 'coccicheck' and calls the 'coccicheck' 44Makefile. This target is named 'coccicheck' and calls the 'coccicheck'
42front-end in the 'scripts' directory. 45front-end in the 'scripts' directory.
43 46
44Four modes are defined: report, patch, context, and org. The mode to 47Four modes are defined: patch, report, context, and org. The mode to
45use is specified by setting the MODE variable with 'MODE=<mode>'. 48use 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
53diff-like style.Lines of interest are indicated with '-'. 56diff-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
57Note that not all semantic patches implement all modes. 60Note that not all semantic patches implement all modes. For easy use
61of Coccinelle, the default mode is "chain" which tries the previous
62modes in the order above until one succeeds.
58 63
59To make a report for every semantic patch, run the following command: 64To 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
70The coccicheck target applies every semantic patch available in the 75The coccicheck target applies every semantic patch available in the
71subdirectories of 'scripts/coccinelle' to the entire Linux kernel. 76sub-directories of 'scripts/coccinelle' to the entire Linux kernel.
72 77
73For each semantic patch, a changelog message is proposed. It gives a 78For each semantic patch, a commit message is proposed. It gives a
74description of the problem being checked by the semantic patch, and 79description of the problem being checked by the semantic patch, and
75includes a reference to Coccinelle. 80includes 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
104To apply Coccinelle on a file basis, instead of a directory basis, the
105following command may be used:
106
107 make C=1 CHECK="scripts/coccicheck"
108
109To check only newly edited code, use the value 2 for the C flag, i.e.
110
111 make C=2 CHECK="scripts/coccicheck"
112
113This runs every semantic patch in scripts/coccinelle by default. The
114COCCI variable may additionally be used to only apply a single
115semantic patch as shown in the previous section.
116
117The "chain" mode is the default. You can select another one with the
118MODE variable explained above.
119
120In this mode, there is no information about semantic patches
121displayed, and no commit message proposed.
122
123
96 Proposing new semantic patches 124 Proposing new semantic patches
97~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 125~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
98 126
99New semantic patches can be proposed and submitted by kernel 127New semantic patches can be proposed and submitted by kernel
100developers. For sake of clarity, they should be organized in the 128developers. For sake of clarity, they should be organized in the
101subdirectories of 'scripts/coccinelle/'. 129sub-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
112Running 140Running
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
116will execute the following part of the SmPL script. 144will execute the following part of the SmPL script.
117 145
@@ -149,7 +177,7 @@ identified.
149Example: 177Example:
150 178
151Running 179Running
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
154will execute the following part of the SmPL script. 182will 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
193Example: 221Example:
194 222
195Running 223Running
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
198will execute the following part of the SmPL script. 226will 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
228Example: 256Example:
229 257
230Running 258Running
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
233will execute the following part of the SmPL script. 261will execute the following part of the SmPL script.
234 262