Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Application of rule 14.10 for Autogenerated code
#1
I have recently received a question from a customer using our code generation tools (embedded coder).
The code that we generate for a block (saturate block) is like this:

Code:
rtB_out = something;
if(rtB_out > maxlim) {
   rtB_out = maxlim;
}
else {
   if(rtB_out < minlim) {
      rtB_out = minlim;
   }
}

The customer asked whether the code above was MISRA compliant, in particular with respect to rule 14.10.
It is an “
Code:
if ... else { if { ... } }
” construct and very close to the “
Code:
if ... else if ...
” construct as described in the rule 14.10.
However, it can be read as a simple if being the statement in an else clause.

Personally, I find the code quite readable as it is and it is easy to check that there is no path where rtB_out is not assigned a value.
Would you recommend to have a final else in this context?
<t></t>
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)