int_sqrt() adjustments

From: Florian La Roche
Date: Thu Jan 24 2019 - 13:21:13 EST



__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),
change __fls() to fls() for 32bit and also adjust masking the lowest bit
to be a signed int.
Now the 32bit and the 64bit version are again similar.

best regards,

Florian La Roche



Signed-off-by: Florian La Roche <Florian.LaRoche@xxxxxxxxxxxxxx>
---
lib/int_sqrt.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/int_sqrt.c b/lib/int_sqrt.c
index 30e0f9770f88..66eb93105812 100644
--- a/lib/int_sqrt.c
+++ b/lib/int_sqrt.c
@@ -23,7 +23,7 @@ unsigned long int_sqrt(unsigned long x)
if (x <= 1)
return x;

- m = 1UL << (__fls(x) & ~1UL);
+ m = 1UL << ((fls(x) - 1) & ~1L);
while (m != 0) {
b = y + m;
y >>= 1;
@@ -52,7 +52,7 @@ u32 int_sqrt64(u64 x)
if (x <= ULONG_MAX)
return int_sqrt((unsigned long) x);

- m = 1ULL << ((fls64(x) - 1) & ~1ULL);
+ m = 1ULL << ((fls64(x) - 1) & ~1LL);
while (m != 0) {
b = y + m;
y >>= 1;
--
2.17.1