From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-f67.google.com (mail-lf1-f67.google.com [209.85.167.67]) (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 ECA38469719 for ; Wed, 28 Oct 2020 21:56:53 +0300 (MSK) Received: by mail-lf1-f67.google.com with SMTP id 126so96161lfi.8 for ; Wed, 28 Oct 2020 11:56:53 -0700 (PDT) Date: Wed, 28 Oct 2020 21:56:50 +0300 From: Cyrill Gorcunov Message-ID: <20201028185650.GA198833@grain> References: <20201028181352.260915-1-gorcunov@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201028181352.260915-1-gorcunov@gmail.com> Subject: [Tarantool-patches] [PATCH v2] raft: make sure the voting mask is wide enough List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: tml Cc: 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 --- I didn't make any branch here since it is trivial, fetch it from the mbox please if decide to apply. In v2 I fixed a few grammar typos. 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 are enough bits to track all replicas. + */ + static_assert(sizeof(raft.vote_mask) * 8 >= VCLOCK_MAX, + "RAFT: vote_mask is too short"); }