For loop increment expression does not change loop counter.
MISRA-C Rule 13.5 (required): The three expressions of a for statement shall be concerned only with loop control.
This rule is also covered by MISRA.FOR.COND.
The three expressions of a for statement shall be used only for these purposes:
- First expression Initialising the loop counter ('i' in the following example)
- Second expression Shall include testing the loop counter ('i'), and optionally other loop control variables ('flag')
- Third expression Increment or decrement of the loop counter ('i')
The following options are allowed:
- (a) All three expressions shall be present;
- (b) The second and third expressions shall be present with prior initialisation of the loop counter;
- (c) All three expressions shall be empty for a deliberate infinite loop.