From da876aec63b133b64eb6e71f8b87df5c84e7ec3b Mon Sep 17 00:00:00 2001 From: Sebastian Hahn Date: Sun, 25 Dec 2011 23:19:08 +0100 Subject: Provide correct timeradd/timersup replacements Bug caught and patch provided by Vektor. Fixes bug 4778.t --- src/common/compat.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/common/compat.h b/src/common/compat.h index 3e1b5b8263..e0b074cf53 100644 --- a/src/common/compat.h +++ b/src/common/compat.h @@ -334,7 +334,7 @@ struct tm *tor_gmtime_r(const time_t *timep, struct tm *result); #define timeradd(tv1,tv2,tvout) \ do { \ (tvout)->tv_sec = (tv1)->tv_sec + (tv2)->tv_sec; \ - (tvout)->tv_usec = (tv2)->tv_usec + (tv2)->tv_usec; \ + (tvout)->tv_usec = (tv1)->tv_usec + (tv2)->tv_usec; \ if ((tvout)->tv_usec >= 1000000) { \ (tvout)->tv_usec -= 1000000; \ (tvout)->tv_sec++; \ @@ -348,7 +348,7 @@ struct tm *tor_gmtime_r(const time_t *timep, struct tm *result); #define timersub(tv1,tv2,tvout) \ do { \ (tvout)->tv_sec = (tv1)->tv_sec - (tv2)->tv_sec; \ - (tvout)->tv_usec = (tv2)->tv_usec - (tv2)->tv_usec; \ + (tvout)->tv_usec = (tv1)->tv_usec - (tv2)->tv_usec; \ if ((tvout)->tv_usec < 0) { \ (tvout)->tv_usec += 1000000; \ (tvout)->tv_sec--; \ -- cgit v1.2.3-54-g00ecf