[Git][NTPsec/ntpsec][master] 4 commits: Rename two ntp.ntpc tests from the same name.

Hal Murray (@hal.murray) gitlab at mg.gitlab.com
Mon Dec 4 09:38:44 UTC 2023



Hal Murray pushed to branch master at NTPsec / ntpsec


Commits:
509da4fb by James Browning at 2023-12-03T17:02:38-08:00
Rename two ntp.ntpc tests from the same name.

- - - - -
caf4ee6f by James Browning at 2023-12-03T23:48:15-08:00
attic/samba: Fix nits from codacy and clang.

- - - - -
587474a8 by James Browning at 2023-12-03T23:50:27-08:00
Add docstring to OpenSSL waf helper.

- - - - -
59e30510 by James Browning at 2023-12-03T23:50:56-08:00
Make pylint shut up about f-strings.

- - - - -


6 changed files:

- attic/samba/fake-ntp-client.c
- attic/samba/fake-ntp-server.c
- attic/samba/fake-samba.c
- pylintrc
- tests/pylib/test_ntpc.py
- wafhelpers/openssl.py


Changes:

=====================================
attic/samba/fake-ntp-client.c
=====================================
@@ -16,12 +16,12 @@
 
 #include "fake.h"
 
-char* host = "time.example.com";// First arg
-int packets = 1;		// Second arg
-int delay = 1000;		// Third arg, microseconds after each packet
+static char* host = "time.example.com";// First arg
+static int packets = 1;		// Second arg
+static useconds_t delay = 1000;		// Third arg, microseconds after each packet
 
-int sock;
-struct ntp_packet ntp_send, ntp_recv;
+static int sock;
+static struct ntp_packet ntp_send, ntp_recv;
 
 void bailout(char *msg);
 
@@ -37,7 +37,7 @@ void bailout(char *msg)
   printf("** %s %s: errno = %d, %s\n",
     timetxt, msg, saverrr, strerror(saverrr));
   exit(1);
-};
+}
 
 int main (int argc, char *argv[])
 {
@@ -46,7 +46,7 @@ int main (int argc, char *argv[])
   float timeout = 5.0;
   struct timeval tv;
   int addr;
-  int i, ec, len;
+  int i, ec;
 
   if (argc > 3) delay = atoi(argv[3]);
   if (delay < 0) bailout("Bad delay");
@@ -68,7 +68,7 @@ int main (int argc, char *argv[])
     (addr >> 8) & 0xff,
     (addr >> 0) & 0xff);
 
