Skip to main content

IAR Embedded Workbench for RISC-V 3.40

MISRAC++2008-6-6-5

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

lowmedium.png
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, 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

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;
	}
}