[PATCH] tst-fopen-threaded: Only check EOF for failing read

Florian Weimer fweimer@redhat.com
Fri Mar 14 14:55:48 GMT 2025


* Siddhesh Poyarekar:

> -  ret =
> -    fread (&read_buffer, sizeof (char), sizeof (read_buffer), my_data->fd);
> -  if (feof (my_data->fd) != 0)
> +  ret = fread (&read_buffer, sizeof (char), sizeof (read_buffer), my_data->fd);

The line is almost too long, you could replace sizeof (char) with 1. 8-)

> +  /* If no data is returned, look for EOF flag and record it in MY_DATA.
> +     Successful readers could still see the EOF if they fall behind the failing
> +     read when calling feof(), which could result in a false negative.  To
> +     avoid this race, we only make the failing reader check for EOF or
> +     error.  */

Negative/positive is ambiguous in this context.  I think you mean “false
test failure”.

You don't mention anywhere why you remove the clearerr call?  I think
that's necessary because the test assumes that feof is sticky.

Thanks,
Florian



More information about the Libc-alpha mailing list