2121# Define the file path for storing a list of package `include` paths:
2222cppcheck_include_paths := $(TMP_DIR ) /__tmp_cppcheck_include_paths__.txt
2323
24+ # Define the path to a list of warnings to suppress:
25+ CPPCHECK_SUPPRESSIONS_LIST ?= $(CONFIG_DIR ) /cppcheck/suppressions.txt
26+
27+ # Define the path to a list of warnings to suppress for examples:
28+ CPPCHECK_SUPPRESSIONS_LIST_EXAMPLES ?= $(CONFIG_DIR ) /cppcheck/suppressions.examples.txt
29+
30+ # Define the path to a list of warnings to suppress for benchmarks:
31+ CPPCHECK_SUPPRESSIONS_LIST_BENCHMARKS ?= $(CONFIG_DIR ) /cppcheck/suppressions.benchmarks.txt
32+
33+ # Define the path to a list of warnings to suppress for test fixtures:
34+ CPPCHECK_SUPPRESSIONS_LIST_TESTS_FIXTURES ?= $(CONFIG_DIR ) /cppcheck/suppressions.tests_fixtures.txt
35+
2436# Define the command-line options to use when invoking the cppcheck executable:
2537CPPCHECK_FLAGS ?= \
2638 --std=c99 \
@@ -29,10 +41,8 @@ CPPCHECK_FLAGS ?= \
2941 --includes-file=$(cppcheck_include_paths ) \
3042 --language=c \
3143 --error-exitcode=1 \
32- --suppress=duplicateExpression \
33- --suppress=missingIncludeSystem \
34- --suppress=unmatchedSuppression \
35- --suppress=variableScope
44+ --inline-suppr \
45+ --quiet
3646
3747
3848# RULES #
@@ -94,13 +104,13 @@ ifeq ($(FAIL_FAST), true)
94104 $(QUIET) $(FIND_C_SOURCES_CMD) | grep '^[\/]\|^[a-zA-Z]:[/\]' | while read -r file; do \
95105 echo ''; \
96106 echo "Linting file: $$file"; \
97- $(CPPCHECK) $(CPPCHECK_FLAGS) $$file || exit 1; \
107+ $(CPPCHECK) $(CPPCHECK_FLAGS) --suppressions-list=$(CPPCHECK_SUPPRESSIONS_LIST) $$file || exit 1; \
98108 done
99109else
100110 $(QUIET) $(FIND_C_SOURCES_CMD) | grep '^[\/]\|^[a-zA-Z]:[/\]' | while read -r file; do \
101111 echo ''; \
102112 echo "Linting file: $$file"; \
103- $(CPPCHECK) $(CPPCHECK_FLAGS) $$file || echo 'Linting failed.'; \
113+ $(CPPCHECK) $(CPPCHECK_FLAGS) --suppressions-list=$(CPPCHECK_SUPPRESSIONS_LIST) $$file || echo 'Linting failed.'; \
104114 done
105115endif
106116
@@ -130,13 +140,13 @@ ifeq ($(FAIL_FAST), true)
130140 $(QUIET) $(FIND_C_EXAMPLES_CMD) | grep '^[\/]\|^[a-zA-Z]:[/\]' | while read -r file; do \
131141 echo ''; \
132142 echo "Linting file: $$file"; \
133- $(CPPCHECK) $(CPPCHECK_FLAGS) $$file || exit 1; \
143+ $(CPPCHECK) $(CPPCHECK_FLAGS) --suppressions-list=$(CPPCHECK_SUPPRESSIONS_LIST_EXAMPLES) $$file || exit 1; \
134144 done
135145else
136146 $(QUIET) $(FIND_C_EXAMPLES_CMD) | grep '^[\/]\|^[a-zA-Z]:[/\]' | while read -r file; do \
137147 echo ''; \
138148 echo "Linting file: $$file"; \
139- $(CPPCHECK) $(CPPCHECK_FLAGS) $$file || echo 'Linting failed.'; \
149+ $(CPPCHECK) $(CPPCHECK_FLAGS) --suppressions-list=$(CPPCHECK_SUPPRESSIONS_LIST_EXAMPLES) $$file || echo 'Linting failed.'; \
140150 done
141151endif
142152
@@ -166,13 +176,13 @@ ifeq ($(FAIL_FAST), true)
166176 $(QUIET) $(FIND_C_BENCHMARKS_CMD) | grep '^[\/]\|^[a-zA-Z]:[/\]' | while read -r file; do \
167177 echo ''; \
168178 echo "Linting file: $$file"; \
169- $(CPPCHECK) $(CPPCHECK_FLAGS) $$file || exit 1; \
179+ $(CPPCHECK) $(CPPCHECK_FLAGS) --suppressions-list=$(CPPCHECK_SUPPRESSIONS_LIST_BENCHMARKS) $$file || exit 1; \
170180 done
171181else
172182 $(QUIET) $(FIND_C_BENCHMARKS_CMD) | grep '^[\/]\|^[a-zA-Z]:[/\]' | while read -r file; do \
173183 echo ''; \
174184 echo "Linting file: $$file"; \
175- $(CPPCHECK) $(CPPCHECK_FLAGS) $$file || echo 'Linting failed.'; \
185+ $(CPPCHECK) $(CPPCHECK_FLAGS) --suppressions-list=$(CPPCHECK_SUPPRESSIONS_LIST_BENCHMARKS) $$file || echo 'Linting failed.'; \
176186 done
177187endif
178188
@@ -202,13 +212,13 @@ ifeq ($(FAIL_FAST), true)
202212 $(QUIET) $(FIND_C_TESTS_FIXTURES_CMD) | grep '^[\/]\|^[a-zA-Z]:[/\]' | while read -r file; do \
203213 echo ''; \
204214 echo "Linting file: $$file"; \
205- $(CPPCHECK) $(CPPCHECK_FLAGS) $$file || exit 1; \
215+ $(CPPCHECK) $(CPPCHECK_FLAGS) --suppressions-list=$(CPPCHECK_SUPPRESSIONS_LIST_TESTS_FIXTURES) $$file || exit 1; \
206216 done
207217else
208218 $(QUIET) $(FIND_C_TESTS_FIXTURES_CMD) | grep '^[\/]\|^[a-zA-Z]:[/\]' | while read -r file; do \
209219 echo ''; \
210220 echo "Linting file: $$file"; \
211- $(CPPCHECK) $(CPPCHECK_FLAGS) $$file || echo 'Linting failed.'; \
221+ $(CPPCHECK) $(CPPCHECK_FLAGS) --suppressions-list=$(CPPCHECK_SUPPRESSIONS_LIST_TESTS_FIXTURES) $$file || echo 'Linting failed.'; \
212222 done
213223endif
214224
@@ -235,13 +245,13 @@ ifeq ($(FAIL_FAST), true)
235245 $(QUIET) for file in $(FILES); do \
236246 echo ''; \
237247 echo "Linting file: $$file"; \
238- $(CPPCHECK) $(CPPCHECK_FLAGS) $$file || exit 1; \
248+ $(CPPCHECK) $(CPPCHECK_FLAGS) --suppressions-list=$(CPPCHECK_SUPPRESSIONS_LIST) $$file || exit 1; \
239249 done
240250else
241251 $(QUIET) for file in $(FILES); do \
242252 echo ''; \
243253 echo "Linting file: $$file"; \
244- $(CPPCHECK) $(CPPCHECK_FLAGS) $$file || echo 'Linting failed.'; \
254+ $(CPPCHECK) $(CPPCHECK_FLAGS) --suppressions-list=$(CPPCHECK_SUPPRESSIONS_LIST) $$file || echo 'Linting failed.'; \
245255 done
246256endif
247257
0 commit comments