[previous] 3333 [next] A 'break' statement has been used in the middle of a 'switch' 'case'/'default' clause.
Control flow

This 'break' statement is breaking out of a 'switch' statement in an unstructured way.

'break' statements are an accepted and vital component in 'switch' statements when they occur as the final statement in a 'case' or 'default' clause. In this instance, the 'break' statement is not the final statement.

For example:


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

extern int g;

extern void foo(int n, int flag)
{
    switch(n)
    {
    case 1:
        ++g;
        break;                          /*              */

    case 2:
        if (flag == 0)
        {
            break;                      /* Message 3333 */
        }
        g = 10;
        break;                          /*              */

    default:
        g = 0;
        break;                          /*              */
    }
}


No MISRA C:2012 Rules applicable to message 3333


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