[Git][NTPsec/ntpsec][master] More elimination of unused macros and signature simplification.

Eric S. Raymond gitlab at mg.gitlab.com
Thu Jan 5 18:06:45 UTC 2017


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


Commits:
a58e7b5f by Eric S. Raymond at 2017-01-05T13:06:01-05:00
More elimination of unused macros and signature simplification.

- - - - -


11 changed files:

- include/ntp_fp.h
- include/timespecops.h
- libntp/dolfptoa.c
- libntp/systime.c
- libparse/ieee754io.c
- ntpd/ntp_monitor.c
- ntpd/ntp_proto.c
- ntpd/refclock_gpsd.c
- ntpd/refclock_jupiter.c
- tests/libntp/lfpfunc.c
- tests/libntp/timespecops.c


Changes:

=====================================
include/ntp_fp.h
=====================================
--- a/include/ntp_fp.h
+++ b/include/ntp_fp.h
@@ -106,9 +106,6 @@ static inline l_fp ntohl_fp(l_fp_w lfpw) {
     return lfpinit(ntohl(lfpw.l_ui), ntohl(lfpw.l_uf));
 }
 
-/* Convert unsigned ts fraction to net order ts */
-#define	HTONL_UF(uf, nts)	*nts = lfpint(0, htonl(uf))
-
 /*
  * Primitive operations on long fixed point values.  If these are
  * reminiscent of assembler op codes it's only because some may
@@ -129,14 +126,11 @@ static inline l_fp ntohl_fp(l_fp_w lfpw) {
  * native operations is to be independent of whether the l_fp
  * type is signed or unsigned.
  */
