MISRA.SWITCH.WELL_FORMED.TWO_CLAUSES.2012Every switch statement shall have at least two switch-clauses.
MISRA C 2012 Rule 16.6: Every switch statement shall have at least two switch-clausesCategory: Required Analysis: Decidable, Single Translation Unit Applies to: C90, C99 RationaleA switch statement with a single path is redundant and may be indicative of a programming error.Exampleswitch ( x ) { default: /* Non-compliant - switch is redundant */ x = 0; break; } switch ( y ) { case 1: default: /* Non-compliant - switch is redundant */ y = 0; break; } switch ( z ) { case 1: z = 2; break; default: /* Compliant */ z = 0; break; } See alsoRule 16.1 |