TICS Coding Standard Viewer 
TIOBE Software Quality Framework
Print-friendly version
©TIOBE Software www.tiobe.com
 
ASML C Coding Standard
Search

Rule:  6.8.4.2.cChecked automatically with code checker

Synopsis:Each non empty case clause and default clause shall end with a break statement.
Language:C
Severity Level:2
Category:Statement and Blocks


Description:

Justification

Allowing "case" clauses to fall-through into each other is a confusing practice - if two (or more) clauses share common tail code, that should be made explicit by making the tail code a function and calling it from each of the clauses that requires it.

Example 1

switch (trigger)
{
case 1:
case 2:
   /* do something */
   break; /* RIGHT */
default: /* WRONG */
}

Example 2

switch (trigger)
{
case 4:
   i = 10; /* WRONG */
case 5:
default:
   break;
}