[Git][NTPsec/ntpsec][master] 4 commits: tests/lfpfunc: Add more output for NetBSD failure.

Gary E. Miller gitlab at mg.gitlab.com
Fri Apr 14 03:01:31 UTC 2017


Gary E. Miller pushed to branch master at NTPsec / ntpsec


Commits:
2a233d34 by Gary E. Miller at 2017-04-13T19:28:40-07:00
tests/lfpfunc: Add more output for NetBSD failure.

- - - - -
e40a9ac4 by Gary E. Miller at 2017-04-13T19:46:30-07:00
refclock_magnavox: Fix several discards 'const' qualifier

And traded for a fewer number of same.

- - - - -
01b8bb33 by Gary E. Miller at 2017-04-13T19:51:36-07:00
Fix many discards 'const' qualifier.

No tradeoffs.

- - - - -
8e75f667 by Gary E. Miller at 2017-04-13T20:00:10-07:00
refclock_magnavox: fix recently added discards const issues.

- - - - -


3 changed files:

- ntpd/refclock_magnavox.c
- ntptime/ntptime.c
- tests/libntp/lfpfunc.c


Changes:

=====================================
ntpd/refclock_magnavox.c
=====================================
--- a/ntpd/refclock_magnavox.c
+++ b/ntpd/refclock_magnavox.c
@@ -134,17 +134,17 @@ static	void	mx4200_shutdown	(int, struct peer *);
 static	void	mx4200_receive	(struct recvbuf *);
 static	void	mx4200_poll	(int, struct peer *);
 
-static	char *	mx4200_parse_t	(struct peer *);
-static	char *	mx4200_parse_p	(struct peer *);
-static	char *	mx4200_parse_s	(struct peer *);
+static	const char *	mx4200_parse_t	(struct peer *);
+static	const char *	mx4200_parse_p	(struct peer *);
+static	const char *	mx4200_parse_s	(struct peer *);
 int	mx4200_cmpl_fp	(const void *, const void *);
 static	bool	mx4200_config	(struct peer *);
 static	void	mx4200_ref	(struct peer *);
-static	void	mx4200_send	(struct peer *, char *, ...)
+static	void	mx4200_send	(struct peer *, const char *, ...)
     __attribute__ ((format (printf, 2, 3)));
 static	uint8_t	mx4200_cksum	(char *, int);
 static	int	mx4200_jday	(int, int, int);
-static	void	mx4200_debug	(struct peer *, char *, ...)
+static	void	mx4200_debug	(struct peer *, const char *, ...)
     __attribute__ ((format (printf, 2, 3)));
 static	bool	mx4200_pps	(struct peer *);
 
