[previous] 0769 [next] A 'break' statement has been used to terminate an iteration statement.
Control flow

A break statement has been used to terminate an iteration statement, i.e. a while, do ... while or for statement. If multiple break statements are used within the same iteration statement, the code can become dangerously unstructured.

For example:


/*PRQA S 2017,3408,3447 ++*/


extern int x;
extern int y;
extern int z;

extern void foo(int n)
{
    while (n > 0)
    {
        --n;
        if (n == x)
        {
            break;                      /* Message 0769 */
        }
        if (n == y)
        {
            break;                      /* Message 0771 */
        }
        if (n == z)
        {
            break;                      /* Message 0771 */
        }
    }
}


No MISRA C:2012 Rules applicable to message 0769


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