14-01-2013, 01:49 PM
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:
The customer asked whether the code above was MISRA compliant, in particular with respect to rule 14.10.
It is an Ҡconstruct and very close to the Ҡ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?
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 { ... } }
Code:
if ... else if ...
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>