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"
19 OPTIONS="-dir $srctree"
22 if [ ! -x "$SPATCH" ]; then
23 echo 'spatch is part of the Coccinelle project and is available at http://coccinelle.lip6.fr/'
27 if [ "$MODE" = "" ] ; then
28 if [ "$ONLINE" = "0" ] ; then
29 echo 'You have not explicitly specified the mode to use. Using default "chain" mode.'
30 echo 'All available modes will be tried (in that order): patch, report, context, org'
31 echo 'You can specify the mode with "make coccicheck MODE=<mode>"'
36 if [ "$ONLINE" = "0" ] ; then
38 echo 'Please check for false positives in the output before submitting a patch.'
39 echo 'When using "patch" mode, carefully review the patch before submitting it.'
46 OPT=`grep "Option" $COCCI | cut -d':' -f2`
48 # The option '-parse_cocci' can be used to syntaxically check the SmPL files.
50 # $SPATCH -D $MODE $FLAGS -parse_cocci $COCCI $OPT > /dev/null
52 if [ "$ONLINE" = "0" ] ; then
54 FILE=`echo $COCCI | sed "s|$srctree/||"`
56 echo "Processing `basename $COCCI`"
57 echo "with option(s) \"$OPT\""
59 echo 'Message example to submit a patch:'
61 sed -ne 's|^///||p' $COCCI
63 echo ' The semantic patch that makes this change is available'
66 echo ' More information about semantic patching is available at'
67 echo ' http://coccinelle.lip6.fr/'
70 if [ "`sed -ne 's|^//#||p' $COCCI`" ] ; then
71 echo 'Semantic patch information:'
72 sed -ne 's|^//#||p' $COCCI
77 if [ "$MODE" = "chain" ] ; then
78 $SPATCH -D patch $FLAGS -sp_file $COCCI $OPT $OPTIONS || \
79 $SPATCH -D report $FLAGS -sp_file $COCCI $OPT $OPTIONS || \
80 $SPATCH -D context $FLAGS -sp_file $COCCI $OPT $OPTIONS || \
81 $SPATCH -D org $FLAGS -sp_file $COCCI $OPT $OPTIONS || exit 1
83 $SPATCH -D $MODE $FLAGS -sp_file $COCCI $OPT $OPTIONS || exit 1
88 if [ "$COCCI" = "" ] ; then
89 for f in `find $srctree/scripts/coccinelle/ -name '*.cocci' -type f | sort`; do