Re: int_sqrt() adjustments

From: Linus Torvalds
Date: Thu Jan 24 2019 - 15:03:22 EST


On Fri, Jan 25, 2019 at 7:58 AM Florian La Roche
<florian.laroche@xxxxxxxxxxxxxx> wrote:
>
> __fls() is returning an unsigned long, but fls() and fls64() are
> both returning a (signed) int.
> As we need a signed int as right operand of "<<" (as Linus pointed out),

It's not that the "signed" part is all that important, it's that using
another type is unnecessary and maybe misleading, when just the
default plain regular integer constant works right.

So I think this:

> - m = 1UL << (__fls(x) & ~1UL);
> + m = 1UL << ((fls(x) - 1) & ~1);
..
> - m = 1ULL << ((fls64(x) - 1) & ~1ULL);
> + m = 1ULL << ((fls64(x) - 1) & ~1);

is all good and simplifies the code to not have suffixes that don't
really matter or help.

Thanks,

Linus