Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 16 Apr 1997 15:02:29 -0700 (MST)
From:      Terry Lambert <terry@lambert.org>
To:        bde@zeta.org.au (Bruce Evans)
Cc:        current@FreeBSD.org, toor@dyson.iquest.net
Subject:   Re: You will need to recompile your libc and apps!!!
Message-ID:  <199704162202.PAA28198@phaeton.artisoft.com>
In-Reply-To: <199704160807.SAA03190@godzilla.zeta.org.au> from "Bruce Evans" at Apr 16, 97 06:07:19 pm

next in thread | previous in thread | raw e-mail | index | archive | help
> 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.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199704162202.PAA28198>