Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 25 Nov 2003 18:21:13 -0800
From:      Terry Lambert <tlambert2@mindspring.com>
To:        Stefan Farfeleder <stefan@fafoe.narf.at>
Cc:        current@freebsd.org
Subject:   Re: [PATCH] libc_r bug: successful close(2) sets errno to ENOTTY
Message-ID:  <3FC40E19.6A2989B6@mindspring.com>
References:  <20031123141408.GA1426@ratsnest.hole> <20031124174457.GB27782@madman.celabo.org> <20031124182322.GB621@wombat.fafoe.narf.at>

next in thread | previous in thread | raw e-mail | index | archive | help
Stefan Farfeleder wrote:
> On Mon, Nov 24, 2003 at 07:05:02PM +0100, boyd, rounin wrote:
> > From: "Jacques A. Vidrine" <nectar@FreeBSD.org>
> > > The application is broken.  You must only check errno if you get an
> > > error indication from the library call.
> >
> > errno is only meaningful after a syscall error.
> 
> Wrong, counter-example: strtol().

Wrong; the standard specifies that the errno shall only be
checked when the return value is -1.  The exception in the
strtol() case is only for presetting errno to 0 before you
make the call, and making a check only following a -1 return.

You cannot make assumptions about underlying implementations;
they may be either system calls or library routines, and your
application is not supposed to know or depend on which case
prevails.

-- Terry



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3FC40E19.6A2989B6>