Fix BZ 18756 (fmemopen(..., 0, ...) does not fail)

Rasmus Villemoes rv@rasmusvillemoes.dk
Mon Aug 3 13:35:00 GMT 2015


On Mon, Aug 03 2015, Adhemerval Zanella <adhemerval.zanella@linaro.org> wrote:

> Hi,
>
> Thanks for the patch, it straightforward enough. Only a comment below.
>

But why? What happened to
https://sourceware.org/bugzilla/show_bug.cgi?id=11216 ?

What I_WANT_SANE_FMEMOPEN_SEMANTICS flag should I set to avoid having to
special-case the empty string in fmemopen(s, strlen(s), "r")? 

Why should a memory buffer which happens to be of length 0 be treated
any differently than fopen() of an empty file [or /dev/full in the case
of writing]? Or put another way, in what scenario is it useful for
fmemopen() to return NULL/errno==EINVAL when len==0?


"The standard says/said so" is not a valid reason: that would just imply
that the standard is broken. Which they sort-of seem to have
acknowledged. Please, let's keep trying to steer the supertanker in the
right direction instead of mindlessly following it along its misdirected
course.

Rasmus



More information about the Libc-alpha mailing list