/* >>>------------------------------------------------------------ * * File: rule_14.1.c, Module: M2CM-3.2-QAC-8.1.2 * * RULE 14.1 (Required): * There shall be no unreachable code. * * Implemented by messages: * 594 Negative 'case' label expression is incompatible with * unsigned controlling expression in 'switch' statement. * * 1460 'Switch' label value, %s, not contained in enum type. * * 1503 The function '%1s' is defined but is not used within * this project. * * 2008 Code statements precede the first label in this 'switch' * construct. * * 2742 This 'if' controlling expression is a constant * expression and its value is 'false'. * * 2744 This 'while' or 'for' loop controlling expression is a * constant expression and its value is 'false'. The loop * will not be entered. * * 2880 This code is unreachable. * * 2882 This 'switch' statement will bypass the initialization * of local variables. * * 3219 Static function '%s()' is not used within this * translation unit. * * <<<------------------------------------------------------------ */ /* PRQA S 3205 ++ */ #include "misra.h" #include "m2cmex.h" #define LIMIT 10 static S32 test_1401b( void ); extern S16 test_1401( void ) { if ( s16a < 0 ) { if (s16a > 10) { /* MISRA Violation */ s16a = 10; } else { s16a = 5; } } if (s16b < 0) { s16b = 0; } if (s16b > 1) { s16b = 1; } switch( s16b ) { S16 m = 1; /* MISRA Violation */ s16c = 0; /* MISRA Violation */ case 0: s16c = 1; break; case 1: s16c = 10; break; default: s16c = 0; break; } while ( s16a > 10 ) { --s16a; break; ++s16c; /* MISRA Violation */ } while ( 0 ) { /* MISRA Violation */ ++s16a; } if ( LIMIT != 10 ) { /* MISRA Violation */ ++s16a; } return s16a + s16c; } extern void test_1401a( void ) /* MISRA Violation */ { } static S32 test_1401b( void ) /* MISRA Violation */ { return 0; }