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