[Git][NTPsec/ntpsec][working] 14 commits: Another bool

Matt Selsky gitlab at mg.gitlab.com
Tue Apr 24 13:52:29 UTC 2018


Matt Selsky pushed to branch working at NTPsec / ntpsec


Commits:
d547cdda by Hal Murray at 2018-04-10T20:24:49Z
Another bool

- - - - -
370820d9 by Hal Murray at 2018-04-19T19:31:01Z
Fix for warnings when compiling on gcc 8.0

- - - - -
37f0e717 by Hal Murray at 2018-04-19T19:49:50Z
Fix to previous bool attempt

- - - - -
a5be6fe6 by Matt Selsky at 2018-04-20T05:35:38Z
Retry gitlab CI jobs up to 2x if they fail

This should help to work-around transient failures in gitlab.com infrax

- - - - -
fea2ff1a by Matt Selsky at 2018-04-20T05:44:50Z
Use moving Fedora labels from Docker for gitlab CI

Instead of hard-coding Fedora 26 and Fedora 27, and updating as each release
comes out, use "latest", "branched", and "rawhide" labels as listed at
https://store.docker.com/images/fedora

Fixes Gitlab issue #480

- - - - -
0eb62494 by Matt Selsky at 2018-04-20T05:51:20Z
Allow Fedora rawhide gitlab CI jobs to fail

- - - - -
6eefe89b by Matt Selsky at 2018-04-20T07:08:55Z
yum requires -y in batch mode

- - - - -
e2cb83e4 by Matt Selsky at 2018-04-20T07:13:26Z
dnf also needs -y in batch mode

- - - - -
19153a6e by Matt Selsky at 2018-04-20T07:28:52Z
We mean glibc here, not libc

- - - - -
3d229805 by Hal Murray at 2018-04-20T11:49:05Z
Fix a couple more gcc 8 warnings, #479

Still more in tests/ntpd/leapsec.c

- - - - -
df6b236c by Hal Murray at 2018-04-20T22:39:43Z
Squash a few more warnings, #479

- - - - -
c455f93d by Matt Selsky at 2018-04-21T05:10:50Z
Add openSUSE jobs to gitlab CI

- - - - -
e77e2f0b by Matt Selsky at 2018-04-24T13:38:41Z
Use docker labels for debian releases instead of hardcoding

Also, add testing and unstable

- - - - -
492572bf by Ian Bruene at 2018-04-24T13:51:55Z
Removed type-punning on struct ntp_control.

- - - - -


7 changed files:

- .gitlab-ci.yml
- buildprep
- ntpd/ntp_control.c
- ntpd/ntp_loopfilter.c
- ntpd/refclock_generic.c
- ntpd/refclock_neoclock.c
- ntpd/refclock_oncore.c


Changes:

=====================================
.gitlab-ci.yml
=====================================
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -50,6 +50,7 @@
       - build/main/ntpclients/ntpwait
       - build/main/ntpd/ntpd
       - build/main/ntpfrob/ntpfrob
+  retry: 2
 
 gitlab-alpine-basic:
   <<: *job_definition
@@ -76,9 +77,9 @@ gitlab-refclocks:
   tags:
     - gitlab-org
 
-debian-wheezy-basic:
+debian-oldoldstable-basic:
   <<: *job_definition
-  image: debian:wheezy-slim
+  image: debian:oldoldstable-slim
   script:
     - apt-get update
     - apt-get install -y netbase bison gcc libssl-dev libcap-dev pps-tools python-dev
@@ -86,9 +87,9 @@ debian-wheezy-basic:
   tags:
     - gitlab-org
 
-debian-wheezy-refclocks:
+debian-oldoldstable-refclocks:
   <<: *job_definition
-  image: debian:wheezy-slim
+  image: debian:oldoldstable-slim
   script:
     - apt-get update
     - apt-get install -y netbase bison gcc libssl-dev libcap-dev pps-tools python-dev
@@ -96,9 +97,9 @@ debian-wheezy-refclocks:
   tags:
     - gitlab-org
 
-debian-jessie-basic:
+debian-oldstable-basic:
   <<: *job_definition
