expressions: make assign_expression() take an op argument
[smatch.git] / smatch_scripts / gen_allocation_list.sh
blob20175624bd647216b4676e8b0e516003b0d445f8
1 #!/bin/bash
3 file=$1
4 project=$(echo "$2" | cut -d = -f 2)
6 if [[ "$file" = "" ]] ; then
7 echo "Usage: $0 <file with smatch messages> -p=<project>"
8 exit 1
9 fi
11 if [[ "$project" != "kernel" ]] ; then
12 exit 0
15 bin_dir=$(dirname $0)
16 remove=$(echo ${bin_dir}/../smatch_data/kernel.allocation_funcs.remove)
17 tmp=$(mktemp /tmp/smatch.XXXX)
19 echo "// list of functions that return a new allocation." \
20 > kernel.allocation_funcs
21 echo '// generated by `gen_allocation_list.sh`' >> kernel.allocation_funcs
22 grep "allocation func$" $file | cut -s -d ' ' -f 2 | cut -d '(' -f 1 | \
23 sort -u > $tmp
24 echo "kmalloc" >> $tmp
25 echo "kzalloc" >> $tmp
26 echo "kcalloc" >> $tmp
27 echo "__alloc_skb" >> $tmp
28 cat $tmp $remove $remove 2> /dev/null | sort | uniq -u \
29 >> kernel.allocation_funcs
30 rm $tmp
31 echo "Done. List saved as 'kernel.allocation_funcs'"