]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
time-util: Fixed usec comparison in timeval_cmp_margin().
authorStephan Bosch <stephan@dovecot.fi>
Tue, 14 Jun 2016 23:53:44 +0000 (01:53 +0200)
committerStephan Bosch <stephan@dovecot.fi>
Wed, 15 Jun 2016 18:18:54 +0000 (20:18 +0200)
src/lib/time-util.c

index 9bfad68558c4e82dabfddd0891a00908b468ec56..3ab1a86821aee92b0fb5a74c91d3aca7570a3383 100644 (file)
@@ -28,10 +28,10 @@ int timeval_cmp_margin(const struct timeval *tv1, const struct timeval *tv2,
        if (tv1->tv_sec > tv2->tv_sec)
                return 1;
 
-       if (tv1->tv_usec - tv2->tv_usec < (int)usec_margin)
-               return -1;
-       if (tv1->tv_usec - tv2->tv_usec > (int)usec_margin)
+       if ((tv2->tv_usec - tv1->tv_usec) > (int)usec_margin)
                return -1;
+       if ((tv1->tv_usec - tv2->tv_usec) > (int)usec_margin)
+               return 1;
        return 0;
 }