*new* smatch_scripts/follow_params.pl
[smatch.git] / smatch_scripts / gen_array_bounds.sh
bloba9fa56621ec8bbe46a3c29a37b5004be2735415c
1 #!/bin/bash
3 file=$1
5 if [[ "$file" = "" ]] ; then
6 echo "Usage: $0 <file with smatch messages>"
7 exit 1
8 fi
10 new_file=kernel.array_bounds
11 bin_dir=$(dirname $0)
12 remove=$(echo ${bin_dir}/../smatch_data/kernel.array_bounds.remove)
13 tmp=$(mktemp /tmp/smatch.XXXX)
15 echo "// the format is: function <param> <max in array>" > $new_file
16 echo '// generated by `gen_puts_list.sh`' >> $new_file
17 grep "array index" $file | sed -e 's/(.*)//' | cut -d ' ' -f 3,6,10 | \
18 perl -ne 'if ($_ =~ /\w+ \d+ \d+/) {print "$_\n"}' | \
19 sort -u > $tmp
20 cat $tmp $remove $remove 2> /dev/null | sort | uniq -u >> $new_file
21 rm $tmp
22 echo "Done. List saved as '$new_file'"