[Git][NTPsec/ntpsec][master] 3 commits: Fix to work on systems without STA_NANO

Hal Murray (@hal.murray) gitlab at mg.gitlab.com
Wed Jun 11 07:24:55 UTC 2025



Hal Murray pushed to branch master at NTPsec / ntpsec


Commits:
9a7d7e6b by Hal Murray at 2025-06-09T14:51:06-07:00
Fix to work on systems without STA_NANO

See email from Fri Jun 6 01:49:57 UTC 2025
  Do we run on any systems that don't support STA_NANO?
  https://lists.ntpsec.org/pipermail/devel/2025-June/010822.html

- - - - -
70f63d13 by Hal Murray at 2025-06-09T22:07:29-07:00
Fix for Coverity warning in libntp/ntp_random.c

- - - - -
7077cd59 by Hal Murray at 2025-06-10T18:31:54-07:00
Fix a few printf %x int errors

Discovered by FreeBSD clang version 19.1.7

- - - - -


4 changed files:

- libntp/clockwork.c
- libntp/ntp_random.c
- libparse/clk_meinberg.c
- ntpd/refclock_generic.c


Changes:

=====================================
libntp/clockwork.c
=====================================
@@ -36,11 +36,15 @@
  * ntptime code has a scaling expression in it that implies
  * nanoseconds if that flash bit is on. It is unknown under what
  * circumstances, if any, this was ever correct.
+ *   Linux sets it to 1
+ *   FreeBSD /usr/include/sys/timex.h says
+ *     STA_NANO applies to offset, precision and jitter
+ * It's never used so it doesn't matter.  2025-Jun-08
  */
 int ntp_adjtime_ns(struct timex *ntx)
 {
-#ifdef STA_NANO
 	static bool nanoseconds = false;
+#ifdef STA_NANO
 	static bool initial_call = true;
 	if (initial_call)
 	{


=====================================
libntp/ntp_random.c
=====================================
@@ -46,10 +46,10 @@ void ntp_RAND_bytes(unsigned char *buf, int num) {
 		return ntp_pool_rand_fill(buf, num);
 	}
 	if (PRAND_BUF_LEN < num + prand_burned) {
-		ntp_pool_rand_fill(&prand_buffer[0], prand_burned);
+		ntp_pool_rand_fill(prand_buffer, prand_burned);
 		prand_burned = 0;
 	}
-	memcpy(buf, &prand_buffer[0] + prand_burned, num);
+	memcpy(buf, prand_buffer + prand_burned, num);
 	prand_burned += num;
 }
 


=====================================
libparse/clk_meinberg.c
=====================================
@@ -656,15 +656,15 @@ gps_input(
 		get_mbg_header(&datap, &header);
 
 		parseprintf(DD_PARSE, ("gps_input: header: cmd 0x%x, len %d, dcsum 0x%x, hcsum 0x%x\n",
-				       (int)header.cmd, (int)header.len, (int)header.data_csum,
-				       (int)header.hdr_csum));
+			header.cmd, (int)header.len, \
+			header.data_csum, header.hdr_csum));
 
 
 		calc_csum = mbg_csum( (unsigned char *) parseio->parse_dtime.parse_msg + 1, (unsigned short)6 );
 
 		if ( calc_csum != header.hdr_csum ) {
 			parseprintf(DD_PARSE, ("gps_input: header checksum mismatch expected 0x%x, got 0x%x\n",
-					       (int)calc_csum, (int)mbg_csum( (unsigned char *) parseio->parse_dtime.parse_msg, (unsigned short)6 )));
+					       calc_csum, mbg_csum( (unsigned char *) parseio->parse_dtime.parse_msg, (unsigned short)6 )));
 
 			msg_buf->phase = MBG_NONE;  /* back to hunting mode */
 			return PARSE_INP_DATA;      /* invalid header checksum received - pass up for detection */


=====================================
ntpd/refclock_generic.c
=====================================
@@ -4926,7 +4926,7 @@ trimbletsip_message(
 
 			printf("TRIMBLE BAD packet, size %u:\n	", size);
 			for (i = 0; i < size; i++) {
-				printf ("%2.2x, ", buffer[i]&0xff);
+				printf ("%2.2x, ", (uint8_t)(buffer[i]&0xff));
 				if (i%16 == 15) printf("\n\t");
 			}
 			printf("\n");
@@ -4950,7 +4950,7 @@ trimbletsip_message(
 			printf("TRIMBLE packet 0x%02x, size %u:\n	",
                                cmd, size);
 			for (i = 0; i < size; i++) {
-				printf ("%2.2x, ", buffer[i]&0xff);
+				printf ("%2.2x, ", (uint8_t)(buffer[i]&0xff));
 				if (i%16 == 15) printf("\n\t");
 			}
 			printf("\n");



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/compare/b71da3bb2aeb3a5c618a1491ab174a45165afccd...7077cd5932371834dacd6a7469c0768bd168528e

-- 
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/compare/b71da3bb2aeb3a5c618a1491ab174a45165afccd...7077cd5932371834dacd6a7469c0768bd168528e
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/20250611/ad7bd0ae/attachment-0001.htm>


More information about the vc mailing list