-#define	L_NEG(v)	(*v) = (-1 * (int64_t)(*v))
-#define L_ADDUF(r, uf)	(*r) = ((*r) + (uf))
-#define L_SUBUF(r, uf)	(*r) = ((*r) - (uf))
-#define	L_ADDF(r, f)	(*r) = ((int64_t)(*r) + (int64_t)(uf))
-#define	L_ISNEG(v)	M_ISNEG(lfpuint(*v))
-#define	L_ISGT(a, b)	((int64_t)(*a) > (int64_t)(*b))
-#define	L_ISGTU(a, b)	((*a) > (*b))
-#define	L_ISGEQ(a, b)	((int64_t)(*a) >= (int64_t)(*b))
+#define	L_NEG(v)	(v) = (-1 * (int64_t)(v))
+#define	L_ISNEG(v)	M_ISNEG(lfpuint(v))
+#define	L_ISGT(a, b)	((int64_t)(a) > (int64_t)(b))
+#define	L_ISGTU(a, b)	((a) > (b))
+#define	L_ISGEQ(a, b)	((int64_t)(a) >= (int64_t)(b))
 
 /*
  * s_fp/double and u_fp/double conversions


=====================================
include/timespecops.h
=====================================
--- a/include/timespecops.h
+++ b/include/timespecops.h
@@ -325,10 +325,10 @@ lfp_intv_to_tspec(
 	l_fp		absx;
 	int		neg;
 	
-	neg = L_ISNEG(&x);
+	neg = L_ISNEG(x);
 	absx = x;
 	if (neg) {
-		L_NEG(&absx);	
+		L_NEG(absx);
 	}
 	out.tv_nsec = FTOTVN(lfpfrac(absx));
 	out.tv_sec = lfpsint(absx);


=====================================
libntp/dolfptoa.c
=====================================
--- a/libntp/dolfptoa.c
+++ b/libntp/dolfptoa.c
@@ -164,10 +164,10 @@ mfptoa(
 	short	ndec
 	)
 {
-	bool	isneg = L_ISNEG(&lfp);
+	bool	isneg = L_ISNEG(lfp);
 
 	if (isneg) {
-		L_NEG(&lfp);
+		L_NEG(lfp);
 	}
 
 	return dolfptoa(lfp, isneg, ndec, false);
@@ -180,10 +180,10 @@ mfptoms(
 	short	ndec
 	)
 {
-	bool	isneg = L_ISNEG(&lfp);
+	bool	isneg = L_ISNEG(lfp);
 
 	if (isneg) {
-		L_NEG(&lfp);
+		L_NEG(lfp);
 	}
 
 	return dolfptoa(lfp, isneg, ndec, true);


=====================================
libntp/systime.c
=====================================
--- a/libntp/systime.c
+++ b/libntp/systime.c
@@ -196,7 +196,7 @@ normalize_time(
 	 * determined.
 	 */
 	if (lfp_prev != 0 && !lamport_violated) {
-		if (!L_ISGTU(&result, &lfp_prev) &&
+		if (!L_ISGTU(result, lfp_prev) &&
 		    sys_fuzz > 0.) {
 			msyslog(LOG_ERR, "ts_prev %s ts_min %s",
 				tspectoa(ts_prev_log),


=====================================
libparse/ieee754io.c
=====================================
--- a/libparse/ieee754io.c
+++ b/libparse/ieee754io.c
@@ -359,7 +359,7 @@ fetch_ieee754(
 	       */
 	      if (sign)
 		{
-		  L_NEG(lfpp);
+		  L_NEG(*lfpp);
 		}
 	      
 	      return IEEE_OK;
@@ -425,9 +425,9 @@ put_ieee754(
   /*
    * find sign
    */
-  if (L_ISNEG(&outlfp))
+  if (L_ISNEG(outlfp))
     {
-      L_NEG(&outlfp);
+      L_NEG(outlfp);
 #ifdef DEBUG_PARSELIB
       sign = 1;
 #endif


=====================================
ntpd/ntp_monitor.c
=====================================
--- a/ntpd/ntp_monitor.c
+++ b/ntpd/ntp_monitor.c
@@ -294,7 +294,7 @@ int mon_get_oldest_age(l_fp now)
     oldest = TAIL_DLIST(mon_mru_list, mru);
     now -= oldest->last;
     /* add one-half second to round up */
-    L_ADDUF(&now, 0x80000000);
+    now += 0x80000000;
     return lfpsint(now);
 }
 /*
@@ -355,7 +355,7 @@ ntp_monitor(
 		interval_fp = rbufp->recv_time;
 		interval_fp -= mon->last;
 		/* add one-half second to round up */
-		L_ADDUF(&interval_fp, 0x80000000);
+		interval_fp += 0x80000000;
 		interval = lfpsint(interval_fp);
 		mon->last = rbufp->recv_time;
 		NSRCPORT(&mon->rmtadr) = NSRCPORT(&rbufp->recv_srcadr);


=====================================
ntpd/ntp_proto.c
=====================================
--- a/ntpd/ntp_proto.c
+++ b/ntpd/ntp_proto.c
@@ -2676,7 +2676,7 @@ measure_tick_fuzz(void)
 		ldiff = val;
 		ldiff -= last;
 		last = val;
-		if (L_ISGT(&ldiff, &minstep)) {
+		if (L_ISGT(ldiff, minstep)) {
 			max_repeats = max(repeats, max_repeats);
 			repeats = 0;
 			changes++;


=====================================
ntpd/refclock_gpsd.c
=====================================
--- a/ntpd/refclock_gpsd.c
+++ b/ntpd/refclock_gpsd.c
@@ -1648,7 +1648,7 @@ process_pps(
 	 * primary channel. Sanity checks are done in evaluation step.
 	 */
 	up->pps_stamp = up->pps_recvt;
-	L_ADDUF(&up->pps_stamp, 0x80000000u);
+	up->pps_stamp += 0x80000000u;
 	setlfpfrac(up->pps_stamp, 0);
 
 	if (NULL != up->pps_peer)


=====================================
ntpd/refclock_jupiter.c
=====================================
--- a/ntpd/refclock_jupiter.c
+++ b/ntpd/refclock_jupiter.c
@@ -716,8 +716,8 @@ jupiter_control(
 
 	instance->limit = dtolfp(pp->fudgetime2);
 	/* Force positive value. */
-	if (L_ISNEG(&instance->limit))
-		L_NEG(&instance->limit);
+	if (L_ISNEG(instance->limit))
+		L_NEG(instance->limit);
 
 #ifdef HAVE_PPSAPI
 	instance->assert = !(pp->sloppyclockflag & CLK_FLAG3);
@@ -820,7 +820,7 @@ jupiter_receive(struct recvbuf *rbufp)
 			 * the second.
 			 */
 			tstamp -= pp->lastrec;
-			if (!L_ISGEQ(&tstamp, &instance->limit))
+			if (!L_ISGEQ(tstamp, instance->limit))
 				bumplfpuint(pp->lastrec, 1);
 
 			/* Parse timecode (even when there's no pps) */


=====================================
tests/libntp/lfpfunc.c
=====================================
--- a/tests/libntp/lfpfunc.c
+++ b/tests/libntp/lfpfunc.c
@@ -71,7 +71,7 @@ static int l_fp_ucmp(const l_fp first, l_fp second)
 static l_fp l_fp_negate(const l_fp first)
 {
 	l_fp temp = first;
-	L_NEG(&temp);
+	L_NEG(temp);
 
 	return temp;
 }
@@ -79,8 +79,8 @@ static l_fp l_fp_negate(const l_fp first)
 static l_fp l_fp_abs(const l_fp first)
 {
 	l_fp temp = first;
-	if (L_ISNEG(&temp))
-		L_NEG(&temp);
+	if (L_ISNEG(temp))
+		L_NEG(temp);
 	return temp;
 }
 
@@ -110,17 +110,17 @@ static void l_fp_swap(l_fp * first, l_fp *second)
 
 static bool l_isgt (const l_fp first, const l_fp second)
 {
-	return L_ISGT(&first, &second);
+	return L_ISGT(first, second);
 }
 
 static bool l_isgtu(const l_fp first, const l_fp second)
 {
-	return L_ISGTU(&first, &second);
+	return L_ISGTU(first, second);
 }
 
 static bool l_isgeq(const l_fp first, const l_fp second)
 {
-	return L_ISGEQ(&first, &second);
+	return L_ISGEQ(first, second);
 }
 
 //----------------------------------------------------------------------


=====================================
tests/libntp/timespecops.c
=====================================
--- a/tests/libntp/timespecops.c
+++ b/tests/libntp/timespecops.c
@@ -61,14 +61,14 @@ static bool AssertFpClose(const l_fp m, const l_fp n, const l_fp limit)
 {
 	l_fp diff;
 
-	if (L_ISGEQ(&m, &n)) {
+	if (L_ISGEQ(m, n)) {
 		diff = m;
 		diff -= n;
 	} else {
 		diff = n;
 		diff -= m;
 	}
-	if (L_ISGEQ(&limit, &diff)) {
+	if (L_ISGEQ(limit, diff)) {
 		return true;
 	}
 	else {



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/a58e7b5f6c18fec6da5928924eb23107f9e57966
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20170105/714ceae0/attachment.html>


More information about the vc mailing list