Fix wrap bug in mtime_since()
authorJens Axboe <axboe@kernel.dk>
Fri, 16 Mar 2012 12:55:27 +0000 (13:55 +0100)
committerJens Axboe <axboe@kernel.dk>
Fri, 16 Mar 2012 12:55:27 +0000 (13:55 +0100)
Signed-off-by: Jens Axboe <axboe@kernel.dk>
time.c

diff --git a/time.c b/time.c
index ef05094..4af84bc 100644 (file)
--- a/time.c
+++ b/time.c
@@ -48,16 +48,13 @@ unsigned long mtime_since(struct timeval *s, struct timeval *e)
                usec += 1000000;
        }
 
+       if (sec < 0 || (sec == 0 && usec < 0))
+               return 0;
+
        sec *= 1000UL;
        usec /= 1000UL;
        ret = sec + usec;
 
-       /*
-        * time warp bug on some kernels?
-        */
-       if (ret < 0)
-               ret = 0;
-
        return ret;
 }