Root/
1 | #!/bin/sh |
2 | |
3 | SPATCH="`which ${SPATCH:=spatch}`" |
4 | |
5 | # The verbosity may be set by the environmental parameter V= |
6 | # as for example with 'make V=1 coccicheck' |
7 | |
8 | if [ -n "$V" -a "$V" != "0" ]; then |
9 | VERBOSE=1 |
10 | else |
11 | VERBOSE=0 |
12 | fi |
13 | |
14 | if [ "$C" = "1" -o "$C" = "2" ]; then |
15 | ONLINE=1 |
16 | |
17 | # This requires Coccinelle >= 0.2.3 |
18 | # FLAGS="-ignore_unknown_options -very_quiet" |
19 | # OPTIONS=$* |
20 | |
21 | # Workaround for Coccinelle < 0.2.3 |
22 | FLAGS="-I $srctree/include -very_quiet" |
23 | shift $(( $# - 1 )) |
24 | OPTIONS=$1 |
25 | else |
26 | ONLINE=0 |
27 | FLAGS="-very_quiet" |
28 | if [ "$KBUILD_EXTMOD" = "" ] ; then |
29 | OPTIONS="-dir $srctree" |
30 | else |
31 | OPTIONS="-dir $KBUILD_EXTMOD -patch $srctree -I $srctree/include -I $KBUILD_EXTMOD/include" |
32 | fi |
33 | fi |
34 | |
35 | if [ ! -x "$SPATCH" ]; then |
36 | echo 'spatch is part of the Coccinelle project and is available at http://coccinelle.lip6.fr/' |
37 | exit 1 |
38 | fi |
39 | |
40 | if [ "$MODE" = "" ] ; then |
41 | if [ "$ONLINE" = "0" ] ; then |
42 | echo 'You have not explicitly specified the mode to use. Using default "chain" mode.' |
43 | echo 'All available modes will be tried (in that order): patch, report, context, org' |
44 | echo 'You can specify the mode with "make coccicheck MODE=<mode>"' |
45 | fi |
46 | MODE="chain" |
47 | elif [ "$MODE" = "report" -o "$MODE" = "org" ] ; then |
48 | FLAGS="$FLAGS -no_show_diff" |
49 | fi |
50 | |
51 | if [ "$ONLINE" = "0" ] ; then |
52 | echo '' |
53 | echo 'Please check for false positives in the output before submitting a patch.' |
54 | echo 'When using "patch" mode, carefully review the patch before submitting it.' |
55 | echo '' |
56 | fi |
57 | |
58 | run_cmd() { |
59 | if [ $VERBOSE -ne 0 ] ; then |
60 | echo "Running: $@" |
61 | fi |
62 | eval $@ |
63 | } |
64 | |
65 | |
66 | coccinelle () { |
67 | COCCI="$1" |
68 | |
69 | OPT=`grep "Option" $COCCI | cut -d':' -f2` |
70 | |
71 | # The option '-parse_cocci' can be used to syntactically check the SmPL files. |
72 | # |
73 | # $SPATCH -D $MODE $FLAGS -parse_cocci $COCCI $OPT > /dev/null |
74 | |
75 | if [ $VERBOSE -ne 0 ] ; then |
76 | |
77 | FILE=`echo $COCCI | sed "s|$srctree/||"` |
78 | |
79 | echo "Processing `basename $COCCI`" |
80 | echo "with option(s) \"$OPT\"" |
81 | echo '' |
82 | echo 'Message example to submit a patch:' |
83 | |
84 | sed -ne 's|^///||p' $COCCI |
85 | |
86 | if [ "$MODE" = "patch" ] ; then |
87 | echo ' The semantic patch that makes this change is available' |
88 | elif [ "$MODE" = "report" ] ; then |
89 | echo ' The semantic patch that makes this report is available' |
90 | elif [ "$MODE" = "context" ] ; then |
91 | echo ' The semantic patch that spots this code is available' |
92 | elif [ "$MODE" = "org" ] ; then |
93 | echo ' The semantic patch that makes this Org report is available' |
94 | else |
95 | echo ' The semantic patch that makes this output is available' |
96 | fi |
97 | echo " in $FILE." |
98 | echo '' |
99 | echo ' More information about semantic patching is available at' |
100 | echo ' http://coccinelle.lip6.fr/' |
101 | echo '' |
102 | |
103 | if [ "`sed -ne 's|^//#||p' $COCCI`" ] ; then |
104 | echo 'Semantic patch information:' |
105 | sed -ne 's|^//#||p' $COCCI |
106 | echo '' |
107 | fi |
108 | fi |
109 | |
110 | if [ "$MODE" = "chain" ] ; then |
111 | run_cmd $SPATCH -D patch \ |
112 | $FLAGS -sp_file $COCCI $OPT $OPTIONS || \ |
113 | run_cmd $SPATCH -D report \ |
114 | $FLAGS -sp_file $COCCI $OPT $OPTIONS -no_show_diff || \ |
115 | run_cmd $SPATCH -D context \ |
116 | $FLAGS -sp_file $COCCI $OPT $OPTIONS || \ |
117 | run_cmd $SPATCH -D org \ |
118 | $FLAGS -sp_file $COCCI $OPT $OPTIONS -no_show_diff || exit 1 |
119 | elif [ "$MODE" = "rep+ctxt" ] ; then |
120 | run_cmd $SPATCH -D report \ |
121 | $FLAGS -sp_file $COCCI $OPT $OPTIONS -no_show_diff && \ |
122 | run_cmd $SPATCH -D context \ |
123 | $FLAGS -sp_file $COCCI $OPT $OPTIONS || exit 1 |
124 | else |
125 | run_cmd $SPATCH -D $MODE $FLAGS -sp_file $COCCI $OPT $OPTIONS || exit 1 |
126 | fi |
127 | |
128 | } |
129 | |
130 | if [ "$COCCI" = "" ] ; then |
131 | for f in `find $srctree/scripts/coccinelle/ -name '*.cocci' -type f | sort`; do |
132 | coccinelle $f |
133 | done |
134 | else |
135 | coccinelle $COCCI |
136 | fi |
137 |
Branches:
ben-wpan
ben-wpan-stefan
javiroman/ks7010
jz-2.6.34
jz-2.6.34-rc5
jz-2.6.34-rc6
jz-2.6.34-rc7
jz-2.6.35
jz-2.6.36
jz-2.6.37
jz-2.6.38
jz-2.6.39
jz-3.0
jz-3.1
jz-3.11
jz-3.12
jz-3.13
jz-3.15
jz-3.16
jz-3.18-dt
jz-3.2
jz-3.3
jz-3.4
jz-3.5
jz-3.6
jz-3.6-rc2-pwm
jz-3.9
jz-3.9-clk
jz-3.9-rc8
jz47xx
jz47xx-2.6.38
master
Tags:
od-2011-09-04
od-2011-09-18
v2.6.34-rc5
v2.6.34-rc6
v2.6.34-rc7
v3.9