diff --git a/common/rfb/Timer.cxx b/common/rfb/Timer.cxx index 4654d50c8d..fbc9bae95e 100644 --- a/common/rfb/Timer.cxx +++ b/common/rfb/Timer.cxx @@ -54,7 +54,10 @@ inline static timeval addMillis(timeval inTime, int millis) { } inline static int diffTimeMillis(timeval later, timeval earlier) { - return ((later.tv_sec - earlier.tv_sec) * 1000) + ((later.tv_usec - earlier.tv_usec + 999) / 1000); + long udiff; + udiff = ((later.tv_sec - earlier.tv_sec) * 1000000) + + (later.tv_usec - earlier.tv_usec); + return (udiff + 999) / 1000; } std::list Timer::pending;