aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlvaro Herrera <alvherre@alvh.no-ip.org>2017-01-18 18:06:13 -0300
committerAlvaro Herrera <alvherre@alvh.no-ip.org>2017-01-18 18:06:13 -0300
commit75c155f65b046686242ece4bbfb688359f28feea (patch)
tree341d0bfec6dd8099b1d1a6f163a94e39a4a780e1 /src
parent9e7f00d861fffacaec49473f89513ee8abca076c (diff)
downloadpostgresql-75c155f65b046686242ece4bbfb688359f28feea.tar.gz
postgresql-75c155f65b046686242ece4bbfb688359f28feea.zip
Change some test macros to return true booleans
These macros work fine when they are used directly in an "if" test or similar, but as soon as the return values are assigned to boolean variables (or passed as boolean arguments to some function), they become bugs, hopefully caught by compiler warnings. To avoid future problems, fix the definitions so that they return actual booleans. To further minimize the risk that somebody uses them in back-patched fixes that only work correctly in branches starting from the current master and not in old ones, back-patch the change to supported branches as appropriate. See also commit af4472bcb88ab36b9abbe7fd5858e570a65a2d1a, and the long discussion (and larger patch) in the thread mentioned in its commit message. Discussion: https://postgr.es/m/18672.1483022414@sss.pgh.pa.us
Diffstat (limited to 'src')
-rw-r--r--src/include/access/htup_details.h10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/include/access/htup_details.h b/src/include/access/htup_details.h
index a4efcf4ec42..b4eca16973d 100644
--- a/src/include/access/htup_details.h
+++ b/src/include/access/htup_details.h
@@ -225,8 +225,8 @@ struct HeapTupleHeaderData
*/
#define HEAP_LOCKED_UPGRADED(infomask) \
( \
- ((infomask) & HEAP_XMAX_IS_MULTI) && \
- ((infomask) & HEAP_XMAX_LOCK_ONLY) && \
+ ((infomask) & HEAP_XMAX_IS_MULTI) != 0 && \
+ ((infomask) & HEAP_XMAX_LOCK_ONLY) != 0 && \
(((infomask) & (HEAP_XMAX_EXCL_LOCK | HEAP_XMAX_KEYSHR_LOCK)) == 0) \
)
@@ -297,7 +297,7 @@ struct HeapTupleHeaderData
#define HeapTupleHeaderXminCommitted(tup) \
( \
- (tup)->t_infomask & HEAP_XMIN_COMMITTED \
+ ((tup)->t_infomask & HEAP_XMIN_COMMITTED) != 0 \
)
#define HeapTupleHeaderXminInvalid(tup) \
@@ -465,7 +465,7 @@ do { \
#define HeapTupleHeaderIsHeapOnly(tup) \
( \
- (tup)->t_infomask2 & HEAP_ONLY_TUPLE \
+ ((tup)->t_infomask2 & HEAP_ONLY_TUPLE) != 0 \
)
#define HeapTupleHeaderSetHeapOnly(tup) \
@@ -480,7 +480,7 @@ do { \
#define HeapTupleHeaderHasMatch(tup) \
( \
- (tup)->t_infomask2 & HEAP_TUPLE_HAS_MATCH \
+ ((tup)->t_infomask2 & HEAP_TUPLE_HAS_MATCH) != 0 \
)
#define HeapTupleHeaderSetMatch(tup) \