CERT-EXP37-C_a
In this section:
Synopsis
Call functions with the correct number and type of arguments.
Enabled by default
Yes
Severity/Certainty
Medium/Medium

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 <stdio.h>
#include <string.h>
char *(*fp)() = strchr;
void example(void) {
const char *c;
fp = strchr;
c = fp('e', "Hello");
printf("%s\n", c);
}
The following code example passes the check and will not give a warning about this issue:
#include <stdio.h>
#include <string.h>
char *(*fp)(const char *, int);
void example(void) {
const char *c;
fp = strchr;
c = fp("Hello",'e');
printf("%s\n", c);
}