From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-f196.google.com (mail-lj1-f196.google.com [209.85.208.196]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id DF65144643A for ; Thu, 12 Nov 2020 22:51:49 +0300 (MSK) Received: by mail-lj1-f196.google.com with SMTP id x9so7651241ljc.7 for ; Thu, 12 Nov 2020 11:51:49 -0800 (PST) From: Cyrill Gorcunov Date: Thu, 12 Nov 2020 22:51:12 +0300 Message-Id: <20201112195121.191366-3-gorcunov@gmail.com> In-Reply-To: <20201112195121.191366-1-gorcunov@gmail.com> References: <20201112195121.191366-1-gorcunov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH 02/11] vclock: vclock_get - drop misleading masking List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: tml Cc: Vladislav Shpilevoy We rely heavily that VCLOCK_MAX is 32 bits wide and using "VCLOCK_MAX - 1" as a mask for safe access to the replica id is simply misleading. Instead use assert here because we might change the number of supported replicas one day and they do not have to be pow2 value. And no need for this completely useless comment. Signed-off-by: Cyrill Gorcunov --- src/lib/vclock/vclock.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/lib/vclock/vclock.h b/src/lib/vclock/vclock.h index 5865f7443..fd4072c94 100644 --- a/src/lib/vclock/vclock.h +++ b/src/lib/vclock/vclock.h @@ -160,11 +160,7 @@ vclock_is_set(const struct vclock *vclock) static inline int64_t vclock_get(const struct vclock *vclock, uint32_t replica_id) { - /* - * If replica_id does not fit in VCLOCK_MAX - 1 then - * let result be undefined. - */ - replica_id &= VCLOCK_MAX - 1; + assert(replica_id < VCLOCK_MAX); /* Evaluate a bitmask to avoid branching. */ int64_t mask = 0ULL - ((vclock->map >> replica_id) & 0x1); return mask & vclock->lsn[replica_id]; -- 2.26.2