lkml.org 
[lkml]   [2019]   [Jan]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: 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

\
 
 \ /
  Last update: 2019-01-24 21:04    [W:0.308 / U:0.564 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site