[Git][NTPsec/ntpsec][master] Experimental cleanups for lgtm. No logic changes.

Eric S. Raymond gitlab at mg.gitlab.com
Wed Sep 2 13:24:44 UTC 2020



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


Commits:
949c0072 by Eric S. Raymond at 2020-09-02T09:25:55-04:00
Experimental cleanups for lgtm. No logic changes.

See https://lgtm.com/projects/g/ntpsec/ntpsec/?mode=list

- - - - -


5 changed files:

- attic/backwards.c
- attic/cmac-timing.c
- ntpclients/ntpq.py
- ntpclients/ntpviz.py
- wafhelpers/asciidoc.py


Changes:

=====================================
attic/backwards.c
=====================================
@@ -39,6 +39,7 @@ main(int argc, char *argv[])
 		if ((ts0.tv_sec < ts1.tv_sec) ||
 		    ((ts0.tv_sec == ts1.tv_sec) &&
 		     (ts0.tv_nsec <= ts1.tv_nsec))) {
+		    continue;
 		} else {
 			ts_print(&ts0, &ts1);
 			if (ts0.tv_sec == ts1.tv_sec


=====================================
attic/cmac-timing.c
=====================================
@@ -38,7 +38,7 @@
 #define UNUSED_ARG(arg)         ((void)(arg))
 
 
-int NUM = 1000000;
+int SAMPLESIZE = 1000000;
 
 #define PACKET_LENGTH 48
 #define MAX_KEY_LENGTH 64
@@ -139,7 +139,7 @@ static void DoCMAC(
 	}
 
 	clock_gettime(CLOCK_MONOTONIC, &start);
-	for (int i = 0; i < NUM; i++) {
+	for (int i = 0; i < SAMPLESIZE; i++) {
 		digestlength = One_CMAC(cipher, key, keylength, pkt, pktlength);
 		if (0 == digestlength)
 			break;
@@ -147,7 +147,7 @@ static void DoCMAC(
 	clock_gettime(CLOCK_MONOTONIC, &stop);
 	fast = (stop.tv_sec-start.tv_sec)*1E9 + (stop.tv_nsec-start.tv_nsec);
 	printf("%12s  %2d %2d %2lu %6.0f  %6.3f",
-	       name, keylength, pktlength, digestlength, fast/NUM,  fast/1E9);
+	       name, keylength, pktlength, digestlength, fast/SAMPLESIZE,  fast/1E9);
 	PrintHex(answer, digestlength);
 	printf("\n");
 }
@@ -207,14 +207,14 @@ static void DoPKEY(
 	EVP_MD_CTX_set_flags(ctx, EVP_MD_CTX_FLAG_FINALISE);
 
 	clock_gettime(CLOCK_MONOTONIC, &start);
-	for (int i = 0; i < NUM; i++) {
+	for (int i = 0; i < SAMPLESIZE; i++) {
 		digestlength = One_PKEY(pkey, ctx, pkt, pktlength);
 	}
 
 	clock_gettime(CLOCK_MONOTONIC, &stop);
 	fast = (stop.tv_sec-start.tv_sec)*1E9 + (stop.tv_nsec-start.tv_nsec);
 	printf("%12s  %2d %2d %2lu %6.0f  %6.3f",
-	       name, keylength, pktlength, digestlength, fast/NUM,  fast/1E9);
+	       name, keylength, pktlength, digestlength, fast/SAMPLESIZE,  fast/1E9);
 	PrintHex(answer, digestlength);
 	printf("\n");
 	EVP_MD_CTX_free(ctx);
@@ -289,14 +289,14 @@ static void Do_EVP_MAC(
 
 
 	clock_gettime(CLOCK_MONOTONIC, &start);
-	for (int i = 0; i < NUM; i++) {
+	for (int i = 0; i < SAMPLESIZE; i++) {
 		digestlength = One_EVP_MAC(evp, cbc, key, keylength, pkt, pktlength);
 if (0 == digestlength) break;
 	}
 	clock_gettime(CLOCK_MONOTONIC, &stop);
 	fast = (stop.tv_sec-start.tv_sec)*1E9 + (stop.tv_nsec-start.tv_nsec);
 	printf("%12s  %2d %2d %2lu %6.0f  %6.3f",
-	       name, keylength, pktlength, digestlength, fast/NUM,  fast/1E9);
+	       name, keylength, pktlength, digestlength, fast/SAMPLESIZE,  fast/1E9);
 	PrintHex(answer, digestlength);
 	printf("\n");
 }
@@ -363,14 +363,14 @@ static void Do_EVP_MAC2(
 
 
 	clock_gettime(CLOCK_MONOTONIC, &start);
-	for (int i = 0; i < NUM; i++) {
+	for (int i = 0; i < SAMPLESIZE; i++) {
 		digestlength = One_EVP_MAC2(evp, pkt, pktlength);
 if (0 == digestlength) break;
 	}
 	clock_gettime(CLOCK_MONOTONIC, &stop);
 	fast = (stop.tv_sec-start.tv_sec)*1E9 + (stop.tv_nsec-start.tv_nsec);
 	printf("%12s  %2d %2d %2lu %6.0f  %6.3f",
-	       name, keylength, pktlength, digestlength, fast/NUM,  fast/1E9);
+	       name, keylength, pktlength, digestlength, fast/SAMPLESIZE,  fast/1E9);
 	PrintHex(answer, digestlength);
 	printf("\n");
 }


=====================================
ntpclients/ntpq.py
=====================================
@@ -14,7 +14,6 @@ from __future__ import print_function, division
 
 import cmd
 import getopt
-import hashlib
 import os
 import re
 import resource


=====================================
ntpclients/ntpviz.py
=====================================
@@ -791,9 +791,9 @@ plot \\
 
         for key in gpslist:
             plot_template += """\
-'-' using 1:2 title '%(key)s TDOP' with line ls 1, \\
-'-' using 1:3 title '%(key)s nSat' with line ls 2 axis x1y2, \\
-""" % locals()
+'-' using 1:2 title '%s TDOP' with line ls 1, \\
+'-' using 1:3 title '%s nSat' with line ls 2 axis x1y2, \\
+""" % (key,)
 
         # strip the trailing ", \\n"
         plot_template = plot_template[:-4] + "\n"
@@ -1288,7 +1288,7 @@ plot \
 def local_offset_multiplot(statlist):
     "Plot comparative local offsets for a list of NTPViz objects."
 
-    out = []
+    out = {}
     out['size'] = args.img_size
     out['terminal'] = args.terminal
 


=====================================
wafhelpers/asciidoc.py
=====================================
@@ -170,4 +170,4 @@ def run_manpage(self, node):
     out_n = self.bld.path.find_or_declare(out)
     self.create_task('man', node, out_n)
     self.bld.install_files('${MANDIR}/man%s/' % self.section, out_n)
-    weight = 3
+    #weight = 3



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/commit/949c00724320a3c6ef3df23af7d273d4b02f3c23

-- 
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/commit/949c00724320a3c6ef3df23af7d273d4b02f3c23
You're receiving this email because of your account on gitlab.com.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20200902/1d7d289d/attachment-0001.htm>


More information about the vc mailing list