13-09-2011, 09:05 AM
Rule 13.5 requires that the second expression include testing the loop counter but it doesn't place any other requirements on the test. MISRA C does not require a "simple test" in the second expression. All 3 of your examples are therefore compliant with Rule 13.5.
The concept of a loop counter is not well defined. In order to assist in identifying loop counters, tools may impose restrictions on the loop and may report violations of this rule even though the code is compliant.
The concept of a loop counter is not well defined. In order to assist in identifying loop counters, tools may impose restrictions on the loop and may report violations of this rule even though the code is compliant.
Posted by and on behalf of the MISRA C Working Group