-  image: debian:jessie-slim
+  image: debian:oldstable-slim
   script:
     - apt-get update
     - apt-get install -y netbase bison gcc libssl-dev libcap-dev pps-tools python-dev
@@ -106,9 +107,9 @@ debian-jessie-basic:
   tags:
     - gitlab-org
 
-debian-jessie-refclocks:
+debian-oldstable-refclocks:
   <<: *job_definition
-  image: debian:jessie-slim
+  image: debian:oldstable-slim
   script:
     - apt-get update
     - apt-get install -y netbase bison gcc libssl-dev libcap-dev pps-tools python-dev
@@ -116,9 +117,9 @@ debian-jessie-refclocks:
   tags:
     - gitlab-org
 
-debian-stretch-basic:
+debian-stable-basic:
   <<: *job_definition
-  image: debian:stretch-slim
+  image: debian:stable-slim
   script:
     - apt-get update
     - apt-get install -y netbase bison gcc libssl-dev libcap-dev pps-tools python-dev
@@ -126,9 +127,51 @@ debian-stretch-basic:
   tags:
     - gitlab-org
 
-debian-stretch-refclocks:
+debian-stable-refclocks:
   <<: *job_definition
-  image: debian:stretch-slim
+  image: debian:stable-slim
+  script:
+    - apt-get update
+    - apt-get install -y netbase bison gcc libssl-dev libcap-dev pps-tools python-dev
+    - python ./waf configure --refclock=all build check
+  tags:
+    - gitlab-org
+
+debian-testing-basic:
+  <<: *job_definition
+  image: debian:testing-slim
+  script:
+    - apt-get update
+    - apt-get install -y netbase bison gcc libssl-dev libcap-dev pps-tools python-dev
+    - python ./waf configure build check
+  tags:
+    - gitlab-org
+
+debian-testing-refclocks:
+  <<: *job_definition
+  image: debian:testing-slim
+  script:
+    - apt-get update
+    - apt-get install -y netbase bison gcc libssl-dev libcap-dev pps-tools python-dev
+    - python ./waf configure --refclock=all build check
+  tags:
+    - gitlab-org
+
+debian-unstable-basic:
+  <<: *job_definition
+  image: debian:unstable-slim
+  allow_failure: true
+  script:
+    - apt-get update
+    - apt-get install -y netbase bison gcc libssl-dev libcap-dev pps-tools python-dev
+    - python ./waf configure build check
+  tags:
+    - gitlab-org
+
+debian-unstable-refclocks:
+  <<: *job_definition
+  image: debian:unstable-slim
+  allow_failure: true
   script:
     - apt-get update
     - apt-get install -y netbase bison gcc libssl-dev libcap-dev pps-tools python-dev
@@ -286,36 +329,56 @@ centos-7-refclocks:
   tags:
     - gitlab-org
 
-fedora-26-basic:
+fedora-latest-basic:
   <<: *job_definition
-  image: fedora:26
+  image: fedora:latest
   script:
     - yum -y install bison gcc openssl-devel libcap-devel pps-tools-devel python-devel
     - python ./waf configure build check
   tags:
     - gitlab-org
 
-fedora-26-refclocks:
+fedora-latest-refclocks:
   <<: *job_definition
-  image: fedora:26
+  image: fedora:latest
   script:
     - yum -y install bison gcc openssl-devel libcap-devel pps-tools-devel python-devel
     - python ./waf configure --refclock=all build check
   tags:
     - gitlab-org
 
-fedora-27-basic:
+fedora-branched-basic:
   <<: *job_definition
-  image: fedora:27
+  image: fedora:branched
   script:
     - yum -y install bison gcc openssl-devel libcap-devel pps-tools-devel python-devel
     - python ./waf configure build check
   tags:
     - gitlab-org
 
-fedora-27-refclocks:
+fedora-branched-refclocks:
   <<: *job_definition
