aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndres Freund <andres@anarazel.de>2016-03-27 17:17:00 +0200
committerAndres Freund <andres@anarazel.de>2016-03-27 18:10:19 +0200
commit1a7a43672bf2939dda93a27d498349e7a4aa3c14 (patch)
tree7c2b58901af052b421fa1114d4c899c4b870163c
parentaf4472bcb88ab36b9abbe7fd5858e570a65a2d1a (diff)
downloadpostgresql-1a7a43672bf2939dda93a27d498349e7a4aa3c14.tar.gz
postgresql-1a7a43672bf2939dda93a27d498349e7a4aa3c14.zip
Don't use !! but != 0/NULL to force boolean evaluation.
I introduced several uses of !! to force bit arithmetic to be boolean, but per discussion the project prefers != 0/NULL. Discussion: CA+TgmoZP5KakLGP6B4vUjgMBUW0woq_dJYi0paOz-My0Hwt_vQ@mail.gmail.com
-rw-r--r--contrib/sepgsql/uavc.c2
-rw-r--r--src/backend/access/transam/xact.c3
-rw-r--r--src/backend/replication/logical/reorderbuffer.c2
-rw-r--r--src/backend/storage/lmgr/lwlock.c12
-rw-r--r--src/include/access/xact.h4
5 files changed, 12 insertions, 11 deletions
diff --git a/contrib/sepgsql/uavc.c b/contrib/sepgsql/uavc.c
index 057245ff038..10fa9a0b0bc 100644
--- a/contrib/sepgsql/uavc.c
+++ b/contrib/sepgsql/uavc.c
@@ -407,7 +407,7 @@ sepgsql_avc_check_perms_label(const char *tcontext,
audit_name != SEPGSQL_AVC_NOAUDIT &&
sepgsql_get_mode() != SEPGSQL_MODE_INTERNAL)
{
- sepgsql_audit_log(!!denied,
+ sepgsql_audit_log(denied != 0,
cache->scontext,
cache->tcontext_is_valid ?
cache->tcontext : sepgsql_avc_unlabeled(),
diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c
index 89a14b4cbe4..e31540548e0 100644
--- a/src/backend/access/transam/xact.c
+++ b/src/backend/access/transam/xact.c
@@ -5335,7 +5335,8 @@ xact_redo_commit(xl_xact_parsed_commit *parsed,
LWLockRelease(XidGenLock);
}
- Assert(!!(parsed->xinfo & XACT_XINFO_HAS_ORIGIN) == (origin_id != InvalidRepOriginId));
+ Assert(((parsed->xinfo & XACT_XINFO_HAS_ORIGIN) == 0) ==
+ (origin_id == InvalidRepOriginId));
if (parsed->xinfo & XACT_XINFO_HAS_ORIGIN)
commit_time = parsed->origin_timestamp;
diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c
index f2b8f4b7b84..9d78c8c134e 100644
--- a/src/backend/replication/logical/reorderbuffer.c
+++ b/src/backend/replication/logical/reorderbuffer.c
@@ -603,7 +603,7 @@ ReorderBufferTXNByXid(ReorderBuffer *rb, TransactionId xid, bool create,
if (is_new)
*is_new = !found;
- Assert(!create || !!txn);
+ Assert(!create || txn != NULL);
return txn;
}
diff --git a/src/backend/storage/lmgr/lwlock.c b/src/backend/storage/lmgr/lwlock.c
index 11e4a51adf6..31626cb5b04 100644
--- a/src/backend/storage/lmgr/lwlock.c
+++ b/src/backend/storage/lmgr/lwlock.c
@@ -209,11 +209,11 @@ PRINT_LWDEBUG(const char *where, LWLock *lock, LWLockMode mode)
errmsg_internal("%d: %s(%s): excl %u shared %u haswaiters %u waiters %u rOK %d",
MyProcPid,
where, MainLWLockNames[id],
- !!(state & LW_VAL_EXCLUSIVE),
+ (state & LW_VAL_EXCLUSIVE) != 0,
state & LW_SHARED_MASK,
- !!(state & LW_FLAG_HAS_WAITERS),
+ (state & LW_FLAG_HAS_WAITERS) != 0,
pg_atomic_read_u32(&lock->nwaiters),
- !!(state & LW_FLAG_RELEASE_OK))));
+ (state & LW_FLAG_RELEASE_OK) != 0)));
else
ereport(LOG,
(errhidestmt(true),
@@ -221,11 +221,11 @@ PRINT_LWDEBUG(const char *where, LWLock *lock, LWLockMode mode)
errmsg_internal("%d: %s(%s %d): excl %u shared %u haswaiters %u waiters %u rOK %d",
MyProcPid,
where, T_NAME(lock), id,
- !!(state & LW_VAL_EXCLUSIVE),
+ (state & LW_VAL_EXCLUSIVE) != 0,
state & LW_SHARED_MASK,
- !!(state & LW_FLAG_HAS_WAITERS),
+ (state & LW_FLAG_HAS_WAITERS) != 0,
pg_atomic_read_u32(&lock->nwaiters),
- !!(state & LW_FLAG_RELEASE_OK))));
+ (state & LW_FLAG_RELEASE_OK) != 0)));
}
}
diff --git a/src/include/access/xact.h b/src/include/access/xact.h
index ebeb5823e80..3ba23f5e87b 100644
--- a/src/include/access/xact.h
+++ b/src/include/access/xact.h
@@ -149,9 +149,9 @@ typedef void (*SubXactCallback) (SubXactEvent event, SubTransactionId mySubid,
/* Access macros for above flags */
#define XactCompletionRelcacheInitFileInval(xinfo) \
- (!!(xinfo & XACT_COMPLETION_UPDATE_RELCACHE_FILE))
+ ((xinfo & XACT_COMPLETION_UPDATE_RELCACHE_FILE) != 0)
#define XactCompletionForceSyncCommit(xinfo) \
- (!!(xinfo & XACT_COMPLETION_FORCE_SYNC_COMMIT))
+ ((xinfo & XACT_COMPLETION_FORCE_SYNC_COMMIT) != 0)
typedef struct xl_xact_assignment
{