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.
(cherry picked from commit 82dd78d698
)
This commit is contained in:
parent
fc81223045
commit
f24e148432
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Reference in New Issue