From abf31d367a8e80a13cb6d2a8a6c499914c2e91e7 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Mon, 26 Jul 2010 22:33:54 -0400 Subject: [PATCH] Fix integer truncating bug in calc_future_timer(). Be sure to promote to u64 before multiplication. --- src/clock.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/clock.c b/src/clock.c index 49ab901..6d46501 100644 --- a/src/clock.c +++ b/src/clock.c @@ -1,6 +1,6 @@ // 16bit code to handle system clocks. // -// Copyright (C) 2008 Kevin O'Connor +// Copyright (C) 2008-2010 Kevin O'Connor // Copyright (C) 2002 MandrakeSoft S.A. // // This file may be distributed under the terms of the GNU LGPLv3 license. @@ -238,7 +238,7 @@ calc_future_timer(u32 msecs) { if (!msecs) return GET_BDA(timer_counter); - u32 kticks = DIV_ROUND_UP((u64)(msecs * PIT_TICK_RATE), PIT_TICK_INTERVAL); + u32 kticks = DIV_ROUND_UP((u64)msecs * PIT_TICK_RATE, PIT_TICK_INTERVAL); u32 ticks = DIV_ROUND_UP(kticks, 1000); return calc_future_timer_ticks(ticks); } -- 2.25.1