![]() |
![]() |
2467 | ![]() |
||||
![]() | |||||||
| Control flow | |||||||
The control variable in this loop construct is never modified. QAC attempts to identify a loop control variable when analysing for loops and while loops. Sometimes this is not possible because the concept of a loop control variable is not an intrinsic feature of the C language and loop control may depend on more than one variable. However in most situations, control of a loop is associated with a single local variable and it is important that modification of its value is clearly understood. In this loop, it appears that the loop control variable is not modified either in the control statement or in the body of the loop and so the loop could execute indefinitely. Is this intended ? For example:
/*PRQA S 1-9999 ++*/
/*PRQA S 2463, 2467, 2871, 2990 --*/
extern void foo(void)
{
int i = 10;
int j;
for (j = 0; j < 10; ++i ) /* Message 2463 + 2871 + 2990 */
{
} /* Message 2467 */
}
MISRA C:2012 Rules applicable to message 2467:
| Rule-14.2 (Required) | A for loop shall be well-formed |
See also:
![]() | ||
| 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 |