strange case of "if ((a & b))" - Mailing list pgsql-hackers
From | Justin Pryzby |
---|---|
Subject | strange case of "if ((a & b))" |
Date | |
Msg-id | 20210428182936.GE27406@telsasoft.com Whole thread Raw |
Responses |
Re: strange case of "if ((a & b))"
Re: strange case of "if ((a & b))" |
List | pgsql-hackers |
These look strange to me - the inner parens don't do anything. I wouldn't write it with 2x parens for the same reason I wouldn't write it with 8x parens. diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c index 9f159eb3db..3bbc13c443 100644 --- a/contrib/amcheck/verify_heapam.c +++ b/contrib/amcheck/verify_heapam.c @@ -693,7 +693,7 @@ check_tuple_header(HeapCheckContext *ctx) report_corruption(ctx, psprintf("tuple data should begin at byte %u, but actually begins at byte %u (1 attribute,has nulls)", expected_hoff, ctx->tuphdr->t_hoff)); - else if ((infomask & HEAP_HASNULL)) + else if ((infomask & HEAP_HASNULL) != 0) report_corruption(ctx, psprintf("tuple data should begin at byte %u, but actually begins at byte %u (%u attributes,has nulls)", expected_hoff, ctx->tuphdr->t_hoff, ctx->natts)); diff --git a/contrib/ltree/ltree_io.c b/contrib/ltree/ltree_io.c index 15115cb29f..0dd2838f8b 100644 --- a/contrib/ltree/ltree_io.c +++ b/contrib/ltree/ltree_io.c @@ -661,17 +661,17 @@ deparse_lquery(const lquery *in) } memcpy(ptr, curtlevel->name, curtlevel->len); ptr += curtlevel->len; - if ((curtlevel->flag & LVAR_SUBLEXEME)) + if ((curtlevel->flag & LVAR_SUBLEXEME) != 0) { *ptr = '%'; ptr++; } - if ((curtlevel->flag & LVAR_INCASE)) + if ((curtlevel->flag & LVAR_INCASE) != 0) { *ptr = '@'; ptr++; } - if ((curtlevel->flag & LVAR_ANYEND)) + if ((curtlevel->flag & LVAR_ANYEND) != 0) { *ptr = '*'; ptr++; diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c index 13396eb7f2..f5a4db5c57 100644 --- a/src/backend/access/heap/heapam.c +++ b/src/backend/access/heap/heapam.c @@ -2107,7 +2107,8 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid, vmstatus = visibilitymap_get_status(relation, BufferGetBlockNumber(buffer), &vmbuffer); - if ((starting_with_empty_page || vmstatus & VISIBILITYMAP_ALL_FROZEN)) + if (starting_with_empty_page || + (vmstatus & VISIBILITYMAP_ALL_FROZEN) != 0) all_frozen_set = true; } diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c index 441445927e..28fdd2943b 100644 --- a/src/backend/access/transam/xact.c +++ b/src/backend/access/transam/xact.c @@ -2417,7 +2417,7 @@ PrepareTransaction(void) * cases, such as a temp table created and dropped all within the * transaction. That seems to require much more bookkeeping though. */ - if ((MyXactFlags & XACT_FLAGS_ACCESSEDTEMPNAMESPACE)) + if ((MyXactFlags & XACT_FLAGS_ACCESSEDTEMPNAMESPACE) != 0) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("cannot PREPARE a transaction that has operated on temporary objects"))); @@ -5530,7 +5530,7 @@ XactLogCommitRecord(TimestampTz commit_time, xl_xinfo.xinfo |= XACT_COMPLETION_UPDATE_RELCACHE_FILE; if (forceSyncCommit) xl_xinfo.xinfo |= XACT_COMPLETION_FORCE_SYNC_COMMIT; - if ((xactflags & XACT_FLAGS_ACQUIREDACCESSEXCLUSIVELOCK)) + if ((xactflags & XACT_FLAGS_ACQUIREDACCESSEXCLUSIVELOCK) != 0) xl_xinfo.xinfo |= XACT_XINFO_HAS_AE_LOCKS; /* @@ -5681,7 +5681,7 @@ XactLogAbortRecord(TimestampTz abort_time, xlrec.xact_time = abort_time; - if ((xactflags & XACT_FLAGS_ACQUIREDACCESSEXCLUSIVELOCK)) + if ((xactflags & XACT_FLAGS_ACQUIREDACCESSEXCLUSIVELOCK) != 0) xl_xinfo.xinfo |= XACT_XINFO_HAS_AE_LOCKS; if (nsubxacts > 0) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 8e717ada28..f341e6d143 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -16029,7 +16029,7 @@ PreCommit_on_commit_actions(void) * relations, we can skip truncating ON COMMIT DELETE ROWS * tables, as they must still be empty. */ - if ((MyXactFlags & XACT_FLAGS_ACCESSEDTEMPNAMESPACE)) + if ((MyXactFlags & XACT_FLAGS_ACCESSEDTEMPNAMESPACE) != 0) oids_to_truncate = lappend_oid(oids_to_truncate, oc->relid); break; case ONCOMMIT_DROP: diff --git a/src/backend/nodes/nodeFuncs.c b/src/backend/nodes/nodeFuncs.c index ff3dcc7b18..fe825c6ede 100644 --- a/src/backend/nodes/nodeFuncs.c +++ b/src/backend/nodes/nodeFuncs.c @@ -2390,7 +2390,7 @@ query_tree_walker(Query *query, * don't contain actual expressions. However they do contain OIDs which * may be needed by dependency walkers etc. */ - if ((flags & QTW_EXAMINE_SORTGROUP)) + if ((flags & QTW_EXAMINE_SORTGROUP) != 0) { if (walker((Node *) query->groupClause, context)) return true; @@ -3328,7 +3328,7 @@ query_tree_mutator(Query *query, * may be of interest to some mutators. */ - if ((flags & QTW_EXAMINE_SORTGROUP)) + if ((flags & QTW_EXAMINE_SORTGROUP) != 0) { MUTATE(query->groupClause, query->groupClause, List *); MUTATE(query->windowClause, query->windowClause, List *); diff --git a/src/backend/replication/logical/decode.c b/src/backend/replication/logical/decode.c index 7924581cdc..62baf48f8e 100644 --- a/src/backend/replication/logical/decode.c +++ b/src/backend/replication/logical/decode.c @@ -337,7 +337,7 @@ DecodeXactOp(LogicalDecodingContext *ctx, XLogRecordBuffer *buf) ReorderBufferXidSetCatalogChanges(ctx->reorder, xid, buf->origptr); } - else if ((!ctx->fast_forward)) + else if ((!ctx->fast_forward) != 0) ReorderBufferImmediateInvalidation(ctx->reorder, invals->nmsgs, invals->msgs);
pgsql-hackers by date: