buffer_tree: Add code to splice out a node of the buffer tree.
[paraslash.git] / time.c
diff --git a/time.c b/time.c
index 0ebc6ec0c8f3f10e66f77ffe18d0f8fe05d7210a..0cb9babe2ae8de65be0fdfdc4e65ee6a626688e8 100644 (file)
--- a/time.c
+++ b/time.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005-2008 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 2005-2009 Andre Noll <maan@systemlinux.org>
  *
  * Licensed under the GPL v2. For licencing details see COPYING.
  */
@@ -106,9 +106,10 @@ void tv_add(const struct timeval *a, const struct timeval *b,
 void tv_scale(const unsigned long mult, const struct timeval *tv,
        struct timeval *result)
 {
-       result->tv_sec = mult * tv->tv_sec;
-       result->tv_sec += tv->tv_usec * mult / 1000 / 1000;
-       result->tv_usec = tv->tv_usec * mult % (1000 * 1000);
+       uint64_t x = ((uint64_t)tv->tv_sec * 1000 * 1000 + tv->tv_usec) * mult;
+
+       result->tv_sec = x / 1000 / 1000;
+       result->tv_usec = x % (1000 * 1000);
 }
 
 /**