Hello,
I have the following code that cppcheck didn't detect an error for (MISRA Rule 16.3: An unconditional break statement shall terminate every switch-clause):
Hi Amir,
I'm not sure about your problem.
The MISRA 16.3 rules indicates that a break shall terminate every case and default.
But two or more consecutives case without code are allowed. So in your example, i didn't see any deviation to MISRA 16.3 rule.
The two consecutive break could be an error, but not regarding MISRA 16.3.
Could you explain where you expect a MISRA 16.3 deviation ?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
I have the following code that cppcheck didn't detect an error for (MISRA Rule 16.3: An unconditional break statement shall terminate every switch-clause):
typedef enum {
EAL_INIT,
EAL_SELF_TEST,
EAL_ON,
EAL_PRESHUTDOWN,
EAL_SHUTDOWN
}Eal_State_t;
void Asw_MainTaskManager(Eal_State_t ealSt)
{
switch(ealSt)
{
case EAL_INIT:
break;
case EAL_SELF_TEST:
break;
case EAL_SHUTDOWN:
case EAL_ON:
Asw_Manager(ealSt);
break;
case EAL_PRESHUTDOWN:
break;
break;
default:
break;
}
}
Regards,
Amir
Hello, Amir,
Thanks for the report. I created a ticket: https://trac.cppcheck.net/ticket/10036
Hi Amir,
I'm not sure about your problem.
The MISRA 16.3 rules indicates that a break shall terminate every case and default.
But two or more consecutives case without code are allowed. So in your example, i didn't see any deviation to MISRA 16.3 rule.
The two consecutive break could be an error, but not regarding MISRA 16.3.
Could you explain where you expect a MISRA 16.3 deviation ?
You're right, my mistake. Fall through cases are allowed according to MISRA. You can disregard this.
ok thanks! I close 10036 then