/* >>>------------------------------------------------------------ * * File: rule_14.9.c, Module: M2CM-3.2-QAC-8.1.2 * * RULE 14.9 (Required): * An if (expression) construct shall be followed by a compound * statement. The else keyword shall be followed by either a * compound statement, or another if statement. * * Implemented by messages: * 2212 Body of control statement is not enclosed within braces. * * 2214 Body of control statement is on the same line and is not * enclosed within braces. * * 3402 Braces are needed to clarify the structure of this * 'if'-'if'-'else' statement. * * <<<------------------------------------------------------------ */ #include "misra.h" #include "m2cmex.h" extern S16 test_1409( void ) { S16 n = 0; if ( s16a == 0 ) { s16c += 4; } else if ( s16a == 1 ) { if ( s16b > 1 ) { ++s16b; } } else { ++s16c; } if ( s16b == 2 ) s16c += 3; /* MISRA Violation */ else n = 2; /* MISRA Violation */ if ( s16b == 5 ) n = 6; /* MISRA Violation */ else n = n - s16a; /* MISRA Violation */ if ( n > 5 ) if ( s16b > 10 ) /* MISRA Violation */ { s16a = 1; } else { s16a = 2; } return s16a; }