![]() |
![]() |
0735 | ![]() |
||||
![]() | |||||||
| Switch statements | |||||||
This switch statement has a controlling expression which is effectively Boolean - i.e. it will evaluate to either 0 or 1. This is probably a mistake. For example:
/*PRQA S 2017 ++*/
/*PRQA S 2002,2017,3227,3408,3447 ++*/
extern int x;
void foo(int option, int pick)
{
switch (option == pick) /* Message 0735 */
{
case 0:
++x;
break;
case 1:
x = 0;
break;
}
}
MISRA C:2012 Rules applicable to message 0735:
| Rule-16.7 (Required) | A switch-expression shall not have essentially Boolean type |
![]() | ||
| 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 |