Merge branch 'timespec_add_msec_overflow' of https://github.com/sitsofe/fio
authorJens Axboe <axboe@kernel.dk>
Tue, 22 Aug 2017 16:32:18 +0000 (10:32 -0600)
committerJens Axboe <axboe@kernel.dk>
Tue, 22 Aug 2017 16:32:18 +0000 (10:32 -0600)
time.c

diff --git a/time.c b/time.c
index edfe779bc2423876e949be48b11fb3ed354af986..07984190d67a914173e1980f0ed0461b45ea5ee8 100644 (file)
--- a/time.c
+++ b/time.c
@@ -8,17 +8,17 @@ static unsigned long ns_granularity;
 
 void timespec_add_msec(struct timespec *ts, unsigned int msec)
 {
-       unsigned long adj_nsec = 1000000 * msec;
+       uint64_t adj_nsec = 1000000ULL * msec;
 
        ts->tv_nsec += adj_nsec;
        if (adj_nsec >= 1000000000) {
-               unsigned long adj_sec = adj_nsec / 1000000000UL;
+               uint64_t adj_sec = adj_nsec / 1000000000;
 
-               ts->tv_nsec -=  adj_sec * 1000000000UL;
+               ts->tv_nsec -= adj_sec * 1000000000;
                ts->tv_sec += adj_sec;
        }
-       if (ts->tv_nsec >= 1000000000UL){
-               ts->tv_nsec -= 1000000000UL;
+       if (ts->tv_nsec >= 1000000000){
+               ts->tv_nsec -= 1000000000;
                ts->tv_sec++;
        }
 }