From 598e2c55ebbbb292c4f79c4acdc8567bf18ef9be Mon Sep 17 00:00:00 2001 From: Andres Freund Date: Sun, 27 Mar 2016 17:47:46 +0200 Subject: [PATCH] Change various Gin*Is* macros to return 0/1. Returning the direct result of bit arithmetic, in a macro intended to be used in a boolean manner, can be problematic if the return value is stored in a variable of type 'bool'. If bool is implemented using C99's _Bool, that can lead to comparison failures if the variable is then compared again with the expression (see ginStepRight() for an example that fails), as _Bool forces the result to be 0/1. That happens in some configurations of newer MSVC compilers. It's also problematic when storing the result of such an expression in a narrower type. Several gin macros have been declared in that style since gin's initial commit in 8a3631f8d86. There's a lot more macros like this, but this is the only one causing regression test failures; and I don't want to commit and backpatch a larger patch with lots of conflicts just before the next set of minor releases. Discussion: 20150811154237.GD17575@awork2.anarazel.de Backpatch: All supported branches --- src/include/access/gin_private.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/include/access/gin_private.h b/src/include/access/gin_private.h index 665ca886f8..9537ae78cd 100644 --- a/src/include/access/gin_private.h +++ b/src/include/access/gin_private.h @@ -101,17 +101,17 @@ typedef struct GinMetaPageData */ #define GinPageGetOpaque(page) ( (GinPageOpaque) PageGetSpecialPointer(page) ) -#define GinPageIsLeaf(page) ( GinPageGetOpaque(page)->flags & GIN_LEAF ) +#define GinPageIsLeaf(page) ( (GinPageGetOpaque(page)->flags & GIN_LEAF) != 0 ) #define GinPageSetLeaf(page) ( GinPageGetOpaque(page)->flags |= GIN_LEAF ) #define GinPageSetNonLeaf(page) ( GinPageGetOpaque(page)->flags &= ~GIN_LEAF ) -#define GinPageIsData(page) ( GinPageGetOpaque(page)->flags & GIN_DATA ) +#define GinPageIsData(page) ( (GinPageGetOpaque(page)->flags & GIN_DATA) != 0 ) #define GinPageSetData(page) ( GinPageGetOpaque(page)->flags |= GIN_DATA ) -#define GinPageIsList(page) ( GinPageGetOpaque(page)->flags & GIN_LIST ) +#define GinPageIsList(page) ( (GinPageGetOpaque(page)->flags & GIN_LIST) != 0 ) #define GinPageSetList(page) ( GinPageGetOpaque(page)->flags |= GIN_LIST ) -#define GinPageHasFullRow(page) ( GinPageGetOpaque(page)->flags & GIN_LIST_FULLROW ) +#define GinPageHasFullRow(page) ( (GinPageGetOpaque(page)->flags & GIN_LIST_FULLROW) != 0 ) #define GinPageSetFullRow(page) ( GinPageGetOpaque(page)->flags |= GIN_LIST_FULLROW ) -#define GinPageIsDeleted(page) ( GinPageGetOpaque(page)->flags & GIN_DELETED) +#define GinPageIsDeleted(page) ( (GinPageGetOpaque(page)->flags & GIN_DELETED) != 0 ) #define GinPageSetDeleted(page) ( GinPageGetOpaque(page)->flags |= GIN_DELETED) #define GinPageSetNonDeleted(page) ( GinPageGetOpaque(page)->flags &= ~GIN_DELETED) -- 2.40.0