[Git][NTPsec/ntpsec][master] 4 commits: Fix mrulist sorting

Eric S. Raymond gitlab at mg.gitlab.com
Sat Nov 26 23:26:57 UTC 2016


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


Commits:
8c1f9e46 by Matt Selsky at 2016-11-26T18:04:12-05:00
Fix mrulist sorting

dict's use get, not getkey
fix exception name for bad sort keys
keep sort key and sort function variables distinct

- - - - -
a97e0b13 by Matt Selsky at 2016-11-26T18:04:12-05:00
refid_as_address() is not static, so make sure to use "self"

- - - - -
fd1106d7 by Matt Selsky at 2016-11-26T18:04:12-05:00
Fix NameError: global name 'count' is not defined

- - - - -
ee49ffc4 by Matt Selsky at 2016-11-26T18:05:06-05:00
Typos in comments

- - - - -


2 changed files:

- ntpd/refclock_oncore.c
- pylib/packet.py


Changes:

=====================================
ntpd/refclock_oncore.c
=====================================
--- a/ntpd/refclock_oncore.c
+++ b/ntpd/refclock_oncore.c
@@ -629,8 +629,8 @@ oncore_start(
 	oncore_log(instance, LOG_NOTICE, "state = ONCORE_NO_IDEA");
 
 	/* Now open files.
-	 * This is a bit complicated, a we don't want to open the same file twice
-	 * (its a problem on some OS), and device2 may not exist for the new PPS
+	 * This is a bit complicated, and we don't want to open the same file twice
+	 * (it's a problem on some OS), and device2 may not exist for the new PPS
 	 */
 
 	(void)snprintf(device1, sizeof(device1), DEVICE1, unit);


=====================================
pylib/packet.py
=====================================
--- a/pylib/packet.py
+++ b/pylib/packet.py
@@ -489,9 +489,9 @@ class SyncPacket(Packet):
         "Represent a posixized sync packet in an eyeball-friendly format."
         r = "<NTP:%s:%d%:%d" % (self.leap(), self.version(), self.mode())
         r += "%f:%f:" % (self.root_delay, self.root_dispersion)
-        rs = self.refid_as_string
+        rs = self.refid_as_string()
         if not rs.isprint():
-            rd = refid_as_address()
+            rd = self.refid_as_address()
         r += ":" + rs 
         r += ":" + ntp.util.rfc3339(SyncPacket.ntp_to_posix(self.reference_timestamp))
         r += ":" + ntp.util.rfc3339(SyncPacket.ntp_to_posix(self.origin_timestamp))
@@ -982,14 +982,14 @@ class ControlSession:
             shouldbesize = (ControlPacket.HEADER_LEN + rpkt.count + 3) & ~3
             if len(rawdata) < shouldbesize:
                 warn("Response packet claims %u octets payload, above %d received\n" % \
-                    (count, len(rawdata) - ControlPacket.HEADER_LEN))
+                    (rpkt.count, len(rawdata) - ControlPacket.HEADER_LEN))
                 raise ControlException(SERR_INCOMPLETE)
 
             if self.debug > 1:
                 warn("Got packet, size = %d\n"% len(rawdata))
             if rpkt.count > (len(rawdata) - ControlPacket.HEADER_LEN):
                     warn("Received count of %u octets, data in packet is %ld\n"\
-                                   % (count, len(rawdata) - ControlPacket.HEADER_LEN))
+                                   % (rpkt.count, len(rawdata) - ControlPacket.HEADER_LEN))
                     continue
 
             # Someday, perhaps, check authentication here
@@ -1169,7 +1169,7 @@ class ControlSession:
 
         if variables:
             if "sort" in variables:
-                sorter = variables["sort"]
+                sortkey = variables["sort"]
                 del variables["sort"]
                 # FIXME: implement sorting by address, in case anyone cares
                 sortdict = {
@@ -1182,12 +1182,12 @@ class ControlSession:
                 "count" : lambda e: e.ct,	# hit count ascending
                 "-count": lambda e: -e.ct,	# hit count descending
                 }
-                if sorter == "listint":
-                    sorter = None
-                if sorter is not None:
-                    sorter = sortdict.getkey(key)
+                if sortkey == "listint":
+                    sortkey = None
+                if sortkey is not None:
+                    sorter = sortdict.get(sortkey)
                     if sorter == None:
-                        raise ControlException(BAD_SORT % key)
+                        raise ControlException(SERR_BADSORT % sortkey)
             for k in list(variables.keys()):
                 if k in ("mincount", "resall", "resany",
                          "maxlstint", "laddr", "sort"):



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/e1927a2fde4a1af175dfa97ef8269ab80210a9ac...ee49ffc45991a2f376dee5cccd3a097a4bbc4883
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20161126/01e7e4d3/attachment.html>


More information about the vc mailing list