-  if (0) printf("Sending: len = %ld, header=%8x\n",
+  if ((0)) printf("Sending: len = %zu, header=%8x\n",
     sizeof(ntp_send), ntp_send.header); 
 
   bzero((char *)&server, sizeof(server));
@@ -98,6 +98,7 @@ int main (int argc, char *argv[])
   ntp_send.keyid = 56578;  
 
   for (i = 0; i < packets; i++) {
+    int len;
     struct timespec start, stop;
     double elapsed;
     ntp_send.t3.seconds = htonl(i);


=====================================
attic/samba/fake-ntp-server.c
=====================================
@@ -17,7 +17,7 @@
 
 #include "fake.h"
 
-char *name = FAKE_SAMBA_SOCKET;
+static char *name = FAKE_SAMBA_SOCKET;
 
 int main(int argc, char *argv[]) {
 	struct timespec start, stop;
@@ -28,6 +28,8 @@ int main(int argc, char *argv[]) {
 	struct from_samba reply;
 	int len;
 	uint32_t length, net_length, op;
+	((void)(argc));
+	((void)(argv));
 
         clock_gettime(CLOCK_MONOTONIC, &start);
 
@@ -86,17 +88,17 @@ int main(int argc, char *argv[]) {
 
 	/* check stuff */
 	if (length != sizeof(reply)) {
-	  printf("** Wrong length word: %d\n", length);
+	  printf("** Wrong length word: %u\n", length);
 	}
 	op = ntohl(reply.op);
 	if (op != 3) {
-	  printf("** Wrong op field: %d\n", op);
+	  printf("** Wrong op field: %u\n", op);
 	}
 	if (reply.packet_id != HACK_PACKET_ID) {
-	  printf("** Wrong packet_id field: %d\n", reply.packet_id);
+	  printf("** Wrong packet_id field: %u\n", reply.packet_id);
 	}
 	if (reply.key_id != HACK_KEY_ID) {
-	  printf("** Wrong key_id field: %d\n", reply.key_id);
+	  printf("** Wrong key_id field: %u\n", reply.key_id);
 	}
 
 	if (memcmp(reply.pkt, request.pkt, sizeof(reply.pkt))) {


=====================================
attic/samba/fake-samba.c
=====================================
@@ -17,12 +17,14 @@
 
 #include "fake.h"
 
-char *name = FAKE_SAMBA_SOCKET;
+static char *name = FAKE_SAMBA_SOCKET;
 
 int main(int argc, char *argv[]) {
 	int listener;
 	struct sockaddr_un addr;
 	uint32_t length, net_length;
+	((void)(argc));
+	((void)(argv));
 
 	unlink(name);  /* Don't care if it fails. */
 
@@ -53,7 +55,7 @@ int main(int argc, char *argv[]) {
 	  return 4;
 	}
 
-	for (int i=0; ; i++) {
+	for (;;) {
 	  struct sockaddr_un who;
 	  socklen_t len = sizeof(who);
 	  int client;
@@ -83,7 +85,7 @@ int main(int argc, char *argv[]) {
 	    length = ntohl(net_length);
 	  }
 	  if (length != sizeof(request)) {
-	    printf("** Wrong length word: %d\n", length);
+	    printf("** Wrong length word: %u\n", length);
 	  }
 	  len = read(client, buffer, sizeof(buffer));
 	  if (len <0) {
@@ -100,7 +102,7 @@ int main(int argc, char *argv[]) {
 	    memcpy(&request, buffer, sizeof(request));
 	  }
 	  if (request.op != 0) {
-	    printf("** Wrong op field: %d\n", request.op);
+	    printf("** Wrong op field: %u\n", request.op);
 	  }
 
 	  /* construct reply */
@@ -135,7 +137,7 @@ int main(int argc, char *argv[]) {
 	    printf("## wrote %d bytes\n", len);
           }
 	  close(client);
-	  printf("packet_id: %d, key_id: %d\n",
+	  printf("packet_id: %u, key_id: %d\n",
 	    request.packet_id, request.key_id);
 	  printf("\n");
 	}


=====================================
pylintrc
=====================================
@@ -13,6 +13,7 @@
 
 # Disable warnings that are silly
 disable=bad-continuation,
+        consider-using-f-string,
         invalid-name,
         misplaced-comparison-constant,
         no-self-use,


=====================================
tests/pylib/test_ntpc.py
=====================================
@@ -30,7 +30,7 @@ class TestPylibNtpc(unittest.TestCase):
             self.assertEqual(ntp.ntpc.prettydate(in_string), to_string)
             self.assertAlmostEqual(ntp.ntpc.lfptofloat(in_string), to_float)
 
-    def test_nul_trunc16(self):
+    def test_nul_trunc16b(self):
         k_type = "aes-128"
         key = ntp.util.hexstr2octets(
             "0fd2287c1e97a50cb9d3cb9f80debcb6")
@@ -45,7 +45,7 @@ class TestPylibNtpc(unittest.TestCase):
         mac1 = ntp.poly.polybytes(sample[52:])
         self.assertEqual([len(mac1), mac1], [len(mac2), mac2], msg="nul trunc")
 
-    def test_nul_trunc16(self):
+    def test_nul_trunc16f(self):
         k_type = "aes-256"
         key = ntp.util.hexstr2octets(
             "fc0af35640142bb85ad03a892a81fa9d" +


=====================================
wafhelpers/openssl.py
=====================================
@@ -1,3 +1,5 @@
+"""Report on OpenSSL version and features for OpenSSL."""
+
 SNIP_LIBSSL_TLS13_CHECK = """
 #include <openssl/tls1.h>
 
@@ -12,6 +14,7 @@ int main(void) {
 
 
 def check_libssl_tls13(ctx):
+    """Report if OpenSSL supports TLS 1.3 for ./waf configure."""
     ctx.check_cc(
       fragment=SNIP_LIBSSL_TLS13_CHECK,
       use="SSL CRYPTO",
@@ -33,6 +36,7 @@ int main(void) {
 
 
 def check_openssl_bad_version(ctx):
+    """Report if OpenSSL has a good version to ./waf configure."""
     ctx.check_cc(
       fragment=SNIP_OPENSSL_BAD_VERSION_CHECK,
       use="SSL CRYPTO",
@@ -56,6 +60,7 @@ int main(void) {
 
 
 def dump_openssl_version(ctx):
+    """Report OpenSSL version to ./waf configure."""
     _ = "XXX_LIBSSL_VERSION"
     ctx.start_msg("LibSSL version")
     ret = ctx.check_cc(



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/compare/a3a047142ca6588b885c979c74f52167d00c28ff...59e305105186dfd59491abc45f0971b92fb9437d

-- 
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/compare/a3a047142ca6588b885c979c74f52167d00c28ff...59e305105186dfd59491abc45f0971b92fb9437d
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/20231204/15fef3b8/attachment-0001.htm>


More information about the vc mailing list