[Git][NTPsec/ntpsec][master] Change "/ NS_PER_S" to "* S_PER_NS" fixing a conversion problem.

Gary E. Miller gitlab at mg.gitlab.com
Fri Mar 17 20:51:28 UTC 2017


Gary E. Miller pushed to branch master at NTPsec / ntpsec


Commits:
3569dfe1 by Gary E. Miller at 2017-03-17T13:48:30-07:00
Change  "/ NS_PER_S" to "* S_PER_NS" fixing a conversion problem.

In this instance NS_PER_S replaced 1e9 with 1000000000, and that
caused integer instead of float arithmetic which caused precision
errors.  This change fixes that error and repalces division with
multiplication.

Yet another case where the warning messages we ignore woulda
alerted about the problem.

- - - - -


1 changed file:

- ntpd/ntp_loopfilter.c


Changes:

=====================================
ntpd/ntp_loopfilter.c
=====================================
--- a/ntpd/ntp_loopfilter.c
+++ b/ntpd/ntp_loopfilter.c
@@ -827,14 +827,14 @@ local_clock(
 			ntp_adjtime_error_handler(__func__, &ntv, ntp_adj_ret, errno, hardpps_enable, false, __LINE__ - 1);
 		}
 		pll_status = ntv.status;
-		clock_offset = ntv.offset / NS_PER_S;
+		clock_offset = ntv.offset * S_PER_NS;
 		clock_frequency = FREQTOD(ntv.freq);
 
 		/*
 		 * If the kernel PPS is lit, monitor its performance.
 		 */
 		if (ntv.status & STA_PPSTIME) {
-			clock_jitter = ntv.jitter / NS_PER_S;
+			clock_jitter = ntv.jitter * S_PER_NS;
 		}
 
 #if defined(STA_NANO) && NTP_API == 4



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/3569dfe13238e06aa2c4deded9d4b74529ea2521
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20170317/eea5fa6a/attachment.html>


More information about the vc mailing list