From 784babbea1247660f39463403233589a74c6e73b Mon Sep 17 00:00:00 2001 From: Simon Wilkinson Date: Sat, 18 Jun 2011 11:48:45 +0100 Subject: [PATCH] rx: Make clock_Add correctly add to itself 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. Change-Id: Ia71b387ce521a11e4caf9ec200907efe1d2be8ff Reviewed-on: http://gerrit.openafs.org/4864 Reviewed-by: Derrick Brashear Reviewed-by: Jeffrey Altman Tested-by: Jeffrey Altman --- src/rx/rx_clock.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rx/rx_clock.h b/src/rx/rx_clock.h index 483bb07..2bdc0b8 100644 --- a/src/rx/rx_clock.h +++ b/src/rx/rx_clock.h @@ -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) -- 1.9.4