[Git][NTPsec/ntpsec][master] Eliminate a third order table.

Eric S. Raymond gitlab at mg.gitlab.com
Tue Feb 19 23:40:52 UTC 2019


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


Commits:
ddb759e2 by Eric S. Raymond at 2019-02-19T23:40:24Z
Eliminate a third order table.

- - - - -


1 changed file:

- ntpd/ntp_control.c


Changes:

=====================================
ntpd/ntp_control.c
=====================================
@@ -493,41 +493,21 @@ static const struct ctl_var peer_var[] = {
  * Clock variable list
  */
 static const struct ctl_var clock_var[] = {
-	{ 0,		PADDING, "" },		/* 0 */
-	{ CC_NAME,	RO, "name" },		/* 1 */
-	{ CC_TIMECODE,	RO, "timecode" },	/* 2 */
-	{ CC_POLL,	RO, "poll" },		/* 3 */
-	{ CC_NOREPLY,	RO, "noreply" },	/* 4 */
-	{ CC_BADFORMAT, RO, "badformat" },	/* 5 */
-	{ CC_BADDATA,	RO, "baddata" },	/* 6 */
-	{ CC_FUDGETIME1, RO, "fudgetime1" },	/* 7 */
-	{ CC_FUDGETIME2, RO, "fudgetime2" },	/* 8 */
-	{ CC_FUDGEVAL1, RO, "stratum" },	/* 9 */
-	{ CC_FUDGEVAL2, RO, "refid" },		/* 10 */
-	{ CC_FLAGS,	RO, "flags" },		/* 11 */
-	{ CC_DEVICE,	RO, "device" },		/* 12 */
-	{ CC_VARLIST,	RO, "clock_var_list" },	/* 13 */
-	{ 0,		EOV, ""  }		/* 14 */
-};
-
-
-/*
- * Clock variables printed by default
- */
-static const uint8_t def_clock_var[] = {
-	CC_DEVICE,
-	CC_NAME,
-	CC_TIMECODE,
-	CC_POLL,
-	CC_NOREPLY,
-	CC_BADFORMAT,
-	CC_BADDATA,
-	CC_FUDGETIME1,
-	CC_FUDGETIME2,
-	CC_FUDGEVAL1,
-	CC_FUDGEVAL2,
-	CC_FLAGS,
-	0
+	{ 0,			PADDING, "" },		/* 0 */
+	{ CC_NAME,		RO|DEF, "name" },	/* 1 */
+	{ CC_TIMECODE,		RO|DEF, "timecode" },	/* 2 */
+	{ CC_POLL,		RO|DEF, "poll" },	/* 3 */
+	{ CC_NOREPLY,		RO|DEF, "noreply" },	/* 4 */
+	{ CC_BADFORMAT, 	RO|DEF, "badformat" },	/* 5 */
+	{ CC_BADDATA,		RO|DEF, "baddata" },	/* 6 */
+	{ CC_FUDGETIME1,	RO|DEF, "fudgetime1" },	/* 7 */
+	{ CC_FUDGETIME2,	RO|DEF, "fudgetime2" },	/* 8 */
+	{ CC_FUDGEVAL1, 	RO|DEF, "stratum" },	/* 9 */
+	{ CC_FUDGEVAL2, 	RO|DEF, "refid" },	/* 10 */
+	{ CC_FLAGS,		RO|DEF, "flags" },	/* 11 */
+	{ CC_DEVICE,		RO, 	"device" },	/* 12 */
+	{ CC_VARLIST,		RO, 	"clock_var_list"},	/* 13 */
+	{ 0,			EOV,	""  }		/* 14 */
 };
 #endif
 
@@ -4002,7 +3982,6 @@ read_clockstatus(
 	uint8_t *		wants;
 	size_t			wants_alloc;
 	bool			gotvar;
-	const uint8_t *		cc;
 	struct ctl_var *	kv;
 	struct refclockstat	cs;
 
@@ -4079,8 +4058,9 @@ read_clockstatus(
 						    strlen(kv[i].text),
 						    false);
 	} else {
-		for (cc = def_clock_var; *cc != 0; cc++)
-			ctl_putclock((int)*cc, &cs, false);
+		for (v = clock_var; v != NULL && !(EOV & v->flags); v++)
+			if (DEF & v->flags)
+				ctl_putclock(v->code, &cs, false);
 		for ( ; kv != NULL && !(EOV & kv->flags); kv++)
 			if (DEF & kv->flags)
 				ctl_putdata(kv->text, strlen(kv->text),



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/ddb759e22b20c34e1b22234bf70b3d2e12b3ccbe

-- 
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/ddb759e22b20c34e1b22234bf70b3d2e12b3ccbe
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/20190219/483f2fda/attachment-0001.html>


More information about the vc mailing list