From: Frank Mori Hess Date: Mon, 21 Feb 2005 20:52:55 +0000 (+0000) Subject: patch from Ian Abbott : X-Git-Tag: r0_7_70~44 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=f40b0e226417334db8a7ad7b3c26498bbc6d6e90;p=comedi.git patch from Ian Abbott : Here's a couple more minor patches for the i8253_cascade_ns_to_timer_2div function, which I should have spotted earlier. 8253_dupcalc.patch gets rid of a duplicate calculation 8253_overflow.patch adds some arithmetic overflow checks to the "early exit" test. --- diff --git a/comedi/drivers/8253.h b/comedi/drivers/8253.h index 97066b71..12f9ae44 100644 --- a/comedi/drivers/8253.h +++ b/comedi/drivers/8253.h @@ -133,9 +133,14 @@ static inline void i8253_cascade_ns_to_timer_2div(int i8253_osc_base, * and execution) */ div1 = *d1 ? *d1 : 0x10000; div2 = *d2 ? *d2 : 0x10000; + divider = div1 * div2; if(div1 * div2 * i8253_osc_base == *nanosec && div1 > 1 && div1 <= 0x10000 && - div2 > 1 && div2 <= 0x10000) + div2 > 1 && div2 <= 0x10000 && + /* check for overflow */ + divider > div1 && divider > div2 && + divider * i8253_osc_base > divider && + divider * i8253_osc_base > i8253_osc_base) { return; } @@ -160,7 +165,6 @@ static inline void i8253_cascade_ns_to_timer_2div(int i8253_osc_base, div2_glb = div2; } if (div2 <= 0x10000) { - ns = i8253_osc_base * div1 * div2; if (ns >= *nanosec && ns < ns_lub) { ns_lub = ns; div1_lub = div1;