Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rule 15.2: MISRA warning is not generated
#1
Hi All,

The Rule 15.2 says:
"An unconditional break statement shall terminate every non-empty switch clause"
i.e. The last statement in every switch clause shall be a break statement, or if the switch clause is a compound statement, then the last statement in the compound statement shall be a break statement.

I understand this as:
"In a switch clause, whatever be the path traversed by the code, there shall be one break statement at the end of every path"

In a project I have the following code for which I am not getting any MISRA warning (for case 1). If my understanding is incorrect, then somebody please correct me.

Code:
switch (variable_1)
{
  case 0:
    {
        // some code here;
        break;
    }
  case 1:
    {
        // some code here;
        if (variable_2 == 0)
        {
            break;
        }
    }
    default:
        break;
}

Best Regards,
Vinay Vastrad
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)