Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rule 15.4 - no boolean switch expressions
#2
Rule 15.4 relates to the effective type of the controlling expression of the switch statement. The intent is to identify a switch statement that can have only two possible cases. Such switch statements are unusual and may be indicative of a programming error. The same effect could be achieved more clearly using if ... else.

Since an enumerated type is not effectively Boolean, there is no violation of Rule 15.4 in this case.

The body of the switch statement contains at least one case clause so there is no violation of Rule 15.5 either.
Posted by and on behalf of the MISRA C Working Group
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 3 Guest(s)