From 77c296cf598a23b249a2451a410d36a89de55d87 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ren=C3=A9=20Kijewski?= <rene.kijewski@fu-berlin.de>
Date: Thu, 17 Apr 2014 14:46:21 +0200
Subject: [PATCH] vtimer: fix integer overflow in vtimer_now() for MSP-430

---
 sys/vtimer/vtimer.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/sys/vtimer/vtimer.c b/sys/vtimer/vtimer.c
index eb27347600..625334fc28 100644
--- a/sys/vtimer/vtimer.c
+++ b/sys/vtimer/vtimer.c
@@ -261,9 +261,10 @@ static int vtimer_set(vtimer_t *timer)
 void vtimer_now(timex_t *out)
 {
     uint32_t us = HWTIMER_TICKS_TO_US(hwtimer_now() - longterm_tick_start);
+    uint32_t us_per_s = 1000ul * 1000ul;
 
-    out->seconds = seconds + us / (1000 * 1000);
-    out->microseconds = us % (1000 * 1000);
+    out->seconds = seconds + us / us_per_s;
+    out->microseconds = us % us_per_s;
 }
 
 void vtimer_gettimeofday(struct timeval *tp) {
-- 
GitLab