Re: GinPageIs* don't actually return a boolean

From: Andres Freund <andres(at)anarazel(dot)de>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>, Teodor Sigaev <teodor(at)sigaev(dot)ru>
Subject: Re: GinPageIs* don't actually return a boolean
Date: 2015-08-11 16:08:11
Message-ID: 20150811160811.GB28835@awork2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2015-08-11 12:04:48 -0400, Robert Haas wrote:
> On Tue, Aug 11, 2015 at 11:42 AM, Andres Freund <andres(at)anarazel(dot)de> wrote:
> > #define GinPageIsLeaf(page) ( GinPageGetOpaque(page)->flags & GIN_LEAF )
> > #define GinPageIsData(page) ( GinPageGetOpaque(page)->flags & GIN_DATA )
> > #define GinPageIsList(page) ( GinPageGetOpaque(page)->flags & GIN_LIST )
> > ...
> >
> > These macros don't actually return a boolean that's comparable with our
> > true/false. That doesn't strike me as a good idea.
> >
> > If there's actually a boolean type defined by some included header (in
> > which case we don't overwrite it in c.h!) this actually can lead to
> > tests failing. If e.g. stdbool.h is included in c.h the tests fail with
> > gcc-4.9.
>
> !! is unknown to our codebase except where you've added it, and
> personally, I hate that idiom. I think we should write (val) != 0
> instead of !!val.

Hm. I find !! slightly simpler and it's pretty widely used in other
projects, but I don't care much. As long as we fix the underlying issue,
which != 0 certainly does...

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2015-08-11 16:16:11 Re: Mention column name in error messages
Previous Message Robert Haas 2015-08-11 16:04:48 Re: GinPageIs* don't actually return a boolean