MISRAC2012-Rule-22.5_b
In this section:
Synopsis
(Mandatory) A pointer to a FILE object shall not be dereferenced
Enabled by default
Yes
Severity/Certainty
Medium/Medium

Full description
A file pointer was found that is implicitly dereferenced by a library function. This check is identical to RESOURCE-implicit-deref-file.
Coding standards
- MISRA C:2012 Rule-22.5
(Mandatory) A pointer to a FILE object shall not be dereferenced
Code examples
The following code example fails the check and will give a warning:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void example(void) {
FILE *ptr1 = fopen("hello", "r");
int *a;
memcpy(ptr1, a, 10);
}
The following code example passes the check and will not give a warning about this issue:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void example(void) {
FILE *ptr1;
int *a;
memcpy(a, a, 0);
}