On Thu, May 06, 2021 at 12:00:21PM +0200, Stefano Brivio wrote: > On Thu, 6 May 2021 11:18:14 +0200 > Phil Sutter <phil@xxxxxx> wrote: > > > On Thu, May 06, 2021 at 12:23:13AM +0200, Stefano Brivio wrote: [...] > > > diff --git a/src/segtree.c b/src/segtree.c > > > index ad199355532e..353a0053ebc0 100644 > > > --- a/src/segtree.c > > > +++ b/src/segtree.c > > > @@ -838,8 +838,8 @@ static int range_mask_len(const mpz_t start, const mpz_t end, unsigned int len) > > > mpz_t tmp_start, tmp_end; > > > int ret; > > > > > > - mpz_init_set_ui(tmp_start, mpz_get_ui(start)); > > > - mpz_init_set_ui(tmp_end, mpz_get_ui(end)); > > > + mpz_init_set(tmp_start, start); > > > + mpz_init_set(tmp_end, end); > > > > The old code is a bit funny, was there a specific reason why you > > exported the values into a C variable intermediately? > > Laziness, ultimately: I didn't remember the name of gmp_printf(), > didn't look it up, and used a fprintf() instead to check 'start' and > 'end'... and then whoops, I left the mpz_get_ui() calls there. OK, so this patch not just fixes a bug but also streamlines the code for performance (and something with refactoring, too). ;) Cheers, Phil