MISRA Discussion Forums
Rule 15.5 - Printable Version

+- MISRA Discussion Forums (https://forum.misra.org.uk)
+-- Forum: MISRA C (https://forum.misra.org.uk/forumdisplay.php?fid=4)
+--- Forum: MISRA C:2012 and MISRA C:2023 guidelines (https://forum.misra.org.uk/forumdisplay.php?fid=21)
+---- Forum: 8.15 Control flow (https://forum.misra.org.uk/forumdisplay.php?fid=170)
+---- Thread: Rule 15.5 (/showthread.php?tid=1098)



Rule 15.5 - Mandar_Pitale - 13-08-2014

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?


Re: Rule 15.5 - Andrew Banks - 14-08-2014

For cross-reference, originally discussed on LinkedIn ISO26262 group

http://lnkd.in/dJZd7FR


Re: Rule 15.5 - misra-c - 22-08-2014

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.


Re: Rule 15.5 - Mandar_Pitale - 22-08-2014

Thanks very much for the reply.