This is the mail archive of the libc-alpha@sourceware.cygnus.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: [eric_backus@agilent.com] libc/1510: getc on /dev/null sets errno to 25


Andreas Schwab wrote:

> Andreas Jaeger <aj@suse.de> writes:
> 
> |> We've received the appended bug report.  I can reproduce the problem.
> |> Any volunteers checking the report?
> 
> I don't think that this is a bug.  If ferror says there is no error then
> the value of errno is undefined.


Strictly speaking, I guess you are correct.  This points out a
portability problem in my own code, which examines errno in cases
where it may have an undefined value.

I realize that we're stuck with this definition of errno, but this
definition makes it difficult for me to use errno after calling
functions in any library other than libc, because the value of errno
might be valid (if the library called a libc function which failed),
or might be undefined (if the library called a libc function which
didn't fail), regardless of whether the non-libc library function was
successful.


I could still argue that it would be better if GNU libc didn't modify
errno in this case.  The behavior *is* unexpected (different than
other operating systems, different than if you use a regular file of
zero length, and probably different than older versions of Linux
libc).  If GNU libc never modified errno unless there truly is an
error to report, it would be easier to use errno on GNU systems,
though of course such usage would be non-portable.

I note in the source code to GNU libc that there are other cases where
errno is saved and restored around certain operations.  Assuming we
could identify where this particular errno comes from, similar code
could be added.  I briefly attempted to track down exactly where this
is happening, but the code was too much for me to follow in the short
time I had.

--
			Eric Backus <eric_backus@agilent.com>

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]