[Git][NTPsec/ntpsec][master] Eliminate the "displayname" peer variable introduced to mode 6 in June.

Eric S. Raymond gitlab at mg.gitlab.com
Sun Oct 23 18:17:41 UTC 2016


Eric S. Raymond pushed to branch master at NTPsec / ntpsec


Commits:
f6d8eaf4 by Eric S. Raymond at 2016-10-23T14:14:44-04:00
Eliminate the "displayname" peer variable introduced to mode 6 in June.

Turns out this can be dine in a backward-copatibe way by setting the
srchost variable.

- - - - -


2 changed files:

- ntpd/ntp_control.c
- ntpq/ntpq-subs.c


Changes:

=====================================
ntpd/ntp_control.c
=====================================
--- a/ntpd/ntp_control.c
+++ b/ntpd/ntp_control.c
@@ -262,8 +262,7 @@ static const struct ctl_proc control_codes[] = {
 #define	CP_SELDISP		48
 #define	CP_SELBROKEN		49
 #define	CP_CANDIDATE		50
-#define CP_DISPLAYNAME		51
-#define	CP_MAXCODE		CP_DISPLAYNAME
+#define	CP_MAXCODE		CP_CANDIDATE
 
 /*
  * Clock variables we understand
@@ -473,8 +472,7 @@ static const struct ctl_var peer_var[] = {
 	{ CP_SELDISP,	RO, "seldisp" },	/* 48 */
 	{ CP_SELBROKEN,	RO, "selbroken" },	/* 49 */
 	{ CP_CANDIDATE, RO, "candidate" },	/* 50 */
-	{ CP_DISPLAYNAME, RO, "displayname" },	/* 51 */
-	{ 0,		EOV, "" }		/* 51/58 */
+	{ 0,		EOV, "" }		/* 50/58 */
 };
 
 
@@ -516,7 +514,6 @@ static const uint8_t def_peer_var[] = {
 	CP_FILTDELAY,
 	CP_FILTOFFSET,
 	CP_FILTERROR,
-	CP_DISPLAYNAME,
 	0
 };
 
@@ -2027,6 +2024,13 @@ ctl_putpeer(
 		if (p->hostname != NULL)
 			ctl_putstr(peer_var[id].text, p->hostname,
 				   strlen(p->hostname));
+#ifdef REFCLOCK
+		if (p->procptr != NULL) {
+		    char buf[NI_MAXHOST];
+		    strlcpy(buf, refclock_name(p), sizeof(buf));
+		    ctl_putstr(peer_var[id].text, buf, strlen(buf));
+		}
+#endif /* REFCLOCK */
 		break;
 
 	case CP_DSTADR:
@@ -2260,16 +2264,6 @@ ctl_putpeer(
 		ctl_putuint(peer_var[id].text, p->status);
 		break;
 
-	case CP_DISPLAYNAME:
-#ifdef REFCLOCK
-		if (p->procptr != NULL) {
-		    char buf[NI_MAXHOST];
-		    strlcpy(buf, refclock_name(p), sizeof(buf));
-		    ctl_putunqstr(peer_var[id].text, buf, strlen(buf));
-		}
-#endif /* REFCLOCK */
-		break;
-
 	default:
 		break;
 	}


=====================================
ntpq/ntpq-subs.c
=====================================
--- a/ntpq/ntpq-subs.c
+++ b/ntpq/ntpq-subs.c
@@ -1599,7 +1599,6 @@ doprintpeers(
 	char type = '?';
 	char whenbuf[8], pollbuf[8];
 	char clock_name[NI_MAXHOST];
-	char *displayname = NULL;
 
 	get_systime(&ts);
 	
@@ -1721,8 +1720,6 @@ doprintpeers(
 		} else if (!strcmp("reftime", name)) {
 			if (!decodets(value, &reftime))
 				L_CLR(&reftime);
-		} else if (!strcmp("displayname", name)) {
-			displayname = value;
 		} else {
 			// fprintf(stderr, "UNRECOGNIZED name=%s ", name);
 		}
@@ -1748,7 +1745,7 @@ doprintpeers(
 		break;
 
 	case MODE_CLIENT:
-		if (displayname != NULL)
+		if (have_srchost && strchr(clock_name, '(') != NULL)
 			type = 'l';	/* local refclock*/
 		else if (SOCK_UNSPEC(&srcadr))
 			type = 'p';	/* pool */
@@ -1791,9 +1788,7 @@ doprintpeers(
 		fprintf(fp, "%-*s ", (int)maxhostlen, serverlocal);
 	}
 	if (AF_UNSPEC == af || AF(&srcadr) == af) {
-		if (displayname != NULL && showhostnames)
-			strlcpy(clock_name, displayname, sizeof(clock_name));
-		else if (!have_srchost)
+		if (!have_srchost || !showhostnames)
 			strlcpy(clock_name, nntohost(&srcadr),
 				sizeof(clock_name));
 		if (wideremote && 15 < strlen(clock_name))



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/f6d8eaf48fd4365a89ee68d935194cb99fe6693c
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20161023/3e997e5c/attachment.html>


More information about the vc mailing list