MISRAC2012-Rule-22.3
In this section:
Synopsis
(Required) The same file shall not be open for read and write access at the same time on different streams.
Enabled by default
Yes
Severity/Certainty
Medium/Medium

Full description
A file was found that is open for read and write access at the same time on different streams.
Coding standards
- MISRA C:2012 Rule-22.3
(Required) The same file shall not be open for read and write access at the same time on different streams
Code examples
The following code example fails the check and will give a warning:
#include <stdio.h>
void example(void) {
FILE *f1 = fopen("foo", "r");
FILE *f2;
f2 = fopen("foo", "w");
}
The following code example passes the check and will not give a warning about this issue:
#include <stdio.h>
void example(void) {
FILE *f1 = fopen("foo", "r");
FILE *f2;
fclose(f1);
f2 = fopen("foo", "r");
}