2019-10-23 07:40:09 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# If we have coccinelle installed, run try_parse.sh on every filename passed
|
2019-10-23 14:17:37 +02:00
|
|
|
# as an argument. If no filenames are supplied, scan a standard Tor 0.3.5 or
|
|
|
|
# later directory layout.
|
|
|
|
#
|
|
|
|
# Uses the default coccinelle exceptions file, or $TOR_COCCI_EXCEPTIONS_FILE,
|
|
|
|
# if it is set.
|
2019-10-23 07:40:09 +02:00
|
|
|
#
|
|
|
|
# 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
|
|
|
|
|
2019-10-23 14:17:37 +02:00
|
|
|
if test $# -ge 1 ; then
|
|
|
|
"$try_parse" "$@"
|
|
|
|
exitcode=$?
|
|
|
|
else
|
2019-10-28 04:28:50 +01:00
|
|
|
cd "$top" || exit 1
|
2019-10-23 14:17:37 +02:00
|
|
|
# This is the layout in 0.3.5
|
|
|
|
"$try_parse" \
|
|
|
|
src/lib/*/*.[ch] \
|
|
|
|
src/core/*/*.[ch] \
|
|
|
|
src/feature/*/*.[ch] \
|
|
|
|
src/app/*/*.[ch] \
|
|
|
|
src/test/*.[ch] \
|
|
|
|
src/test/*/*.[ch] \
|
|
|
|
src/tools/*.[ch]
|
|
|
|
exitcode=$?
|
|
|
|
fi
|
2019-10-23 07:40:09 +02:00
|
|
|
|
|
|
|
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"
|