-  image: fedora:27
+  image: fedora:branched
+  script:
+    - yum -y install bison gcc openssl-devel libcap-devel pps-tools-devel python-devel
+    - python ./waf configure --refclock=all build check
+  tags:
+    - gitlab-org
+
+fedora-rawhide-basic:
+  <<: *job_definition
+  image: fedora:rawhide
+  allow_failure: true
+  script:
+    - yum -y install bison gcc openssl-devel libcap-devel pps-tools-devel python-devel
+    - python ./waf configure build check
+  tags:
+    - gitlab-org
+
+fedora-rawhide-refclocks:
+  <<: *job_definition
+  image: fedora:rawhide
+  allow_failure: true
   script:
     - yum -y install bison gcc openssl-devel libcap-devel pps-tools-devel python-devel
     - python ./waf configure --refclock=all build check
@@ -357,3 +420,40 @@ clang-refclocks:
   tags:
     - gitlab-org
 
+openSUSE-latest-basic:
+  <<: *job_definition
+  image: opensuse:latest
+  script:
+    - zypper -n install bison gcc libopenssl-devel libcap-devel pps-tools-devel python-devel
+    - python ./waf configure build check
+  tags:
+    - gitlab-org
+
+openSUSE-latest-refclocks:
+  <<: *job_definition
+  image: opensuse:latest
+  script:
+    - zypper -n install bison gcc libopenssl-devel libcap-devel pps-tools-devel python-devel
+    - python ./waf configure --refclock=all build check
+  tags:
+    - gitlab-org
+
+openSUSE-tumbleweed-basic:
+  <<: *job_definition
+  image: opensuse:tumbleweed
+  allow_failure: true
+  script:
+    - zypper -n install bison gcc libopenssl-devel libcap-devel pps-tools-devel python-devel
+    - python ./waf configure build check
+  tags:
+    - gitlab-org
+
+openSUSE-tumbleweed-refclocks:
+  <<: *job_definition
+  image: opensuse:tumbleweed
+  allow_failure: true
+  script:
+    - zypper -n install bison gcc libopenssl-devel libcap-devel pps-tools-devel python-devel
+    - python ./waf configure --refclock=all build check
+  tags:
+    - gitlab-org


=====================================
buildprep
=====================================
--- a/buildprep
+++ b/buildprep
@@ -78,11 +78,11 @@ then
 elif yum version 2>/dev/null
 then
     installer=yum
-    install="$do $installer install"
+    install="$do $installer -y install"
 elif dnf --version >/dev/null 2>&1
 then
     installer=dnf
-    install="$do $installer install"
+    install="$do $installer -y install"
 elif apt-get --version >/dev/null 2>&1
 then
     installer=apt
@@ -98,7 +98,7 @@ then
     install="$do $installer --install"
 elif  apk --version >/dev/null 2>&1
 then
-    # Alpine Linux, musl rather than libc
+    # Alpine Linux, musl rather than glibc
     installer=apk
     install="$do $installer add"
 else


=====================================
ntpd/ntp_control.c
=====================================
--- a/ntpd/ntp_control.c
+++ b/ntpd/ntp_control.c
@@ -55,11 +55,10 @@ static	unsigned short ctlclkstatus	(struct refclockstat *);
 static	void	ctl_flushpkt	(uint8_t);
 static	void	ctl_putdata	(const char *, unsigned int, bool);
 static	void	ctl_putstr	(const char *, const char *, size_t);
-static	void	ctl_putdblf	(const char *, int, int, double);
-#define	ctl_putdbl(tag, d)	ctl_putdblf(tag, 1, 3, d)
-#define	ctl_putdbl6(tag, d)	ctl_putdblf(tag, 1, 6, d)
-#define	ctl_putsfp(tag, sfp)	ctl_putdblf(tag, 0, -1, \
-					    FP_UNSCALE(sfp))
+static	void	ctl_putdblf	(const char *, bool, int, double);
+#define	ctl_putdbl(tag, d)	ctl_putdblf(tag, true, 3, d)
+#define	ctl_putdbl6(tag, d)	ctl_putdblf(tag, true, 6, d)
+#define	ctl_putsfp(tag, sfp)	ctl_putdblf(tag, false, -1, FP_UNSCALE(sfp))
 static	void	ctl_putuint	(const char *, uint64_t);
 static	void	ctl_puthex	(const char *, uint64_t);
 static	void	ctl_putint	(const char *, long);
