MISRAC2004-14.7
In this section:
Synopsis
(Required) A function shall have a single point of exit at the end of the function.
Enabled by default
Yes
Severity/Certainty
Low/Medium

Full description
More than one point of exit was found in a function, or an exit point before the end of the function. This check is identical to MISRAC++2008-6-6-5, MISRAC2012-Rule-15.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;
}
}