[PATCH] tst-fopen-threaded: Only check EOF for failing read
Siddhesh Poyarekar
siddhesh@sourceware.org
Fri Mar 14 15:05:12 GMT 2025
On 2025-03-14 10:55, Florian Weimer wrote:
> * 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-)
Hah, it's exactly 79 chars :D I'll change it though :)
>> + /* 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”.
Thanks, I'll use this.
> You don't mention anywhere why you remove the clearerr call? I think
> that's necessary because the test assumes that feof is sticky.
Would it change the outcome though? If there are multiple failing
readers, they would reliably result in the test failing regardless of
whether the EOF/error flag is cleared.
Thanks,
Sid
More information about the Libc-alpha
mailing list