Skip to main content

IAR Embedded Workbench for RX 5.20

MISRAC++2008-0-3-2

In this section:
Synopsis

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

Enabled by default

Yes

Severity/Certainty

Medium/Medium

mediummedium.png
Full description

The return value for a library function that might return an error value is not used. This check is identical to LIB-return-error, MISRAC2004-16.10.

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.

Code examples

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

#include <stdlib.h>

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 = (int *)malloc(sizeof(int));  // OK - return value
                                 // is stored
}