]> granicus.if.org Git - postgresql/commitdiff
Don't use !! but != 0/NULL to force boolean evaluation.
authorAndres Freund <andres@anarazel.de>
Sun, 27 Mar 2016 15:17:00 +0000 (17:17 +0200)
committerAndres Freund <andres@anarazel.de>
Sun, 27 Mar 2016 16:10:19 +0000 (18:10 +0200)
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

contrib/sepgsql/uavc.c
src/backend/access/transam/xact.c
src/backend/replication/logical/reorderbuffer.c
src/backend/storage/lmgr/lwlock.c
src/include/access/xact.h

index 057245ff03825763d8614976834bbef024c79254..10fa9a0b0bc742a45e9461049d2eee4d3f9f93d4 100644 (file)
@@ -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(),
index 89a14b4cbe4bdd4583342a9ee2f1faea14ae3d4a..e31540548e06ff2262b3a44e374cc59c32be4bd2 100644 (file)
@@ -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;
index f2b8f4b7b842f4ab14afb8f70d3cc8a921a52afb..9d78c8c134ea457ce160d55a3080dec0600b969c 100644 (file)
@@ -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;
 }
 
index 11e4a51adf642c59d1ccbbdcf7deb88e6d40c1ef..31626cb5b040b38f3a6054ffec1f30004b685996 100644 (file)
@@ -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)));
        }
 }
 
index ebeb5823e802232d7345a1b882d67044d8efcbd2..3ba23f5e87b7e7cdf64cd4fd4ae9948d224c55d2 100644 (file)
@@ -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
 {