[Git][NTPsec/ntpsec][master] 3 commits: test/lfpfunc: make sure printf works on 32-bit.

Gary E. Miller gitlab at mg.gitlab.com
Thu Apr 13 00:07:48 UTC 2017


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


Commits:
e472c22e by Gary E. Miller at 2017-04-12T15:47:36-07:00
test/lfpfunc: make sure printf works on 32-bit.

- - - - -
a61e099d by Gary E. Miller at 2017-04-12T16:55:45-07:00
oncore: fix format signed-ness

- - - - -
4a5c1394 by Gary E. Miller at 2017-04-12T17:06:08-07:00
refclock_mode: fix format signed-ness

- - - - -


3 changed files:

- ntpd/refclock_modem.c
- ntpd/refclock_oncore.c
- tests/libntp/lfpfunc.c


Changes:

=====================================
ntpd/refclock_modem.c
=====================================
--- a/ntpd/refclock_modem.c
+++ b/ntpd/refclock_modem.c
@@ -502,7 +502,7 @@ modem_timeout(
 				report_event(PEVNT_CLOCK, peer, "modem: port busy");
 				return;
 			}
-			snprintf(pidbuf, sizeof(pidbuf), "%d\n",
+			snprintf(pidbuf, sizeof(pidbuf), "%u\n",
 			    (u_int)getpid());
 			if (write(fd, pidbuf, strlen(pidbuf)) < 0)
 				msyslog(LOG_ERR, "modem: write lock fails %m");
@@ -780,7 +780,7 @@ modem_timecode(
 	 */
 	case LENACTS:
 		if (sscanf(str,
-		    "%5ld %2d-%2d-%2d %2d:%2d:%2d %2d %1d %3lf %5lf %9s %c",
+		    "%5lu %2d-%2d-%2d %2d:%2d:%2d %2u %1u %3lf %5lf %9s %c",
 		    &mjd, &pp->year, &month, &day, &pp->hour,
 		    &pp->minute, &pp->second, &dst, &leap, &dut1,
 		    &msADV, utc, &flag) != 13) {
@@ -805,7 +805,7 @@ modem_timecode(
 	 * USNO format: "jjjjj nnn hhmmss UTC"
 	 */
 	case LENUSNO:
-		if (sscanf(str, "%5ld %3d %2d%2d%2d %3s",
+		if (sscanf(str, "%5lu %3d %2d%2d%2d %3s",
 		    &mjd, &pp->day, &pp->hour, &pp->minute,
 		    &pp->second, utc) != 6) {
 			refclock_report(peer, CEVNT_BADREPLY);
@@ -828,7 +828,7 @@ modem_timecode(
 	 */
 	case LENPTB:
 		if (sscanf(str,
-		    "%*4d-%*2d-%*2d %*2d:%*2d:%2d %*5c%*12c%4d%2d%2d%2d%2d%5ld%2lf%c%2d%3lf%*15c%c",
+		    "%*4d-%*2d-%*2d %*2d:%*2d:%2d %*5c%*12c%4d%2d%2d%2d%2d%5lu%2lf%c%2d%3lf%*15c%c",
 		    &pp->second, &pp->year, &month, &day, &pp->hour,
 		    &pp->minute, &mjd, &dut1, &leapdir, &leapmonth,
 		    &msADV, &flag) != 12) {


=====================================
ntpd/refclock_oncore.c
=====================================
--- a/ntpd/refclock_oncore.c
+++ b/ntpd/refclock_oncore.c
@@ -1779,17 +1779,22 @@ oncore_get_timestamp(
  "%u.%09lu %d %d %2d %2d %2d %2ld rstat   %02x dop %4.1f nsat %2d,%d traim %d,%s,%s sigma %s neg-sawtooth %s sat %d%d%d%d%d%d%d%d",
 		    lfpuint(ts), j,
 		    instance->pp->year, instance->pp->day,
-		    instance->pp->hour, instance->pp->minute, instance->pp->second,
+		    instance->pp->hour, instance->pp->minute,
+                    instance->pp->second,
 		    (long) tsp->tv_sec % 60,
-		    Rsm, 0.1*(256*instance->BEHa[35]+instance->BEHa[36]),
+		    (unsigned)Rsm,
+                    0.1*(256*instance->BEHa[35]+instance->BEHa[36]),
 		    /*rsat	dop */
-		    instance->BEHa[38], instance->BEHa[39], instance->traim, f1, f2,
+		    instance->BEHa[38], instance->BEHa[39], instance->traim,
+                    f1, f2,
 		    /*	nsat visible,	  nsat tracked,     traim,traim,traim */
 		    f3, f4,
 		    /* sigma neg-sawtooth */
-	  /*sat*/   instance->BEHa[41], instance->BEHa[45], instance->BEHa[49], instance->BEHa[53],
-		    instance->BEHa[57], instance->BEHa[61], instance->BEHa[65], instance->BEHa[69]
-		    );					/* will be 0 for 6 chan */
+	  /*sat*/   instance->BEHa[41], instance->BEHa[45],
+                    instance->BEHa[49], instance->BEHa[53],
+		    instance->BEHa[57], instance->BEHa[61],
+                    instance->BEHa[65], instance->BEHa[69]
+		    );		/* will be 0 for 6 chan */
 	} else if (instance->chan == 12) {
 		char	f1[5], f2[5], f3[5], f4[5];
 		if (instance->traim) {
@@ -1812,17 +1817,23 @@ oncore_get_timestamp(
  "%u.%09lu %d %d %2d %2d %2d %2ld rstat %02x dop %4.1f nsat %2d,%d traim %d,%s,%s sigma %s neg-sawtooth %s sat %d%d%d%d%d%d%d%d%d%d%d%d",
 		    lfpuint(ts), j,
 		    instance->pp->year, instance->pp->day,
-		    instance->pp->hour, instance->pp->minute, instance->pp->second,
+		    instance->pp->hour, instance->pp->minute,
+                    instance->pp->second,
 		    (long) tsp->tv_sec % 60,
-		    Rsm, 0.1*(256*instance->BEHa[53]+instance->BEHa[54]),
+		    (unsigned)Rsm, 
+                    0.1*(256*instance->BEHa[53]+instance->BEHa[54]),
 		    /*rsat	dop */
-		    instance->BEHa[55], instance->BEHa[56], instance->traim, f1, f2,
+		    instance->BEHa[55], instance->BEHa[56],
+                    instance->traim, f1, f2,
 		    /*	nsat visible,	  nsat tracked	 traim,traim,traim */
 		    f3, f4,
 		    /* sigma neg-sawtooth */
-	  /*sat*/   instance->BEHa[58], instance->BEHa[64], instance->BEHa[70], instance->BEHa[76],
-		    instance->BEHa[82], instance->BEHa[88], instance->BEHa[94], instance->BEHa[100],
-		    instance->BEHa[106], instance->BEHa[112], instance->BEHa[118], instance->BEHa[124]
+	  /*sat*/   instance->BEHa[58], instance->BEHa[64],
+                    instance->BEHa[70], instance->BEHa[76],
+		    instance->BEHa[82], instance->BEHa[88],
+                    instance->BEHa[94], instance->BEHa[100],
+		    instance->BEHa[106], instance->BEHa[112],
+                    instance->BEHa[118], instance->BEHa[124]
 		    );
 	}
 
@@ -2054,7 +2065,7 @@ oncore_msg_Az(
 
 	instance->delay = (u_long)buf_w32(&buf[4]);
 
-	oncore_log_f(instance, LOG_INFO, "Cable delay is set to %ld ns",
+	oncore_log_f(instance, LOG_INFO, "Cable delay is set to %lu ns",
 		     instance->delay);
 }
 
@@ -2414,7 +2425,7 @@ oncore_msg_Bd(
 {
 	UNUSED_ARG(len);
 	oncore_log_f(instance, LOG_NOTICE,
-		     "Bd: Almanac %s, week = %d, t = %d, %d SVs: %x",
+		     "Bd: Almanac %s, week = %d, t = %d, %d SVs: %d",
 		     ((buf[4]) ? "LOADED" : "(NONE)"), buf[5], buf[6],
 		     buf[7], w32(&buf[8]));
 }
@@ -2940,8 +2951,8 @@ oncore_msg_Cj_id(
 	/* use MODEL to set CHAN and TRAIM and possibly zero SHMEM */
 
 	oncore_log_f(instance, LOG_INFO,
-		     "This looks like an Oncore %s with version %d.%d firmware.",
-		     cp, instance->version, instance->revision);
+		   "This looks like an Oncore %s with version %u.%u firmware.",
+		   cp, instance->version, instance->revision);
 
 	instance->chan_id = 8;	   /* default */
 	if (instance->model == ONCORE_BASIC || instance->model == ONCORE_PVT6)
@@ -2999,8 +3010,8 @@ oncore_msg_Cj_init(
 	if (instance->chan == 12) {
 		instance->shmem_bad_Ea = 1;
 		oncore_log_f(instance, LOG_NOTICE,
-			     "*** SHMEM partially enabled for ONCORE M12 s/w v%d.%d ***",
-			     instance->version, instance->revision);
+		   "*** SHMEM partially enabled for ONCORE M12 s/w v%u.%u ***",
+		   instance->version, instance->revision);
 	}
 
 	oncore_sendmsg(instance, oncore_cmd_Cg, sizeof(oncore_cmd_Cg)); /* Return to  Posn Fix mode */


=====================================
tests/libntp/lfpfunc.c
=====================================
--- a/tests/libntp/lfpfunc.c
+++ b/tests/libntp/lfpfunc.c
@@ -262,8 +262,10 @@ TEST(lfpfunc, FDF_RoundTrip) {
 
 		l_fp temp = op1 - op3;
 		double d = lfptod(temp);
-                snprintf(msg, sizeof(msg), "%d not %d within %d",
-                         op1, op2, eps(op2));
+                /* cast to long unsgiend int for 32 bit binaries */
+                snprintf(msg, sizeof(msg), "%llx not %llx within %f",
+                         (long long unsigned)op1,
+                         (long long unsigned)op2, eps(op2));
 		TEST_ASSERT_DOUBLE_WITHIN_MESSAGE(eps(op2), 0.0, fabs(d), msg);
 	}
 



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/03c35d891562f1ca4d0d45905b6dfba04f72b53a...4a5c139433290c084b264007c86761a850e7b2af

---
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/03c35d891562f1ca4d0d45905b6dfba04f72b53a...4a5c139433290c084b264007c86761a850e7b2af
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/20170413/f31b4288/attachment.html>


More information about the vc mailing list