I found that --suppress=unmatchedSuppression
only suppresses unmatched suppression types in cppcheck options, but NOT unmatched inline suppressions.
Is this the expected behavior?
test.c
Line 4 is wrong. It should be warned arrayIndexOutOfBounds
Line 7 is okay. It should NOT be warned arrayIndexOutOfBounds
I have inline cppcheck-suppress
for both lines.
1 void f() {
2 char arr[5];
3 // cppcheck-suppress arrayIndexOutOfBounds
4 arr[10] = 0;
5
6 // cppcheck-suppress arrayIndexOutOfBounds
7 const char ok[] = "this line is ok";
8 }
Situation 1
Suppress cstyleCast
, which does NOT exist in code.
cppcheck --inline-suppr --force --enable=all
--xml-version=2 --suppress=cstyleCast test.c
2>cppcheckresults.xml
I get warned about (among other irrelevant warnings)
unmatchedSuppression: arrayIndexOutOfBounds
in test.c
line 7
(as expected)
unmatchedSuppression: cstyleCast
in *
line 0
(as expected)
Situation 2
Same as situation 1, but with additional --suppress=unmatchedSuppression
option
cppcheck --inline-suppr --force --enable=all
--xml-version=2 --suppress=cstyleCast --suppress=unmatchedSuppressiontest.c
2>cppcheckresults.xml
I expect both previous unmatchedSuppression
warnings to go away. But I still get
unmatchedSuppression
in test.c
line 7
(NOT expected)What I recently found is that an unmatchedSuppression
warning from inline suppressions cannot be suppressed by a generic --suppress=unmatchedSuppression
or putting just that warning ID in a --suppressions-list
file. You have to qualify it with the filename. For example --suppress=unmatchedSuppression:test.c
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With