Don't set errno in read functions ad it's a libc interface which we
should not be overriding. None of the functions up the call stack (some
examples) check on it.
Signed-off-by: Max Kunzelmann <maxdev@posteo.de>
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/240
[ Reword commit message according to suggestion by Emil and remove
inline ]
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
return 0;
}
-static int read_char(FILE *in)
+static inline int read_char(FILE *in)
{
- int ch;
-
- errno = 0;
- ch = getc_unlocked(in);
- if (ch == EOF)
- errno = EINVAL;
- return ch;
+ return getc_unlocked(in);
}
static bool read_u32s(FILE *in, uint32_t *l, size_t n)
{
size_t i;
- errno = 0;
if (fread_unlocked(l, sizeof(uint32_t), n, in) != n) {
- errno = EINVAL;
return false;
}
for (i = 0; i < n; i++)
file = fopen(filename, "re");
if (!file)
return NULL;
- errno = EINVAL;
if (!read_u32(file, &magic) || magic != INDEX_MAGIC)
goto err;
new->tmp = NULL;
new->tmp_size = 0;
- errno = 0;
return new;
err:
fclose(file);