[Git][NTPsec/ntpsec][master] Fix a NetBSD/FreeBSD port bug in ntp_adjtime_ns().

Eric S. Raymond gitlab at mg.gitlab.com
Sun Oct 16 10:44:48 UTC 2016


Eric S. Raymond pushed to branch master at NTPsec / ntpsec


Commits:
ee8f8751 by Eric S. Raymond at 2016-10-16T06:44:18-04:00
Fix a NetBSD/FreeBSD port bug in ntp_adjtime_ns().

- - - - -


1 changed file:

- libntp/machines.c


Changes:

=====================================
libntp/machines.c
=====================================
--- a/libntp/machines.c
+++ b/libntp/machines.c
@@ -67,10 +67,18 @@ int clock_gettime(clockid_t clk_id, struct timespec *tp)
  * absent, however, this way callers can tell what accuracy they're
  * actually getting.
  *
- * Problems: the Linux manual page for adjtimex(2) says the precision member
- * is microseconds and doesn't mention STA_NANO, but the legacy ntptime code
- * has a scaling expression in it that implies nanoseconds if that flash bit
- * is on.
+ * Some versions of ntp_adtime(2), notably the Linux one which is
+ * implemented in terms of a local, unstandardized adjtimex(2), have a
+ * time member that can be used to retrieve and increment
+ * (ADJ_SETOFFSET) system time.  If this were portable there would be
+ * scaling of ntx->time.tv_usec in here for non-STA_NANO systems.  It
+ * isn't; NetBSD and FreeBSD don't have that time member.
+ *
+ * Problem: the Linux manual page for adjtimex(2) says the precision
+ * member is microseconds and doesn't mention STA_NANO, but the legacy
+ * ntptime code has a scaling expression in it that implies
+ * nanoseconds if that flash bit is on. It is unknown under what
+ * circumstances, if any, this was ever correct.
  */
 int ntp_adjtime_ns(struct timex *ntx)
 {
@@ -88,17 +96,13 @@ int ntp_adjtime_ns(struct timex *ntx)
 #ifdef STA_NANO
     if (!nanoseconds)
 #endif
-    {
-	ntx->time.tv_usec /= 1000;
 	ntx->offset /= 1000;
-    }
     int errval = ntp_adjtime(ntx);
 #ifdef STA_NANO
     nanoseconds = (STA_NANO & ntx->status) != 0;
     if (!nanoseconds)
 #endif
     {
-	ntx->time.tv_usec *= 1000;
 	ntx->offset *= 1000;
 	//ntx->precision *= 1000;
 	ntx->jitter *= 1000;



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/ee8f875176d88038a3eb601c5f2929b0a3754504
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20161016/4e1a4039/attachment.html>


More information about the vc mailing list