From: andreaskoepke Date: Wed, 17 Dec 2008 17:42:22 +0000 (+0000) Subject: avoid integer overflow X-Git-Tag: rc_6_tinyos_2_1_1~542 X-Git-Url: https://oss.titaniummirror.com/gitweb/?a=commitdiff_plain;ds=sidebyside;h=98d4eae39755d369b001971ec9c5f1dd741bc82d;p=tinyos-2.x.git avoid integer overflow --- diff --git a/tos/chips/cc2420/lpl/DefaultLplP.nc b/tos/chips/cc2420/lpl/DefaultLplP.nc index d93debb0..3ada9db6 100644 --- a/tos/chips/cc2420/lpl/DefaultLplP.nc +++ b/tos/chips/cc2420/lpl/DefaultLplP.nc @@ -230,7 +230,7 @@ implementation { return 0; } - return (DUTY_ON_TIME * (10000 - dutyCycle)) / dutyCycle; + return ((uint32_t)DUTY_ON_TIME * (10000 - dutyCycle)) / dutyCycle; } /** @@ -245,7 +245,7 @@ implementation { return 10000; } - return getActualDutyCycle((DUTY_ON_TIME * 10000) + return getActualDutyCycle(((uint32_t)DUTY_ON_TIME * 10000) / (sleepInterval + DUTY_ON_TIME)); }