Home | History | Annotate | Line # | Download | only in util
find-unused-errs revision 1.1
      1 #! /bin/bash
      2 # Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
      3 #
      4 # Licensed under the OpenSSL license (the "License").  You may not use
      5 # this file except in compliance with the License.  You can obtain a copy
      6 # in the file LICENSE in the source distribution or at
      7 # https://www.openssl.org/source/license.html
      8 
      9 # Find unused error function-names and reason-codes, and edit them
     10 # out of the source.  Doesn't handle line-wrapping, might have to do
     11 # some manual cleanups to fix compile errors.
     12 
     13 export X1=/tmp/f.1.$$
     14 export X2=/tmp/f.2.$$
     15 
     16 cd include/openssl || exit 1
     17 grep '_[RF]_' * | awk '{print $3;}' | sort -u >$X1
     18 cd ../..
     19 
     20 for F in `cat $X1` ; do
     21     git grep -l --full-name -F $F >$X2
     22     NUM=`wc -l <$X2`
     23     test $NUM -gt 2 && continue
     24     if grep -q $F crypto/err/openssl.ec ; then
     25         echo Possibly unused $F found in openssl.ec
     26         continue
     27     fi
     28     echo $F
     29     for FILE in `cat $X2` ; do
     30         grep -v -w $F <$FILE >$FILE.new
     31         mv $FILE.new $FILE
     32     done
     33 done
     34 
     35 rm $X1 $X2
     36