smatch: add a --succeed option
[smatch.git] / smatch_scripts / kchecker
blob9754b21f93d03a9dedd30357e9829c892977c130
1 #!/bin/bash
3 function usage {
4 echo "Usage: $0 [--sparse][--valgrind][--debug] path/to/file.c"
5 exit 1
8 SCRIPT_DIR=$(dirname $0)
9 if [ -e $SCRIPT_DIR/../smatch ] ; then
10 CMD=$SCRIPT_DIR/../smatch
11 elif which smatch | grep smatch > /dev/null ; then
12 CMD=smatch
13 else
14 echo "Smatch binary not found."
15 exit 1
18 while true ; do
19 if [[ "$1" == "--sparse" ]] ; then
20 CMD="sparse"
21 shift
22 elif [[ "$1" == "--test-parsing" ]] ; then
23 CMD="$SCRIPT_DIR/../test-parsing -no-lineno"
24 shift
25 elif echo "$1" | grep -q -- "--outfile=" ; then
26 outfile=$(echo "$1" | cut -d '=' -f 2)
27 if [ "outfile" != "" ] ; then
28 POST="$POST > $outfile"
30 shift
31 elif [[ "$1" == "--valgrind" ]] ; then
32 PRE="valgrind"
33 shift
34 elif [[ "$1" == "--endian" ]] ; then
35 ENDIAN="CF=-D__CHECK_ENDIAN__"
36 shift
37 elif [[ "$1" == "" ]] ; then
38 break
39 else
40 if [[ "$1" == "--help" ]] ; then
41 $CMD --help
42 exit 1
44 if echo $1 | grep -q ^- ; then
45 POST="$1 $POST"
46 else
47 break
49 shift
51 done
52 if echo $CMD | grep -q smatch ; then
53 POST="--project=kernel --succeed $POST"
56 cname=$1
57 cname=$(echo ${cname/.o/.c})
58 if [[ "$cname" == "" ]] ; then
59 usage
61 if ! test -e $cname ; then
62 usage
65 oname=$(echo ${cname/.c/.o})
66 if ! echo $oname | grep -q .o$ && ! echo $oname | grep -q /$ ; then
67 usage
69 if echo $oname | grep -q .o$ ; then
70 rm -f $oname
73 make C=2 $ENDIAN CHECK="$PRE $CMD $POST" $oname