[previous] 2467 [next] Loop control variable, %s, is not modified inside loop.
Control flow

The control variable in this loop construct is never modified.

QA·C 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 */
}

See also:

QA·C Source Code Analyser 8.1.2
© 2013 Programming Research.
www.programmingresearch.com
Personality Groups | Glossary | Message Index Contents