From f0c00257d63463fa9d692e632fae037d6c0e67b0 Mon Sep 17 00:00:00 2001 From: Peter Williams Date: Fri, 3 Feb 2006 03:04:33 -0800 Subject: [PATCH] lib: Fix bug in int_sqrt() for 64 bit longs The implementation of int_sqrt() assumes that longs have 32 bits. On systems that have 64 bit longs this will result in gross errors when the argument to the function is greater than 2^32 - 1 on such systems. I doubt whether any such use is currently made of int_sqrt() but the attached patch fixes the problem anyway. Signed-off-by: Peter Williams Cc: Dave Jones Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- lib/int_sqrt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/int_sqrt.c') diff --git a/lib/int_sqrt.c b/lib/int_sqrt.c index a5d2cdc5684c..fd355a99327c 100644 --- a/lib/int_sqrt.c +++ b/lib/int_sqrt.c @@ -15,7 +15,7 @@ unsigned long int_sqrt(unsigned long x) op = x; res = 0; - one = 1 << 30; + one = 1UL << (BITS_PER_LONG - 2); while (one > op) one >>= 2; -- cgit v1.2.3-70-g09d2