Re: Testing system call return values

From: Ari Lukumies (ari.lukumies_at_gmail.com)
Date: 06/26/05


Date: Sun, 26 Jun 2005 02:48:42 +0300

tom dailey wrote:
> Much code that I've seen tests the return value from a system call as
> follows:
>
> rv = some_system_call...
> if ( rv < 0 ) {
> ...handle error condition
> }
>
> My question is, why
> is the first above test used in so much UNIX code? Am I missing something?

Because -1 is less than zero, and the test against 0 (or less) taken
apart, takes less clock cycles than comparison with -1.

-atl-

-- 
A multiverse is figments of its own creations