Coccinelle: Use new comment format to explain kfree.cocci
[deliverable/linux.git] / scripts / coccicheck
CommitLineData
74425eee
NP
1#!/bin/sh
2
3SPATCH="`which ${SPATCH:=spatch}`"
4
1e9dea2a
NP
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"
19fi
20
74425eee
NP
21if [ ! -x "$SPATCH" ]; then
22 echo 'spatch is part of the Coccinelle project and is available at http://coccinelle.lip6.fr/'
23 exit 1
24fi
25
26if [ "$MODE" = "" ] ; then
1e9dea2a 27 if [ "$ONLINE" = "0" ] ; then
3c908417 28 echo 'You have not explicitly specified the mode to use. Fallback to "report".'
1e9dea2a
NP
29 echo 'You can specify the mode with "make coccicheck MODE=<mode>"'
30 echo 'Available modes are: report, patch, context, org'
31 fi
74425eee
NP
32 MODE="report"
33fi
34
1e9dea2a
NP
35if [ "$ONLINE" = "0" ] ; then
36 echo ''
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.'
39 echo ''
40fi
74425eee 41
1e9dea2a 42coccinelle () {
74425eee 43 COCCI="$1"
74425eee
NP
44
45 OPT=`grep "Option" $COCCI | cut -d':' -f2`
74425eee 46
1e9dea2a
NP
47# The option '-parse_cocci' can be used to syntaxically check the SmPL files.
48#
49# $SPATCH -D $MODE $FLAGS -parse_cocci $COCCI $OPT > /dev/null
74425eee 50
1e9dea2a 51 if [ "$ONLINE" = "0" ] ; then
74425eee 52
1e9dea2a 53 FILE=`echo $COCCI | sed "s|$srctree/||"`
74425eee 54
3c908417
NP
55 echo "Processing `basename $COCCI`"
56 echo "with option(s) \"$OPT\""
57 echo ''
1e9dea2a
NP
58 echo 'Message example to submit a patch:'
59
3c908417 60 sed -ne 's|^///||p' $COCCI
1e9dea2a
NP
61
62 echo ' The semantic patch that makes this change is available'
63 echo " in $FILE."
64 echo ''
65 echo ' More information about semantic patching is available at'
66 echo ' http://coccinelle.lip6.fr/'
67 echo ''
68
3c908417
NP
69 if [ "`sed -ne 's|^//#||p' $COCCI`" ] ; then
70 echo 'Semantic patch information:'
71 sed -ne 's|^//#||p' $COCCI
72 echo ''
73 fi
74
1e9dea2a
NP
75 $SPATCH -D $MODE $FLAGS -sp_file $COCCI $OPT -dir $srctree || exit 1
76 else
77 $SPATCH -D $MODE $FLAGS -sp_file $COCCI $OPT $OPTIONS || exit 1
78 fi
74425eee 79
74425eee
NP
80}
81
82if [ "$COCCI" = "" ] ; then
83 for f in `find $srctree/scripts/coccinelle/ -name '*.cocci' -type f | sort`; do
1e9dea2a 84 coccinelle $f
74425eee
NP
85 done
86else
1e9dea2a 87 coccinelle $COCCI
74425eee 88fi
This page took 0.029237 seconds and 5 git commands to generate.