Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

In this compliant solution, each sequence of statements following a case label ends with a break statement.:

Code Block
bgColor#CCCCFF
langc
enum WidgetEnum { WE_W, WE_X, WE_Y, WE_Z } widget_type;
widget_type = WE_X;

switch (widget_type) {
  case WE_W:
    /* ... */
    break;
  case WE_X:
    /* ... */
    break;
  case WE_Y: 
  case WE_Z:
    /* ... */
    break;
  default: /* can't happen */
	 /* Handle error condition */
}

...

Tool

Version

Checker

Description

Compass/ROSE

 

 

 

Coverity

Include Page
Coverity_V
Coverity_V

MISSING_BREAK

Can find instances of missing break statement between cases in switch statement.

ECLAIR

Include Page
ECLAIR_V
ECLAIR_V

swchsynt

Fully implemented.

Related Vulnerabilities

Search for vulnerabilities resulting from the violation of this rule on the CERT website.

...