From 823952afda151688e8b509be4f4e09b4ac1efd75 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Mon, 15 Dec 2014 13:45:53 -0700 Subject: [PATCH] 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 --- backend.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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++; } -- 2.25.1