From: Jens Axboe Date: Mon, 15 Dec 2014 20:45:53 +0000 (-0700) Subject: backend: fix off-by-one in nsec calculation X-Git-Tag: fio-2.2.0~14 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=823952afda151688e8b509be4f4e09b4ac1efd75;p=fio.git backend: fix off-by-one in nsec calculation If it's equal to 10^9 we need to bump seconds and subtract 10^9 from nsec, not only if it's larger than. Signed-off-by: Jens Axboe --- diff --git a/backend.c b/backend.c index 3424a098..f1def38b 100644 --- a/backend.c +++ b/backend.c @@ -2109,7 +2109,7 @@ static void *helper_thread_main(void *data) gettimeofday(&tv, NULL); ts.tv_sec = tv.tv_sec + sec; ts.tv_nsec = (tv.tv_usec * 1000) + nsec; - if (ts.tv_nsec > 1000000000ULL) { + if (ts.tv_nsec >= 1000000000ULL) { ts.tv_nsec -= 1000000000ULL; ts.tv_sec++; }