Re: [HACKERS] Bad bug in fopen() wrapper code

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Zeugswetter Andreas DCP SD" <ZeugswetterA(at)spardat(dot)at>
Cc: "Bruce Momjian" <bruce(at)momjian(dot)us>, "Magnus Hagander" <mha(at)sollentuna(dot)net>, pgsql-hackers(at)postgresql(dot)org, "Claudio Natoli" <claudio(dot)natoli(at)memetrics(dot)com>, pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] Bad bug in fopen() wrapper code
Date: 2006-10-03 13:59:03
Message-ID: 24827.1159883943@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

"Zeugswetter Andreas DCP SD" <ZeugswetterA(at)spardat(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message mark 2006-10-03 14:12:57 Re: Faster StrNCpy
Previous Message Benny Amorsen 2006-10-03 13:21:12 Re: Faster StrNCpy

Browse pgsql-patches by date

  From Date Subject
Next Message mark 2006-10-03 14:12:57 Re: Faster StrNCpy
Previous Message Benny Amorsen 2006-10-03 13:21:12 Re: Faster StrNCpy