[Git][NTPsec/ntpsec][master] 2 commits: Fix nasty typo.

Eric S. Raymond gitlab at mg.gitlab.com
Wed Dec 7 11:59:33 UTC 2016


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


Commits:
48de41aa by Eric S. Raymond at 2016-12-07T06:37:27-05:00
Fix nasty typo.

- - - - -
0f42058f by Eric S. Raymond at 2016-12-07T06:57:23-05:00
Restore regrewsion-test cleanliness of C ntpdig.

This code will go away soon, but it's good practice to leave it
in a clean state.

- - - - -


6 changed files:

- ntpdig/main.c
- ntpdig/networking.c
- ntpdig/utilities.c
- ntpdig/utilities.h
- ntpfrob/bumpclock.c
- tests/ntpdig/utilities.c


Changes:

=====================================
ntpdig/main.c
=====================================
--- a/ntpdig/main.c
+++ b/ntpdig/main.c
@@ -1512,27 +1512,27 @@ offset_calculation(
 	if (debug > 3) {
 		double ftime;
 		struct timespec ts_tmp;
-		pkt_output(rpkt, rpktl, stdout);
+		pkt_output(rpkt, rpktl, false, stdout);
 		printf("ntpdig rootdelay: %f\n", FPTOD(p_rdly));
 		printf("ntpdig rootdisp: %f\n", FPTOD(p_rdsp));
 		printf("ntpdig syncdist: %f\n", *synch_distance);
 		ts_tmp = lfp_stamp_to_tspec(p_ref, NULL);
-		ftime = ts_tmp.tv_sec + ts_tmp.tv_nsec / 1000000.0;
+		ftime = ts_tmp.tv_sec + ts_tmp.tv_nsec / 1e9;
 		printf("ntpdig offset_calculation: ref: %f ", ftime);
 		l_fp_output(&p_ref, stdout);
 		ts_tmp = lfp_stamp_to_tspec(p_org, NULL);
-		ftime = ts_tmp.tv_sec + ts_tmp.tv_nsec / 1000000.0;
+		ftime = ts_tmp.tv_sec + ts_tmp.tv_nsec / 1e9;
 		printf("ntpdig offset_calculation: org: %f ", ftime);
 		l_fp_output(&p_org, stdout);
 		ts_tmp = lfp_stamp_to_tspec(p_rec, NULL);
-		ftime = ts_tmp.tv_sec + ts_tmp.tv_nsec / 1000000.0;
+		ftime = ts_tmp.tv_sec + ts_tmp.tv_nsec / 1e9;
 		printf("ntpdig offset_calculation: rec: %f ", ftime);
 		l_fp_output(&p_rec, stdout);
 		ts_tmp = lfp_stamp_to_tspec(p_xmt, NULL);
-		ftime = ts_tmp.tv_sec + ts_tmp.tv_nsec / 1000000.0;
+		ftime = ts_tmp.tv_sec + ts_tmp.tv_nsec / 1e9;
 		printf("ntpdig offset_calculation: xmt: %f ", ftime);
 		l_fp_output(&p_xmt, stdout);
-		ftime = tv_dst->tv_sec + tv_dst->tv_usec / 1000.0;
+		ftime = tv_dst->tv_sec + tv_dst->tv_usec / 1e6;
 		printf("ntpdig dst %f\n", ftime);
 	}
 #endif


=====================================
ntpdig/networking.c
=====================================
--- a/ntpdig/networking.c
+++ b/ntpdig/networking.c
@@ -17,7 +17,7 @@ sendpkt (
 #ifdef DEBUG
 	if (debug > 2) {
 		printf("ntpdig sendpkt: Packet data:\n");
-		pkt_output(pkt, len, stdout);
+		pkt_output(pkt, len, true, stdout);
 	}
 #endif
 	TRACE(1, ("ntpdig sendpkt: Sending packet to %s ...\n",
@@ -56,7 +56,7 @@ recvdata(
 #ifdef DEBUG
 	if (debug > 2) {
 		printf("Received %d bytes from %s:\n", recvc, sockporttoa(sender));
-		pkt_output((struct pkt *)rdata, recvc, stdout);
+		pkt_output((struct pkt *)rdata, recvc, true, stdout);
 	}
 #endif
 	return recvc;


=====================================
ntpdig/utilities.c
=====================================
--- a/ntpdig/utilities.c
+++ b/ntpdig/utilities.c
@@ -8,7 +8,8 @@
 void 
 pkt_output (
 		struct pkt *dpkg,
-		int pkt_length, 
+		int pkt_length,
+		bool longform,
 		FILE *output
 	   )
 {
@@ -17,24 +18,26 @@ pkt_output (
 
 	pkt = (uint8_t *)dpkg;
 
-#ifdef __UNUSED__
-	fprintf(output, HLINE);
-
-	for (a = 0; a < pkt_length; a++) {
-		if (a > 0 && a % 8 == 0)
-			fprintf(output, "\n");
+	if (longform) {
+	    fprintf(output, HLINE);
 
-		fprintf(output, "%d: %x \t", a, pkt[a]);
-	}
+	    for (a = 0; a < pkt_length; a++) {
+		    if (a > 0 && a % 8 == 0)
+		        fprintf(output, "\n");
 
-	fprintf(output, "\n");
-	fprintf(output, HLINE);
-#endif /* __UNUSED__ */
+		    fprintf(output, "%d: %x \t", a, pkt[a]);
+	    }
 
-	for (a = 0; a < pkt_length; a++) {
-	    fprintf(output, "%02x", pkt[a]);
+	    fprintf(output, "\n");
+	    fprintf(output, HLINE);
+	}
+	else
+	{
+		for (a = 0; a < pkt_length; a++) {
+		    fprintf(output, "%02x", pkt[a]);
+		}
+		fprintf(output, "\n");
 	}
-	fprintf(output, "\n");
 
 }
 


=====================================
ntpdig/utilities.h
=====================================
--- a/ntpdig/utilities.h
+++ b/ntpdig/utilities.h
@@ -14,7 +14,7 @@
 #define STDLINE printf(HLINE);
 
 
-void pkt_output(struct pkt *dpkg, int pkt_length, FILE *output);
+void pkt_output(struct pkt *dpkg, int pkt_length, bool longform, FILE *output);
 void l_fp_output(l_fp *ts, FILE *output);
 void l_fp_output_bin(l_fp *ts, FILE *output);
 void l_fp_output_dec(l_fp *ts, FILE *output);


=====================================
ntpfrob/bumpclock.c
=====================================
--- a/ntpfrob/bumpclock.c
+++ b/ntpfrob/bumpclock.c
@@ -10,7 +10,7 @@
 #include <string.h>
 #include <time.h>
 
-#define NANOSECONDS	100000000
+#define NANOSECONDS	1000000000
 
 void bumpclock(int bump)
 {


=====================================
tests/ntpdig/utilities.c
=====================================
--- a/tests/ntpdig/utilities.c
+++ b/tests/ntpdig/utilities.c
@@ -154,7 +154,7 @@ TEST(utilities, DebugPktOutput) {
 	test.l_uf = 2147483647; // Lots of ones.
 	HTONL_FP(&test, &testpkt.xmt);
 
-	pkt_output(&testpkt, LEN_PKT_NOMAC, outputFile);
+	pkt_output(&testpkt, LEN_PKT_NOMAC, true, outputFile);
 
 	FinishDebugTest(CreatePath("debug-input-pkt", INPUT_DIR), filename);
 }



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/f58442bff1463f43bd6adf0c1bbabe28ebb45e3f...0f42058f015ce65e0a6ae1cf17329fea579d9ad5
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20161207/9421ea58/attachment.html>


More information about the vc mailing list