Menu

MISRA Rule 16.3 Not Detected

Amir
2020-12-15
2021-01-05
  • Amir

    Amir - 2020-12-15

    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

     
  • Georgiy Komarov

    Georgiy Komarov - 2020-12-15

    Hello, Amir,

    Thanks for the report. I created a ticket: https://trac.cppcheck.net/ticket/10036

     
  • Jean-Loic MARTIN

    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 ?

     
    • Amir

      Amir - 2021-01-05

      You're right, my mistake. Fall through cases are allowed according to MISRA. You can disregard this.

       
  • Daniel Marjamäki

    ok thanks! I close 10036 then

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.