Re: Question about ECPGset_noind_null() and ECPGis_noind_null()

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Boszormenyi Zoltan <zb(at)cybertec(dot)at>
Cc: Michael Meskes <meskes(at)postgresql(dot)org>, pgsql-hackers(at)postgresql(dot)org, Hans-Juergen Schoenig <hs(at)cybertec(dot)at>
Subject: Re: Question about ECPGset_noind_null() and ECPGis_noind_null()
Date: 2009-11-19 19:33:47
Message-ID: 28071.1258659227@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Boszormenyi Zoltan <zb(at)cybertec(dot)at> writes:
> for (; length > 0 && ptr[--length] == 0xff;);

> I suspect that GCC does the "--length" after checking
> "length > 0" and before checking the "ptr[...] == 0xff",
> but HP CC does it before checking "length > 0".

If it does, that is *unquestionably* a bug in HP's CC and should be
reported to them. However, the code is sufficiently unreadable to
be worth rewriting anyhow. Your suggestion is an improvement but
personally I'd plump for

int i;

for (i = 0; i < length; i++)
if (ptr[i] != 0xff)
return false;
return true;

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2009-11-19 19:46:50 Re: Question about ECPGset_noind_null() and ECPGis_noind_null()
Previous Message hgonzalez 2009-11-19 19:21:47 Re: Timezones (in 8.5?)