diff options
author | Nicolas Palix <npalix@diku.dk> | 2010-06-06 11:15:01 -0400 |
---|---|---|
committer | Michal Marek <mmarek@suse.cz> | 2010-06-11 18:00:29 -0400 |
commit | 74425eee71eb44c9f370bd922f72282b69bb0eab (patch) | |
tree | 2ae2900a70a163653b1f734fd6eeb5d24a05e376 | |
parent | 64ffc9ff424c65adcffe7d590018cc75e2d5d42a (diff) |
Add a target to use the Coccinelle checker
A 'coccicheck' target is added. It can be called with four different
modes. Each one generates a different kind of output, i.e. context,
patch, org, report, according to the corresponding mode to be
activated.
The new target calls the 'coccicheck' front-end in the 'scripts'
directory with the MODE argument. Every SmPL file in the
subdirectories of 'scripts/coccinelle' is then given to the front-end
and applied to the entire source tree.
The four modes behave as follows:
'report' generates a list in the following format:
file:line:column-column: message
'patch' proposes a fix, when possible.
'context' highlights lines of interest and their context in a
diff-like style. Lines of interest are indicated with '-'.
'org' generates a report in the Org mode format of Emacs.
Signed-off-by: Nicolas Palix <npalix@diku.dk>
Signed-off-by: Julia Lawall <julia@diku.dk>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Acked-by: Joerg Roedel <joerg.roedel@amd.com>
Signed-off-by: Michal Marek <mmarek@suse.cz>
-rw-r--r-- | MAINTAINERS | 10 | ||||
-rw-r--r-- | Makefile | 10 | ||||
-rw-r--r-- | scripts/Makefile.help | 3 | ||||
-rwxr-xr-x | scripts/coccicheck | 54 |
4 files changed, 74 insertions, 3 deletions
diff --git a/MAINTAINERS b/MAINTAINERS index ce3601e5e3c8..0572b7ea5f9f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
@@ -1476,6 +1476,16 @@ M: Daniel Oliveira Nascimento <don@syst.com.br> | |||
1476 | S: Supported | 1476 | S: Supported |
1477 | F: drivers/platform/x86/classmate-laptop.c | 1477 | F: drivers/platform/x86/classmate-laptop.c |
1478 | 1478 | ||
1479 | COCCINELLE/Semantic Patches (SmPL) | ||
1480 | M: Julia Lawall <julia@diku.dk> | ||
1481 | M: Gilles Muller <Gilles.Muller@lip6.fr> | ||
1482 | M: Nicolas Palix <npalix@diku.dk> | ||
1483 | L: cocci@diku.dk (moderated for non-subscribers) | ||
1484 | W: http://coccinelle.lip6.fr/ | ||
1485 | S: Supported | ||
1486 | F: scripts/coccinelle/ | ||
1487 | F: scripts/coccicheck | ||
1488 | |||
1479 | CODA FILE SYSTEM | 1489 | CODA FILE SYSTEM |
1480 | M: Jan Harkes <jaharkes@cs.cmu.edu> | 1490 | M: Jan Harkes <jaharkes@cs.cmu.edu> |
1481 | M: coda@cs.cmu.edu | 1491 | M: coda@cs.cmu.edu |
@@ -412,7 +412,7 @@ endif | |||
412 | # of make so .config is not included in this case either (for *config). | 412 | # of make so .config is not included in this case either (for *config). |
413 | 413 | ||
414 | no-dot-config-targets := clean mrproper distclean \ | 414 | no-dot-config-targets := clean mrproper distclean \ |
415 | cscope TAGS tags help %docs check% \ | 415 | cscope TAGS tags help %docs check% coccicheck \ |
416 | include/linux/version.h headers_% \ | 416 | include/linux/version.h headers_% \ |
417 | kernelrelease kernelversion | 417 | kernelrelease kernelversion |
418 | 418 | ||
@@ -1279,8 +1279,9 @@ help: | |||
1279 | @echo ' includecheck - Check for duplicate included header files' | 1279 | @echo ' includecheck - Check for duplicate included header files' |
1280 | @echo ' export_report - List the usages of all exported symbols' | 1280 | @echo ' export_report - List the usages of all exported symbols' |
1281 | @echo ' headers_check - Sanity check on exported headers' | 1281 | @echo ' headers_check - Sanity check on exported headers' |
1282 | @echo ' headerdep - Detect inclusion cycles in headers'; \ | 1282 | @echo ' headerdep - Detect inclusion cycles in headers' |
1283 | echo '' | 1283 | @$(MAKE) -f $(srctree)/scripts/Makefile.help checker-help |
1284 | @echo '' | ||
1284 | @echo 'Kernel packaging:' | 1285 | @echo 'Kernel packaging:' |
1285 | @$(MAKE) $(build)=$(package-dir) help | 1286 | @$(MAKE) $(build)=$(package-dir) help |
1286 | @echo '' | 1287 | @echo '' |
@@ -1439,6 +1440,9 @@ versioncheck: | |||
1439 | -name '*.[hcS]' -type f -print | sort \ | 1440 | -name '*.[hcS]' -type f -print | sort \ |
1440 | | xargs $(PERL) -w $(srctree)/scripts/checkversion.pl | 1441 | | xargs $(PERL) -w $(srctree)/scripts/checkversion.pl |
1441 | 1442 | ||
1443 | coccicheck: | ||
1444 | $(Q)$(CONFIG_SHELL) $(srctree)/scripts/$@ | ||
1445 | |||
1442 | namespacecheck: | 1446 | namespacecheck: |
1443 | $(PERL) $(srctree)/scripts/namespace.pl | 1447 | $(PERL) $(srctree)/scripts/namespace.pl |
1444 | 1448 | ||
diff --git a/scripts/Makefile.help b/scripts/Makefile.help new file mode 100644 index 000000000000..d03608f5db04 --- /dev/null +++ b/scripts/Makefile.help | |||
@@ -0,0 +1,3 @@ | |||
1 | |||
2 | checker-help: | ||
3 | @echo ' coccicheck - Check with Coccinelle.' | ||
diff --git a/scripts/coccicheck b/scripts/coccicheck new file mode 100755 index 000000000000..037424b9ede5 --- /dev/null +++ b/scripts/coccicheck | |||
@@ -0,0 +1,54 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | SPATCH="`which ${SPATCH:=spatch}`" | ||
4 | |||
5 | if [ ! -x "$SPATCH" ]; then | ||
6 | echo 'spatch is part of the Coccinelle project and is available at http://coccinelle.lip6.fr/' | ||
7 | exit 1 | ||
8 | fi | ||
9 | |||
10 | if [ "$MODE" = "" ] ; then | ||
11 | echo 'You have not explicitly specify the mode to use. Fallback to "report".' | ||
12 | echo 'You can specify the mode with "make coccicheck MODE=<mode>"' | ||
13 | echo 'Available modes are: report, patch, context, org' | ||
14 | MODE="report" | ||
15 | fi | ||
16 | |||
17 | echo '' | ||
18 | echo 'Please check for false positives in the output before submitting a patch.' | ||
19 | echo 'When using "patch" mode, carefully review the patch before submitting it.' | ||
20 | echo '' | ||
21 | |||
22 | function coccinelle { | ||
23 | COCCI="$1" | ||
24 | DIR="$2" | ||
25 | |||
26 | OPT=`grep "Option" $COCCI | cut -d':' -f2` | ||
27 | FILE=`echo $COCCI | sed "s|$DIR/||"` | ||
28 | |||
29 | echo "Processing `basename $COCCI` with option(s) \"$OPT\"" | ||
30 | echo 'Message example to submit a patch:' | ||
31 | |||
32 | sed -e '/\/\/\//!d' -e 's|^///||' $COCCI | ||
33 | |||
34 | echo ' The semantic patch that makes this change is available' | ||
35 | echo " in $FILE." | ||
36 | echo '' | ||
37 | echo ' More information about semantic patching is available at' | ||
38 | echo ' http://coccinelle.lip6.fr/' | ||
39 | echo '' | ||
40 | |||
41 | # The option '-parse_cocci' can be used to syntaxically check the SmPL files. | ||
42 | # | ||
43 | # $SPATCH -D $MODE -very_quiet -parse_cocci $COCCI $OPT > /dev/null | ||
44 | |||
45 | $SPATCH -D $MODE -very_quiet -sp_file $COCCI $OPT -dir $DIR | ||
46 | } | ||
47 | |||
48 | if [ "$COCCI" = "" ] ; then | ||
49 | for f in `find $srctree/scripts/coccinelle/ -name '*.cocci' -type f | sort`; do | ||
50 | coccinelle $f $srctree; | ||
51 | done | ||
52 | else | ||
53 | coccinelle $COCCI $srctree | ||
54 | fi | ||