2016-12-09 64 views
3

--suppress=unmatchedSuppressionは、cppcheckオプションで不一致の抑制タイプのみを抑制しますが、比類のないインライン抑制は抑制しません。cppcheckインライン非適合抑制を抑制する方法は?

これは予期された動作ですか?

test.cの

  • 4行目は間違っています。 arrayIndexOutOfBounds

  • ライン7は大丈夫です。私が両方のラインのインラインcppcheck-suppressを持って

arrayIndexOutOfBoundsを警告してはいけません。

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 } 

コードに存在しない状況1

抑制cstyleCast、。

cppcheck --inline-suppr --force --enable=all 
      --xml-version=2 --suppress=cstyleCast test.c 
      2>cppcheckresults.xml 

私は

  1. unmatchedSuppression: arrayIndexOutOfBoundsに(他の無関係な警告の中で)について警告を受けるtest.cline 7(予想通り)

  2. unmatchedSuppression: cstyleCast*line 0(予想通り)

状況1と同じですが、追加の--suppress=unmatchedSuppressionオプション

cppcheck --inline-suppr --force --enable=all 
      --xml-version=2 --suppress=cstyleCast --suppress=unmatchedSuppressiontest.c 
      2>cppcheckresults.xml 

私は両方以前unmatchedSuppression警告が離れて行くことを期待して状況。しかし、私はまだ取得中

  1. unmatchedSuppressiontest.cline 7(予想NOT)

答えて

1

私は最近見つかったことは、インライン抑止からunmatchedSuppression警告がジェネリック--suppress=unmatchedSuppressionによって抑制またはちょうどその警告IDを置くことができないということです--suppressions-listファイルにあります。ファイル名で修飾する必要があります。例えば、--suppress=unmatchedSuppression:test.c