From owner-freebsd-current Wed Apr 16 15:24:34 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id PAA21623 for current-outgoing; Wed, 16 Apr 1997 15:24:34 -0700 (PDT) Received: from phaeton.artisoft.com (phaeton.Artisoft.COM [198.17.250.50]) by freefall.freebsd.org (8.8.5/8.8.5) with SMTP id PAA21541 for ; Wed, 16 Apr 1997 15:24:28 -0700 (PDT) Received: (from terry@localhost) by phaeton.artisoft.com (8.6.11/8.6.9) id PAA28198; Wed, 16 Apr 1997 15:02:29 -0700 From: Terry Lambert Message-Id: <199704162202.PAA28198@phaeton.artisoft.com> Subject: Re: You will need to recompile your libc and apps!!! To: bde@zeta.org.au (Bruce Evans) Date: Wed, 16 Apr 1997 15:02:29 -0700 (MST) Cc: current@FreeBSD.org, toor@dyson.iquest.net In-Reply-To: <199704160807.SAA03190@godzilla.zeta.org.au> from "Bruce Evans" at Apr 16, 97 06:07:19 pm X-Mailer: ELM [version 2.4 PL24] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-current@FreeBSD.org X-Loop: FreeBSD.org Precedence: bulk > I forget if successful syscalls can clobber errno - what happens for > > { errno = 0; susccessful_syscall(); assert(errno == 0); } > > ? The errno is not modified by a successful system call. FreeBSD only sets errno in the real call case if the KERNCALL fails; your assert will not fail, unless the system call is actually encapsulated (see below). Since you can't depend on errno being set to 0 on a successful call, though: { errno = 5; successful_syscall(); assert(errno == 0); } will almost certainly fail (at least one platform I'm aware of wastes a couple of instruction cycles to zero errno on after a successful call; that platform is Wrong, since it is promoting platform dependency of user code). Also, there is no guarantee that the error state is not encapsulated in a (3) function which can make multiple (2) calls, one of which may fail without the encapsulated function failing, so you can not rely on the value not changing in all cases, so coding like: errno = 0; (void) successful_syscall(); if( errno) ... is a bad practice anyway, since provision of the actual "system call" functions is platform dependent, and the code is not portable to an encapsulation platform (like NT or VMS). Regards, Terry Lambert terry@lambert.org --- Any opinions in this posting are my own and not those of my present or previous employers.