Print fewer messages about unreached code
[smatch.git] / smatch_scripts / kchecker
blobc0735abbd423884fe6f5065d932f37f4ed6e52ed
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 POST="--project=kernel"
20 while true ; do
21 if [[ "$1" == "--sparse" ]] ; then
22 CMD="sparse"
23 shift
24 elif [[ "$1" == "--valgrind" ]] ; then
25 PRE="valgrind"
26 shift
27 elif [[ "$1" == "" ]] ; then
28 break
29 else
30 if [[ "$1" == "--help" ]] ; then
31 $CMD --help
32 exit 1
34 if echo $1 | grep -q ^- ; then
35 POST="$POST $1"
36 else
37 break
39 shift
41 done
43 cname=$1
44 cname=$(echo ${cname/.o/.c})
45 if [[ "$cname" == "" ]] ; then
46 useage
48 if ! test -e $cname ; then
49 useage
52 oname=$(echo ${cname/.c/.o})
53 if ! echo $oname | grep .o$ > /dev/null ; then
54 useage
56 rm -f $oname
57 make C=y CHECK="$PRE $CMD $POST" $oname