]> git.sesse.net Git - greproxy/commitdiff
Fix a bug in subtract_timeval_saturate.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 8 Feb 2015 22:35:22 +0000 (23:35 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 8 Feb 2015 22:35:22 +0000 (23:35 +0100)
timeutil.cpp
timeutil.h

index b3d58a7c8fd6f8369e920d9023bbb8a2e558a8d2..0649f0cbe9ae360b42cd67a133b9531b86830c3d 100644 (file)
@@ -17,10 +17,10 @@ bool less_than(const timeval &a, const timeval &b)
        return make_pair(a.tv_sec, a.tv_usec) < make_pair(b.tv_sec, b.tv_usec);
 }
 
-timeval subtract_timeval_saturate(const timeval &a, const timeval &b)
+timeval subtract_timeval_saturate(const timeval &b, const timeval &a)
 {      
        timeval ret;
-       if (less_than(a, b)) {
+       if (less_than(b, a)) {
                ret.tv_sec = ret.tv_usec = 0;
                return ret;
        }
index 93d6973fcdd4784ad526ba31923bc358bcd6dbb1..ca65adf8e2904d61dc04b1a1e858dbc30ec3902f 100644 (file)
@@ -5,7 +5,7 @@
 
 double tdiff(const timeval& a, const timeval& b);
 bool less_than(const timeval &a, const timeval &b);
-timeval subtract_timeval_saturate(const timeval &a, const timeval &b);
+timeval subtract_timeval_saturate(const timeval &b, const timeval &a);  // b - a
 timeval offset_timeval_seconds(const timeval &a, double s);
 
 #endif  // !defined(_TIMEUTIL_H)