3 SPATCH="`which ${SPATCH:=spatch}`"
5 if [ "$C" = "1" -o "$C" = "2" ]; then
8 # This requires Coccinelle >= 0.2.3
9 # FLAGS="-ignore_unknown_options -very_quiet"
12 # Workaround for Coccinelle < 0.2.3
13 FLAGS="-I $srctree/include -very_quiet"
21 if [ ! -x "$SPATCH" ]; then
22 echo 'spatch is part of the Coccinelle project and is available at http://coccinelle.lip6.fr/'
26 if [ "$MODE" = "" ] ; then
27 if [ "$ONLINE" = "0" ] ; then
28 echo 'You have not explicitly specify the mode to use. Fallback to "report".'
29 echo 'You can specify the mode with "make coccicheck MODE=<mode>"'
30 echo 'Available modes are: report, patch, context, org'
35 if [ "$ONLINE" = "0" ] ; then
37 echo 'Please check for false positives in the output before submitting a patch.'
38 echo 'When using "patch" mode, carefully review the patch before submitting it.'
45 OPT=`grep "Option" $COCCI | cut -d':' -f2`
47 # The option '-parse_cocci' can be used to syntaxically check the SmPL files.
49 # $SPATCH -D $MODE $FLAGS -parse_cocci $COCCI $OPT > /dev/null
51 if [ "$ONLINE" = "0" ] ; then
53 FILE=`echo $COCCI | sed "s|$srctree/||"`
55 echo "Processing `basename $COCCI` with option(s) \"$OPT\""
56 echo 'Message example to submit a patch:'
58 sed -e '/\/\/\//!d' -e 's|^///||' $COCCI
60 echo ' The semantic patch that makes this change is available'
63 echo ' More information about semantic patching is available at'
64 echo ' http://coccinelle.lip6.fr/'
67 $SPATCH -D $MODE $FLAGS -sp_file $COCCI $OPT -dir $srctree || exit 1
69 $SPATCH -D $MODE $FLAGS -sp_file $COCCI $OPT $OPTIONS || exit 1
74 if [ "$COCCI" = "" ] ; then
75 for f in `find $srctree/scripts/coccinelle/ -name '*.cocci' -type f | sort`; do