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