Skip to main content

IAR Embedded Workbench for RH850 3.20.x

CERT-EXP37-C_c

In this section:
Synopsis

Call functions with the correct number and type of arguments.

Enabled by default

Yes

Severity/Certainty

Medium/Medium

mediummedium.png
Full description

Do not call a function with the wrong number or type of arguments. Undefined behavior (UB) may arise as a result of invoking a function using a declaration that is incompatible with its definition or by supplying incorrect types or numbers of arguments.

Coding standards
CERT EXP37-C

Call functions with the arguments intended by the API

Code examples

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

#include "fcntl.h"

void func(const char *ms) {
  /* ... */
  int fd;
  fd = open(ms, O_CREAT | O_EXCL | O_WRONLY | O_TRUNC);
  if (fd == -1) {
    /* Handle error */
  }
}

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

#include "fcntl.h"

void func(const char *ms, mode_t perms) {
  /* ... */
  int fd;
  fd = open(ms, O_CREAT | O_EXCL | O_WRONLY | O_TRUNC, perms);
  if (fd == -1) {
    /* Handle error */
  }
}