diff mbox

[PATCHv3,06/10] linux-generic: tm: avoid underflow on log2 of 0

Message ID 1464306409-7325-7-git-send-email-bill.fischofer@linaro.org
State Accepted
Commit 46b3eb72933118d85d2cc137f6bae84e2481a46d
Headers show

Commit Message

Bill Fischofer May 26, 2016, 11:46 p.m. UTC
Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org>
---
 platform/linux-generic/odp_timer_wheel.c | 3 +++
 1 file changed, 3 insertions(+)
diff mbox

Patch

diff --git a/platform/linux-generic/odp_timer_wheel.c b/platform/linux-generic/odp_timer_wheel.c
index a8717b7..66600b7 100644
--- a/platform/linux-generic/odp_timer_wheel.c
+++ b/platform/linux-generic/odp_timer_wheel.c
@@ -166,6 +166,9 @@  static uint32_t _odp_internal_ilog2(uint64_t value)
 	uint64_t pwr_of_2;
 	uint32_t bit_shift;
 
+	if (value == 0)
+		return 64;
+
 	for (bit_shift = 0; bit_shift < 64; bit_shift++) {
 		pwr_of_2 = 1ULL << bit_shift;
 		if (value == pwr_of_2)