ref: d4d6143eec631fa520c26482defdf3804b051f26
parent: 1fa53aab19efe6ccd1b521574a71fb6ce0e0f126
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Mon Aug 20 08:47:31 EDT 2018
[lib/c] Don't compare char with EOF The type of the pointer is unsigned char, so it cannot be EOF ever.
--- a/lib/c/fread.c
+++ b/lib/c/fread.c
@@ -8,6 +8,7 @@
{
unsigned char *bp = ptr;
size_t n, i;
+ int c;
if (size == 0)
return 0;
@@ -15,8 +16,9 @@
for (n = 0; n < nmemb; n++) {
i = size;
do {
- if ((*bp++ = getc(fp)) == EOF)
+ if ((c = getc(fp)) == EOF)
return n;
+ *bp++ = c;
} while (--i);
}