[Git][NTPsec/ntpsec][master] 2 commits: Another bool

Hal Murray gitlab at mg.gitlab.com
Thu Apr 19 19:32:30 UTC 2018


Hal Murray pushed to branch master 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

- - - - -


2 changed files:

- ntpd/ntp_control.c
- ntpd/ntp_loopfilter.c


Changes:

=====================================
ntpd/ntp_control.c
=====================================
--- a/ntpd/ntp_control.c
+++ b/ntpd/ntp_control.c
@@ -56,10 +56,9 @@ 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))
+#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);
@@ -1161,7 +1160,7 @@ ctl_putunqstr(
 static void
 ctl_putdblf(
 	const char *	tag,
-	int		use_f,
+	bool		use_f,
 	int		precision,
 	double		d
 	)
@@ -1833,7 +1832,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 +1841,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 +1860,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;
 


=====================================
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



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/861012e34b983bdaf2ec1c9567862669cd67d503...370820d9f7f60f011b7a8accca32cd222fa3f1a3

---
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/861012e34b983bdaf2ec1c9567862669cd67d503...370820d9f7f60f011b7a8accca32cd222fa3f1a3
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/20180419/14e54de5/attachment.html>


More information about the vc mailing list