[Git][NTPsec/ntpsec][master] 7 commits: Fix PEP8 E703 statement ends with a semicolon

Eric S. Raymond gitlab at mg.gitlab.com
Tue Sep 13 03:39:02 UTC 2016


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


Commits:
4b9e01ec by Matt Selsky at 2016-09-12T21:21:57-04:00
Fix PEP8 E703 statement ends with a semicolon

- - - - -
56bb62c0 by Matt Selsky at 2016-09-12T21:21:57-04:00
Fix PEP8 W391 blank line at end of file

- - - - -
885d3a36 by Matt Selsky at 2016-09-12T21:21:57-04:00
Fix PEP8 E711 comparison to None should be 'if cond is None:' or similar

- - - - -
702a4013 by Matt Selsky at 2016-09-12T21:21:57-04:00
popen is mark of 'os' module, not 'sys'.

- - - - -
8d380e5f by Matt Selsky at 2016-09-12T21:21:57-04:00
Fix pylint: Undefined variable 'sys' (undefined-variable)

- - - - -
6be1aad9 by Matt Selsky at 2016-09-12T21:21:57-04:00
Fix comment since overflow counter was unused

- - - - -
a93c8fcd by Matt Selsky at 2016-09-12T21:21:57-04:00
Boolification

- - - - -


26 changed files:

- contrib/cpu-temp-log
- contrib/smartctl-temp-log
- include/timevalops.h
- libntp/atolfp.c
- libntp/systime.c
- ntpd/ntp_control.c
- ntpd/ntp_timer.c
- ntpd/refclock_nmea.c
- ntpstats/ntpviz
- ntpsweep/ntpsweep
- ntpwait/ntpwait
- pylib/packet.py
- pylib/statfiles.py
- pylib/util.py
- util/calc_tickadj/calc_tickadj
- wafhelpers/bin_test.py
- wafhelpers/check_cap.py
- wafhelpers/check_openssl.py
- wafhelpers/check_seccomp.py
- wafhelpers/check_sizeof.py
- wafhelpers/check_sockaddr.py
- wafhelpers/compiler.py
- wafhelpers/configure.py
- wafhelpers/rtems_trace.py
- wafhelpers/tool.py
- wafhelpers/waf.py


Changes:

=====================================
contrib/cpu-temp-log
=====================================
--- a/contrib/cpu-temp-log
+++ b/contrib/cpu-temp-log
@@ -57,4 +57,3 @@ for line in lines:
         temp = match.group(1)
         sys.stdout.write( '%d LM%d %s\n' % (now, index, temp))
         index += 1
-


=====================================
contrib/smartctl-temp-log
=====================================
--- a/contrib/smartctl-temp-log
+++ b/contrib/smartctl-temp-log
@@ -72,4 +72,3 @@ for line in lines:
     if match and match.group(1):
         temp = match.group(1)
         sys.stdout.write( '%d SMART %s\n' % (now, temp))
-


