summaryrefslogtreecommitdiff
path: root/other
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2020-05-02 00:34:13 +0100
committeriphydf <iphydf@users.noreply.github.com>2020-05-02 22:00:09 +0100
commitf8ab32aaa4efce2c9a310a14d10b19fb8544cfd9 (patch)
tree4dbc49882d6af0954c533b2482b2100d312d2bc7 /other
parent2570ddcb17fdf5bea56c6bc1c5c2d04ba2068ee7 (diff)
Add a check that we don't have any unused functions.
This check puts all of our code in a C++ anonymous namespace, which is effectively making all functions `static`. This allows the compiler to determine that a function is unused, so we can delete it.
Diffstat (limited to 'other')
-rw-r--r--other/analysis/gen-file.sh35
-rw-r--r--other/bootstrap_daemon/docker/tox-bootstrapd.sha2562
-rw-r--r--other/cpufeatures.c2
3 files changed, 23 insertions, 16 deletions
diff --git a/other/analysis/gen-file.sh b/other/analysis/gen-file.sh
index 019bd8f9..ad8df3b8 100644
--- a/other/analysis/gen-file.sh
+++ b/other/analysis/gen-file.sh
@@ -17,20 +17,20 @@ put() {
17 if [ "$SKIP_LINES" = "" ]; then 17 if [ "$SKIP_LINES" = "" ]; then
18 echo "#line 1 \"$1\"" >> amalgamation.cc 18 echo "#line 1 \"$1\"" >> amalgamation.cc
19 fi 19 fi
20 cat $1 >> amalgamation.cc 20 cat "$1" >> amalgamation.cc
21} 21}
22 22
23putmain() { 23putmain() {
24 echo "namespace $(echo $1 | sed -e 's/[^a-zA-Z0-9_]/_/g') {" >> amalgamation.cc 24 echo "namespace $(echo "$1" | sed -e 's/[^a-zA-Z0-9_]/_/g') {" >> amalgamation.cc
25 if [ "$SKIP_LINES" = "" ]; then 25 if [ "$SKIP_LINES" = "" ]; then
26 echo "#line 1 \"$1\"" >> amalgamation.cc 26 echo "#line 1 \"$1\"" >> amalgamation.cc
27 fi 27 fi
28 sed -e 's/^int main(/static &/' $1 >> amalgamation.cc 28 sed -e 's/^int main(/static &/' "$1" >> amalgamation.cc
29 echo "} // namespace $(echo $1 | sed -e 's/[^a-zA-Z0-9_]/_/g')" >> amalgamation.cc 29 echo "} // namespace $(echo "$1" | sed -e 's/[^a-zA-Z0-9_]/_/g')" >> amalgamation.cc
30} 30}
31 31
32callmain() { 32callmain() {
33 echo " call($(echo $1 | sed -e 's/[^a-zA-Z0-9_]/_/g')::main, argc, argv);" >> amalgamation.cc 33 echo " call($(echo "$1" | sed -e 's/[^a-zA-Z0-9_]/_/g')::main, argc, argv);" >> amalgamation.cc
34} 34}
35 35
36:> amalgamation.cc 36:> amalgamation.cc
@@ -53,25 +53,32 @@ FIND_QUERY="$FIND_QUERY -and -not -name av_test.c"
53FIND_QUERY="$FIND_QUERY -and -not -name dht_test.c" 53FIND_QUERY="$FIND_QUERY -and -not -name dht_test.c"
54FIND_QUERY="$FIND_QUERY -and -not -name version_test.c" 54FIND_QUERY="$FIND_QUERY -and -not -name version_test.c"
55 55
56for i in $(eval $FIND_QUERY); do 56(for i in $(eval "$FIND_QUERY"); do
57 if ! grep -q '^int main(' $i; then 57 grep -o '#include <[^>]*>' "$i" \
58 put $i 58 | grep -E -v '<win|<ws|<iphlp|<libc|<mach/|<crypto_|<randombytes|<u.h>|<sys/filio|<linux'
59done) | sort -u >> amalgamation.cc
60
61echo 'namespace {' >> amalgamation.cc
62for i in $(eval "$FIND_QUERY"); do
63 if ! grep -q '^int main(' "$i"; then
64 put "$i"
59 fi 65 fi
60done 66done
61 67
62for i in $(eval $FIND_QUERY); do 68for i in $(eval "$FIND_QUERY"); do
63 if grep -q '^int main(' $i; then 69 if grep -q '^int main(' "$i"; then
64 putmain $i 70 putmain "$i"
65 fi 71 fi
66done 72done
67 73
68echo "static void call(int m(), int argc, char **argv) { m(); }" >> amalgamation.cc 74echo "static void call(int m(), int argc, char **argv) { m(); }" >> amalgamation.cc
69echo "static void call(int m(int, char **), int argc, char **argv) { m(argc, argv); }" >> amalgamation.cc 75echo "static void call(int m(int, char **), int argc, char **argv) { m(argc, argv); }" >> amalgamation.cc
76echo '} // namespace' >> amalgamation.cc
70 77
71echo "int main(int argc, char **argv) {" >> amalgamation.cc 78echo "int main(int argc, char **argv) {" >> amalgamation.cc
72for i in $(eval $FIND_QUERY); do 79for i in $(eval "$FIND_QUERY"); do
73 if grep -q '^int main(' $i; then 80 if grep -q '^int main(' "$i"; then
74 callmain $i 81 callmain "$i"
75 fi 82 fi
76done 83done
77echo " return 0;" >> amalgamation.cc 84echo " return 0;" >> amalgamation.cc
diff --git a/other/bootstrap_daemon/docker/tox-bootstrapd.sha256 b/other/bootstrap_daemon/docker/tox-bootstrapd.sha256
index 5287541b..4d02d38f 100644
--- a/other/bootstrap_daemon/docker/tox-bootstrapd.sha256
+++ b/other/bootstrap_daemon/docker/tox-bootstrapd.sha256
@@ -1 +1 @@
e7b6d31485b5e1561659be08f3e3ef003cef186042d7e0fe2ef48cf341932b5a /usr/local/bin/tox-bootstrapd 89df21d6a19a1b6652db5b7e6e9f65ad5f8be8abdca9f58645548b9e0c9383e3 /usr/local/bin/tox-bootstrapd
diff --git a/other/cpufeatures.c b/other/cpufeatures.c
index 3da06e58..38c97059 100644
--- a/other/cpufeatures.c
+++ b/other/cpufeatures.c
@@ -3,4 +3,4 @@
3#include ANDROID_CPU_FEATURES 3#include ANDROID_CPU_FEATURES
4#endif 4#endif
5 5
6extern int unused_declaration; 6typedef int unused_declaration;