From b0f7efd59ea793e4eaf8b8ebe909a34d9282de2a Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Tue, 10 Jan 2017 17:23:47 +0100 Subject: [PATCH] util: handle zero in conversion of NTP timestamps Handle zero NTP timestamp in UTI_Ntp64ToTimespec() as a special value to make it symmetric with UTI_TimespecToNtp64(). This is needed since commit d75f6830f190037421a66754849571fd0b495e35, in which a timestamp is converted back and forth without checking for zero. It also makes zero NTP timestamps more apparent in debug output. --- util.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/util.c b/util.c index 0488f010..977580a6 100644 --- a/util.c +++ b/util.c @@ -754,8 +754,11 @@ UTI_Ntp64ToTimespec(NTP_int64 *src, struct timespec *dest) { uint32_t ntp_sec, ntp_frac; - /* As yet, there is no need to check for zero - all processing that - has to detect that case is in the NTP layer */ + /* Zero is a special value */ + if (UTI_IsZeroNtp64(src)) { + UTI_ZeroTimespec(dest); + return; + } ntp_sec = ntohl(src->hi); ntp_frac = ntohl(src->lo); -- 2.47.3