MISRAC2012-Rule-15.5
In this section:
Synopsis
(Advisory) A function should have a single point of exit at the end
Enabled by default
No
Severity/Certainty
Low/Medium

Full description
One or more functions have multiple exit points or an exit point that is not at the end of the function. This check is identical to MISRAC2004-14.7, MISRAC++2008-6-6-5.
Coding standards
- MISRA C:2004 14.7
(Required) A function shall have a single point of exit at the end of the function.
- MISRA C:2012 Rule-15.5
(Advisory) A function should have a single point of exit at the end
- MISRA C++ 2008 6-6-5
(Required) A function shall have a single point of exit at the end of the function.
Code examples
The following code example fails the check and will give a warning:
extern int errno;
void example(void) {
if (errno) {
return;
}
return;
}
The following code example passes the check and will not give a warning about this issue:
extern int errno;
void example(void) {
if (errno) {
goto end;
}
end:
{
return;
}
}