type: introduce is_pointer() function
[smatch.git] / smatch_scripts / kchecker
blob3ebab458e915df8d7bfdb644875e77ba7a18623c
1 #!/bin/bash
3 function useage {
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" == "" ]] ; then
35 break
36 else
37 if [[ "$1" == "--help" ]] ; then
38 $CMD --help
39 exit 1
41 if echo $1 | grep -q ^- ; then
42 POST="$POST $1"
43 else
44 break
46 shift
48 done
49 if echo $CMD | grep -q smatch ; then
50 POST="--project=kernel $POST"
53 cname=$1
54 cname=$(echo ${cname/.o/.c})
55 if [[ "$cname" == "" ]] ; then
56 useage
58 if ! test -e $cname ; then
59 useage
62 oname=$(echo ${cname/.c/.o})
63 if ! echo $oname | grep .o$ > /dev/null ; then
64 useage
66 rm -f $oname
68 make C=y CHECK="$PRE $CMD $POST" $oname