13-11-2017, 11:04 AM
An example of a compliant switch statement is:
Other compliant examples can be seen in the example sections of rules 16.4, 16.5, and 16.6 in the MISRA C:2012 guidelines.
Code:
typedef signed char int8_t;
extern void use_int8(int8_t i);
void R_16_1 ( int8_t input )
{
switch ( input )
{
case 0:
{
use_int8 ( input );
break;
}
case 1:
/* { .. } not required at this level */
use_int8 ( -input );
break;
default:
{
use_int8 ( 0 );
break;
}
}
}
Posted by and on behalf of the MISRA C Working Group