MISRAC2012-Rule-16.6
In this section:
Synopsis
(Required) Every switch statement shall have at least two switch-clauses
Enabled by default
Yes
Severity/Certainty
Low/Medium

Full description
Switch statements without case clauses were found.
Coding standards
- MISRA C:2012 Rule-16.6
(Required) Every switch statement shall have at least two switch-clauses
Code examples
The following code example fails the check and will give a warning:
int example(int x) {
switch(x){
default:
return 2;
break;
}
}
The following code example passes the check and will not give a warning about this issue:
int example(int x) {
switch(x){
case 3:
return 0;
break;
case 5:
return 1;
break;
default:
return 2;
break;
}
}