@@ -698,6 +697,31 @@ init_control(void)
 
 }
 
+/*
+ * unmarshall_ntp_control - unmarshall data stream into a ntp_sontrol struct
+ */
+void
+unmarshall_ntp_control(struct ntp_control *pkt, struct recvbuf *rbufp)
+{
+  pkt->li_vn_mode = (uint8_t)rbufp->recv_buffer[0];
+  pkt->r_m_e_op = (uint8_t)rbufp->recv_buffer[1];
+  pkt->sequence = (uint16_t)rbufp->recv_buffer[2] << 8;
+  pkt->sequence |= (uint16_t)rbufp->recv_buffer[3];
+  pkt->sequence = ntohs(pkt->sequence);
+  pkt->status = (uint16_t)rbufp->recv_buffer[4] << 8;
+  pkt->status |= (uint16_t)rbufp->recv_buffer[5];
+  pkt->status = ntohs(pkt->status);
+  pkt->associd = (uint16_t)rbufp->recv_buffer[6] << 8;
+  pkt->associd |= (uint16_t)rbufp->recv_buffer[7];
+  pkt->associd = ntohs(pkt->associd);
+  pkt->offset = (uint16_t)rbufp->recv_buffer[8] << 8;
+  pkt->offset |= (uint16_t)rbufp->recv_buffer[9];
+  pkt->offset = ntohs(pkt->offset);
+  pkt->count = (uint16_t)rbufp->recv_buffer[10] << 8;
+  pkt->count |= (uint16_t)rbufp->recv_buffer[11];
+  pkt->count = ntohs(pkt->count);
+  memcpy(&pkt->data, rbufp->recv_buffer + 12, 480 + MAX_MAC_LEN);
+}
 
 /*
  * ctl_error - send an error response for the current request
@@ -743,6 +767,7 @@ process_control(
 	)
 {
 	struct ntp_control *pkt;
+	struct ntp_control pkt_core;
 	int req_count;
 	int req_data;
 	const struct ctl_proc *cc;
@@ -758,7 +783,8 @@ process_control(
 	numctlreq++;
 	rmt_addr = &rbufp->recv_srcadr;
 	lcl_inter = rbufp->dstadr;
-	pkt = (struct ntp_control *)&rbufp->recv_buffer;
+	unmarshall_ntp_control(&pkt_core, rbufp);
+	pkt = &pkt_core;
 
 	/*
 	 * If the length is less than required for the header, or
@@ -1161,7 +1187,7 @@ ctl_putunqstr(
 static void
 ctl_putdblf(
 	const char *	tag,
-	int		use_f,
+	bool		use_f,
 	int		precision,
 	double		d
 	)
@@ -1833,7 +1859,7 @@ ctl_putsys(
 			putfunc args	/* no trailing ; */
 
 	case CS_K_OFFSET:
