summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorotto <otto@openbsd.org>2007-01-14 19:18:12 +0000
committerotto <otto@openbsd.org>2007-01-14 19:18:12 +0000
commitc5565af98a75bbfb13fe30c44e494bd0fbdda655 (patch)
treed269c3d271b9603fe676c062c22ae8acda6a882d
parentragge@netbsd fixed the copyright, thanks. ok miod@ (diff)
downloadwireguard-openbsd-c5565af98a75bbfb13fe30c44e494bd0fbdda655.tar.xz
wireguard-openbsd-c5565af98a75bbfb13fe30c44e494bd0fbdda655.zip
Add some comments on the expresssion which converts sensor timedeltas
to ntp offsets; also, rewrite the expression to make it more clear with no change in semantics. ok henning@
-rw-r--r--usr.sbin/ntpd/sensors.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/usr.sbin/ntpd/sensors.c b/usr.sbin/ntpd/sensors.c
index 7057220e4ce..0216667163c 100644
--- a/usr.sbin/ntpd/sensors.c
+++ b/usr.sbin/ntpd/sensors.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sensors.c,v 1.28 2006/12/28 00:24:27 naddy Exp $ */
+/* $OpenBSD: sensors.c,v 1.29 2007/01/14 19:18:12 otto Exp $ */
/*
* Copyright (c) 2006 Henning Brauer <henning@openbsd.org>
@@ -164,8 +164,13 @@ sensor_query(struct ntp_sensor *s)
s->last = sensor.tv.tv_sec;
memcpy(&refid, "HARD", sizeof(refid));
- s->offsets[s->shift].offset = (0 - (float)sensor.value / 1000000000.0) -
- getoffset();
+ /*
+ * TD = device time
+ * TS = system time
+ * sensor.value = TS - TD in ns
+ * if value is positive, system time is ahead
+ */
+ s->offsets[s->shift].offset = (sensor.value / -1e9) - getoffset();
s->offsets[s->shift].rcvd = sensor.tv.tv_sec;
s->offsets[s->shift].good = 1;