From 82dd78d69847ccbf0056c0917bf34c5e6e1d7cfa Mon Sep 17 00:00:00 2001 From: Alexander Chemeris Date: Tue, 24 Aug 2010 20:45:59 +0400 Subject: [PATCH] Fix a bug with Timeval difference calculation on 64-bit Linux. Subtracting uint32_t from uin32_t gives you uint32_t. And assigning result to a long doesn't make it a signed value, because on 64-bit Linux long is 64 bits. --- public-trunk/CommonLibs/Timeval.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public-trunk/CommonLibs/Timeval.cpp b/public-trunk/CommonLibs/Timeval.cpp index d61de0c..ae57345 100644 --- a/public-trunk/CommonLibs/Timeval.cpp +++ b/public-trunk/CommonLibs/Timeval.cpp @@ -70,8 +70,8 @@ double Timeval::seconds() const long Timeval::delta(const Timeval& other) const { // 2^31 milliseconds is just over 4 years. - long deltaS = other.sec() - sec(); - long deltaUs = other.usec() - usec(); + int32_t deltaS = other.sec() - sec(); + int32_t deltaUs = other.usec() - usec(); return 1000*deltaS + deltaUs/1000; }