C and C++


LANG.STRUCT.EBS : 空の分岐命令

要旨

分岐命令の中身が、空もしくは意味のない実行文となっています。

プロパティ

複数のワーニングクラスでこのニーモニックを共有しています。

これら全てのワーニングクラスのチェックはデフォルトで 有効になっています。チェックを全て無効にするには、プロジェクト設定ファ イル(configuration file)に以下の WARNING_FILTER ルールを追加し てください。

WARNING_FILTER += discard categories:LANG.STRUCT.EBS
クラス名 Empty Branch Statement
日本語クラス名 空の分岐命令
クラス分類 冗長性 (redundancy)
ニーモニック LANG.STRUCT.EBS
カテゴリー
CERT-C CERT-C:EXP15-C Do not place a semicolon on the same line as an if, for, or while statement
  CERT-C:MSC12-C Detect and remove code that has no effect or is never executed
対応言語 C および C++ で利用可能です。
有効/無効設定 このワーニングクラスのチェックはデフォルトで有効になっています。チェックを無効にするにはプロジェクト設定ファイル (configuration file)に以下の WARNING_FILTER ルールを追加してください。
WARNING_FILTER += discard class="Empty Branch Statement"
クラス名 Empty for Statement
日本語クラス名 空のfor文
クラス分類 冗長性 (redundancy)
ニーモニック LANG.STRUCT.EBS
カテゴリー
CERT-C CERT-C:EXP15-C Do not place a semicolon on the same line as an if, for, or while statement
  CERT-C:MSC12-C Detect and remove code that has no effect or is never executed
対応言語 C および C++ で利用可能です。
有効/無効設定 このワーニングクラスのチェックはデフォルトで有効になっています。チェックを無効にするにはプロジェクト設定ファイル (configuration file)に以下の WARNING_FILTER ルールを追加してください。
WARNING_FILTER += discard class="Empty for Statement"
クラス名 Empty if Statement
日本語クラス名 空のif文
クラス分類 冗長性 (redundancy)
ニーモニック LANG.STRUCT.EBS
カテゴリー
CWE CWE:390 Detection of Error Condition Without Action
CERT-C CERT-C:EXP15-C Do not place a semicolon on the same line as an if, for, or while statement
  CERT-C:MSC12-C Detect and remove code that has no effect or is never executed
対応言語 C および C++ で利用可能です。
有効/無効設定 このワーニングクラスのチェックはデフォルトで有効になっています。チェックを無効にするにはプロジェクト設定ファイル (configuration file)に以下の WARNING_FILTER ルールを追加してください。
WARNING_FILTER += discard class="Empty if Statement"
クラス名 Empty switch Statement
日本語クラス名 空のswitch文
クラス分類 冗長性 (redundancy)
ニーモニック LANG.STRUCT.EBS
カテゴリー
CERT-C CERT-C:EXP15-C Do not place a semicolon on the same line as an if, for, or while statement
  CERT-C:MSC12-C Detect and remove code that has no effect or is never executed
対応言語 C および C++ で利用可能です。
有効/無効設定 このワーニングクラスのチェックはデフォルトで有効になっています。チェックを無効にするにはプロジェクト設定ファイル (configuration file)に以下の WARNING_FILTER ルールを追加してください。
WARNING_FILTER += discard class="Empty switch Statement"
クラス名 Empty while Statement
日本語クラス名 空のwhile文
クラス分類 冗長性 (redundancy)
ニーモニック LANG.STRUCT.EBS
カテゴリー
CERT-C CERT-C:EXP15-C Do not place a semicolon on the same line as an if, for, or while statement
  CERT-C:MSC12-C Detect and remove code that has no effect or is never executed
対応言語 C および C++ で利用可能です。
有効/無効設定 このワーニングクラスのチェックはデフォルトで有効になっています。チェックを無効にするにはプロジェクト設定ファイル (configuration file)に以下の WARNING_FILTER ルールを追加してください。
WARNING_FILTER += discard class="Empty while Statement"

int lang_struct_ebs(int a){
    int x = 1;
    if (a < 5);  /* 'Empty if Statement' warning issued here
                  * - semicolon means conditional has no effect
                  */
    {
        x = x+5;;
    }

    switch(123); // Empty switch Statement issued here

    while(0); // Empty while Statement issued here
        x++;

    for(;;); // Empty for Statement issued here
        x++;

    return x;
}

関連のある設定ファイルパラメータ

設定ファイルの以下のパラメータがこのワーニングクラスのチェックに影響します。