![]() |
![]() |
2469 | ![]() |
||||
![]() | |||||||
| Control flow | |||||||
The variable identified as the control variable in this 'for' loop has been modified inside the body of the loop. QAC identifies a control variable by examining the 3 'for-loop' expressions. Usually it is a variable in the 2nd expression and is the operand of a relational operator. In a conventional for loop, the loop control variable is only modified in the 3rd expression of the for statement. Modification in other places within the loop is likely to cause confusion. For example:
/*PRQA S 2017 ++*/
/*PRQA S 2017,3120,3199,3408 ++*/
extern void foo(void)
{
int j;
for (j = 0; j < 10; j++ )
{
++j; /* Message 2469 */
}
}
MISRA C:2012 Rules applicable to message 2469:
| Rule-14.2 (Required) | A for loop shall be well-formed |
![]() | ||
| QA·C Source Code Analyser 8.1
MISRA C:2012 Compliance Module 1.0 © 2012 Programming Research. www.programmingresearch.com | Personality Groups | Glossary | Message Index | MISRA C:2012 Rule Index | Contents |