Messages in this thread | | | From | Linus Torvalds <> | Date | Fri, 25 Jan 2019 09:02:57 +1300 | Subject | Re: int_sqrt() adjustments |
| |
On Fri, Jan 25, 2019 at 7:58 AM Florian La Roche <florian.laroche@googlemail.com> 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
| |