TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags
[wireshark-sm.git] / tools / validate-clang-check.sh
blob2d295bcc7e23096e5bf9b8a3e3bde7c52d86d7c4
1 #!/bin/bash
2 # Copyright 2018, Alexis La Goutte (See AUTHORS file)
4 # Verifies last commit with clang-check (like scan-build) for Petri Dish
6 # Wireshark - Network traffic analyzer
7 # By Gerald Combs <gerald@wireshark.org>
8 # Copyright 1998 Gerald Combs
10 # SPDX-License-Identifier: GPL-2.0-or-later
13 COMMIT_FILES=$( git diff-index --cached --name-status HEAD^ | grep -v "^D" | cut -f2 | grep "\\.c$\|cpp$" )
14 CLANG_CHECK_CMD=clang-check
16 while getopts c: OPTCHAR
18 case $OPTCHAR in
20 CLANG_CHECK_CMD="clang-check-$OPTARG"
23 echo "Usage: $( basename "$0" ) [ -c <clang version> ]"
24 exit 0
25 esac
26 done
28 for FILE in $COMMIT_FILES; do
29 # Skip some special cases
30 FILE_BASENAME="$( basename "$FILE" )"
31 # If we don't have a build rule for this file, it's probably because we're missing
32 # necessary includes.
33 for BUILD_RULE_FILE in compile_commands.json build.ninja ; do
34 if [[ -f $BUILD_RULE_FILE ]] && ! grep "/$FILE_BASENAME\." $BUILD_RULE_FILE &> /dev/null ; then
35 echo "Don't know how to build $FILE_BASENAME. Skipping."
36 continue 2
38 done
39 # wsutil/file_util.c is Windows-only.
40 if test "$FILE_BASENAME" = "file_util.c"
41 then
42 continue
44 # iLBC: the file is not even compiled when ilbc is not installed
45 if test "$FILE_BASENAME" = "iLBCdecode.c"
46 then
47 continue
49 # This is a template file, not a final '.c' file.
50 if echo "$FILE_BASENAME" | grep -Eq "packet-.*-template.c"
51 then
52 continue
55 "$CLANG_CHECK_CMD" "../$FILE"
56 "$CLANG_CHECK_CMD" -analyze "../$FILE"
57 done