From: Willy Tarreau Date: Fri, 23 Apr 2021 14:03:21 +0000 (+0200) Subject: CLEANUP: time: use __tv_to_ms() in tv_update_date() instead of open-coding X-Git-Tag: v2.4-dev17~6 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1f9e11e7f0a7c5778ddeae51f10e80aa3c06d7a3;p=thirdparty%2Fhaproxy.git CLEANUP: time: use __tv_to_ms() in tv_update_date() instead of open-coding Instead of calculating the current date in milliseconds by hand, let's use __tv_to_ms() which was made exactly for this purpose. --- diff --git a/src/time.c b/src/time.c index cb106ca3f9..4ebde3779f 100644 --- a/src/time.c +++ b/src/time.c @@ -236,7 +236,7 @@ void tv_update_date(int max_wait, int interrupted) do { tmp_now.tv_sec = (unsigned int)(old_now >> 32); tmp_now.tv_usec = old_now & 0xFFFFFFFFU; - old_now_ms = tmp_now.tv_sec * 1000 + tmp_now.tv_usec / 1000; + old_now_ms = __tv_to_ms(&tmp_now); if (__tv_islt(&now, &tmp_now)) now = tmp_now; @@ -245,7 +245,7 @@ void tv_update_date(int max_wait, int interrupted) * equal to or newer. */ new_now = ((ullong)now.tv_sec << 32) + (uint)now.tv_usec; - now_ms = now.tv_sec * 1000 + now.tv_usec / 1000; + now_ms = __tv_to_ms(&now); if (tick_is_lt(now_ms, old_now_ms)) now_ms = old_now_ms;