[ntpsec commit] Magic-number elimination.

Eric S. Raymond esr at ntpsec.org
Sun Oct 4 02:31:50 UTC 2015


Module:    ntpsec
Branch:    master
Commit:    1afddc45fe6a1cbb2c70d834b9f3719a26225c98
Changeset: http://git.ntpsec.org/ntpsec/commit/?id=1afddc45fe6a1cbb2c70d834b9f3719a26225c98

Author:    Eric S. Raymond <esr at thyrsus.com>
Date:      Sat Oct  3 17:46:10 2015 -0400

Magic-number elimination.

---

 ntpd/ntp_proto.c | 10 +++++-----
 ntpd/ntp_timer.c |  2 +-
 ntpd/ntpsim.c    |  2 +-
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/ntpd/ntp_proto.c b/ntpd/ntp_proto.c
index 3385744..ad78100 100644
--- a/ntpd/ntp_proto.c
+++ b/ntpd/ntp_proto.c
@@ -1916,7 +1916,7 @@ clock_update(
 		clear_all();
 		sys_leap = LEAP_NOTINSYNC;
 		sys_stratum = STRATUM_UNSPEC;
-		memcpy(&sys_refid, "STEP", 4);
+		memcpy(&sys_refid, "STEP", REFIDLEN);
 		sys_rootdelay = 0;
 		sys_rootdisp = 0;
 		L_CLR(&sys_reftime);
@@ -2162,7 +2162,7 @@ peer_clear(
 #endif
 		peer->leap = LEAP_NOTINSYNC;
 		peer->stratum = STRATUM_UNSPEC;
-		memcpy(&peer->refid, ident, 4);
+		memcpy(&peer->refid, ident, REFIDLEN);
 #ifdef REFCLOCK
 	}
 #endif
@@ -2431,7 +2431,7 @@ clock_select(void)
 #ifdef ENABLE_LOCKCLOCK
 	sys_leap = LEAP_NOTINSYNC;
 	sys_stratum = STRATUM_UNSPEC;
-	memcpy(&sys_refid, "DOWN", 4);
+	memcpy(&sys_refid, "DOWN", REFIDLEN);
 #endif /* ENABLE_LOCKCLOCK */
 
 	/*
@@ -3457,7 +3457,7 @@ fast_xmit(
 		xpkt.stratum = STRATUM_PKT_UNSPEC;
 		xpkt.ppoll = max(rpkt->ppoll, ntp_minpoll);
 		xpkt.precision = rpkt->precision;
-		memcpy(&xpkt.refid, "RATE", 4);
+		memcpy(&xpkt.refid, "RATE", REFIDLEN);
 		xpkt.rootdelay = rpkt->rootdelay;
 		xpkt.rootdisp = rpkt->rootdisp;
 		xpkt.reftime = rpkt->reftime;
@@ -3994,7 +3994,7 @@ init_proto(const bool verbose)
 	 */
 	sys_leap = LEAP_NOTINSYNC;
 	sys_stratum = STRATUM_UNSPEC;
-	memcpy(&sys_refid, "INIT", 4);
+	memcpy(&sys_refid, "INIT", REFIDLEN);
 	sys_peer = NULL;
 	sys_rootdelay = 0;
 	sys_rootdisp = 0;
diff --git a/ntpd/ntp_timer.c b/ntpd/ntp_timer.c
index ac8d106..f980df1 100644
--- a/ntpd/ntp_timer.c
+++ b/ntpd/ntp_timer.c
@@ -307,7 +307,7 @@ timer(void)
 		if (sys_stratum > 1)
 			sys_refid = htonl(LOOPBACKADR);
 		else
-			memcpy(&sys_refid, "LOOP", 4);
+			memcpy(&sys_refid, "LOOP", REFIDLEN);
 		sys_offset = 0;
 		sys_rootdelay = 0;
 		sys_rootdisp = 0;
diff --git a/ntpd/ntpsim.c b/ntpd/ntpsim.c
index 413d5d2..ff3a1f2 100644
--- a/ntpd/ntpsim.c
+++ b/ntpd/ntpsim.c
@@ -297,7 +297,7 @@ int simulate_server(
     xpkt.li_vn_mode = PKT_LI_VN_MODE(LEAP_NOWARNING, NTP_VERSION,
 				     MODE_SERVER);
     xpkt.stratum = STRATUM_TO_PKT(((uint8_t)1));
-    memcpy(&xpkt.refid, "GPS", 4);
+    memcpy(&xpkt.refid, "GPS", REFIDLEN);
     xpkt.ppoll = rpkt->ppoll;
     xpkt.precision = rpkt->precision;
     xpkt.rootdelay = 0;



More information about the vc mailing list