Andres Freund <and...@anarazel.de> writes:
> #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.

Agreed, this is risky.  For example, if the bit being tested is to the
left of the lowest byte of "flags", storing the result into a bool
variable would do the wrong thing.

> I think we should add a !! to these macros to make sure it's an actual
> boolean.

Please write it more like

#define GinPageIsLeaf(page)  ((GinPageGetOpaque(page)->flags & GIN_LEAF) != 0)

We do not use !! elsewhere for this purpose, and I for one find it a
pretty ugly locution.

                        regards, tom lane


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to