@@ -645,6 +645,7 @@ mx4200_receive(
 	struct refclockproc *pp;
 	struct peer *peer;
 	char *cp;
+	const char *ccp;
 	int sentence_type;
 	uint8_t ck;
 
@@ -756,9 +757,9 @@ mx4200_receive(
 		 * indicates the receiver needs to be initialized; thus, it is
 		 * not necessary to decode the status message.
 		 */
-		if ((cp = mx4200_parse_s(peer)) != NULL) {
+		if ((ccp = mx4200_parse_s(peer)) != NULL) {
 			mx4200_debug(peer,
-				     "mx4200_receive: status: %s\n", cp);
+				     "mx4200_receive: status: %s\n", ccp);
 		}
 		mx4200_debug(peer, "mx4200_receive: reset receiver\n");
 		mx4200_config(peer);
@@ -773,8 +774,9 @@ mx4200_receive(
 			/*
 			 * Parse the message, calculating our averaged position.
 			 */
-			if ((cp = mx4200_parse_p(peer)) != NULL) {
-				mx4200_debug(peer, "mx4200_receive: pos: %s\n", cp);
+			if ((ccp = mx4200_parse_p(peer)) != NULL) {
+				mx4200_debug(peer, "mx4200_receive: pos: %s\n",
+                                             ccp);
 				return;
 			}
 			mx4200_debug(peer,
@@ -802,9 +804,9 @@ mx4200_receive(
 	case PMVXG_D_SOFTCONF:
 	case PMVXG_D_TRECOVUSEAGE:
 
-		if ((cp = mx4200_parse_s(peer)) != NULL) {
+		if ((ccp = mx4200_parse_s(peer)) != NULL) {
 			mx4200_debug(peer,
-				     "mx4200_receive: multi-record: %s\n", cp);
+				     "mx4200_receive: multi-record: %s\n", ccp);
 		}
 		break;
 
@@ -828,8 +830,8 @@ mx4200_receive(
 		 * Parse the time recovery message, and keep the info
 		 * to print the pretty billboards.
 		 */
-		if ((cp = mx4200_parse_t(peer)) != NULL) {
-			mx4200_debug(peer, "mx4200_receive: time: %s\n", cp);
+		if ((ccp = mx4200_parse_t(peer)) != NULL) {
+			mx4200_debug(peer, "mx4200_receive: time: %s\n", ccp);
 			refclock_report(peer, CEVNT_BADREPLY);
 			return;
 		}
@@ -923,7 +925,7 @@ mx4200_receive(
  *			further ahead of UTC time.
  *
  */
-static char *
+static const char *
 mx4200_parse_t(
 	struct peer *peer
 	)
@@ -1206,7 +1208,7 @@ mx4200_jday(
  *			57 = 3 sat startup failed
  *			58 = Command abort
  */
-static char *
+static const char *
 mx4200_parse_p(
 	struct peer *peer
 	)
@@ -1428,7 +1430,7 @@ mx4200_parse_p(
  *	8	Position Known PRN (absent on MX 4200)
  *
  */
-static char *
+static const char *
 mx4200_parse_s(
 	struct peer *peer
 	)
@@ -1532,7 +1534,7 @@ mx4200_pps(
  * mx4200_debug - print debug messages
  */
 static void
-mx4200_debug(struct peer *peer, char *fmt, ...)
+mx4200_debug(struct peer *peer, const char *fmt, ...)
 {
 	UNUSED_ARG(peer);
 #ifndef DEBUG
@@ -1558,7 +1560,7 @@ mx4200_debug(struct peer *peer, char *fmt, ...)
  * Send a character string to the receiver.  Checksum is appended here.
  */
 static void
-mx4200_send(struct peer *peer, char *fmt, ...)
+mx4200_send(struct peer *peer, const char *fmt, ...)
 {
 	struct refclockproc *pp;
 


=====================================
ntptime/ntptime.c
=====================================
--- a/ntptime/ntptime.c
+++ b/ntptime/ntptime.c
@@ -342,25 +342,25 @@ main(
 	} else {
 		char binbuf[132];
 		/* oldstyle formats */
-		char *ofmt7 = "ntp_adjtime() returns code %d (%s)\n";
-		char *ofmt8 = "  modes %s,\n";
-		char *ofmt9 = "  offset %.3f";
-		char *ofmt10 = " us, frequency %.3f ppm, interval %d s,\n";
-		char *ofmt11 = "  maximum error %lu us, estimated error %lu us,\n";
-		char *ofmt12 = "  status %s,\n";
-		char *ofmt13 = "  time constant %lu, precision %.3f us, tolerance %.0f ppm,\n";
-		char *ofmt14 = "  pps frequency %.3f ppm, stability %.3f ppm, jitter %.3f us,\n";
-		char *ofmt15 = "  intervals %lu, jitter exceeded %lu, stability exceeded %lu, errors %lu.\n";
+		const char *ofmt7 = "ntp_adjtime() returns code %d (%s)\n";
+		const char *ofmt8 = "  modes %s,\n";
+		const char *ofmt9 = "  offset %.3f";
+		const char *ofmt10 = " us, frequency %.3f ppm, interval %d s,\n";
+		const char *ofmt11 = "  maximum error %lu us, estimated error %lu us,\n";
+		const char *ofmt12 = "  status %s,\n";
+		const char *ofmt13 = "  time constant %lu, precision %.3f us, tolerance %.0f ppm,\n";
+		const char *ofmt14 = "  pps frequency %.3f ppm, stability %.3f ppm, jitter %.3f us,\n";
+		const char *ofmt15 = "  intervals %lu, jitter exceeded %lu, stability exceeded %lu, errors %lu.\n";
 		/* JSON formats */
-		char *jfmt7 = "\"adjtime-code\":%d,\"adjtime-status\":\"%s\",";
-		char *jfmt8 = "\"modes\":\"%s\",";
-		char *jfmt9 = "\"offset\":%.3f,";
-		char *jfmt10 = "\"frequency\":%.3f,\"interval\":%d,";
-		char *jfmt11 = "\"maximum-error\":%lu,\"estimated-error\":%lu,";
-		char *jfmt12 = "\"status\":\"%s\",";
-		char *jfmt13 = "\"time-constant\":%lu,\"precision\":%.3f,\"tolerance\":%.0f,";
-		char *jfmt14 = "\"pps-frequency\":%.3f,\"stability\":%.3f,\"jitter\":%.3f,";
-		char *jfmt15 = "\"intervals\":%lu,\"jitter-exceeded\":%lu,\"stability-exceeded\":%lu,\"errors:%lu\n";
+		const char *jfmt7 = "\"adjtime-code\":%d,\"adjtime-status\":\"%s\",";
+		const char *jfmt8 = "\"modes\":\"%s\",";
+		const char *jfmt9 = "\"offset\":%.3f,";
+		const char *jfmt10 = "\"frequency\":%.3f,\"interval\":%d,";
+		const char *jfmt11 = "\"maximum-error\":%lu,\"estimated-error\":%lu,";
+		const char *jfmt12 = "\"status\":\"%s\",";
+		const char *jfmt13 = "\"time-constant\":%lu,\"precision\":%.3f,\"tolerance\":%.0f,";
+		const char *jfmt14 = "\"pps-frequency\":%.3f,\"stability\":%.3f,\"jitter\":%.3f,";
+		const char *jfmt15 = "\"intervals\":%lu,\"jitter-exceeded\":%lu,\"stability-exceeded\":%lu,\"errors:%lu\n";
 
 		flash = ntx.status;
 		printf(json ? jfmt7 : ofmt7, status, timex_state(status));


=====================================
tests/libntp/lfpfunc.c
=====================================
--- a/tests/libntp/lfpfunc.c
+++ b/tests/libntp/lfpfunc.c
@@ -258,15 +258,15 @@ TEST(lfpfunc, FDF_RoundTrip) {
                 double op2, d;
 		l_fp op1 = lfpinit_u(addsub_tab[idx][0].l_ui,
                                      addsub_tab[idx][0].l_uf);
-		// op2 = lfptod(op1);
-                op2 = ldexp((double)((int64_t)op1), -32);
+		op2 = lfptod(op1);
 		l_fp op3 = dtolfp(op2);
 
 		l_fp temp = op1 - op3;
 		d = lfptod(temp);
                 /* cast to long unsgiend int for 32 bit binaries */
-                snprintf(msg, sizeof(msg), "op2: %f diff %f not within %e",
-                         op2, d, eps(op2));
+                snprintf(msg, sizeof(msg),
+                         "\nop2: %f op3: %s diff %f not within %e",
+                         op2, mfptoa(op3, 8), d, eps(op2));
 		TEST_ASSERT_DOUBLE_WITHIN_MESSAGE(eps(op2), 0.0, fabs(d), msg);
 	}
 



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/65c8b87fcef14aaf02e410663b77cfdcb2fca0f6...8e75f667dcc30795d9750f71a14baf48973c92cd

---
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/65c8b87fcef14aaf02e410663b77cfdcb2fca0f6...8e75f667dcc30795d9750f71a14baf48973c92cd
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/20170414/f52eaf1d/attachment.html>


More information about the vc mailing list