laforge
/
openbts-osmo
Archived
1
0
Fork 0

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.
This commit is contained in:
Alexander Chemeris 2010-08-24 20:45:59 +04:00
parent e139404884
commit 82dd78d698
1 changed files with 2 additions and 2 deletions

View File

@ -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;
}