Main Content
MISRA C:2023 Rule 15.5
Description
Rule Definition
A function should have a single point of exit at the end.
Rationale
This rule requires that a return
statement
must occur as the last statement in the function body. Otherwise,
the following issues can occur:
Code following a
return
statement can be unintentionally omitted.If a function that modifies some of its arguments has early
return
statements, when reading the code, it is not immediately clear which modifications actually occur.
Troubleshooting
If you expect a rule violation but do not see it, refer to Diagnose Why Coding Standard Violations Do Not Appear as Expected.
Examples
Check Information
Group: Control Flow |
Category: Advisory |
AGC Category: Advisory |