1 1.1 christos #! /bin/bash 2 1.1 christos # Copyright 2016 The OpenSSL Project Authors. All Rights Reserved. 3 1.1 christos # 4 1.1.1.3 christos # Licensed under the Apache License 2.0 (the "License"). You may not use 5 1.1 christos # this file except in compliance with the License. You can obtain a copy 6 1.1 christos # in the file LICENSE in the source distribution or at 7 1.1 christos # https://www.openssl.org/source/license.html 8 1.1 christos 9 1.1 christos # Find unused error function-names and reason-codes, and edit them 10 1.1 christos # out of the source. Doesn't handle line-wrapping, might have to do 11 1.1 christos # some manual cleanups to fix compile errors. 12 1.1 christos 13 1.1 christos export X1=/tmp/f.1.$$ 14 1.1 christos export X2=/tmp/f.2.$$ 15 1.1 christos 16 1.1.1.2 christos case "$1" in 17 1.1.1.2 christos -f) 18 1.1.1.2 christos PAT='_F_' 19 1.1.1.2 christos echo Functions only 20 1.1.1.2 christos ;; 21 1.1.1.2 christos -[er]) 22 1.1.1.2 christos PAT='_R_' 23 1.1.1.2 christos echo Reason codes only 24 1.1.1.2 christos ;; 25 1.1.1.2 christos "") 26 1.1.1.2 christos PAT='_[FR]_' 27 1.1.1.2 christos echo Function and reasons 28 1.1.1.2 christos ;; 29 1.1.1.2 christos *) 30 1.1.1.2 christos echo "Usage error; one of -[efr] required." 31 1.1.1.2 christos exit 1; 32 1.1.1.2 christos ;; 33 1.1.1.2 christos esac 34 1.1.1.2 christos 35 1.1 christos cd include/openssl || exit 1 36 1.1.1.2 christos grep "$PAT" * | grep -v ERR_FATAL_ERROR | awk '{print $3;}' | sort -u >$X1 37 1.1 christos cd ../.. 38 1.1 christos 39 1.1 christos for F in `cat $X1` ; do 40 1.1 christos git grep -l --full-name -F $F >$X2 41 1.1 christos NUM=`wc -l <$X2` 42 1.1 christos test $NUM -gt 2 && continue 43 1.1 christos if grep -q $F crypto/err/openssl.ec ; then 44 1.1 christos echo Possibly unused $F found in openssl.ec 45 1.1 christos continue 46 1.1 christos fi 47 1.1 christos echo $F 48 1.1 christos for FILE in `cat $X2` ; do 49 1.1 christos grep -v -w $F <$FILE >$FILE.new 50 1.1 christos mv $FILE.new $FILE 51 1.1 christos done 52 1.1 christos done 53 1.1 christos 54 1.1 christos rm $X1 $X2 55