[previous] 2877 [next] This loop will never be executed more than once.
Control flow

This loop will only be executed once and so the loop mechanism is redundant. Has there been a mistake ?

For example:


/*PRQA S 2017,2465,2467,3120,3227,3408 ++*/
void foo(void)
{
    int i;
    
    for (i = 0; i < 1; ++i)             /* 2877 */
    {
    }
    

    i = 10;

    while (i <= 10)                     /* 2877 */
    {
        ++i;
    }
    
}


MISRA-C:2004 Rules applicable to message 2877:

Rule  21.1  (Required) Minimisation of run-time failures shall be ensured by the use of at least one of (a) static analysis tools/techniques; (b) dynamic analysis tools/techniques; (c) explicit coding of checks to handle run-time faults


QA·C Source Code Analyser 8.1
MISRA-C:2004 Compliance Module 3.2
© 2012 Programming Research.
www.programmingresearch.com
Personality Groups | Glossary | Message Index | MISRA-C:2004 Rule Index Contents