Skip to main content

IAR Embedded Workbench for RL78 5.20

RESOURCE-implicit-deref-file

In this section:
Synopsis

A file pointer is implicitly dereferenced by a library function.

Enabled by default

No

Severity/Certainty

Medium/Medium

mediummedium.png
Full description

A file pointer is implicitly dereferenced by a library function. This check is identical to MISRAC2012-Rule-22.5_b.

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);
}