MISRA.ITER.ONETERMIteration statement has more than one break or goto for loop termination. MISRA-C Rule 14.6 (required): For any iteration statement there shall be at most one break statement used for loop termination.These rules are in the interests of good structured programming. One break statement is allowed in a loop since this allows, for example, for dual outcome loops or for optimal coding. MISRA-C++ Rule 6-6-4 (required): For any iteration statement there shall be no more than one break or goto statement used for loop termination.RationaleRestricting the number of exits from a loop is done in the interests of good structured programming. One break or goto statement is acceptable in a loop since this allows, for example, for dual outcome loops or optimal coding. Examplefor ( int32_t i = 0; i < 10; i++ ) { if ( ... ) { break; // Compliant } } while ( ... ) { if ( ... ) { break; // Compliant } } for ( int32_t i = 0; i < 10; i++ ) { if ( ... ) { break; } else if ( ... ) { break; // Non-compliant — second jump from loop } else { ... } } while ( ... ) { if ( ... ) { break; } if ( ... ) { break; // Non-compliant — second jump from loop } } |