move up apply_ctype()'s declaration
[smatch.git] / smatch_scripts / gen_returns_held.sh
blobf8e7fe383ce5c8049b9b23206b05dd9b3707e4b9
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.returns_held.remove)
17 tmp=$(mktemp /tmp/smatch.XXXX)
19 echo "// list of functions that return a held device." \
20 > kernel.returns_held_funcs
21 echo '// generated by `gen_returns_held.sh`' >> kernel.returns_held_funcs
22 grep "returned dev is held" $file | cut -s -d ' ' -f 2 | cut -d '(' -f 1 | \
23 sort -u > $tmp
24 cat $tmp $remove $remove 2> /dev/null | sort | uniq -u \
25 >> kernel.returns_held_funcs
26 rm $tmp
27 echo "Done. List saved as 'kernel.returns_held_funcs'"