summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Woodhouse <dwmw2@infradead.org>2007-04-08 22:57:12 -0400
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2007-04-09 13:03:52 +1000
commit4baa63366fd5a4a077cb2461496dc45d0a7d0a5c (patch)
treeb00ae3827eddcfd7fd84c0756df22918951bda76
parent4a5bf1e1705c3921b091e565ef98ca41bc287a47 (diff)
Fix overflow in twin_fixed_sqrt()
Twin_fixed_sqrt() suffers from overflow. Fix it. Signed-off-by: David Woodhouse <dwmw2@infradead.org> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
-rw-r--r--libtwin/twin_fixed.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/libtwin/twin_fixed.c b/libtwin/twin_fixed.c
index 060fb08..a4caa3a 100644
--- a/libtwin/twin_fixed.c
+++ b/libtwin/twin_fixed.c
@@ -109,6 +109,10 @@ twin_fixed_sqrt (twin_fixed_t a)
while (max > min)
{
mid = (max + min) >> 1;
+ if (mid >= 181*TWIN_FIXED_ONE) {
+ max = mid - 1;
+ continue;
+ }
sqr = twin_fixed_mul (mid, mid);
if (sqr == a)
return mid;