[PATCH v2] libio: Ignore setbuf for open_memstream [BZ #34019]
Adhemerval Zanella Netto
adhemerval.zanella@linaro.org
Mon May 4 12:04:35 GMT 2026
On 01/05/26 13:24, Rocket Ma wrote:
>> Wouldn't this change the behavior or setbuf (NULL, ..) and setbuf (..., 0)
>> to not be _IO_UNBUFFERED?
>>
>> I think it does not seems to matter though, since the resulting buffer operated
>> by open_memstream can only be accessible after a fflush/fclose. The
>> setbuf/setvbuf would only be a way to optimize the stdio buffer flush to
>> final one, which I am also not fully sure it would matter here.
>>
>
> Referencing POSIX standard[1], fflush and fclose are explicitly
> mentioned when describing `bufp` and `sizep`, which may indicate that
> user shall always flush the stream. But the standard does not mention
> the behavior of setbuf. I'm also not sure if we should allow user to
> setbuf.
>
> [1]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/open_memstream.html
I think ignoring set{v}buf makes sense here, we can make it orthogonal to other
stream by the current POSIX description makes invisible to user anyway.
More information about the Libc-alpha
mailing list