This is an automated email from the ASF dual-hosted git repository.
pkarashchenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new f4d5a23571 libc/fixedmatch: Avoid "divide by zero" error
f4d5a23571 is described below
commit f4d5a235717a67bd7ff7443d39846004d3b7cbce
Author: Xiang Xiao <[email protected]>
AuthorDate: Fri Apr 22 06:52:11 2022 +0800
libc/fixedmatch: Avoid "divide by zero" error
Signed-off-by: Xiang Xiao <[email protected]>
---
libs/libc/fixedmath/lib_ubsqrt.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/libs/libc/fixedmath/lib_ubsqrt.c b/libs/libc/fixedmath/lib_ubsqrt.c
index ed9dfdf8f9..342da15283 100644
--- a/libs/libc/fixedmath/lib_ubsqrt.c
+++ b/libs/libc/fixedmath/lib_ubsqrt.c
@@ -55,7 +55,7 @@ ub16_t ub32sqrtub16(ub32_t a)
xk = (uint64_t)1 << 63;
}
- do
+ while (xk)
{
uint64_t xk1 = (xk + n / xk) >> 1;
@@ -66,7 +66,6 @@ ub16_t ub32sqrtub16(ub32_t a)
xk = xk1;
}
- while (1);
/* 'xk' now holds 'sqrt(n)' => 'sqrt(a * 2^32)' => 'sqrt(a) * 2^16', thus
* 'xk' holds square root of 'a' in ub16_t format.
@@ -101,7 +100,7 @@ ub8_t ub16sqrtub8(ub16_t a)
xk = (uint32_t)1 << 31;
}
- do
+ while (xk)
{
uint32_t xk1 = (xk + n / xk) >> 1;
@@ -112,7 +111,6 @@ ub8_t ub16sqrtub8(ub16_t a)
xk = xk1;
}
- while (1);
/* 'xk' now holds 'sqrt(n)' => 'sqrt(a * 2^16)' => 'sqrt(a) * 2^8', thus
* 'xk' holds square root of 'a' in ub8_t format.