-		ctl_putdblf(sys_var[varid].text, 0, -1,
+		ctl_putdblf(sys_var[varid].text, false, -1,
 			ntp_error_in_seconds(ntx.offset) * MS_PER_S);
 		break;
 
@@ -1842,12 +1868,12 @@ ctl_putsys(
 		break;
 
 	case CS_K_MAXERR:
-		ctl_putdblf(sys_var[varid].text, 0, 6,
+		ctl_putdblf(sys_var[varid].text, false, 6,
 			    ntp_error_in_seconds(ntx.maxerror) * MS_PER_S);
 		break;
 
 	case CS_K_ESTERR:
-		ctl_putdblf(sys_var[varid].text, 0, 6,
+		ctl_putdblf(sys_var[varid].text, false, 6,
 			 ntp_error_in_seconds(ntx.esterror) * MS_PER_S);
 		break;
 
@@ -1861,7 +1887,7 @@ ctl_putsys(
 		break;
 
 	case CS_K_PRECISION:
-		ctl_putdblf(sys_var[varid].text, 0, 6,
+		ctl_putdblf(sys_var[varid].text, false, 6,
 			    ntp_error_in_seconds(ntx.precision) * MS_PER_S);
 		break;
 
@@ -3963,6 +3989,7 @@ read_ordlist(
 	const char addr_rst_s[] = "addr_restrictions";
 	const size_t a_r_chars = COUNTOF(addr_rst_s) - 1;
 	struct ntp_control *	cpkt;
+	struct ntp_control pkt_core;
 	unsigned short		qdata_octets;
 
 	UNUSED_ARG(rbufp);
@@ -3979,7 +4006,8 @@ read_ordlist(
 	 * which are access control lists.  Other request data return
 	 * CERR_UNKNOWNVAR.
 	 */
-	cpkt = (struct ntp_control *)&rbufp->recv_buffer;
+	unmarshall_ntp_control(&pkt_core, rbufp);
+	cpkt = &pkt_core;
 	qdata_octets = ntohs(cpkt->count);
 	if (0 == qdata_octets || (ifstatint8_ts == qdata_octets &&
 	    !memcmp(ifstats_s, cpkt->data, ifstatint8_ts))) {


=====================================
ntpd/ntp_loopfilter.c
=====================================
--- a/ntpd/ntp_loopfilter.c
+++ b/ntpd/ntp_loopfilter.c
@@ -362,44 +362,40 @@ or, from ntp_adjtime():
 	    case TIME_ERROR: /* 5: unsynchronized, or loss of synchronization */
 				/* error (see status word) */
 
+		des[0] = 0;
+		des[1] = 0;  /* we skip first ":".  */
+
 		if (ptimex->status & STA_UNSYNC)
-			snprintf(des, sizeof(des), "%s%sClock Unsynchronized",
-				des, (*des) ? "; " : "");
+			strlcat(des, ":Clock Unsynchronized", sizeof(des));
 
 		if (ptimex->status & STA_CLOCKERR)
-			snprintf(des, sizeof(des), "%s%sClock Error",
-				des, (*des) ? "; " : "");
+			strlcat(des, ":Clock Error", sizeof(des));
 
 		if (!(ptimex->status & STA_PPSSIGNAL)
 		    && ptimex->status & STA_PPSFREQ)
-			snprintf(des, sizeof(des), "%s%sPPS Frequency Sync wanted but no PPS",
-				des, (*des) ? "; " : "");
+			strlcat(des, ":PPS Frequency Sync wanted but no PPS", sizeof(des));
 
 		if (!(ptimex->status & STA_PPSSIGNAL)
 		    && ptimex->status & STA_PPSTIME)
-			snprintf(des, sizeof(des), "%s%sPPS Time Sync wanted but no PPS signal",
-				des, (*des) ? "; " : "");
+			strlcat(des, ":PPS Time Sync wanted but no PPS signal", sizeof(des));
 
 		if (   ptimex->status & STA_PPSTIME
 		    && ptimex->status & STA_PPSJITTER)
-			snprintf(des, sizeof(des), "%s%sPPS Time Sync wanted but PPS Jitter exceeded",
-				des, (*des) ? "; " : "");
+			strlcat(des, ":PPS Time Sync wanted but PPS Jitter exceeded", sizeof(des));
 
 		if (   ptimex->status & STA_PPSFREQ
 		    && ptimex->status & STA_PPSWANDER)
-			snprintf(des, sizeof(des), "%s%sPPS Frequency Sync wanted but PPS Wander exceeded",
-				des, (*des) ? "; " : "");
+			strlcat(des, ":PPS Frequency Sync wanted but PPS Wander exceeded", sizeof(des));
 
 		if (   ptimex->status & STA_PPSFREQ
 		    && ptimex->status & STA_PPSERROR)
-			snprintf(des, sizeof(des), "%s%sPPS Frequency Sync wanted but Calibration error detected",
-				des, (*des) ? "; " : "");
+			strlcat(des, ":PPS Frequency Sync wanted but Calibration error detected", sizeof(des));
 
 		if (pps_call && !(ptimex->status & STA_PPSSIGNAL))
 			report_event(EVNT_KERN, NULL,
 			    "no PPS signal");
 		DPRINT(1, ("kernel loop status %#x (%s)\n",
-			   (unsigned)ptimex->status, des));
+			   (unsigned)ptimex->status, des+1));
 		/*
 		 * This code may be returned when ntp_adjtime() has just
 		 * been called for the first time, quite a while after
@@ -415,7 +411,7 @@ or, from ntp_adjtime():
 		 * msyslog(LOG_INFO, "CLOCK: kernel reports time synchronization lost");
 		 */
 		msyslog(LOG_INFO, "CLOCK: kernel reports TIME_ERROR: %#x: %s",
-			(unsigned)ptimex->status, des);
+			(unsigned)ptimex->status, des+1);
 	    break;
 #else
 # warning TIME_ERROR is not defined


=====================================
ntpd/refclock_generic.c
=====================================
--- a/ntpd/refclock_generic.c
+++ b/ntpd/refclock_generic.c
@@ -4120,16 +4120,15 @@ gps16x_message(
 					char buffer[128];
 
 					get_mbg_ascii_msg(&bufp, &gps_ascii_msg);
-
+					strncpy(buffer, "gps_message=", sizeof(buffer));
 					if (gps_ascii_msg.valid)
 						{
 							char buffer1[128];
 							mkreadable(buffer1, sizeof(buffer1), gps_ascii_msg.s, strlen(gps_ascii_msg.s), (int)0);
-
-							snprintf(buffer, sizeof(buffer), "gps_message=\"%s\"", buffer1);
+							strlcat(buffer, buffer1, sizeof(buffer));
 						}
 					else
-						snprintf(buffer, sizeof(buffer), "gps_message=<NONE>");
+						strlcat(buffer, "<None>", sizeof(buffer));
 
 					set_var(&parse->kv, buffer, sizeof(buffer), RO|DEF);
 				}


=====================================
ntpd/refclock_neoclock.c
=====================================
--- a/ntpd/refclock_neoclock.c
+++ b/ntpd/refclock_neoclock.c
@@ -660,8 +660,8 @@ neoclock4x_control(int unit,
 	       up->utc_year, up->utc_month, up->utc_day,
 	       up->utc_hour, up->utc_minute, up->utc_second,
 	       up->utc_msec);
-      tt = add_var(&out->kv_list, sizeof(tmpbuf)-1, RO|DEF);
-      snprintf(tt, sizeof(tmpbuf)-1, "calc_utc=\"%s\"", tmpbuf);
+      tt = add_var(&out->kv_list, sizeof(tmpbuf)+20, RO|DEF);
+      snprintf(tt, sizeof(tmpbuf)+20, "calc_utc=\"%s\"", tmpbuf);
 
 #define MAXINTSIZE	20	/* max % of decimal digits in integer */
 #define S_RADIOSIGNAL	sizeof(up->radiosignal) + 15


=====================================
ntpd/refclock_oncore.c
=====================================
--- a/ntpd/refclock_oncore.c
+++ b/ntpd/refclock_oncore.c
@@ -1762,7 +1762,7 @@ oncore_get_timestamp(
 		Rsm = ((instance->BEHa[129]<<8) | instance->BEHa[130]);
 
 	if (instance->chan == 6 || instance->chan == 8) {
-		char	f1[5], f2[5], f3[5], f4[5];
+		char	f1[5], f2[5], f3[8], f4[5];
 		if (instance->traim) {
 			snprintf(f1, sizeof(f1), "%d",
 				 instance->BEHn[21]);
@@ -1800,7 +1800,7 @@ oncore_get_timestamp(
                     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];
+		char	f1[5], f2[5], f3[8], f4[5];
 		if (instance->traim) {
 			snprintf(f1, sizeof(f1), "%d",
 				 instance->BEHn[6]);



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/6d5ac823e750039162762fcf6dfe54c9bed14658...492572bf04b28345ef71eebd7ec1641425b3c1a0

---
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/6d5ac823e750039162762fcf6dfe54c9bed14658...492572bf04b28345ef71eebd7ec1641425b3c1a0
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/20180424/1120abdc/attachment.html>


More information about the vc mailing list