Skip to main content

IAR Embedded Workbench for Arm 9.70.x

MISRAC2004-16.10

In this section:
Synopsis

(Required) If a function returns error information, then that error information shall be tested.

Enabled by default

Yes

Severity/Certainty

Medium/Medium

mediummedium.png
Full description

A return value for a library function that might return an error value is not used. This check is identical to LIB-return-error, MISRAC++2008-0-3-2.

Coding standards
CWE 252

Unchecked Return Value

CWE 394

Unexpected Status Code or Return Value

MISRA C:2004 16.10

(Required) If a function returns error information, then that error information shall be tested.

MISRA C++ 2008 0-3-2

(Required) If a function generates error information, then that error information shall be tested.

Code examples

The following code example fails the check and will give a warning:

void example(void) {
  malloc(sizeof(int));  // This function could fail,
                        // and the return value is
                        // not checked
}

The following code example passes the check and will not give a warning about this issue:

#include <stdlib.h>

void example(void) {
  int *x = malloc(sizeof(int));  // OK - return value
                                 // is stored
}