X-Git-Url: http://git.cascardo.info/?a=blobdiff_plain;f=scripts%2Fcoccicheck;h=1bb1a1bd2daa832b234edbec3765861d4f41010d;hb=00e375e7e962f938f6b3c93e4cd097a5e26cc788;hp=b8bcf1f7bed784347cdba6a2166c0a5a3bf88469;hpb=b171aa27700c78511086a759383b033949c9d7f0;p=cascardo%2Flinux.git diff --git a/scripts/coccicheck b/scripts/coccicheck index b8bcf1f7bed7..1bb1a1bd2daa 100755 --- a/scripts/coccicheck +++ b/scripts/coccicheck @@ -16,6 +16,7 @@ if [ "$C" = "1" -o "$C" = "2" ]; then else ONLINE=0 FLAGS="-very_quiet" + OPTIONS="-dir $srctree" fi if [ ! -x "$SPATCH" ]; then @@ -25,11 +26,13 @@ fi if [ "$MODE" = "" ] ; then if [ "$ONLINE" = "0" ] ; then - echo 'You have not explicitly specify the mode to use. Fallback to "report".' + 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' echo 'You can specify the mode with "make coccicheck MODE="' - echo 'Available modes are: report, patch, context, org' fi - MODE="report" + MODE="chain" +elif [ "$MODE" = "report" -o "$MODE" = "org" ] ; then + FLAGS="$FLAGS -no_show_diff" fi if [ "$ONLINE" = "0" ] ; then @@ -44,7 +47,7 @@ coccinelle () { OPT=`grep "Option" $COCCI | cut -d':' -f2` -# The option '-parse_cocci' can be used to syntaxically check the SmPL files. +# The option '-parse_cocci' can be used to syntactically check the SmPL files. # # $SPATCH -D $MODE $FLAGS -parse_cocci $COCCI $OPT > /dev/null @@ -52,21 +55,44 @@ coccinelle () { FILE=`echo $COCCI | sed "s|$srctree/||"` - echo "Processing `basename $COCCI` with option(s) \"$OPT\"" + echo "Processing `basename $COCCI`" + echo "with option(s) \"$OPT\"" + echo '' echo 'Message example to submit a patch:' - sed -e '/\/\/\//!d' -e 's|^///||' $COCCI - - echo ' The semantic patch that makes this change is available' + sed -ne 's|^///||p' $COCCI + + 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 echo " in $FILE." echo '' echo ' More information about semantic patching is available at' echo ' http://coccinelle.lip6.fr/' echo '' - $SPATCH -D $MODE $FLAGS -sp_file $COCCI $OPT -dir $srctree || exit 1 + if [ "`sed -ne 's|^//#||p' $COCCI`" ] ; then + echo 'Semantic patch information:' + sed -ne 's|^//#||p' $COCCI + echo '' + fi + fi + + if [ "$MODE" = "chain" ] ; then + $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 else - $SPATCH -D $MODE $FLAGS -sp_file $COCCI $OPT $OPTIONS || exit 1 + $SPATCH -D $MODE $FLAGS -sp_file $COCCI $OPT $OPTIONS || exit 1 fi }