Blame view
scripts/coccicheck
2.94 KB
74425eee7 Add a target to u... |
1 2 3 |
#!/bin/sh SPATCH="`which ${SPATCH:=spatch}`" |
1e9dea2a6 Add support for t... |
4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
if [ "$C" = "1" -o "$C" = "2" ]; then ONLINE=1 # This requires Coccinelle >= 0.2.3 # FLAGS="-ignore_unknown_options -very_quiet" # OPTIONS=$* # Workaround for Coccinelle < 0.2.3 FLAGS="-I $srctree/include -very_quiet" shift $(( $# - 1 )) OPTIONS=$1 else ONLINE=0 FLAGS="-very_quiet" |
2c1160c87 Coccinelle: Add a... |
18 |
OPTIONS="-dir $srctree" |
1e9dea2a6 Add support for t... |
19 |
fi |
74425eee7 Add a target to u... |
20 21 22 23 24 25 |
if [ ! -x "$SPATCH" ]; then echo 'spatch is part of the Coccinelle project and is available at http://coccinelle.lip6.fr/' exit 1 fi if [ "$MODE" = "" ] ; then |
1e9dea2a6 Add support for t... |
26 |
if [ "$ONLINE" = "0" ] ; then |
2c1160c87 Coccinelle: Add a... |
27 28 |
echo 'You have not explicitly specified the mode to use. Using default "chain" mode.' echo 'All available modes will be tried (in that order): patch, report, context, org' |
1e9dea2a6 Add support for t... |
29 |
echo 'You can specify the mode with "make coccicheck MODE=<mode>"' |
1e9dea2a6 Add support for t... |
30 |
fi |
2c1160c87 Coccinelle: Add a... |
31 |
MODE="chain" |
03ee0c42a Coccinelle: Use t... |
32 |
elif [ "$MODE" = "report" -o "$MODE" = "org" ] ; then |
062c1825a Coccinelle: Add c... |
33 |
FLAGS="$FLAGS -no_show_diff" |
74425eee7 Add a target to u... |
34 |
fi |
1e9dea2a6 Add support for t... |
35 36 37 38 39 40 |
if [ "$ONLINE" = "0" ] ; then echo '' echo 'Please check for false positives in the output before submitting a patch.' echo 'When using "patch" mode, carefully review the patch before submitting it.' echo '' fi |
74425eee7 Add a target to u... |
41 |
|
1e9dea2a6 Add support for t... |
42 |
coccinelle () { |
74425eee7 Add a target to u... |
43 |
COCCI="$1" |
74425eee7 Add a target to u... |
44 45 |
OPT=`grep "Option" $COCCI | cut -d':' -f2` |
74425eee7 Add a target to u... |
46 |
|
062c1825a Coccinelle: Add c... |
47 |
# The option '-parse_cocci' can be used to syntactically check the SmPL files. |
1e9dea2a6 Add support for t... |
48 49 |
# # $SPATCH -D $MODE $FLAGS -parse_cocci $COCCI $OPT > /dev/null |
74425eee7 Add a target to u... |
50 |
|
1e9dea2a6 Add support for t... |
51 |
if [ "$ONLINE" = "0" ] ; then |
74425eee7 Add a target to u... |
52 |
|
1e9dea2a6 Add support for t... |
53 |
FILE=`echo $COCCI | sed "s|$srctree/||"` |
74425eee7 Add a target to u... |
54 |
|
3c9084176 Coccinelle: Impro... |
55 56 57 |
echo "Processing `basename $COCCI`" echo "with option(s) \"$OPT\"" echo '' |
1e9dea2a6 Add support for t... |
58 |
echo 'Message example to submit a patch:' |
3c9084176 Coccinelle: Impro... |
59 |
sed -ne 's|^///||p' $COCCI |
1e9dea2a6 Add support for t... |
60 |
|
062c1825a Coccinelle: Add c... |
61 62 63 64 65 66 67 68 69 70 71 |
if [ "$MODE" = "patch" ] ; then echo ' The semantic patch that makes this change is available' elif [ "$MODE" = "report" ] ; then echo ' The semantic patch that makes this report is available' elif [ "$MODE" = "context" ] ; then echo ' The semantic patch that spots this code is available' elif [ "$MODE" = "org" ] ; then echo ' The semantic patch that makes this Org report is available' else echo ' The semantic patch that makes this output is available' fi |
1e9dea2a6 Add support for t... |
72 73 74 75 76 |
echo " in $FILE." echo '' echo ' More information about semantic patching is available at' echo ' http://coccinelle.lip6.fr/' echo '' |
3c9084176 Coccinelle: Impro... |
77 78 79 80 81 |
if [ "`sed -ne 's|^//#||p' $COCCI`" ] ; then echo 'Semantic patch information:' sed -ne 's|^//#||p' $COCCI echo '' fi |
2c1160c87 Coccinelle: Add a... |
82 |
fi |
3c9084176 Coccinelle: Impro... |
83 |
|
2c1160c87 Coccinelle: Add a... |
84 |
if [ "$MODE" = "chain" ] ; then |
03ee0c42a Coccinelle: Use t... |
85 86 87 88 |
$SPATCH -D patch $FLAGS -sp_file $COCCI $OPT $OPTIONS || \ $SPATCH -D report $FLAGS -sp_file $COCCI $OPT $OPTIONS -no_show_diff || \ $SPATCH -D context $FLAGS -sp_file $COCCI $OPT $OPTIONS || \ $SPATCH -D org $FLAGS -sp_file $COCCI $OPT $OPTIONS -no_show_diff || exit 1 |
1e9dea2a6 Add support for t... |
89 |
else |
2c1160c87 Coccinelle: Add a... |
90 |
$SPATCH -D $MODE $FLAGS -sp_file $COCCI $OPT $OPTIONS || exit 1 |
1e9dea2a6 Add support for t... |
91 |
fi |
74425eee7 Add a target to u... |
92 |
|
74425eee7 Add a target to u... |
93 94 95 96 |
} if [ "$COCCI" = "" ] ; then for f in `find $srctree/scripts/coccinelle/ -name '*.cocci' -type f | sort`; do |
1e9dea2a6 Add support for t... |
97 |
coccinelle $f |
74425eee7 Add a target to u... |
98 99 |
done else |
1e9dea2a6 Add support for t... |
100 |
coccinelle $COCCI |
74425eee7 Add a target to u... |
101 |
fi |