MISRA Discussion Forums

Full Version: Rule 15.5
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Rule 15.5 is "A function should have a single point of exit at the end".

The Rationale of this rule says:

Early returns may lead to the unintentional omission of function termination code.

1. What is "function termination code" in this context? Does it mean user defined C statements of the function or the function epilogue after the compilation?

2. If it is the function epilogue, then does it mean that when multiple exit points are used, then it MAY result in imbalanced context retrieval when the function returns, for some compilers?
For cross-reference, originally discussed on LinkedIn ISO26262 group

The statement refers to C statements written by the user. For example a function might intend to always free allocated space, close a file, or make some other change to the program state. This change is likely to have been coded at the end of the function and might not be reached if the function also has an earlier point of exit.
Thanks very much for the reply.