]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
rx: Make clock_Add correctly add to itself
authorSimon Wilkinson <sxw@your-file-system.com>
Sat, 18 Jun 2011 10:48:45 +0000 (11:48 +0100)
committerDerrick Brashear <shadow@dementia.org>
Sat, 9 Jul 2011 05:05:40 +0000 (22:05 -0700)
With the existing clock_Add code, the following:
    struct clock a = {2, 800000};
    clock_Add(&a, &a);
gives a clock value of {6, 600000}, rather than the expected {5, 60000}.

This is because the ordering of instructions leads it to double count
the carry on the seconds field. Reorder the instructions so that the
carry is correctly applied.

Reviewed-on: http://gerrit.openafs.org/4864
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Reviewed-by: Jeffrey Altman <jaltman@openafs.org>
Tested-by: Jeffrey Altman <jaltman@openafs.org>
(cherry picked from commit 784babbea1247660f39463403233589a74c6e73b)

Change-Id: I1e97e9734d04f898dabad59a88afc929d8888e90
Reviewed-on: http://gerrit.openafs.org/4936
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>
src/rx/rx_clock.h

index 483bb07aac0116e71649e2cb7e443537e008c9ae..2bdc0b81e4887a35994d21f1116091d41221073b 100644 (file)
@@ -128,11 +128,11 @@ extern int clock_nUpdates;
 /* Add time c2 to time c1.  Both c2 and c1 must be positive times. */
 #define        clock_Add(c1, c2)                                       \
     BEGIN                                                      \
+       (c1)->sec += (c2)->sec;                                 \
        if (((c1)->usec += (c2)->usec) >= 1000000) {            \
            (c1)->usec -= 1000000;                              \
            (c1)->sec++;                                        \
        }                                                       \
-       (c1)->sec += (c2)->sec;                                 \
     END
 
 #define USEC(cp)        (((cp)->sec * 1000000) + (cp)->usec)