[previous] 3420 [next] Increment expression of 'for' statement has no side effects.
Redundancy REFERENCE - ISO:C90-6.6.5.3 The for Statement

The third expression in this 'for' statement, the 'increment' expression, has no side effects. The expression is therefore completely redundant and is probably a coding mistake.

For example:


/*PRQA S 2017,2463,2469,3120,3227,3408,3600 ++*/


extern void foo(int n)
{
    int i;
    int j;
    int k;

    for (i = 0; i < 10; )
    {
        ++i;
    }

    for (j = 0; j < 10; +j)                     /* Message 3420 */
    {
        ++j;
    }

    for (k = 0; k < 10; k)                      /* Message 3420 */
    {
        ++k;
    }

    n == 0;                                     /* Message 3112 */
}

See also:

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