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

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

For example:


/*PRQA S 2017,2462,3120,3227,3408 ++*/


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

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

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

    for (k - 0; k < 10; ++k)                    /* Message 3419 */
    {
    }

    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