MISRAC2012-Rule-22.7_b
In this section:
Synopsis
The macro EOF shall only be compared with the unmodified return value from any Standard Library function capable of returning EOF
Enabled by default
Yes
Severity/Certainty
Medium/Medium

Full description
The macro EOF is compared with a value not originating from a function capable of returning EOF.
Coding standards
- MISRA C:2012 Rule-22.7
(Required) The macro EOF shall only be compared with the unmodified return value from any Standard Library function capable of returning EOF
Code examples
The following code example fails the check and will give a warning:
#include <stdio.h>
#include <stdint.h>
void f(void)
{
int a = getchar();
a = 5;
if (a == EOF) {
}
}
The following code example passes the check and will not give a warning about this issue:
#include <stdio.h>
#include <stdint.h>
void f(void)
{
int a = getchar();
a = 5;
}