From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp56.i.mail.ru (smtp56.i.mail.ru [217.69.128.36]) (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 C0852469719 for ; Fri, 30 Oct 2020 10:33:34 +0300 (MSK) References: <20201028181352.260915-1-gorcunov@gmail.com> <20201028185650.GA198833@grain> From: Serge Petrenko Message-ID: <8f378d5e-3e6c-8038-64a0-e5cc703ab24a@tarantool.org> Date: Fri, 30 Oct 2020 10:33:33 +0300 MIME-Version: 1.0 In-Reply-To: <20201028185650.GA198833@grain> Content-Type: text/plain; charset="utf-8"; format="flowed" Content-Transfer-Encoding: 8bit Content-Language: en-GB Subject: Re: [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: Cyrill Gorcunov , tml Cc: Vladislav Shpilevoy 28.10.2020 21:56, 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 > --- > 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. Hi! Please see one comment below. > > 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, CHAR_BIT is used instead of `8` everywhere in the code (well, almost everywhere). So please conform. > + "RAFT: vote_mask is too short"); -- Serge Petrenko