diff options
author | Michal Marek <mmarek@suse.cz> | 2010-06-11 18:01:31 -0400 |
---|---|---|
committer | Michal Marek <mmarek@suse.cz> | 2010-06-11 18:01:31 -0400 |
commit | 6ff21517c001f38b02393ad9dc92decbaee209fa (patch) | |
tree | 7cd980dd3d869613669847ccda444459f6fdf0e4 /scripts/coccicheck | |
parent | b396aa03084b51f6822052a8070703287f198360 (diff) | |
parent | 82c4340b0a3ccf090ef38fa111363018cf0594c8 (diff) |
Merge branch 'kbuild/coccinelle' into kbuild/misc
Diffstat (limited to 'scripts/coccicheck')
-rwxr-xr-x | scripts/coccicheck | 54 |
1 files changed, 54 insertions, 0 deletions
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 | ||