Skip to content

Commit e7c184b

Browse files
committed
Support different configurations based on C file use cases
1 parent be61714 commit e7c184b

File tree

1 file changed

+24
-14
lines changed

1 file changed

+24
-14
lines changed

tools/make/lib/lint/c/cppcheck.mk

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,18 @@
2121
# Define the file path for storing a list of package `include` paths:
2222
cppcheck_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:
2537
CPPCHECK_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
99109
else
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
105115
endif
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
135145
else
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
141151
endif
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
171181
else
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
177187
endif
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
207217
else
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
213223
endif
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
240250
else
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
246256
endif
247257

0 commit comments

Comments
 (0)