![]() |
![]() |
2002 | ![]() |
||||
![]() | |||||||
| Switch statements | |||||||
This 'switch' statement does not contain a 'default' clause. This could be dangerous if the controlling expression has an unexpected value. For example:
/*PRQA S 2017,3120,3227,3408 ++*/
extern int foo(int n)
{
int r = 0;
switch (n)
{
case 1:
r = 5;
break;
case 3:
r = 10;
break;
case 5:
r = 20;
break;
} /* Message 2002 */
return r;
}
MISRA C:2012 Rules applicable to message 2002:
| Rule-16.4 (Required) | Every switch statement shall have a default label |
![]() | ||
| 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 |