diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-07-10 19:08:06 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-07-10 19:08:06 -0400 |
commit | ae9249493049fd41fa52fc0470251ee1efaabe74 (patch) | |
tree | cad8b206dda4caec111877a762f8f590702257de /scripts/coccicheck | |
parent | b202c0d5205662fd96f7151afa83f891f2f4d542 (diff) | |
parent | ec97946ed038f4b3faa587bc76152b198805b0c4 (diff) |
Merge branch 'misc' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild
Pull coccinelle updates from Michal Marek:
"The misc branch is reserved for Coccinelle this time:
- 'report' is the default mode
- MAINTAINERS update for Coccinelle
- documentation udate
- use new option format for spatch(1)
- J=<n> variable to mimic make -j for coccicheck
- check for missing pci_free_consistent() calls
There are some patches for rpm-pkg and deb-pkg waiting for the
3.12-rc1 merge window"
* 'misc' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild:
Coccinelle: Update information about the minimal version required
Coccinelle: Update the options used to the new option scheme
scripts: Coccinelle script for pci_free_consistent()
Coccinelle: Update the documentation
Coccinelle: Update section of MAINTAINERS
coccicheck: span checks across CPUs
scripts/coccinelle: check for field address argument to kfree
Coccinelle: Update the Coccinelle section of MAINTAINERS
Coccinelle: Make 'report' the default mode
Diffstat (limited to 'scripts/coccicheck')
-rwxr-xr-x | scripts/coccicheck | 76 |
1 files changed, 57 insertions, 19 deletions
diff --git a/scripts/coccicheck b/scripts/coccicheck index 06fcb3333247..bbf901afb606 100755 --- a/scripts/coccicheck +++ b/scripts/coccicheck | |||
@@ -1,17 +1,31 @@ | |||
1 | #!/bin/bash | 1 | #!/bin/bash |
2 | 2 | ||
3 | # | ||
4 | # This script requires at least spatch | ||
5 | # version 1.0.0-rc11. | ||
6 | # | ||
7 | |||
3 | SPATCH="`which ${SPATCH:=spatch}`" | 8 | SPATCH="`which ${SPATCH:=spatch}`" |
4 | 9 | ||
10 | trap kill_running SIGTERM SIGINT | ||
11 | declare -a SPATCH_PID | ||
12 | |||
5 | # The verbosity may be set by the environmental parameter V= | 13 | # The verbosity may be set by the environmental parameter V= |
6 | # as for example with 'make V=1 coccicheck' | 14 | # as for example with 'make V=1 coccicheck' |
7 | 15 | ||
8 | if [ -n "$V" -a "$V" != "0" ]; then | 16 | if [ -n "$V" -a "$V" != "0" ]; then |
9 | VERBOSE=1 | 17 | VERBOSE="$V" |
10 | else | 18 | else |
11 | VERBOSE=0 | 19 | VERBOSE=0 |
12 | fi | 20 | fi |
13 | 21 | ||
14 | FLAGS="$SPFLAGS -very_quiet" | 22 | if [ -z "$J" ]; then |
23 | NPROC=$(getconf _NPROCESSORS_ONLN) | ||
24 | else | ||
25 | NPROC="$J" | ||
26 | fi | ||
27 | |||
28 | FLAGS="$SPFLAGS --very-quiet" | ||
15 | 29 | ||
16 | # spatch only allows include directories with the syntax "-I include" | 30 | # spatch only allows include directories with the syntax "-I include" |
17 | # while gcc also allows "-Iinclude" and "-include include" | 31 | # while gcc also allows "-Iinclude" and "-include include" |
@@ -27,14 +41,14 @@ if [ "$C" = "1" -o "$C" = "2" ]; then | |||
27 | else | 41 | else |
28 | ONLINE=0 | 42 | ONLINE=0 |
29 | if [ "$KBUILD_EXTMOD" = "" ] ; then | 43 | if [ "$KBUILD_EXTMOD" = "" ] ; then |
30 | OPTIONS="-dir $srctree $COCCIINCLUDE" | 44 | OPTIONS="--dir $srctree $COCCIINCLUDE" |
31 | else | 45 | else |
32 | OPTIONS="-dir $KBUILD_EXTMOD $COCCIINCLUDE" | 46 | OPTIONS="--dir $KBUILD_EXTMOD $COCCIINCLUDE" |
33 | fi | 47 | fi |
34 | fi | 48 | fi |
35 | 49 | ||
36 | if [ "$KBUILD_EXTMOD" != "" ] ; then | 50 | if [ "$KBUILD_EXTMOD" != "" ] ; then |
37 | OPTIONS="-patch $srctree $OPTIONS" | 51 | OPTIONS="--patch $srctree $OPTIONS" |
38 | fi | 52 | fi |
39 | 53 | ||
40 | if [ ! -x "$SPATCH" ]; then | 54 | if [ ! -x "$SPATCH" ]; then |
@@ -44,13 +58,21 @@ fi | |||
44 | 58 | ||
45 | if [ "$MODE" = "" ] ; then | 59 | if [ "$MODE" = "" ] ; then |
46 | if [ "$ONLINE" = "0" ] ; then | 60 | if [ "$ONLINE" = "0" ] ; then |
47 | echo 'You have not explicitly specified the mode to use. Using default "chain" mode.' | 61 | echo 'You have not explicitly specified the mode to use. Using default "report" mode.' |
48 | echo 'All available modes will be tried (in that order): patch, report, context, org' | 62 | echo 'Available modes are the following: patch, report, context, org' |
49 | echo 'You can specify the mode with "make coccicheck MODE=<mode>"' | 63 | echo 'You can specify the mode with "make coccicheck MODE=<mode>"' |
64 | echo 'Note however that some modes are not implemented by some semantic patches.' | ||
65 | fi | ||
66 | MODE="report" | ||
67 | fi | ||
68 | |||
69 | if [ "$MODE" = "chain" ] ; then | ||
70 | if [ "$ONLINE" = "0" ] ; then | ||
71 | echo 'You have selected the "chain" mode.' | ||
72 | echo 'All available modes will be tried (in that order): patch, report, context, org' | ||
50 | fi | 73 | fi |
51 | MODE="chain" | ||
52 | elif [ "$MODE" = "report" -o "$MODE" = "org" ] ; then | 74 | elif [ "$MODE" = "report" -o "$MODE" = "org" ] ; then |
53 | FLAGS="$FLAGS -no_show_diff" | 75 | FLAGS="$FLAGS --no-show-diff" |
54 | fi | 76 | fi |
55 | 77 | ||
56 | if [ "$ONLINE" = "0" ] ; then | 78 | if [ "$ONLINE" = "0" ] ; then |
@@ -61,19 +83,35 @@ if [ "$ONLINE" = "0" ] ; then | |||
61 | fi | 83 | fi |
62 | 84 | ||
63 | run_cmd() { | 85 | run_cmd() { |
86 | local i | ||
64 | if [ $VERBOSE -ne 0 ] ; then | 87 | if [ $VERBOSE -ne 0 ] ; then |
65 | echo "Running: $@" | 88 | echo "Running ($NPROC in parallel): $@" |
66 | fi | 89 | fi |
67 | eval $@ | 90 | for i in $(seq 0 $(( NPROC - 1)) ); do |
91 | eval "$@ --max $NPROC --index $i &" | ||
92 | SPATCH_PID[$i]=$! | ||
93 | if [ $VERBOSE -eq 2 ] ; then | ||
94 | echo "${SPATCH_PID[$i]} running" | ||
95 | fi | ||
96 | done | ||
97 | wait | ||
68 | } | 98 | } |
69 | 99 | ||
100 | kill_running() { | ||
101 | for i in $(seq $(( NPROC - 1 )) ); do | ||
102 | if [ $VERBOSE -eq 2 ] ; then | ||
103 | echo "Killing ${SPATCH_PID[$i]}" | ||
104 | fi | ||
105 | kill ${SPATCH_PID[$i]} 2>/dev/null | ||
106 | done | ||
107 | } | ||
70 | 108 | ||
71 | coccinelle () { | 109 | coccinelle () { |
72 | COCCI="$1" | 110 | COCCI="$1" |
73 | 111 | ||
74 | OPT=`grep "Option" $COCCI | cut -d':' -f2` | 112 | OPT=`grep "Option" $COCCI | cut -d':' -f2` |
75 | 113 | ||
76 | # The option '-parse_cocci' can be used to syntactically check the SmPL files. | 114 | # The option '--parse-cocci' can be used to syntactically check the SmPL files. |
77 | # | 115 | # |
78 | # $SPATCH -D $MODE $FLAGS -parse_cocci $COCCI $OPT > /dev/null | 116 | # $SPATCH -D $MODE $FLAGS -parse_cocci $COCCI $OPT > /dev/null |
79 | 117 | ||
@@ -114,20 +152,20 @@ coccinelle () { | |||
114 | 152 | ||
115 | if [ "$MODE" = "chain" ] ; then | 153 | if [ "$MODE" = "chain" ] ; then |
116 | run_cmd $SPATCH -D patch \ | 154 | run_cmd $SPATCH -D patch \ |
117 | $FLAGS -sp_file $COCCI $OPT $OPTIONS || \ | 155 | $FLAGS --cocci-file $COCCI $OPT $OPTIONS || \ |
118 | run_cmd $SPATCH -D report \ | 156 | run_cmd $SPATCH -D report \ |
119 | $FLAGS -sp_file $COCCI $OPT $OPTIONS -no_show_diff || \ | 157 | $FLAGS --cocci-file $COCCI $OPT $OPTIONS --no-show-diff || \ |
120 | run_cmd $SPATCH -D context \ | 158 | run_cmd $SPATCH -D context \ |
121 | $FLAGS -sp_file $COCCI $OPT $OPTIONS || \ | 159 | $FLAGS --cocci-file $COCCI $OPT $OPTIONS || \ |
122 | run_cmd $SPATCH -D org \ | 160 | run_cmd $SPATCH -D org \ |
123 | $FLAGS -sp_file $COCCI $OPT $OPTIONS -no_show_diff || exit 1 | 161 | $FLAGS --cocci-file $COCCI $OPT $OPTIONS --no-show-diff || exit 1 |
124 | elif [ "$MODE" = "rep+ctxt" ] ; then | 162 | elif [ "$MODE" = "rep+ctxt" ] ; then |
125 | run_cmd $SPATCH -D report \ | 163 | run_cmd $SPATCH -D report \ |
126 | $FLAGS -sp_file $COCCI $OPT $OPTIONS -no_show_diff && \ | 164 | $FLAGS --cocci-file $COCCI $OPT $OPTIONS --no-show-diff && \ |
127 | run_cmd $SPATCH -D context \ | 165 | run_cmd $SPATCH -D context \ |
128 | $FLAGS -sp_file $COCCI $OPT $OPTIONS || exit 1 | 166 | $FLAGS --cocci-file $COCCI $OPT $OPTIONS || exit 1 |
129 | else | 167 | else |
130 | run_cmd $SPATCH -D $MODE $FLAGS -sp_file $COCCI $OPT $OPTIONS || exit 1 | 168 | run_cmd $SPATCH -D $MODE $FLAGS --cocci-file $COCCI $OPT $OPTIONS || exit 1 |
131 | fi | 169 | fi |
132 | 170 | ||
133 | } | 171 | } |