From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp30.i.mail.ru (smtp30.i.mail.ru [94.100.177.90]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id B33A4469719 for ; Fri, 30 Oct 2020 11:39:49 +0300 (MSK) References: <20201028181352.260915-1-gorcunov@gmail.com> <20201028185650.GA198833@grain> <8f378d5e-3e6c-8038-64a0-e5cc703ab24a@tarantool.org> <20201030083033.GC198833@grain> From: Serge Petrenko Message-ID: <570630ad-1fcb-b50b-3d55-d75a8e80be77@tarantool.org> Date: Fri, 30 Oct 2020 11:39:48 +0300 MIME-Version: 1.0 In-Reply-To: <20201030083033.GC198833@grain> Content-Type: text/plain; charset="utf-8"; format="flowed" Content-Transfer-Encoding: 8bit Content-Language: en-GB Subject: Re: [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: Cyrill Gorcunov Cc: tml , Vladislav Shpilevoy 30.10.2020 11:30, Cyrill Gorcunov пишет: > 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"); > } Thanks for the fix! LGTM. -- Serge Petrenko