2018-11-02 10:31:12 +00:00
|
|
|
#!/bin/sh
|
|
|
|
# Copyright 2018, Alexis La Goutte (See AUTHORS file)
|
|
|
|
#
|
|
|
|
# Verifies last commit with clang-check (like scan-build) for Petri Dish
|
|
|
|
#
|
|
|
|
# Wireshark - Network traffic analyzer
|
|
|
|
# By Gerald Combs <gerald@wireshark.org>
|
|
|
|
# Copyright 1998 Gerald Combs
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
#
|
|
|
|
|
|
|
|
COMMIT_FILES=$( git diff-index --cached --name-status HEAD^ | grep -v "^D" | cut -f2 | grep "\\.c$\|cpp$" )
|
2021-04-30 21:06:21 +00:00
|
|
|
CLANG_CHECK_CMD=clang-check
|
|
|
|
|
|
|
|
while getopts c: OPTCHAR
|
|
|
|
do
|
|
|
|
case $OPTCHAR in
|
|
|
|
c)
|
|
|
|
CLANG_CHECK_CMD="clang-check-$OPTARG"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Usage: $( basename "$0" ) [ -c <clang version> ]"
|
2021-09-01 06:46:22 +00:00
|
|
|
exit 0
|
2021-04-30 21:06:21 +00:00
|
|
|
esac
|
|
|
|
done
|
2018-11-02 10:31:12 +00:00
|
|
|
|
|
|
|
for FILE in $COMMIT_FILES; do
|
2020-12-28 12:45:41 +00:00
|
|
|
# Skip some special cases
|
2021-04-30 21:06:21 +00:00
|
|
|
FILE_BASENAME="$( basename "$FILE" )"
|
2020-12-28 12:45:41 +00:00
|
|
|
# iLBC: the file is not even compiled when ilbc is not installed
|
2021-12-22 10:18:07 +00:00
|
|
|
if test \( "$FILE_BASENAME" = "iLBCdecode.c" -o \
|
|
|
|
"$FILE_BASENAME" = "packet-PROTOABBREV.c" \)
|
2021-04-28 10:00:43 +00:00
|
|
|
then
|
|
|
|
continue
|
|
|
|
fi
|
2021-10-29 21:24:44 +00:00
|
|
|
# This is a template file, not a final '.c' file.
|
|
|
|
if test "$FILE_BASENAME" = "packet-asterix-template.c"
|
|
|
|
then
|
|
|
|
continue
|
|
|
|
fi
|
2021-01-11 18:45:24 +00:00
|
|
|
# extcap/{etwdump.c,etl.c,etw_message.c}: those compile, and are compiled,
|
|
|
|
# only on Windows
|
2021-09-23 10:39:11 +00:00
|
|
|
# The same applies to capture-wpcap.c
|
2021-01-11 18:45:24 +00:00
|
|
|
if test \( "$FILE_BASENAME" = "etwdump.c" -o \
|
|
|
|
"$FILE_BASENAME" = "etl.c" -o \
|
2021-09-23 10:39:11 +00:00
|
|
|
"$FILE_BASENAME" = "etw_message.c" -o \
|
|
|
|
"$FILE_BASENAME" = "capture-wpcap.c" \)
|
2021-04-28 10:00:43 +00:00
|
|
|
then
|
|
|
|
continue
|
|
|
|
fi
|
2018-11-02 10:31:12 +00:00
|
|
|
|
2021-04-30 21:06:21 +00:00
|
|
|
"$CLANG_CHECK_CMD" "../$FILE"
|
|
|
|
"$CLANG_CHECK_CMD" -analyze "../$FILE"
|
2018-11-02 10:31:12 +00:00
|
|
|
done
|