1 #!/bin/bash
   2 
   3 file=$1
   4 project=$(echo "$2" | cut -d = -f 2)
   5 
   6 if [[ "$file" = "" ]] ; then
   7     echo "Usage:  $0 <file with smatch messages> -p=<project>"
   8     exit 1
   9 fi
  10 
  11 if [[ "$project" != "kernel" ]] ; then
  12     exit 0
  13 fi
  14 
  15 outfile="kernel.expects_err_ptr"
  16 bin_dir=$(dirname $0)
  17 remove=$(echo ${bin_dir}/../smatch_data/${outfile}.remove)
  18 tmp=$(mktemp /tmp/smatch.XXXX)
  19 
  20 echo "// list of functions which expect an ERR_PTR." > $outfile
  21 echo '// generated by `gen_expects_err_ptr.sh`' >> $outfile
  22 grep -w "expects ERR_PTR" $file | cut -d ' ' -f 2,6 | \
  23     sed -e 's/([1234567890]*)//' | sort -u > $tmp
  24 cat $tmp $remove $remove 2> /dev/null | sort | uniq -u >> $outfile
  25 rm $tmp
  26 echo "Done.  List saved as '$outfile'"