container.c: distinguish ferror/feof from other errors

This commit is contained in:
Xavier Del Campo Romero 2022-02-15 21:34:27 +01:00
parent c6ac388f86
commit 3ce1418ce5
1 changed files with 8 additions and 2 deletions

View File

@ -159,9 +159,15 @@ static int read_all_elements(const struct container *const list, const size_t n,
memset(&done, 0, sizeof done);
for (size_t i = 0; i < sizeof done / sizeof *done; i++)
if (feof(f) || ferror(f)
|| read_element(list, n, f, done))
{
if (feof(f) || ferror(f))
{
fprintf(stderr, "feof or ferror found\n");
goto end;
}
else if (read_element(list, n, f, done))
goto end;
}
for (size_t i = 0; i < sizeof done / sizeof *done; i++)
{