1 #!/bin/bash 2 3 file=$1 4 project=$(echo "$2" | cut -d = -f 2) 5 6 if [[ "$file" = "" ]] ; then 7 echo "Usage: $0 <file with smatch messages> -p=<project>" 8 exit 1 9 fi 10 11 outfile="${project}.sizeof_param" 12 bin_dir=$(dirname $0) 13 remove=$(echo ${bin_dir}/../smatch_data/${outfile}.remove) 14 tmp=$(mktemp /tmp/smatch.XXXX) 15 tmp2=$(mktemp /tmp/smatch.XXXX) 16 17 18 echo "// list of function parameters that are the size of a buffer." > $outfile 19 echo '// generated by `gen_sizeof_param.sh`' >> $outfile 20 21 grep sizeof_param $file | grep '[0-9] [0-9]$' | cut -d ' ' -f 5- | \ 22 sort -u | sed -e "s/'//g" > $tmp 23 grep sizeof_param $file | grep '[0-9] -1$' | cut -d ' ' -f 5- | \ 24 sort -u | sed -e "s/'//g" >> $tmp 25 grep -f $remove $tmp >> $tmp2 2> /dev/null 26 cat $tmp $tmp2 2> /dev/null | sort | uniq -u >> $outfile 27 rm $tmp 28 rm $tmp2 29 30 echo "Done. List saved as '$outfile'" 31