[Tarantool-patches] [PATCH v2] raft: make sure the voting mask is wide enough

Serge Petrenko sergepetrenko at tarantool.org
Fri Oct 30 10:33:33 MSK 2020


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 <gorcunov at gmail.com>
> ---
> 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



More information about the Tarantool-patches mailing list