2019-09-12 00:44:10 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# Echo the name of every argument of this script that is not "perfect"
|
|
|
|
# according to coccinelle's --parse-c.
|
2019-10-23 07:37:20 +02:00
|
|
|
#
|
|
|
|
# If $TOR_COCCI_EXCEPTIONS_FILE is non-empty, skip any files that match the
|
|
|
|
# patterns in the exception file, according to "grep -f"
|
|
|
|
#
|
|
|
|
# If VERBOSE is non-empty, log spatch errors and skipped files.
|
2019-09-12 00:44:10 +02:00
|
|
|
|
|
|
|
top="$(dirname "$0")/../.."
|
|
|
|
|
2019-10-09 15:31:10 +02:00
|
|
|
exitcode=0
|
|
|
|
|
2019-09-12 00:44:10 +02:00
|
|
|
for fn in "$@"; do
|
|
|
|
|
2019-10-23 07:37:20 +02:00
|
|
|
if test "${TOR_COCCI_EXCEPTIONS_FILE}" ; then
|
|
|
|
skip_fn=$(echo "$fn" | grep -f "${TOR_COCCI_EXCEPTIONS_FILE}")
|
|
|
|
if test "${skip_fn}" ; then
|
|
|
|
if test "${VERBOSE}" != ""; then
|
|
|
|
echo "Skipping '${skip_fn}'"
|
|
|
|
fi
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2019-10-24 03:34:28 +02:00
|
|
|
if spatch --macro-file-builtins \
|
|
|
|
"$top"/scripts/coccinelle/tor-coccinelle.h \
|
|
|
|
--defined COCCI \
|
2019-10-09 16:07:50 +02:00
|
|
|
--parse-c "$fn" \
|
2019-09-12 00:44:10 +02:00
|
|
|
2>/dev/null | grep "perfect = 1" > /dev/null; then
|
|
|
|
: # it's perfect
|
|
|
|
else
|
|
|
|
echo "$fn"
|
2019-10-09 15:31:10 +02:00
|
|
|
if test "${VERBOSE}" != ""; then
|
2019-10-24 03:34:28 +02:00
|
|
|
spatch --macro-file-builtins \
|
|
|
|
"$top"/scripts/coccinelle/tor-coccinelle.h \
|
|
|
|
--defined COCCI \
|
2019-10-09 16:07:50 +02:00
|
|
|
--parse-c "$fn"
|
2019-10-09 15:31:10 +02:00
|
|
|
fi
|
|
|
|
exitcode=1
|
2019-09-12 00:44:10 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
done
|
2019-10-09 15:31:10 +02:00
|
|
|
|
|
|
|
exit "$exitcode"
|