Source-Changes-D archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: CVS commit: src/lib/libc/stdio

In article <20100506150045.GA749%marx.bitnet@localhost>,
Jukka Ruohonen  <> wrote:
>On Thu, May 06, 2010 at 02:48:32PM +0200, Joerg Sonnenberger wrote:
>> On Thu, May 06, 2010 at 08:51:29AM +0000, David Holland wrote:
>> > On Thu, May 06, 2010 at 08:14:08AM +0000, Jukka Ruohonen wrote:
>> >  > Correct the discussion about return values: fileno() may fail and
>return -1.
>> >  > Note that in such cases the NetBSD implementation does not set errno to
>> >  > EBADF, hence diverging from the standard in this small detail.
>> > 
>> > How is that not just a bug?
>> -1 is a valid answer for not file-backed FILEs. I don't think it is an
>> error.
>    Upon successful completion, fileno() shall return the integer value of
>the file descriptor associated with stream. Otherwise, the value -1 shall be
>returned and errno set to indicate the error.
>    The fileno() function may fail if:
>    [EBADF]
>        The stream argument is not a valid stream, or the stream is not
>       associated with a file.
>Isn't the above EBADF exactly what you are after?

Our stdio supports funopen() which has FILE *'s where fileno() == -1, but
they work just fine... This should be documented. Perhaps set errno if
it is indeed a bad file descriptor, and don't set it if it is a side-effect
of funopen()?


Home | Main Index | Thread Index | Old Index