1#!/bin/bash 2 3context=6 4while true ; do 5 if [ "$1" = "-C" ] ; then 6 shift 7 context=$1 8 shift 9 continue 10 fi 11 if [ "$1" = "-k" ] ; then 12 shift 13 mode=kernel 14 continue 15 fi 16 if [ "$1" = "-b" ] ; then 17 shift 18 nobreak=yes 19 continue 20 fi 21 break 22done 23 24 25file=$1 26if [[ "$file" = "" ]] ; then 27 echo "Usage: $0 [-C <lines>] [-b] [-k] <file with smatch messages>" 28 echo " -C <lines>: Print <lines> of context" 29 echo " -b : Ignore unreachable break statements" 30 echo " -k : Ignore some kernel defines" 31 exit 1 32fi 33 34kernel_ignore_functions="DLM_ASSERT 35BT_SI_SM_RETURN 36BT_STATE_CHANGE 37PARSE_ERROR1 38PARSE_ERROR 39CMDINSIZE 40PROCESS_SYSTEM_PARAM 41RETURN_STATUS 42ar9170_regwrite_result 43module_put_and_exit 44SEG32 45CASE_PIPExTRE 46" 47 48grep 'ignoring unreachable' $file | cut -d ' ' -f1 | while read loc; do 49 code_file=$(echo $loc | cut -d ':' -f 1) 50 line=$(echo $loc | cut -d ':' -f 2) 51 52 if [ "$mode" = "kernel" ] ; then 53 # BUG() is sometimes defined away on embedded systems 54 if tail -n +$(($line - 1)) $code_file | head -n 1 | \ 55 egrep -qw '(BUG|BT_STATE_CHANGE)' ; then 56 continue; 57 fi 58 skip=0 59 line_txt=$(tail -n +$(($line)) $code_file | head -n 1) 60 for func in $kernel_ignore_functions ; do 61 if echo "$line_txt" | egrep -qw $func ; then 62 skip=1 63 break 64 fi 65 done 66 if [ "$skip" == 1 ] ; then 67 continue 68 fi 69 fi 70 71 if [ "$nobreak" = "yes" ] ; then 72 if tail -n +$(($line)) $code_file | head -n 1 | grep -qw 'break' ; then 73 continue; 74 fi 75 76 fi 77 echo "=========================================================" 78 echo $code_file:$line 79 tail -n +$(($line - ($context - 1))) $code_file | head -n $(($context - 1)) 80 echo "---------------------------------------------------------" 81 tail -n +${line} $code_file | head -n $context 82done 83 84