Re: Question about ECPGset_noind_null() and ECPGis_noind_null() - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Question about ECPGset_noind_null() and ECPGis_noind_null()
Date
Msg-id 28071.1258659227@sss.pgh.pa.us
Whole thread Raw
In response to Re: Question about ECPGset_noind_null() and ECPGis_noind_null()  (Boszormenyi Zoltan <zb@cybertec.at>)
Responses Re: Question about ECPGset_noind_null() and ECPGis_noind_null()
Re: Question about ECPGset_noind_null() and ECPGis_noind_null()
List pgsql-hackers
Boszormenyi Zoltan <zb@cybertec.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


pgsql-hackers by date:

Previous
From: Boszormenyi Zoltan
Date:
Subject: Re: Question about ECPGset_noind_null() and ECPGis_noind_null()
Next
From: Andrew Dunstan
Date:
Subject: Re: Question about ECPGset_noind_null() and ECPGis_noind_null()