]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: time: use __tv_to_ms() in tv_update_date() instead of open-coding
authorWilly Tarreau <w@1wt.eu>
Fri, 23 Apr 2021 14:03:21 +0000 (16:03 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 23 Apr 2021 16:03:06 +0000 (18:03 +0200)
Instead of calculating the current date in milliseconds by hand, let's
use __tv_to_ms() which was made exactly for this purpose.

src/time.c

index cb106ca3f91fc009981722c006e7e76329ccce05..4ebde3779fc786552d18f01180945da88d7eeafe 100644 (file)
@@ -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 <global_now> 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;