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 11if [[ "$project" != "kernel" ]] ; then 12 exit 0 13fi 14 15bin_dir=$(dirname $0) 16remove=$(echo ${bin_dir}/../smatch_data/kernel.allocation_funcs.remove) 17tmp=$(mktemp /tmp/smatch.XXXX) 18 19echo "// list of functions that return a new allocation." \ 20 > kernel.allocation_funcs 21echo '// generated by `gen_allocation_list.sh`' >> kernel.allocation_funcs 22grep "allocation func$" $file | cut -s -d ' ' -f 2 | cut -d '(' -f 1 | \ 23 sort -u > $tmp 24echo "kmalloc" >> $tmp 25echo "kzalloc" >> $tmp 26echo "kcalloc" >> $tmp 27echo "__alloc_skb" >> $tmp 28cat $tmp $remove $remove 2> /dev/null | sort | uniq -u \ 29 >> kernel.allocation_funcs 30rm $tmp 31echo "Done. List saved as 'kernel.allocation_funcs'" 32 33