From e4ba6dbc3f1e76890b22773807ea37fe8fa2b1bc Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 10 Apr 2024 22:34:10 +0200 Subject: Adding upstream version 4.2.2. Signed-off-by: Daniel Baumann --- tools/validate-clang-check.sh | 57 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100755 tools/validate-clang-check.sh (limited to 'tools/validate-clang-check.sh') diff --git a/tools/validate-clang-check.sh b/tools/validate-clang-check.sh new file mode 100755 index 0000000..2d295bc --- /dev/null +++ b/tools/validate-clang-check.sh @@ -0,0 +1,57 @@ +#!/bin/bash +# 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 +# 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$" ) +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 ]" + exit 0 + esac +done + +for FILE in $COMMIT_FILES; do + # Skip some special cases + FILE_BASENAME="$( basename "$FILE" )" + # If we don't have a build rule for this file, it's probably because we're missing + # necessary includes. + for BUILD_RULE_FILE in compile_commands.json build.ninja ; do + if [[ -f $BUILD_RULE_FILE ]] && ! grep "/$FILE_BASENAME\." $BUILD_RULE_FILE &> /dev/null ; then + echo "Don't know how to build $FILE_BASENAME. Skipping." + continue 2 + fi + done + # wsutil/file_util.c is Windows-only. + if test "$FILE_BASENAME" = "file_util.c" + then + continue + fi + # iLBC: the file is not even compiled when ilbc is not installed + if test "$FILE_BASENAME" = "iLBCdecode.c" + then + continue + fi + # This is a template file, not a final '.c' file. + if echo "$FILE_BASENAME" | grep -Eq "packet-.*-template.c" + then + continue + fi + + "$CLANG_CHECK_CMD" "../$FILE" + "$CLANG_CHECK_CMD" -analyze "../$FILE" +done -- cgit v1.2.3