[PATCH v2] libio: Fix stream orientation when using fread [BZ #22796]
Florian Weimer
fweimer@redhat.com
Wed Mar 19 11:40:08 GMT 2025
* Sam Zeter:
>> Aren't there are other xsgetn methods for different stream types? Then
>> this change will not fix them.
>
> Thanks for the response. Unfortunately I'm new to this codebase and not
> entirely sure what other methods you mean for different stream types.
> I thought the issue only affected this particular call to fread.
No worries, unfortunately it's quite a maze.
>> I think it's better to leave orientation handling to the external
>> interface (so for example, __underflow (for getc_unlocked) and fread).
>
> I'm also not sure what you mean by leaving orientation handling to the
> external interface, when __underflow() itself is being called by
> _IO_file_xsgetn(), at least in my test I wrote for fread. Wouldn't
> that make _IO_file_xsgetn() the external interface?
The layering is not very strict. But there are functions that are
expected to be called by applications (such as fread, fputc, getdelim
etc.), functions are strictly internal only, and functions that can be
called from libstdc++ in GCC 2.95. Based on my understanding of the
codebase, orientation is best handled in the first category of
functions. If we do that, the internal-only functions will encounter
oriented streams automatically. The GCC 2.95 stuff does not matter for
orientation purposes because we did not have wide streams back then.
Thanks,
Florian
More information about the Libc-alpha
mailing list