[previous] MISRA C:2012  Rule-16.4:  (Required) [next] Every switch statement shall have a default label

Amplification:

The switch-clause following the default label shall, prior to the terminating break statement, contain either:

Example Code:


#include "misra.h"
#include "m3cmex.h"

extern int16_t rule_1604( void )
{
   int16_t x = 0;

   switch ( s16a )
   {
   case 0:
      x = 2;
      break;
   case 1:
      x = 1;
      break;
   }                            /* 2002 */

   return x;
}


QAC messages that encompass this guideline:

2002 No 'default' label found in this 'switch' statement.



(c) The Motor Industry Research Association, 2012
QA C Source Code Analyser 8.1.2
MISRA C:2012 Compliance Module 1.0
© 2013 Programming Research
www.programmingresearch.com
Personality Groups | Glossary | Message Index | MISRA C:2012 Rule Index Contents