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 13export X1=/tmp/f.1.$$ 14export X2=/tmp/f.2.$$ 15
| 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 13export X1=/tmp/f.1.$$ 14export X2=/tmp/f.2.$$ 15
|
16case "$1" in 17 -f) 18 PAT='_F_' 19 echo Functions only 20 ;; 21 -[er]) 22 PAT='_R_' 23 echo Reason codes only 24 ;; 25 "") 26 PAT='_[FR]_' 27 echo Function and reasons 28 ;; 29 *) 30 echo "Usage error; one of -[efr] required." 31 exit 1; 32 ;; 33esac 34
| |
35cd include/openssl || exit 1
| 16cd include/openssl || exit 1
|
36grep "$PAT" * | grep -v ERR_FATAL_ERROR | awk '{print $3;}' | sort -u >$X1
| 17grep '_[RF]_' * | awk '{print $3;}' | sort -u >$X1
|
37cd ../.. 38 39for F in `cat $X1` ; do 40 git grep -l --full-name -F $F >$X2 41 NUM=`wc -l <$X2` 42 test $NUM -gt 2 && continue 43 if grep -q $F crypto/err/openssl.ec ; then 44 echo Possibly unused $F found in openssl.ec 45 continue 46 fi 47 echo $F 48 for FILE in `cat $X2` ; do 49 grep -v -w $F <$FILE >$FILE.new 50 mv $FILE.new $FILE 51 done 52done 53 54rm $X1 $X2
| 18cd ../.. 19 20for 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 33done 34 35rm $X1 $X2
|