[Git][NTPsec/ntpsec][master] 2 commits: Add comments to decode dates as magic numbers

Hal Murray gitlab at mg.gitlab.com
Tue Apr 4 09:21:23 UTC 2017


Hal Murray pushed to branch master at NTPsec / ntpsec


Commits:
60b517f7 by Hal Murray at 2017-04-04T02:15:17-07:00
Add comments to decode dates as magic numbers

- - - - -
2cc696ff by Hal Murray at 2017-04-04T02:15:17-07:00
Fix 2x if DEBUG => ifdef DEBUG (in refclocks)

- - - - -


3 changed files:

- contrib/make-leap-seconds.py
- ntpd/refclock_jjy.c
- ntpd/refclock_jupiter.c


Changes:

=====================================
contrib/make-leap-seconds.py
=====================================
--- a/contrib/make-leap-seconds.py
+++ b/contrib/make-leap-seconds.py
@@ -83,7 +83,7 @@ args = sys.argv[1:]
 
 leap = time.time()
 days = int(leap/86400)
-leap = days*86400
+leap = (days+1)*86400
 
 if len(args) > 0:
   leapdate = datetime.datetime.strptime(args[0], "%Y-%m-%d")
@@ -97,13 +97,16 @@ if len(args) > 0:
   expire = (expiredate - epoch).total_seconds()
   expire = int(expire)
   args = args[1:]
+leap_txt = time.asctime(time.gmtime(leap))
 leap = str(leap+JAN_1970)
+expire_txt = time.asctime(time.gmtime(expire))
 expire=str(expire+JAN_1970)
 
-update = time.time()
-days = int(update/86400)
-update = days*86400
+update = int(time.time())
+update_txt = time.asctime(time.gmtime(update))
 update = str(update+JAN_1970)
+
+
 tai = "40"          # hardwired
 
 # File format
@@ -121,13 +124,13 @@ tai = "40"          # hardwired
 #  All dates use NTP epoch of 1900-01-01
 
 sha1 = sha.new()
-print("%s %s" % (leap, tai))
+print("%s %s  # %s" % (leap, tai, leap_txt))
 sha1.update(leap)
 sha1.update(tai)
-print("#$ %s" % update)
-sha1.update(update)
-print("#@ %s" % expire)
+print("#@ %s  # %s" % (expire, expire_txt))
 sha1.update(expire)
+print("#$ %s  # %s" % (update, update_txt))
+sha1.update(update)
 digest = sha1.hexdigest()
 print("#h %s %s %s %s %s" % \
  (digest[0:8], digest[8:16], digest[16:24], digest[24:32], digest[32:40]))


=====================================
ntpd/refclock_jjy.c
=====================================
--- a/ntpd/refclock_jjy.c
+++ b/ntpd/refclock_jjy.c
@@ -3492,7 +3492,7 @@ teljjy_conn_data ( struct peer *peer, struct refclockproc *pp, struct jjyunit *u
 		up->iTimestampCount++ ;
 
 		if ( up->iTimestampCount == 6 && ! up->bLineError ) {
-#if DEBUG
+#ifdef DEBUG
 			printf( "refclock_jjy.c : teljjy_conn_data : bLineError=%d iTimestamp=%d, %d, %d\n",
 				up->bLineError,
 				up->iTimestamp[3], up->iTimestamp[4], up->iTimestamp[5] ) ;


=====================================
ntpd/refclock_jupiter.c
=====================================
--- a/ntpd/refclock_jupiter.c
+++ b/ntpd/refclock_jupiter.c
@@ -589,7 +589,7 @@ jupiter_ppsapi(
 	}
 /*	instance->peer->precision = PPS_PRECISION; */
 
-#if DEBUG
+#ifdef DEBUG
 	if (debug) {
 		time_pps_getparams(instance->pps_handle, &instance->pps_params);
 		jupiter_debug(instance->peer, __func__,



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/6077bf19ff2f181acf52f5420611834c95e7d39e...2cc696ffd068039fb286d3d3ff9b3ba8753a4b60
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20170404/9c6ece65/attachment.html>


More information about the vc mailing list