Re: Testing system call return values
From: Ari Lukumies (ari.lukumies_at_gmail.com)
Date: 06/26/05
- Next message: Maxim Yegorushkin: "Re: poll() returns POLLIN but no data ?"
- Previous message: Paul Pluzhnikov: "Re: Testing system call return values"
- In reply to: tom dailey: "Testing system call return values"
- Next in thread: Loic Domaigne: "Re: Testing system call return values"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Next message: Maxim Yegorushkin: "Re: poll() returns POLLIN but no data ?"
- Previous message: Paul Pluzhnikov: "Re: Testing system call return values"
- In reply to: tom dailey: "Testing system call return values"
- Next in thread: Loic Domaigne: "Re: Testing system call return values"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]