tomato/other/analysis/run-cppcheck

47 lines
1.5 KiB
Plaintext
Raw Normal View History

#!/bin/bash
SKIP_GTEST=1
. other/analysis/gen-file.sh
set -e
CPPCHECK=("--enable=all")
CPPCHECK+=("--inconclusive")
CPPCHECK+=("--error-exitcode=1")
# Used for VLA.
CPPCHECK+=("--suppress=allocaCalled")
# False positives in switch statements.
CPPCHECK+=("--suppress=knownConditionTrueFalse")
# Cppcheck does not need standard library headers to get proper results.
CPPCHECK+=("--suppress=missingIncludeSystem")
# TODO(iphydf): Maybe fix?
CPPCHECK+=("--suppress=signConversion")
# TODO(iphydf): Fixed in the toxav refactor PR.
CPPCHECK+=("--suppress=redundantAssignment")
# We have some redundant nullptr checks in assertions
CPPCHECK+=("--suppress=nullPointerRedundantCheck")
# Triggers a false warning in group.c
CPPCHECK+=("--suppress=AssignmentAddressToInteger")
# TODO(sudden6): This triggers a false positive, check again later to enable it
CPPCHECK+=("--suppress=arrayIndexOutOfBoundsCond")
# We're a library. This only works on whole programs.
CPPCHECK_C=("--suppress=unusedFunction")
# False positive in auto_tests.
CPPCHECK_CXX+=("--suppress=shadowArgument")
CPPCHECK_CXX+=("--suppress=shadowFunction")
# False positive for callback functions
CPPCHECK_CXX+=("--suppress=constParameter")
# Used in Messenger.c for a static_assert(...)
CPPCHECK_CXX+=("--suppress=sizeofFunctionCall")
run() {
echo "Running cppcheck in variant '$*'"
cppcheck "${CPPCHECK[@]}" "${CPPCHECK_C[@]}" tox*/*.[ch] tox*/*/*.[ch] "${CPPFLAGS[@]}" "$@"
cppcheck "${CPPCHECK[@]}" "${CPPCHECK_CXX[@]}" amalgamation.cc "${CPPFLAGS[@]}" "$@"
}
. other/analysis/variants.sh