From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-f66.google.com (mail-lf1-f66.google.com [209.85.167.66]) (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 82966469719 for ; Fri, 30 Oct 2020 11:30:36 +0300 (MSK) Received: by mail-lf1-f66.google.com with SMTP id b1so6751685lfp.11 for ; Fri, 30 Oct 2020 01:30:36 -0700 (PDT) Date: Fri, 30 Oct 2020 11:30:33 +0300 From: Cyrill Gorcunov Message-ID: <20201030083033.GC198833@grain> References: <20201028181352.260915-1-gorcunov@gmail.com> <20201028185650.GA198833@grain> <8f378d5e-3e6c-8038-64a0-e5cc703ab24a@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8f378d5e-3e6c-8038-64a0-e5cc703ab24a@tarantool.org> Subject: [Tarantool-patches] [PATCH v3] raft: make sure the voking mask is wide enough List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Serge Petrenko Cc: tml , Vladislav Shpilevoy The vote_mask is declared as uint32_t which is highly coupled with VCLOCK_MAX, lets add a compile time test to be sure. Signed-off-by: Cyrill Gorcunov --- v2: Use CHAR_BIT instead of hardcoded bits number src/box/raft.c | 6 ++++++ 1 file changed, 6 insertions(+) Index: tarantool.git/src/box/raft.c =================================================================== --- tarantool.git.orig/src/box/raft.c +++ tarantool.git/src/box/raft.c @@ -1061,4 +1061,10 @@ raft_init(void) { ev_timer_init(&raft.timer, raft_sm_schedule_new_election_cb, 0, 0); rlist_create(&raft.on_update); + + /* + * Make sure there is enough bits to track all replicas. + */ + static_assert(sizeof(raft.vote_mask) * CHAR_BIT >= VCLOCK_MAX, + "RAFT: vote_mask is too short"); }