Re: [PATCHES] Bad bug in fopen() wrapper code - Mailing list pgsql-hackers

From Tom Lane
Subject Re: [PATCHES] Bad bug in fopen() wrapper code
Date
Msg-id 24827.1159883943@sss.pgh.pa.us
Whole thread Raw
In response to Re: [PATCHES] Bad bug in fopen() wrapper code  ("Zeugswetter Andreas DCP SD" <ZeugswetterA@spardat.at>)
List pgsql-hackers
"Zeugswetter Andreas DCP SD" <ZeugswetterA@spardat.at> writes:
> "If successful, _setmode returns the previous translation mode. A return
> value of -1 indicates an error"

> So, shouldn't we be testing for -1 instead of < 0 ?

I think the usual convention is to test for < 0, unless there are other
negative return values that are legal.  This is doubtless a silly
cycle-shaving habit (on nearly all machines, test against 0 is a bit
more compact than test against other constants), but it is a widespread
habit anyway, and if you sometimes do it one way and sometimes another
you just create a distraction for readers.

            regards, tom lane

pgsql-hackers by date:

Previous
From: Zdenek Kotala
Date:
Subject: PG qsort vs. Solaris
Next
From: mark@mark.mielke.cc
Date:
Subject: Re: Faster StrNCpy