Linux Audio

Check our new training course

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