=====================================
include/timevalops.h
=====================================
--- a/include/timevalops.h
+++ b/include/timevalops.h
@@ -79,14 +79,14 @@ extern const uint32_t tstoushi[128];
 
 #define sTVTOTS(tv, ts) \
 	do { \
-		int isneg = 0; \
+		bool isneg = false; \
 		long usec; \
 		(ts)->l_ui = (tv)->tv_sec; \
 		usec = (tv)->tv_usec; \
 		if (((tv)->tv_sec < 0) || ((tv)->tv_usec < 0)) { \
 			usec = -usec; \
 			(ts)->l_ui = -(ts)->l_ui; \
-			isneg = 1; \
+			isneg = true; \
 		} \
 		TVUTOTSF(usec, (ts)->l_uf); \
 		if (isneg) { \


=====================================
libntp/atolfp.c
=====================================
--- a/libntp/atolfp.c
+++ b/libntp/atolfp.c
@@ -37,12 +37,12 @@ atolfp(
 	register unsigned long dec_f;
 	char *ind;
 	int ndec;
-	int isneg;
+	bool isneg;
 	static const char *digits = "0123456789";
 
 	NTP_REQUIRE(str != NULL);
 
-	isneg = 0;
+	isneg = false;
 	dec_i = dec_f = 0;
 	ndec = 0;
 	cp = str;
@@ -57,7 +57,7 @@ atolfp(
 	
 	if (*cp == '-') {
 		cp++;
-		isneg = 1;
+		isneg = true;
 	}
 	
 	if (*cp == '+')


=====================================
libntp/systime.c
=====================================
--- a/libntp/systime.c
+++ b/libntp/systime.c
@@ -251,7 +251,7 @@ adj_systime(
 	double	quant;		/* quantize to multiples of */
 	double	dtemp;
 	long	ticks;
-	int	isneg = 0;
+	bool	isneg = false;
 
 	/*
 	 * FIXME: With the legacy Windows port on, this might be removable.
@@ -276,7 +276,7 @@ adj_systime(
 	 */
 	dtemp = now + sys_residual;
 	if (dtemp < 0) {
-		isneg = 1;
+		isneg = true;
 		dtemp = -dtemp;
 	}
 	adjtv.tv_sec = (long)dtemp;


=====================================
ntpd/ntp_control.c
=====================================
--- a/ntpd/ntp_control.c
+++ b/ntpd/ntp_control.c
@@ -773,7 +773,7 @@ process_control(
 	req_count = (int)ntohs(pkt->count);
 	datanotbinflag = false;
 	datalinelen = 0;
-	datasent = 0;
+	datasent = false;
 	datapt = rpkt.u.data;
 	dataend = &rpkt.u.data[CTL_MAX_DATA_LEN];
 


=====================================
ntpd/ntp_timer.c
=====================================
--- a/ntpd/ntp_timer.c
+++ b/ntpd/ntp_timer.c
@@ -61,7 +61,7 @@ volatile u_long alarm_overflow;
 u_long current_time;		/* seconds since startup */
 
 /*
- * Stats.  Number of overflows and number of calls to transmit().
+ * Stats.  Time of last reset and number of calls to transmit().
  */
 u_long timer_timereset;
 u_long timer_xmtcalls;


=====================================
ntpd/refclock_nmea.c
=====================================
--- a/ntpd/refclock_nmea.c
+++ b/ntpd/refclock_nmea.c
@@ -811,8 +811,8 @@ nmea_receive(
 	ZERO(date);
 	ZERO(gpsw);
 	sentence = 0;
-	rc_date = 0;
-	rc_time = 0;
+	rc_date = false;
+	rc_time = false;
 	/* 
 	 * Read the timecode and timestamp, then initialise field
 	 * processing. The <CR><LF> at the NMEA line end is translated


=====================================
ntpstats/ntpviz
=====================================
--- a/ntpstats/ntpviz
+++ b/ntpstats/ntpviz
@@ -760,7 +760,7 @@ if __name__ == '__main__':
                 sys.stderr.write("ntpviz: ERROR: missing temps data\n")
                 raise SystemExit(1)
             if show_temps is not None:
-                plot = stats.local_temps_gnuplot();
+                plot = stats.local_temps_gnuplot()
             if generate:
                 gnuplot(plot)
             else:
@@ -1050,7 +1050,7 @@ ntpviz</a>, part of the <a href="https://www.ntpsec.org/">NTPsec project</a>
 
         for (imagename, image) in imagepairs:
             if not image:
-                continue;
+                continue
             div_name = imagename.replace('-', ' ')
             index_buffer += "<div>\n<h2>%s:</h2>\n" % div_name
             if 'peer-jitter-' == imagename[:12]:


=====================================
ntpsweep/ntpsweep
=====================================
--- a/ntpsweep/ntpsweep
+++ b/ntpsweep/ntpsweep
@@ -173,6 +173,6 @@ Host                             st offset(s) version     system       processor
     for host in hostlist:
           scan_host(host, 0)
 
-    sys.exit(0);
+    sys.exit(0)
 
 # end


=====================================
ntpwait/ntpwait
=====================================
--- a/ntpwait/ntpwait
+++ b/ntpwait/ntpwait
@@ -193,4 +193,3 @@ if __name__ == "__main__":
     sys.exit(1)
 
 # end
-


=====================================
pylib/packet.py
=====================================
--- a/pylib/packet.py
+++ b/pylib/packet.py
@@ -175,7 +175,7 @@ SERR_NOHOST = "***No host open, use `host' command\n"
 def dump_hex_printable(xdata):
     "Dump a packet in hex, in a familiar hex format"
     llen = len(xdata)
-    i = 0;
+    i = 0
     while llen > 0:
         rowlen = min(16, llen)
         restart = i
@@ -318,9 +318,9 @@ class ntpq_session:
         # If it isn't authenticated we can just send it.  Otherwise
         # we're going to have to think about it a little.
         if not auth and not self.always_auth:
-            return pkt.send();
+            return pkt.send()
         else:
-            sys.stderr.write("Authenticated send is not yet implemented\n");
+            sys.stderr.write("Authenticated send is not yet implemented\n")
             return -1
     def getresponse(self, opcode, associd, timeo):
         "Get a response expected to match a given opcode and associd."
@@ -331,7 +331,7 @@ class ntpq_session:
          # should have had.  Note we use one long time out, should reconsider.
         fragments = []
         self.response = ''
-        seenlastfrag = False;
+        seenlastfrag = False
         bail = 0
         warn = sys.stderr.write
 
@@ -364,7 +364,7 @@ class ntpq_session:
                         warn("%s: timed out, nothing received\n" % self.name)
                         return SERR_TIMEOUT
                 if timeo:
-                    warn("%s: timed out with incomplete data\n" % self.name);
+                    warn("%s: timed out with incomplete data\n" % self.name)
                     if self.debug:
                         sys.stderr.write("ERR_INCOMPLETE: Received fragments:\n")
                         for (i, frag) in enumerate(fragments):
@@ -373,7 +373,7 @@ class ntpq_session:
                                     ("not " "", )[seenlastfrag])
                     return SERR_INCOMPLETE
 
-            rawdata = self.sock.recv(4096);
+            rawdata = self.sock.recv(4096)
             if self.debug:
                 warn("Received %d octets\n" % len(rawdata))
             rpkt = control_frag(self)
@@ -393,7 +393,7 @@ class ntpq_session:
                 continue
             if not rpkt.is_response():
                 if self.debug:
-                    warn("Received request, wanted response\n");
+                    warn("Received request, wanted response\n")
                 #continue
 
             # Check opcode and sequence number for a match.
@@ -449,7 +449,7 @@ class ntpq_session:
             if len(fragments) > 0:
                 last = fragments[-1]
                 if last.end() > rpkt.offset:
-                    warn("received frag at %d overlaps with %d octet frag at %d\n" % (rpkt.offset, last.count, last.offset));
+                    warn("received frag at %d overlaps with %d octet frag at %d\n" % (rpkt.offset, last.count, last.offset))
                     continue
 
             if not_earlier and rpkt.end() > not_earlier.offset:
@@ -483,10 +483,10 @@ class ntpq_session:
         "send a request and save the response"
         if not self.havehost():
             return SERR_NOHOST
-        done = False;
+        done = False
         while True:
             # Ship the request
-            res = self.sendrequest(opcode, associd, qdata, auth);
+            res = self.sendrequest(opcode, associd, qdata, auth)
             if res is not None:
                 return res
             # Get the response.
@@ -502,7 +502,7 @@ class ntpq_session:
                     continue
             break
         # Return None on success, otherwise an error string
-        return res;
+        return res
     def readvars(self):
         "Read system vars from the host as a dict, or return an error string."
         self.doquery(opcode=CTL_OP_READVAR, quiet=True)


=====================================
pylib/statfiles.py
=====================================
--- a/pylib/statfiles.py
+++ b/pylib/statfiles.py
@@ -27,7 +27,7 @@ class NTPStats:
             # unparseable  time 0 and it will be stripped later
             return None
         # 86400 = 24 * 60 * 60
-        time = 86400*mjd + second - 3506716800; # warning: 32 bit overflows
+        time = 86400*mjd + second - 3506716800 # warning: 32 bit overflows
         if time < starttime or time > endtime:
             return None
         return str(time) + " " + split[2]
@@ -43,7 +43,7 @@ class NTPStats:
         self.period = period
 
         # Default to one week before the latest date
-        if endtime is None and starttime == None:
+        if endtime is None and starttime is None:
             endtime = int(time.time())
             starttime = endtime - period
         elif starttime is None and endtime is not None:
@@ -66,7 +66,7 @@ class NTPStats:
                 for logpart in glob.glob(os.path.join(statsdir, stem) + "*"):
                     # skip files older than starttime
                     if starttime > os.path.getmtime(logpart):
-                        continue;
+                        continue
                     if logpart.endswith("gz"):
                         lines += gzip.open(logpart).readlines()
                     else:
@@ -81,7 +81,7 @@ class NTPStats:
                 # temps is already in UNIX time
                 for line in lines:
                     line = line.strip(' \0\r\n\t')
-                    if line != None:
+                    if line is not None:
                         split = line.split(None, 2)
                         if int(split[0]) >= starttime and \
                            int(split[0]) <= endtime:
@@ -91,7 +91,7 @@ class NTPStats:
                 for line in lines:
                     line = line.strip(' \0\r\n\t')
                     line = NTPStats.unixize(line,starttime, endtime)
-                    if line != None:
+                    if line is not None:
                         lines1.append( line)
 
             # Sort by datestamp


=====================================
pylib/util.py
=====================================
--- a/pylib/util.py
+++ b/pylib/util.py
@@ -3,6 +3,7 @@
 from __future__ import print_function
 
 import socket
+import sys
 
 def canonicalize_dns(hostname):
     try:


=====================================
util/calc_tickadj/calc_tickadj
=====================================
--- a/util/calc_tickadj/calc_tickadj
+++ b/util/calc_tickadj/calc_tickadj
@@ -23,7 +23,7 @@ hyphen and the flag character.
 
 from __future__ import print_function, division
 
-import sys, getopt, re
+import sys, getopt, re, os
 
 if __name__ == '__main__':
     try:
@@ -45,7 +45,7 @@ if __name__ == '__main__':
 
     if tick == 0:
         try:
-            with sys.popen("ntpfrob -A") as rp:
+            with os.popen("ntpfrob -A") as rp:
                 response = rp.read()
                 m = re.search("[0-9]+", response)
                 if m:
@@ -89,4 +89,3 @@ if __name__ == '__main__':
     sys.exit(0)
 
 # end
-


=====================================
wafhelpers/bin_test.py
=====================================
--- a/wafhelpers/bin_test.py
+++ b/wafhelpers/bin_test.py
@@ -28,7 +28,7 @@ cmd_map = {
 def run(cmd, reg):
         check = False
 
-        if cmd[1] == None:
+        if cmd[1] is None:
                 cmd = [cmd[0]]
 
         print("running: ", " ".join(cmd), end="")


=====================================
wafhelpers/check_cap.py
=====================================
--- a/wafhelpers/check_cap.py
+++ b/wafhelpers/check_cap.py
@@ -19,5 +19,3 @@ def check_cap(ctx):
         pprint("RED", "Warning libcap and headers not installed")
         pprint("RED", "Fedora needs libcap-devel")
         pprint("RED", "Debian needs libcap-dev")
-
-


=====================================
wafhelpers/check_openssl.py
=====================================
--- a/wafhelpers/check_openssl.py
+++ b/wafhelpers/check_openssl.py
@@ -58,4 +58,3 @@ def configure_ssl(ctx):
 	if ctx.get_define("HAVE_OPENSSL"):
 		ctx.define("USE_OPENSSL_CRYPTO_RAND", 1, comment="Use OpenSSL pseudo-random number generator")
 		ctx.define("USE_OPENSSL_HASH", 1, comment="Use OpenSSL for hashing")
-


=====================================
wafhelpers/check_seccomp.py
=====================================
--- a/wafhelpers/check_seccomp.py
+++ b/wafhelpers/check_seccomp.py
@@ -6,7 +6,7 @@ def check_seccomp(ctx):
     if  not ctx.options.enable_seccomp:
         return
     if not sys.platform.startswith("linux"):
-        return;
+        return
 
 
     ctx.check_cc(header_name="seccomp.h", mandatory=False)
@@ -18,5 +18,3 @@ def check_seccomp(ctx):
         pprint("RED", "Warning libseccomp and headers")
         pprint("RED", "Fedora needs libseccomp-devel")
         pprint("RED", "Debian needs libseccomp-dev")
-
-


=====================================
wafhelpers/check_sizeof.py
=====================================
--- a/wafhelpers/check_sizeof.py
+++ b/wafhelpers/check_sizeof.py
@@ -80,4 +80,3 @@ def check_sizeof(*kwargs):
 		return check_sizeof_cross(*kwargs)
 	else:
 		return check_sizeof_host(*kwargs)
-


=====================================
wafhelpers/check_sockaddr.py
=====================================
--- a/wafhelpers/check_sockaddr.py
+++ b/wafhelpers/check_sockaddr.py
@@ -35,4 +35,3 @@ def check_sockaddr(ctx):
 		mandatory	= False,
 		comment		= "Whether sockaddr.sa_len exists"
 	)
-


=====================================
wafhelpers/compiler.py
=====================================
--- a/wafhelpers/compiler.py
+++ b/wafhelpers/compiler.py
@@ -61,4 +61,3 @@ def check_compiler(ctx):
 	ctx.env[define] = True # Build system.
 
 	ctx.end_msg(name)
-


=====================================
wafhelpers/configure.py
=====================================
--- a/wafhelpers/configure.py
+++ b/wafhelpers/configure.py
@@ -546,4 +546,3 @@ def cmd_configure(ctx, config):
                 msg("")
                 msg("*** --enable-debug ignored.  (default on now)")
                 msg("")
-


=====================================
wafhelpers/rtems_trace.py
=====================================
--- a/wafhelpers/rtems_trace.py
+++ b/wafhelpers/rtems_trace.py
@@ -6,5 +6,3 @@ from waflib.TaskGen import feature, after_method
 def rtems_trace(self):
 	if self.env.RTEMS_TEST_ENABLE:
 		self.link_task.env.LINK_CC = self.env.BIN_RTEMS_TLD + self.env.RTEMS_TEST_FLAGS + ['--']
-
-


=====================================
wafhelpers/tool.py
=====================================
--- a/wafhelpers/tool.py
+++ b/wafhelpers/tool.py
@@ -7,5 +7,3 @@ def check_sanity(ctx, cond, lib):
 		pprint("RED", "Warning %s headers detected, binaries do not build/run" % lib)
 	elif (not cond) and ctx.get_define(define):
 		pprint("RED", "Warning %s headers not detected, binaries build/run" % lib)
-
-


=====================================
wafhelpers/waf.py
=====================================
--- a/wafhelpers/waf.py
+++ b/wafhelpers/waf.py
@@ -84,4 +84,3 @@ def ntp_test(ctx, **kwargs):
 		args += tg.test_args
 
 	tg.ut_exec = args
-



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/0000eb4556c76b9fd7a67300f7cda4a42d8a6dc1...a93c8fcd0185ebae07b46c1d44e6924f9e1855f0
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20160913/fd3e2e9e/attachment.html>


More information about the vc mailing list