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
intest.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
intest.c
line 7
(NOT expected)
unmatchedSuppression:test.c
" instead of "unmatchedSuppressiontest.c
"? – Plotinus