debug: add a function to do intersections
[smatch.git] / smatch_scripts / gen_allocation_list.sh
blobb095c292f280498e4209194222947b7bfebae8bd
1 #!/bin/bash
3 file=$1
5 if [[ "$file" = "" ]] ; then
6 echo "Usage: $0 <file with smatch messages>"
7 exit 1
8 fi
10 bin_dir=$(dirname $0)
11 remove=$(echo ${bin_dir}/../smatch_data/kernel.allocation_funcs.remove)
12 tmp=$(mktemp /tmp/smatch.XXXX)
14 echo "// list of functions that return a new allocation." \
15 > kernel.allocation_funcs
16 echo '// generated by `gen_allocation_list.sh`' >> kernel.allocation_funcs
17 grep "allocation func$" $file | cut -s -d ' ' -f 2 | cut -d '(' -f 1 | \
18 sort -u > $tmp
19 echo "kmalloc" >> $tmp
20 echo "kzalloc" >> $tmp
21 echo "kcalloc" >> $tmp
22 cat $tmp $remove $remove 2> /dev/null | sort | uniq -u \
23 >> kernel.allocation_funcs
24 rm $tmp
25 echo "Done. List saved as 'kernel.allocation_funcs'"