Skip to content

Commit 64d617f

Browse files
committed
Tweak Cppcheck suppression and use build directory
Cppcheck is under active development and its command-line options can change. This commit updates the suppression list to work with versions 1.9 through 2.6. Additionally, while using a build directory for Cppcheck is optional, it is recommended to store analyzer output in a dedicated directory. Change-Id: I0a3043332661e7b4dc32dadf896cb4792774cdcd
1 parent a30f81a commit 64d617f

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ qtest
66
.devcontainer
77
core*
88
.cmd_history
9+
.out
910

1011
# ctags files
1112
TAGS

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ clean:
8282
(cd traces; rm -f *~)
8383

8484
distclean: clean
85-
rm -f .cmd_history
85+
-rm -f .cmd_history
86+
-rm -rf .out
8687

8788
-include $(deps)

scripts/pre-commit.hook

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,32 @@ done
88
# We suppress the checkLevelNormal warning for Cppcheck versions 2.11 and above.
99
# Please refer to issues/153 for more details.
1010
CPPCHECK_suppresses="--inline-suppr harness.c \
11+
--suppress=unmatchedSuppression \
12+
--suppress=normalCheckLevelMaxBranches \
1113
--suppress=missingIncludeSystem \
1214
--suppress=noValidConfiguration \
1315
--suppress=unusedFunction \
1416
--suppress=identicalInnerCondition:log2_lshift16.h \
1517
--suppress=nullPointerRedundantCheck:report.c \
1618
--suppress=nullPointerRedundantCheck:harness.c \
19+
--suppress=nullPointerOutOfMemory:harness.c \
20+
--suppress=staticFunction:harness.c \
21+
--suppress=nullPointerRedundantCheck:queue.c \
22+
--suppress=constParameterPointer:queue.c \
1723
--suppress=nullPointer:queue.c \
1824
--suppress=nullPointer:qtest.c \
1925
--suppress=returnDanglingLifetime:report.c \
2026
--suppress=constParameterCallback:console.c \
2127
--suppress=constParameterPointer:console.c \
28+
--suppress=staticFunction:console.c \
2229
--suppress=checkLevelNormal:log2_lshift16.h \
2330
--suppress=preprocessorErrorDirective:random.h \
31+
--suppress=constVariablePointer:linenoise.c \
32+
--suppress=staticFunction:linenoise.c \
33+
--suppress=nullPointerOutOfMemory:web.c \
34+
--suppress=staticFunction:web.c \
2435
"
25-
CPPCHECK_OPTS="-I. --enable=all --error-exitcode=1 --force $CPPCHECK_suppresses $CPPCHECK_unmatched ."
36+
CPPCHECK_OPTS="-I. --enable=all --error-exitcode=1 --force $CPPCHECK_suppresses $CPPCHECK_unmatched --cppcheck-build-dir=.out ."
2637

2738
RETURN=0
2839
CLANG_FORMAT=$(which clang-format)
@@ -32,6 +43,7 @@ if [ $? -ne 0 ]; then
3243
fi
3344

3445
CPPCHECK=$(which cppcheck)
46+
mkdir -p .out
3547
if [ $? -ne 0 ]; then
3648
echo "[!] cppcheck not installed. Unable to perform static analysis." >&2
3749
exit 1
@@ -127,6 +139,7 @@ do
127139
done
128140

129141
# static analysis
142+
echo "Running static analysis..."
130143
$CPPCHECK $CPPCHECK_OPTS >/dev/null
131144
if [ $? -ne 0 ]; then
132145
RETURN=1

0 commit comments

Comments
 (0)