This is the mail archive of the
libc-alpha@sourceware.cygnus.com
mailing list for the glibc project.
Re: [eric_backus@agilent.com] libc/1510: getc on /dev/null sets errno to 25
- To: eric_backus at agilent dot com
- Subject: Re: [eric_backus@agilent.com] libc/1510: getc on /dev/null sets errno to 25
- From: Ulrich Drepper <drepper at cygnus dot com>
- Date: 05 Jan 2000 11:09:55 -0800
- Cc: schwab at suse dot de, libc-alpha at sourceware dot cygnus dot com
- References: <200001051856.KAA09281@labejb.lsid.hp.com>
- Reply-To: drepper at cygnus dot com (Ulrich Drepper)
Eric Backus <ericjb@labejb.lsid.hp.com> writes:
> 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.
Since it is unportable to rely on errno, why should we change it?
Such a change only adds costs. Assigning to errno is not cheap.
There is a hidden function call involved.
Plus: there is a good reason why POSIX uses almost exclusively return
values to signal errors. This is how it should have been done in the
first place. errno is historic baggage we have to carry around but we
don't want to make this even more expensive and also we don't want to
encourage people using it.
> I note in the source code to GNU libc that there are other cases where
> errno is saved and restored around certain operations.
This happens only is a standard requires it or an interface is
designed this way (e.g., in NSS).
--
---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace
Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA
Cygnus Solutions `--' drepper at cygnus.com `------------------------