diff options
author | teor <teor@torproject.org> | 2019-10-23 15:40:09 +1000 |
---|---|---|
committer | teor <teor@torproject.org> | 2019-10-24 11:40:58 +1000 |
commit | 330717f01845a2fea45b79d914161d6a2a897815 (patch) | |
tree | 348850574abe0b18b52f29ab84678fa89e6c8d91 /scripts/coccinelle | |
parent | 87ee49e016a100951bb1dd37f2ef57826a951eb1 (diff) | |
download | tor-330717f01845a2fea45b79d914161d6a2a897815.tar.gz tor-330717f01845a2fea45b79d914161d6a2a897815.zip |
scripts/cocci: Add check_cocci_parse.sh and default exceptions
Add check_cocci_parse.sh, which is a thin wrapper around
try_parse.sh. Add a default exceptions file, and use it in
check_cocci_parse.sh.
Part of 31919.
Diffstat (limited to 'scripts/coccinelle')
-rwxr-xr-x | scripts/coccinelle/check_cocci_parse.sh | 36 | ||||
-rw-r--r-- | scripts/coccinelle/exceptions.txt | 24 |
2 files changed, 60 insertions, 0 deletions
diff --git a/scripts/coccinelle/check_cocci_parse.sh b/scripts/coccinelle/check_cocci_parse.sh new file mode 100755 index 0000000000..a422a99dac --- /dev/null +++ b/scripts/coccinelle/check_cocci_parse.sh @@ -0,0 +1,36 @@ +#!/bin/sh + +# If we have coccinelle installed, run try_parse.sh on every filename passed +# as an argument. Uses the default coccinelle exceptions file, if +# $TOR_COCCI_EXCEPTIONS_FILE is not set. +# +# Use TOR_COCCI_EXCEPTIONS_FILE=/dev/null check_cocci_parse.sh to disable +# the default exception file. +# +# If spatch is not installed, remind the user to install it, but exit with +# a success error status. + +scripts_cocci="$(dirname "$0")" +top="$scripts_cocci/../.." +try_parse="$scripts_cocci/try_parse.sh" + +exitcode=0 + +export TOR_COCCI_EXCEPTIONS_FILE="${TOR_COCCI_EXCEPTIONS_FILE:-$scripts_cocci/exceptions.txt}" + +if ! command -v spatch; then + echo "Install coccinelle's spatch to check cocci C parsing!" + exit "$exitcode" +fi + +"$try_parse" "$@" +exitcode=$? + +if test "$exitcode" != 0 ; then + echo "Please fix these cocci parsing errors in the above files" + echo "Set VERBOSE=1 for more details" + echo "Try running test-operator-cleanup or 'make autostyle-operators'" + echo "As a last resort, you can modify scripts/coccinelle/exceptions.txt" +fi + +exit "$exitcode" diff --git a/scripts/coccinelle/exceptions.txt b/scripts/coccinelle/exceptions.txt new file mode 100644 index 0000000000..473f4b22c5 --- /dev/null +++ b/scripts/coccinelle/exceptions.txt @@ -0,0 +1,24 @@ +# A list of exception patterns for check_cocci_parse.sh +# Passed to 'grep -f' +src/lib/cc/compat_compiler.h +src/lib/container/handles.h +src/lib/container/map.c +src/lib/container/map.h +src/lib/container/order.c +src/lib/crypt_ops/crypto_rand.c +src/lib/fs/files.h +src/lib/log/util_bug.c +src/lib/pubsub/pubsub_macros.h +src/lib/smartlist_core/smartlist_foreach.h +src/lib/testsupport/testsupport.h +src/lib/tls/tortls.h +src/lib/tls/tortls_openssl.c +src/lib/tls/x509.h +src/lib/version/version.c +src/core/mainloop/connection.c +src/core/or/reasons.c +src/feature/dirclient/dirclient.c +src/feature/nodelist/networkstatus.c +src/test/test_address.c +src/test/test_hs_cache.c +src/test/test_hs_descriptor.c |