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
11outfile="${project}.no_return_funcs"
12bin_dir=$(dirname $0)
13add_file=$(echo ${bin_dir}/../smatch_data/${outfile}.add)
14remove=$(echo ${bin_dir}/../smatch_data/${outfile}.remove)
15tmp=$(mktemp /tmp/smatch.XXXX)
16tmp2=$(mktemp /tmp/smatch.XXXX)
17
18echo "// list of functions which don't return." > $outfile
19echo '// generated by `gen_no_return_funcs.sh`' >> $outfile
20cat $(echo ${bin_dir}/../smatch_data/no_return_funcs) >> $outfile
21cat $add_file >> $outfile 2> /dev/null
22
23grep no_return_funcs $file | cut -d ' ' -f 2 | cut -d '(' -f 1 > $tmp
24
25cat $tmp | sort -u > $tmp2
26mv $tmp2 $tmp
27cat $tmp $remove $remove 2> /dev/null | sort | uniq -u >> $outfile
28rm $tmp
29echo "Done.  List saved as '$outfile'"
30echo "Copy it to smatch_data/<project>.no_return_funcs"
31