JavaScript is not currently enabled, but is required for full CodeSonar manual search and browse functionality.

If you are viewing this file in your hub's Web GUI, enable JavaScript in your browser: you will also need it for GUI functionality.

If you opened this file directly from disk, your browser may be directly suppressing JavaScript functionality: certain browsers perform this suppression on local files (but not files delivered by web servers) for security reasons.

CodeSonar® 9.2p0 CONFIDENTIAL CodeSecure Inc
C and C++


LANG.STRUCT.EBS : Empty {Branch, for, if, switch, while} Statement

Summary

A conditional statement has only empty or nonexistent branch bodies. (Bodies may have some syntactic content, but are "semantically empty".)

Properties

Multiple warning classes share this mnemonic.

Checks for all these warning classes are enabled by default. To disable them all at once, add the following WARNING_FILTER rule to the project configuration file.

WARNING_FILTER += discard categories:LANG.STRUCT.EBS
Class Name Empty Branch Statement
Significance redundancy
Mnemonic LANG.STRUCT.EBS
Categories
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
Availability Available for C and C++.
Enabling Checks for this warning class are enabled by default. To disable them, add the following WARNING_FILTER rule to the project configuration file.
WARNING_FILTER += discard class="Empty Branch Statement"
Class Name Empty for Statement
Significance redundancy
Mnemonic LANG.STRUCT.EBS
Categories
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
Availability Available for C and C++.
Enabling Checks for this warning class are enabled by default. To disable them, add the following WARNING_FILTER rule to the project configuration file.
WARNING_FILTER += discard class="Empty for Statement"
Class Name Empty if Statement
Significance redundancy
Mnemonic LANG.STRUCT.EBS
Categories
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
Availability Available for C and C++.
Enabling Checks for this warning class are enabled by default. To disable them, add the following WARNING_FILTER rule to the project configuration file.
WARNING_FILTER += discard class="Empty if Statement"
Class Name Empty switch Statement
Significance redundancy
Mnemonic LANG.STRUCT.EBS
Categories
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
Availability Available for C and C++.
Enabling Checks for this warning class are enabled by default. To disable them, add the following WARNING_FILTER rule to the project configuration file.
WARNING_FILTER += discard class="Empty switch Statement"
Class Name Empty while Statement
Significance redundancy
Mnemonic LANG.STRUCT.EBS
Categories
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
Availability Available for C and C++.
Enabling Checks for this warning class are enabled by default. To disable them, add the following WARNING_FILTER rule to the project configuration file.
WARNING_FILTER += discard class="Empty while Statement"

Example

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(a);   /* 'Empty switch Statement' warning issued here */

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

    for(;;);     /* 'Empty for Statement' warning issued here */
        x++;

    return x;
}

Relevant Configuration File Parameters

The following configuration file parameters affect checks for this warning class.

 

To report problems with this documentation, please visit https://support.codesecure.com/.