Synopsis: | All switch statements shall have a default clause, even if that clause is empty. |
Language: | C |
Severity Level: | 3 |
Category: | STATEMENTS |
Description: |
Defensive programming dictates that multiple choice constructs have a guard condition,
to trap "impossible" errors.
Example: switch( a ) { case 'a': case 'b': break; case 'c': j = 4; case 'd': } /* WRONG - no default clause */ Example: switch( a ) { case 'a': case 'b': break; case 'c': j = 4; case 'd': default: ; } /* RIGHT - default case */ |