From: Jens Axboe Date: Tue, 22 Aug 2017 16:32:18 +0000 (-0600) Subject: Merge branch 'timespec_add_msec_overflow' of https://github.com/sitsofe/fio X-Git-Tag: fio-3.1~43 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=deeb3c11c212e99e8d1162e03e0ef734bd0d01a7;hp=168bb5875da97004163c6b755de162ad481134c4 Merge branch 'timespec_add_msec_overflow' of https://github.com/sitsofe/fio --- diff --git a/time.c b/time.c index edfe779b..07984190 100644 --- 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++; } }