From 2ce1eb4d6c0adc209f56789920362d455cca443e Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sat, 11 Nov 2006 14:19:40 +0000 Subject: [PATCH] Make sure loops_per_tick doesn't overflow to zero. --- src/devices/timer.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/devices/timer.c b/src/devices/timer.c index 070c487..662e0c6 100644 --- a/src/devices/timer.c +++ b/src/devices/timer.c @@ -57,8 +57,11 @@ timer_calibrate (void) /* Approximate loops_per_tick as the largest power-of-two still less than one timer tick. */ loops_per_tick = 1u << 10; - while (!too_many_loops (loops_per_tick << 1)) - loops_per_tick <<= 1; + while (!too_many_loops (loops_per_tick << 1)) + { + loops_per_tick <<= 1; + ASSERT (loops_per_tick != 0); + } /* Refine the next 8 bits of loops_per_tick. */ high_bit = loops_per_tick; -- 2.30.2