[Git][NTPsec/ntpsec][dgb-trace] Swapped out explicit debug tests for macros

Ian Bruene gitlab at mg.gitlab.com
Sun Jun 4 17:50:19 UTC 2017


Ian Bruene pushed to branch dgb-trace at NTPsec / ntpsec


Commits:
632544d0 by Ian Bruene at 2017-06-04T12:48:24-05:00
Swapped out explicit debug tests for macros

Debugging logs that are merely printfs have been replaced by
DPRINT / TPRINT, as appropriate. More complicated loggers have been
marked with SPECIAL DEBUG to aid in filtering.

Hand merging of ntp_proto.c, and other squashed fixes.

- - - - -


20 changed files:

- libntp/authkeys.c
- libntp/msyslog.c
- libparse/ieee754io.c
- ntpd/ntp_control.c
- ntpd/ntp_io.c
- ntpd/ntp_loopfilter.c
- ntpd/ntp_proto.c
- ntpd/ntp_refclock.c
- ntpd/ntp_scanner.c
- ntpd/ntp_signd.c
- ntpd/ntp_util.c
- ntpd/ntpd.c
- ntpd/refclock_arbiter.c
- ntpd/refclock_generic.c
- ntpd/refclock_gpsd.c
- ntpd/refclock_hpgps.c
- ntpd/refclock_jjy.c
- ntpd/refclock_oncore.c
- ntpd/refclock_spectracom.c
- ntpd/refclock_trimble.c


Changes:

=====================================
libntp/authkeys.c
=====================================
--- a/libntp/authkeys.c
+++ b/libntp/authkeys.c
@@ -489,7 +489,7 @@ mac_setkey(
 	allocsymkey(bucket, keyno, 0, (unsigned short)keytype,
 		    (unsigned short)secretsize, secret);
 #ifdef DEBUG
-	if (debug >= 4) {
+	if (debug >= 4) { /* SPECIAL DEBUG */
 		printf("auth_setkey: key %d type %d len %d ", (int)keyno,
 		    keytype, (int)secretsize);
 		for (size_t j = 0; j < secretsize; j++)


=====================================
libntp/msyslog.c
=====================================
--- a/libntp/msyslog.c
+++ b/libntp/msyslog.c
@@ -145,7 +145,7 @@ addto_syslog(
 		if (syslog_file != NULL)
 			log_to_file = true;
 #if defined(DEBUG) && DEBUG
-	if (debug > 0)
+	if (debug > 0) /* SPECIAL DEBUG */
 		log_to_term = true;
 #endif
 	if (!(log_to_file || log_to_term))
@@ -334,7 +334,7 @@ init_logging(
 						    ? LOG_NTP
 						    : 0);
 #  ifdef DEBUG
-	if (debug)
+	if (debug) /* SPECIAL DEBUG */
 		setlogmask(LOG_UPTO(LOG_DEBUG));
 	else
 #  endif /* DEBUG */


=====================================
libparse/ieee754io.c
=====================================
--- a/libparse/ieee754io.c
+++ b/libparse/ieee754io.c
@@ -187,7 +187,7 @@ fetch_ieee754(
     shift = exponent + fudge;
 
 #ifdef DEBUG_PARSELIB
-    if ( debug > 4) {
+    if ( debug > 4) { /* SPECIAL DEBUG */
         int length = 8;
         if ( IEEE_SINGLE == size ) {
             length = 4;


=====================================
ntpd/ntp_control.c
=====================================
--- a/ntpd/ntp_control.c
+++ b/ntpd/ntp_control.c
@@ -2641,10 +2641,7 @@ read_status(
 
 	UNUSED_ARG(rbufp);
 	UNUSED_ARG(restrict_mask);
-#ifdef DEBUG
-	if (debug > 2)
-		printf("read_status: ID %d\n", res_associd);
-#endif
+	DPRINT(3, ("read_status: ID %d\n", res_associd));
 	/*
 	 * Two choices here. If the specified association ID is
 	 * zero we return all known association ID's.  Otherwise
@@ -4223,10 +4220,7 @@ report_event(
 			msyslog(LOG_INFO, "%s", statstr);
 	}
 	record_proto_stats(statstr);
-#if defined(DEBUG) && DEBUG
-	if (debug)
-		printf("event at %lu %s\n", current_time, statstr);
-#endif
+	DPRINT(1, ("event at %lu %s\n", current_time, statstr));
 
 }
 


=====================================
ntpd/ntp_io.c
=====================================
--- a/ntpd/ntp_io.c
+++ b/ntpd/ntp_io.c
@@ -297,7 +297,7 @@ maintain_activefds(
 					maxactivefd = i;
 					break;
 				}
-			NTP_INSIST(fd != maxactivefd);
+			INSIST(fd != maxactivefd);
 		}
 	}
 }
@@ -593,8 +593,8 @@ is_ip_address(
 	char tmpbuf[128];
 	char *pch;
 
-	NTP_REQUIRE(host != NULL);
-	NTP_REQUIRE(addr != NULL);
+	REQUIRE(host != NULL);
+	REQUIRE(addr != NULL);
 
 	ZERO_SOCK(addr);
 
@@ -912,15 +912,15 @@ add_nic_rule(
 	rule->action = action;
 
 	if (MATCH_IFNAME == match_type) {
-		NTP_REQUIRE(NULL != if_name);
+		REQUIRE(NULL != if_name);
 		rule->if_name = estrdup(if_name);
 	} else if (MATCH_IFADDR == match_type) {
-		NTP_REQUIRE(NULL != if_name);
+		REQUIRE(NULL != if_name);
 		/* set rule->addr */
 		is_ip = is_ip_address(if_name, AF_UNSPEC, &rule->addr);
-		NTP_REQUIRE(is_ip);
+		REQUIRE(is_ip);
 	} else
-		NTP_REQUIRE(NULL == if_name);
+		REQUIRE(NULL == if_name);
 
 	LINK_SLIST(nic_rule_list, rule, next);
 }
@@ -940,7 +940,7 @@ action_text(
 		t = "ERROR";	/* quiet uninit warning */
 		DPRINT(1, ("fatal: unknown nic_rule_action %u\n",
 			   action));
-		NTP_ENSURE(0);
+		ENSURE(0);
 		break;
 
 	case ACTION_LISTEN:
@@ -2761,7 +2761,7 @@ calc_addr_distance(
 	bool	a1_greater;
 	int	i;
 
-	NTP_REQUIRE(AF(a1) == AF(a2));
+	REQUIRE(AF(a1) == AF(a2));
 
 	ZERO_SOCK(dist);
 	AF(dist) = AF(a1);
@@ -2812,7 +2812,7 @@ cmp_addr_distance(
 {
 	int	i;
 
-	NTP_REQUIRE(AF(d1) == AF(d2));
+	REQUIRE(AF(d1) == AF(d2));
 
 	if (IS_IPV4(d1)) {
 		if (SRCADR(d1) < SRCADR(d2))


=====================================
ntpd/ntp_loopfilter.c
=====================================
--- a/ntpd/ntp_loopfilter.c
+++ b/ntpd/ntp_loopfilter.c
@@ -553,12 +553,8 @@ local_clock(
 		else
 			dtemp = (peer->delay - sys_mindly) / 2;
 		fp_offset += dtemp;
-#ifdef DEBUG
-		if (debug)
-			printf(
-		    "local_clock: size %d mindly %.6f huffpuff %.6f\n",
-			    sys_hufflen, sys_mindly, dtemp);
-#endif
+		DPRINT(1, ("local_clock: size %d mindly %.6f huffpuff %.6f\n",
+			   sys_hufflen, sys_mindly, dtemp));
 	}
 
 	/*
@@ -923,13 +919,9 @@ local_clock(
 	 */
 	record_loop_stats(clock_offset, drift_comp, clock_jitter,
 	    clock_stability, sys_poll);
-#ifdef DEBUG
-	if (debug)
-		printf(
-		    "local_clock: offset %.9f jit %.9f freq %.6f stab %.3f poll %d\n",
-		    clock_offset, clock_jitter, drift_comp * US_PER_S,
-		    clock_stability * US_PER_S, sys_poll);
-#endif /* DEBUG */
+	DPRINT(1, ("local_clock: offset %.9f jit %.9f freq %.6f stab %.3f poll %d\n",
+		   clock_offset, clock_jitter, drift_comp * US_PER_S,
+		   clock_stability * US_PER_S, sys_poll));
 	return (rval);
 #endif /* ENABLE_LOCKCLOCK */
 }
@@ -1029,12 +1021,9 @@ rstclock(
 	double	offset		/* new offset */
 	)
 {
-#ifdef DEBUG
-	if (debug > 1)
-		printf("local_clock: mu %lu state %d poll %d count %d\n",
-		    current_time - clock_epoch, trans, sys_poll,
-		    tc_counter);
-#endif
+        DPRINT(2, ("local_clock: mu %lu state %d poll %d count %d\n",
+		   current_time - clock_epoch, trans, sys_poll,
+		   tc_counter));
 	if (trans != state && trans != EVNT_FSET)
 		report_event(trans, NULL, NULL);
 	state = trans;
@@ -1246,10 +1235,7 @@ loop_config(
 {
 	int	i;
 
-#ifdef DEBUG
-	if (debug > 1)
-		printf("loop_config: item %d freq %f\n", item, freq);
-#endif
+	DPRINT(2, ("loop_config: item %d freq %f\n", item, freq));
 	switch (item) {
 
 	/*


=====================================
ntpd/ntp_proto.c
=====================================
--- a/ntpd/ntp_proto.c
+++ b/ntpd/ntp_proto.c
@@ -1101,12 +1101,8 @@ clock_update(
 	sys_rootdelay = peer->delay + peer->rootdelay;
 	sys_reftime = peer->dst;
 
-#ifdef DEBUG
-	if (debug)
-		printf(
-		    "clock_update: at %lu sample %lu associd %d\n",
-		    current_time, peer->epoch, peer->associd);
-#endif
+	DPRINT(1, ("clock_update: at %lu sample %lu associd %d\n",
+		   current_time, peer->epoch, peer->associd));
 
 	/*
 	 * Comes now the moment of truth. Crank the clock discipline and
@@ -1368,13 +1364,9 @@ peer_clear(
 	    int pseudorandom = peer->associd ^ sock_hash(&peer->srcadr);
 	    peer->nextdate += (u_long)(pseudorandom % (1 << peer->minpoll));
 	}
-#ifdef DEBUG
-	if (debug)
-		printf(
-		    "peer_clear: at %lu next %lu associd %d refid %s\n",
-		    current_time, peer->nextdate, peer->associd,
-		    ident);
-#endif
+	DPRINT(1, ("peer_clear: at %lu next %lu associd %d refid %s\n",
+		   current_time, peer->nextdate, peer->associd,
+		   ident));
 }
 
 
@@ -1537,11 +1529,8 @@ clock_filter(
 	 * packets.
 	 */
 	if (peer->filter_epoch[k] <= peer->epoch) {
-#if defined(DEBUG) && DEBUG
-	if (debug > 1)
-		printf("clock_filter: old sample %lu\n", current_time -
-		    peer->filter_epoch[k]);
-#endif
+        DPRINT(2, ("clock_filter: old sample %lu\n", current_time -
+		   peer->filter_epoch[k]));
 		return;
 	}
 	peer->epoch = peer->filter_epoch[k];
@@ -1552,12 +1541,9 @@ clock_filter(
 	 * clock select algorithm.
 	 */
 	record_peer_stats(peer, ctlpeerstatus(peer));
-#ifdef DEBUG
-	if (debug)
-		printf(
-		    "clock_filter: n %d off %.6f del %.6f dsp %.6f jit %.6f\n",
-		    m, peer->offset, peer->delay, peer->disp,
-		    peer->jitter);
+	DRPINT(1, ("clock_filter: n %d off %.6f del %.6f dsp %.6f jit %.6f\n",
+		   m, peer->offset, peer->delay, peer->disp,
+		   peer->jitter));
 #endif
 	if (peer->burst == 0 || sys_leap == LEAP_NOTINSYNC)
 		clock_select();
@@ -2212,13 +2198,10 @@ peer_xmit(
 		peer->outcount++;
 		peer->throttle += (1 << peer->minpoll) - 2;
 
-#ifdef DEBUG
-		if (debug)
-			printf("transmit: at %lu %s->%s mode %d len %zu\n",
-		    	    current_time, peer->dstadr ?
-			    socktoa(&peer->dstadr->sin) : "-",
-		            socktoa(&peer->srcadr), peer->hmode, sendlen);
-#endif
+		DPRINT(1, ("transmit: at %lu %s->%s mode %d len %zu\n",
+			   current_time, peer->dstadr ?
+			   socktoa(&peer->dstadr->sin) : "-",
+			   socktoa(&peer->srcadr), peer->hmode, sendlen));
 		return;
 	}
 
@@ -2251,13 +2234,10 @@ peer_xmit(
 	peer->sent++;
         peer->outcount++;
 	peer->throttle += (1 << peer->minpoll) - 2;
-#ifdef DEBUG
-	if (debug)
-		printf("transmit: at %lu %s->%s mode %d keyid %08x len %zu\n",
-		    current_time, peer->dstadr ?
-		    socktoa(&peer->dstadr->sin) : "-",
-		    socktoa(&peer->srcadr), peer->hmode, xkeyid, sendlen);
-#endif
+	DPRINT(1, ("transmit: at %lu %s->%s mode %d keyid %08x len %zu\n",
+		   current_time, peer->dstadr ?
+		   socktoa(&peer->dstadr->sin) : "-",
+		   socktoa(&peer->srcadr), peer->hmode, xkeyid, sendlen));
 }
 
 
@@ -2354,9 +2334,9 @@ fast_xmit(
 			leap_smear_add_offs(&this_ref_time, NULL);
 			xpkt.refid = convertLFPToRefID(leap_smear.offset);
 			DPRINT(2, ("fast_xmit: leap_smear.in_progress: refid %8x, smear %s\n",
-				   ntohl(xpkt.refid),
-				   lfptoa(leap_smear.offset, 8)
-				   ));
+				ntohl(xpkt.refid),
+				lfptoa(leap_smear.offset, 8)
+				));
 		}
 		xpkt.reftime = htonl_fp(this_ref_time);
 #else
@@ -2397,13 +2377,9 @@ fast_xmit(
 	sendlen = LEN_PKT_NOMAC;
 	if (rbufp->recv_length == sendlen) {
 		sendpkt(&rbufp->recv_srcadr, rbufp->dstadr, &xpkt, (int)sendlen);
-#ifdef DEBUG
-		if (debug)
-			printf(
-			    "transmit: at %lu %s->%s mode %d len %zu\n",
-			    current_time, socktoa(&rbufp->dstadr->sin),
-			    socktoa(&rbufp->recv_srcadr), xmode, sendlen);
-#endif
+		DPRINT(1, ("transmit: at %lu %s->%s mode %d len %zu\n",
+			   current_time, socktoa(&rbufp->dstadr->sin),
+			   socktoa(&rbufp->recv_srcadr), xmode, sendlen));
 		return;
 	}
 
@@ -2419,13 +2395,9 @@ fast_xmit(
 	get_systime(&xmt_ty);
 	xmt_ty -= xmt_tx;
 	sys_authdelay = xmt_ty;
-#ifdef DEBUG
-	if (debug)
-		printf(
-		    "transmit: at %lu %s->%s mode %d keyid %08x len %zu\n",
-		    current_time, socktoa(&rbufp->dstadr->sin),
-		    socktoa(&rbufp->recv_srcadr), xmode, xkeyid, sendlen);
-#endif
+	DPRINT(1, ("transmit: at %lu %s->%s mode %d keyid %08x len %zu\n",
+		   current_time, socktoa(&rbufp->dstadr->sin),
+		   socktoa(&rbufp->recv_srcadr), xmode, xkeyid, sendlen));
 }
 
 
@@ -2483,7 +2455,6 @@ dns_take_pool(
 	sockaddr_u *		rmtadr
 	)
 {
-	sockaddr_u *		rmtadr;
 	struct peer *		peer;
 	int			restrict_mask;
 	endpt *			lcladr;
@@ -2515,8 +2486,8 @@ dns_take_pool(
 				current_time + POOL_SOLICIT_WINDOW + 1);
 	}
 
-	DPRINTF(1, ("transmit: at %lu %s->%s pool\n",
-	    current_time, latoa(lcladr), socktoa(rmtadr)));
+	DPRINT(1, ("transmit: at %lu %s->%s pool\n",
+		   current_time, latoa(lcladr), socktoa(rmtadr)));
 }
 
 /*
@@ -2567,11 +2538,6 @@ void dns_take_status(struct peer* peer, DNS_Status status) {
 	peer->nextdate = current_time + (1 << hpoll);
 }
 
-		DPRINTF(1, ("transmit: at %lu %s->%s pool\n",
-		    current_time, latoa(lcladr), socktoa(rmtadr)));
-		msyslog(LOG_INFO, "Soliciting pool server %s", socktoa(rmtadr));
-	};
-}
 
 
 /*


=====================================
ntpd/ntp_refclock.c
=====================================
--- a/ntpd/ntp_refclock.c
+++ b/ntpd/ntp_refclock.c
@@ -300,11 +300,8 @@ refclock_transmit(
 	 */
 	if (peer->burst == 0) {
 		uint8_t oreach;
-#ifdef DEBUG
-		if (debug)
-			printf("refclock_transmit: at %lu %s\n",
-			    current_time, socktoa(&(peer->srcadr)));
-#endif
+		DPRINT(1, ("refclock_transmit: at %lu %s\n",
+			   current_time, socktoa(&(peer->srcadr))));
 
 		/*
 		 * Update reachability and poll variables like the
@@ -495,12 +492,8 @@ refclock_sample(
 	}
 	pp->offset /= m;
 	pp->jitter = SQRT(pp->jitter / m);
-#ifdef DEBUG
-	if (debug)
-		printf(
-		    "refclock_sample: n %d offset %.6f disp %.6f jitter %.6f\n",
-		    (int)n, pp->offset, pp->disp, pp->jitter);
-#endif
+	DPRINT(1, ("refclock_sample: n %d offset %.6f disp %.6f jitter %.6f\n",
+		   (int)n, pp->offset, pp->disp, pp->jitter));
 	return (int)n;
 }
 
@@ -521,11 +514,8 @@ refclock_receive(
 {
 	struct refclockproc *pp;
 
-#ifdef DEBUG
-	if (debug)
-		printf("refclock_receive: at %lu %s\n",
-		    current_time, socktoa(&peer->srcadr));
-#endif
+	DPRINT(1, ("refclock_receive: at %lu %s\n",
+		   current_time, socktoa(&peer->srcadr)));
 
 	/*
 	 * Do a little sanity dance and update the peer structure. Groom
@@ -804,11 +794,8 @@ refclock_setup(
 		if (ioctl(fd, TIOCMGET, (char *)&ltemp) < 0)
 			msyslog(LOG_ERR,
 			    "refclock_setup fd %d TIOCMGET: %m", fd);
-#ifdef DEBUG
-		if (debug)
-			printf("refclock_setup fd %d modem status: 0x%x\n",
-			    fd, ltemp);
-#endif
+		DPRINT(1, ("refclock_setup fd %d modem status: 0x%x\n",
+			   fd, ltemp));
 		if (ltemp & TIOCM_DSR && lflags & LDISC_REMOTE)
 			ttyp->c_cflag &= (unsigned int)~CLOCAL;
 #endif /* TIOCMGET */
@@ -1094,11 +1081,8 @@ refclock_catcher(
 	if (dtemp > .5)
 		dtemp -= 1.;
 	SAMPLE(-dtemp + pp->fudgetime1);
-#ifdef DEBUG
-	if (debug > 1)
-		printf("refclock_pps: %lu %f %f\n", current_time,
-		    dtemp, pp->fudgetime1);
-#endif
+	DPRINT(2, ("refclock_pps: %lu %f %f\n", current_time,
+		   dtemp, pp->fudgetime1));
 	return PPS_OK;
 }
 #endif /* HAVE_PPSAPI */


=====================================
ntpd/ntp_scanner.c
=====================================
--- a/ntpd/ntp_scanner.c
+++ b/ntpd/ntp_scanner.c
@@ -27,6 +27,7 @@
 #include "ntpd.h"
 #include "ntp_config.h"
 #include "ntp_scanner.h"
+#include "ntp_debug.h"
 #include "ntp_parser.tab.h"
 #include "timespecops.h"      /* for D_ISZERO_NS() */
 


=====================================
ntpd/ntp_signd.c
=====================================
--- a/ntpd/ntp_signd.c
+++ b/ntpd/ntp_signd.c
@@ -212,13 +212,9 @@ send_via_ntp_signd(
 				sendlen = reply_len - offsetof(struct samba_key_out, pkt);
 				xpkt = &samba_reply.pkt;
 				sendpkt(&rbufp->recv_srcadr, rbufp->dstadr, xpkt, sendlen);
-#ifdef DEBUG
-				if (debug)
-					printf(
-						"transmit ntp_signd packet: at %lu %s->%s mode %d keyid %08x len %d\n",
-						current_time, socktoa(&rbufp->dstadr->sin),
-						socktoa(&rbufp->recv_srcadr), xmode, xkeyid, sendlen);
-#endif
+				DPRINT(1, ("transmit ntp_signd packet: at %lu %s->%s mode %d keyid %08x len %d\n",
+					   current_time, socktoa(&rbufp->dstadr->sin),
+					   socktoa(&rbufp->recv_srcadr), xmode, xkeyid, sendlen));
 			}
 		}
 		


=====================================
ntpd/ntp_util.c
=====================================
--- a/ntpd/ntp_util.c
+++ b/ntpd/ntp_util.c
@@ -185,12 +185,9 @@ write_stats(void)
 		 * the frequncy file. This minimizes the file writes to
 		 * nonvolaile storage.
 		 */
-#ifdef DEBUG
-		if (debug)
-			printf("write_stats: frequency %.6lf thresh %.6lf, freq %.6lf\n",
-			    (prev_drift_comp - drift_comp) * US_PER_S,
-                             wander_resid * US_PER_S, drift_comp * US_PER_S);
-#endif
+	        DPRINT(1, ("write_stats: frequency %.6lf thresh %.6lf, freq %.6lf\n",
+			   (prev_drift_comp - drift_comp) * US_PER_S,
+			   wander_resid * US_PER_S, drift_comp * US_PER_S));
 		if (fabs(prev_drift_comp - drift_comp) < wander_resid) {
 			wander_resid *= 0.5;
 			return;


=====================================
ntpd/ntpd.c
=====================================
--- a/ntpd/ntpd.c
+++ b/ntpd/ntpd.c
@@ -457,7 +457,7 @@ static void
 set_process_priority(void)
 {
 # ifdef DEBUG
-	if (debug > 1)
+	if (debug > 1) /* SPECIAL DEBUG */
 		msyslog(LOG_DEBUG, "set_process_priority: %s",
 			((!need_priority)
 			 ? "Leave priority alone"
@@ -1281,7 +1281,7 @@ moredebug(
 	int saved_errno = errno;
 
 	UNUSED_ARG(sig);
-	if (debug < 255)
+	if (debug < 255) /* SPECIAL DEBUG */
 	{
 		debug++;
 		msyslog(LOG_DEBUG, "debug raised to %d", debug);
@@ -1301,7 +1301,7 @@ lessdebug(
 	int saved_errno = errno;
 
 	UNUSED_ARG(sig);
-	if (debug > 0)
+	if (debug > 0) /* SPECIAL DEBUG */
 	{
 		debug--;
 		msyslog(LOG_DEBUG, "debug lowered to %d", debug);


=====================================
ntpd/refclock_arbiter.c
=====================================
--- a/ntpd/refclock_arbiter.c
+++ b/ntpd/refclock_arbiter.c
@@ -186,9 +186,7 @@ arb_start(
 		free(up);
 		return false;
 	}
-#ifdef DEBUG
-	if(debug) { printf("arbiter: mode = %u.\n", peer->ttl); }
-#endif
+	DPRINT(1, ("arbiter: mode = %u.\n", peer->ttl));
 	IGNORE(write(pp->io.fd, COMMAND_HALT_BCAST, 2));
 	return true;
 }
@@ -309,10 +307,7 @@ arb_receive(
 			strlcat(up->latlon, " ", sizeof(up->latlon));
 			strlcat(up->latlon, tbuf + 2, sizeof(up->latlon));
 			record_clock_stats(peer, up->latlon);
-#ifdef DEBUG
-			if (debug)
-				printf("arbiter: %s\n", up->latlon);
-#endif
+			DPRINT(1, ("arbiter: %s\n", up->latlon));
 			IGNORE(write(pp->io.fd, COMMAND_START_BCAST, 2));
 		}
 	}
@@ -460,10 +455,7 @@ arb_poll(
 	}
 	refclock_receive(peer);
 	record_clock_stats(peer, pp->a_lastcode);
-#ifdef DEBUG
-	if (debug)
-		printf("arbiter: timecode %d %s\n",
-		   pp->lencode, pp->a_lastcode);
-#endif
+	DPRINT(1, ("arbiter: timecode %d %s\n",
+		   pp->lencode, pp->a_lastcode));
 }
 


=====================================
ntpd/refclock_generic.c
=====================================
--- a/ntpd/refclock_generic.c
+++ b/ntpd/refclock_generic.c
@@ -1848,21 +1848,15 @@ local_input(
 							setlfpfrac(parse->parseio.parse_dtime.parse_ptime, (uint32_t)(dtemp * FRAC));
 
 							parse->parseio.parse_dtime.parse_state |= PARSEB_PPS|PARSEB_S_PPS;
-#ifdef DEBUG
-							if (debug > 3)
-							{
-								printf(
-								       "parse: local_receive: fd %d PPSAPI seq %ld - PPS %s\n",
-								       rbufp->fd,
-								       (long)pps_info.assert_sequence + (long)pps_info.clear_sequence,
-								       lfptoa(parse->parseio.parse_dtime.parse_ptime, 6));
-							}
-#endif
+							DPRINT(4, ("parse: local_receive: fd %d PPSAPI seq %ld - PPS %s\n",
+								   rbufp->fd,
+								   (long)pps_info.assert_sequence + (long)pps_info.clear_sequence,
+								   lfptoa(parse->parseio.parse_dtime.parse_ptime, 6)));
 						}
 #ifdef DEBUG
 						else
 						{
-							if (debug > 3)
+							if (debug > 3) /* SPECIAL DEBUG */
 							{
 								printf(
 								       "parse: local_receive: fd %d PPSAPI seq assert %ld, seq clear %ld - NO PPS event\n",
@@ -1876,7 +1870,7 @@ local_input(
 #ifdef DEBUG
 					else
 					{
-						if (debug > 3)
+						if (debug > 3) /* SPECIAL DEBUG */
 						{
 							printf(
 							       "parse: local_receive: fd %d PPSAPI time_pps_fetch errno = %d\n",
@@ -1954,10 +1948,7 @@ local_receive(
 		(caddr_t)rbufp->recv_buffer,
 		sizeof(parsetime_t));
 
-#ifdef DEBUG
-	if (debug > 3)
-	  {
-	    printf("PARSE receiver #%d: status %06x, state %08x, time(fp) %lx.%08lx, stime(fp) %lx.%08lx, ptime(fp) %lx.%08lx\n",
+	DPRINT(4, ("PARSE receiver #%d: status %06x, state %08x, time(fp) %lx.%08lx, stime(fp) %lx.%08lx, ptime(fp) %lx.%08lx\n",
 		   parse->peer->refclkunit,
 		   (unsigned int)parsetime.parse_status,
 		   (unsigned int)parsetime.parse_state,
@@ -1966,9 +1957,7 @@ local_receive(
 		   (unsigned long)lfpuint(parsetime.parse_stime),
 		   (unsigned long)lfpfrac(parsetime.parse_stime),
 		   (unsigned long)lfpuint(parsetime.parse_ptime),
-		   (unsigned long)lfpfrac(parsetime.parse_ptime));
-	  }
-#endif
+		   (unsigned long)lfpfrac(parsetime.parse_ptime)));
 
 	parse_process(parse, &parsetime);
 }
@@ -3487,14 +3476,11 @@ parse_process(
 
 		off -= rectime; /* prepare for PPS adjustments logic */
 
-#ifdef DEBUG
-		if (debug > 3)
-			printf("PARSE receiver #%d: Reftime %s, Recvtime %s - initial offset %s\n",
-			       parse->peer->refclkunit,
-			       prettydate(reftime),
-			       prettydate(rectime),
-			       lfptoa(off,6));
-#endif
+		DPRINT(4, ("PARSE receiver #%d: Reftime %s, Recvtime %s - initial offset %s\n",
+			   parse->peer->refclkunit,
+			   prettydate(reftime),
+			   prettydate(rectime),
+			   lfptoa(off,6)));
 	}
 
 	if (PARSE_PPS(parsetime->parse_state) && CLK_PPS(parse->peer))
@@ -3517,12 +3503,9 @@ parse_process(
 		 */
 		offset = parsetime->parse_ptime;
 
-#ifdef DEBUG
-		if (debug > 3)
-			printf("PARSE receiver #%d: PPStime %s\n",
-				parse->peer->refclkunit,
-				prettydate(offset));
-#endif
+		DPRINT(4, ("PARSE receiver #%d: PPStime %s\n",
+			   parse->peer->refclkunit,
+			   prettydate(offset)));
 		if (PARSE_TIMECODE(parsetime->parse_state))
 		{
 			if (fabs(lfptod(off)) <= 0.5)
@@ -3602,26 +3585,20 @@ parse_process(
 		}
 	}
 
-#ifdef DEBUG
-	if (debug > 3)
-		printf("PARSE receiver #%d: Reftime %s, Recvtime %s - final offset %s\n",
-			parse->peer->refclkunit,
-			prettydate(reftime),
-			prettydate(rectime),
-			lfptoa(off,6));
-#endif
+	DPRINT(4, ("PARSE receiver #%d: Reftime %s, Recvtime %s - final offset %s\n",
+		   parse->peer->refclkunit,
+		   prettydate(reftime),
+		   prettydate(rectime),
+		   lfptoa(off,6)));
 
 
 	rectime = reftime;
 	rectime -= off;	/* just to keep the ntp interface happy */
 
-#ifdef DEBUG
-	if (debug > 3)
-		printf("PARSE receiver #%d: calculated Reftime %s, Recvtime %s\n",
-			parse->peer->refclkunit,
-			prettydate(reftime),
-			prettydate(rectime));
-#endif
+	DPRINT(4, ("PARSE receiver #%d: calculated Reftime %s, Recvtime %s\n",
+		   parse->peer->refclkunit,
+		   prettydate(reftime),
+		   prettydate(rectime)));
 
 	if ((parsetime->parse_status & CVT_ADDITIONAL) &&
 	    parse->parse_type->cl_message)
@@ -3685,16 +3662,11 @@ parse_process(
 	        /*
 		 * only good/trusted samples are interesting
 		 */
-#ifdef DEBUG
-	        if (debug > 2)
-			{
-				       printf("PARSE receiver #%d: refclock_process_offset(reftime=%s, rectime=%s, Fudge=%f)\n",
-				       parse->peer->refclkunit,
-				       prettydate(reftime),
-				       prettydate(rectime),
-				       fudge);
-			}
-#endif
+	        DPRINT(3, ("PARSE receiver #%d: refclock_process_offset(reftime=%s, rectime=%s, Fudge=%f)\n",
+			   parse->peer->refclkunit,
+			   prettydate(reftime),
+			   prettydate(rectime),
+			   fudge));
 		parse->generic->lastref = reftime;
 
 		refclock_process_offset(parse->generic, reftime, rectime, fudge);
@@ -3810,7 +3782,7 @@ gps16x_message(
 		unsigned char *bufp = (unsigned char *)parsetime->parse_msg + 1;
 
 #ifdef DEBUG
-		if (debug > 2)
+		if (debug > 2) /* SPECIAL DEBUG */
 		{
 			char msgbuffer[600];
 
@@ -4212,7 +4184,7 @@ gps16x_poll(
 	put_mbg_header(&outp, header);
 
 #ifdef DEBUG
-	if (debug > 2)
+	if (debug > 2) /* SPECIAL DEBUG */
 	{
 	    char buffer[128];
 
@@ -4583,7 +4555,7 @@ sendetx(
 	else
 	{
 #ifdef DEBUG
-	  if (debug > 2)
+	  if (debug > 2) /* SPECIAL DEBUG */
 	  {
 		  char buffer[256];
 
@@ -4911,7 +4883,7 @@ trimbletsip_message(
 	    (buffer[size-2] != DLE))
 	{
 #ifdef DEBUG
-		if (debug > 2) {
+		if (debug > 2) { /* SPECIAL DEBUG */
 			size_t i;
 
 			printf("TRIMBLE BAD packet, size %u:\n	", size);
@@ -4934,7 +4906,7 @@ trimbletsip_message(
 		cmd_info_t *s;
 
 #ifdef DEBUG
-		if (debug > 3) {
+		if (debug > 3) { /* SPECIAL DEBUG */
 			size_t i;
 
 			printf("TRIMBLE packet 0x%02x, size %u:\n	",


=====================================
ntpd/refclock_gpsd.c
=====================================
--- a/ntpd/refclock_gpsd.c
+++ b/ntpd/refclock_gpsd.c
@@ -2137,7 +2137,7 @@ log_data(
 	clockprocT * const pp = peer->procptr;
 	gpsd_unitT * const up = (gpsd_unitT *)pp->unitptr;
 
-	if (debug > 1) {
+	if (debug > 1) { /* SPECIAL DEBUG */
 		const char *sptr = buf;
 		const char *stop = buf + len;
 		char       *dptr = s_lbuf;


=====================================
ntpd/refclock_hpgps.c
=====================================
--- a/ntpd/refclock_hpgps.c
+++ b/ntpd/refclock_hpgps.c
@@ -275,11 +275,8 @@ hpgps_receive(
 	*pp->a_lastcode = '\0';
 	pp->lencode = refclock_gtlin(rbufp, pp->a_lastcode, BMAX, &trtmp);
 
-#ifdef DEBUG
-	if (debug)
-	    printf("hpgps: lencode: %d timecode:%s\n",
-		   pp->lencode, pp->a_lastcode);
-#endif
+	DPRINT(1, ("hpgps: lencode: %d timecode:%s\n",
+		   pp->lencode, pp->a_lastcode));
 
 	/*
 	 * If there's no characters in the reply, we can quit now
@@ -350,10 +347,7 @@ hpgps_receive(
 	 * deal with an error indication in the prompt here
 	 */
 	if (strrchr(prompt,'E') > strrchr(prompt,'s')){
-#ifdef DEBUG
-		if (debug)
-		    printf("hpgps: error indicated in prompt: %s\n", prompt);
-#endif
+	        DPRINT(1, ("hpgps: error indicated in prompt: %s\n", prompt));
 		if (write(pp->io.fd, "*CLS\r\r", 6) != 6)
 		    refclock_report(peer, CEVNT_FAULT);
 	}
@@ -365,10 +359,7 @@ hpgps_receive(
 	m = sscanf(tcp,"%c%c", &tcodechar1, &tcodechar2);
 
 	if (m != 2){
-#ifdef DEBUG
-		if (debug)
-		    printf("hpgps: no format indicator\n");
-#endif
+	        DPRINT(1, ("hpgps: no format indicator\n"));
 		refclock_report(peer, CEVNT_BADREPLY);
 		return;
 	}
@@ -379,20 +370,14 @@ hpgps_receive(
 	    case '-':
 		m = sscanf(tcp,"%d,%d", &up->tzhour, &up->tzminute);
 		if (m != MTZONE) {
-#ifdef DEBUG
-			if (debug)
-			    printf("hpgps: only %d fields recognized in timezone\n", m);
-#endif
+		        DPRINT(1, ("hpgps: only %d fields recognized in timezone\n", m));
 			refclock_report(peer, CEVNT_BADREPLY);
 			return;
 		}
 		if ((up->tzhour < -12) || (up->tzhour > 13) || 
 		    (up->tzminute < -59) || (up->tzminute > 59)){
-#ifdef DEBUG
-			if (debug)
-			    printf("hpgps: timezone %d, %d out of range\n",
-				   up->tzhour, up->tzminute);
-#endif
+		        DPRINT(1, ("hpgps: timezone %d, %d out of range\n",
+				   up->tzhour, up->tzminute));
 			refclock_report(peer, CEVNT_BADREPLY);
 			return;
 		}
@@ -402,11 +387,8 @@ hpgps_receive(
 		break;
 
 	    default:
-#ifdef DEBUG
-		if (debug)
-		    printf("hpgps: unrecognized reply format %c%c\n",
-			   tcodechar1, tcodechar2);
-#endif
+	        DPRINT(1, ("hpgps: unrecognized reply format %c%c\n",
+			   tcodechar1, tcodechar2));
 		refclock_report(peer, CEVNT_BADREPLY);
 		return;
 	} /* end of tcodechar1 switch */
@@ -424,21 +406,15 @@ hpgps_receive(
 		n = NTCODET2;
 
 		if (m != MTCODET2){
-#ifdef DEBUG
-			if (debug)
-			    printf("hpgps: only %d fields recognized in timecode\n", m);
-#endif
+		        DPRINT(1, ("hpgps: only %d fields recognized in timecode\n", m));
 			refclock_report(peer, CEVNT_BADREPLY);
 			return;
 		}
 		break;
 
 	    default:
-#ifdef DEBUG
-		if (debug)
-		    printf("hpgps: unrecognized timecode format %c%c\n",
-			   tcodechar1, tcodechar2);
-#endif
+	        DPRINT(1, ("hpgps: unrecognized timecode format %c%c\n",
+			   tcodechar1, tcodechar2));
 		refclock_report(peer, CEVNT_BADREPLY);
 		return;
 	} /* end of tcodechar2 format switch */
@@ -453,11 +429,8 @@ hpgps_receive(
 	tcodechksm &= 0x00ff;
 
 	if (tcodechksm != expectedsm) {
-#ifdef DEBUG
-		if (debug)
-		    printf("hpgps: checksum %2hX doesn't match %2hX expected\n",
-			   tcodechksm, expectedsm);
-#endif
+	        DPRINT(1, ("hpgps: checksum %2hX doesn't match %2hX expected\n",
+			   tcodechksm, expectedsm));
 		refclock_report(peer, CEVNT_BADREPLY);
 		return;
 	}
@@ -559,11 +532,8 @@ hpgps_receive(
 			break;
                      
 		    default:
-#ifdef DEBUG
-			if (debug)
-			    printf("hpgps: unrecognized leap indicator: %c\n",
-				   leapchar);
-#endif
+			DPRINT(1, ("hpgps: unrecognized leap indicator: %c\n",
+				   leapchar));
 			refclock_report(peer, CEVNT_BADTIME);
 			return;
 		} /* end of leapchar switch */


=====================================
ntpd/refclock_jjy.c
=====================================
--- a/ntpd/refclock_jjy.c
+++ b/ntpd/refclock_jjy.c
@@ -107,6 +107,7 @@
 #include "ntp_refclock.h"
 #include "ntp_calendar.h"
 #include "ntp_stdlib.h"
+#include "ntp_debug.h"
 
 /**********************************************************************/
 
@@ -411,12 +412,8 @@ jjy_start ( int unit, struct peer *peer )
 	int 	fd ;
 	char	sDeviceName [ sizeof(DEVICE) + 10 ], sLog [ MAX_LOGTEXT ] ;
 
-#ifdef DEBUG
-	if ( debug ) {
-	    printf("refclock_jjy.c: jjy_start: %s  mode=%u  dev=%s  unit=%d\n",
-		     socktoa(&peer->srcadr), peer->ttl, DEVICE, unit ) ;
-	}
-#endif
+        DPRINT(1, printf("refclock_jjy.c: jjy_start: %s  mode=%u  dev=%s  unit=%d\n",
+			 socktoa(&peer->srcadr), peer->ttl, DEVICE, unit )) ;
 
 	/* Allocate memory for the unit structure */
 	up = emalloc_zero( sizeof(*up) ) ;
@@ -633,11 +630,7 @@ jjy_receive ( struct recvbuf *rbufp )
 	  || up->iProcessState == JJY_PROCESS_STATE_ERROR ) {
 		/* Discard received data */
 		up->iRawBufLen = 0 ;
-#ifdef DEBUG
-		if ( debug ) {
-			printf( "refclock_jjy.c : %s : Discard received data\n", sFunctionName ) ;
-		}
-#endif
+	        DPRINT(1, ( "refclock_jjy.c : %s : Discard received data\n", sFunctionName )) ;
 		return ;
 	}
 
@@ -940,21 +933,13 @@ jjy_timer ( int unit, struct peer *peer )
 	struct	refclockproc *pp ;
 	struct	jjyunit      *up ;
 
-#ifdef DEBUG
-	if ( debug ) {
-		printf ( "refclock_jjy.c : jjy_timer\n" ) ;
-	}
-#endif
+	DPRINT(1, ( "refclock_jjy.c : jjy_timer\n" )) ;
 
 	pp = peer->procptr ;
 	up = pp->unitptr ;
 
 	if ( up->bReceiveFlag ) {
-#ifdef DEBUG
-		if ( debug ) {
-			printf ( "refclock_jjy.c : jjy_timer : up->bReceiveFlag= true : Timer skipped.\n" ) ;
-		}
-#endif
+	        DPRINT(1, ( "refclock_jjy.c : jjy_timer : up->bReceiveFlag= true : Timer skipped.\n" )) ;
 		return ;
 	}
 
@@ -1365,15 +1350,11 @@ jjy_poll_tristate_jjy01  ( int unit, struct peer *peer )
 		up->iLineCount = 2 ;
 	}
 
-#ifdef DEBUG
-	if ( debug ) {
-		printf ("%s (refclock_jjy.c) : flag1=%X CLK_FLAG1=%X "
-                        "up->iLineCount=%d\n",
-			sFunctionName, pp->sloppyclockflag, 
-                        (unsigned)CLK_FLAG1,
-			up->iLineCount ) ;
-	}
-#endif
+	DPRINT(1, ("%s (refclock_jjy.c) : flag1=%X CLK_FLAG1=%X "
+		   "up->iLineCount=%d\n",
+		   sFunctionName, pp->sloppyclockflag, 
+		   (unsigned)CLK_FLAG1,
+		   up->iLineCount )) ;
 
 	/*
 	 * Send a first command
@@ -2056,12 +2037,8 @@ jjy_receive_tristate_gpsclock01 ( struct recvbuf *rbufp )
 
 	if ( iLen > 5
 	  && ( strncmp( pBuf, "$GP", 3 ) == 0 || strncmp( pBuf, "$PFEC", 5 ) == 0 ) ) {
-#ifdef DEBUG
-		if ( debug ) {
-			printf ( "%s (refclock_jjy.c) : Skip NMEA stream [%s]\n",
-				sFunctionName, pBuf ) ;
-		}
-#endif
+	        DPRINT(1, ( "%s (refclock_jjy.c) : Skip NMEA stream [%s]\n",
+			    sFunctionName, pBuf )) ;
 		return JJY_RECEIVE_WAIT ;
 	}
 
@@ -2080,12 +2057,8 @@ jjy_receive_tristate_gpsclock01 ( struct recvbuf *rbufp )
 	 */
 	if ( iLen > 5
 	  && ( strncmp( pBuf, "$GP", 3 ) == 0 || strncmp( pBuf, "$PFEC", 5 ) == 0 ) ) {
-#ifdef DEBUG
-		if ( debug ) {
-			printf ( "%s (refclock_jjy.c) : Skip NMEA stream [%s]\n",
-				sFunctionName, pBuf ) ;
-		}
-#endif
+	        DPRINT(1, ( "%s (refclock_jjy.c) : Skip NMEA stream [%s]\n",
+			    sFunctionName, pBuf )) ;
 		return JJY_RECEIVE_WAIT ;
 	}
 
@@ -2283,15 +2256,11 @@ jjy_poll_tristate_gpsclock01 ( int unit, struct peer *peer )
 		up->iLineCount = 1 ;
 	}
 
-#ifdef DEBUG
-	if ( debug ) {
-		printf("%s (refclock_jjy.c) : flag1=%X CLK_FLAG1=%X "
-                       "up->iLineCount=%d\n",
-			sFunctionName, pp->sloppyclockflag,
-                        (unsigned)CLK_FLAG1,
-			up->iLineCount ) ;
-	}
-#endif
+        DPRINT(1, ("%s (refclock_jjy.c) : flag1=%X CLK_FLAG1=%X "
+		   "up->iLineCount=%d\n",
+		   sFunctionName, pp->sloppyclockflag,
+		   (unsigned)CLK_FLAG1,
+		   up->iLineCount )) ;
 
 	/*
 	 * Send a first command
@@ -2996,12 +2965,8 @@ teljjy_control ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up 
 
 	if ( rc == TELJJY_CHANGE_CLOCK_STATE ) {
 		iPostEvent = iTeljjyPostEvent[up->iClockEvent][up->iClockState] ;
-#ifdef DEBUG
-		if ( debug ) {
-			printf( "refclock_jjy.c : teljjy_control : iClockState=%hd -> %hd  iPostEvent=%hd\n",
-				up->iClockState, iTeljjyNextState[up->iClockEvent][up->iClockState], iPostEvent ) ;
-		}
-#endif
+		DPRINT(1, ( "refclock_jjy.c : teljjy_control : iClockState=%hd -> %hd  iPostEvent=%hd\n",
+			    up->iClockState, iTeljjyNextState[up->iClockEvent][up->iClockState], iPostEvent )) ;
 		up->iTeljjySilentTimer = 0 ;
 		if ( up->iClockState != iTeljjyNextState[up->iClockEvent][up->iClockState] ) {
 			/* Telephone JJY state is changing now */
@@ -3405,12 +3370,8 @@ teljjy_conn_send ( struct peer *peer, struct refclockproc *pp, struct jjyunit *u
 		 && teljjy_command_sequence[up->iClockCommandSeq].iExpectedReplyType == TELJJY_REPLY_LOOPBACK
 		 && up->iLoopbackCount < MAX_LOOPBACK ) {
 		/* Loopback character comes */
-#ifdef DEBUG
-		if ( debug ) {
-			printf( "refclock_jjy.c : teljjy_conn_send : iClockCommandSeq=%d iLoopbackCount=%d\n",
-				 up->iClockCommandSeq, up->iLoopbackCount ) ;
-		}
-#endif
+	        DPRINT(1, ( "refclock_jjy.c : teljjy_conn_send : iClockCommandSeq=%d iLoopbackCount=%d\n",
+			    up->iClockCommandSeq, up->iLoopbackCount )) ;
 
 		teljjy_setDelay( peer, up ) ;
 
@@ -3639,11 +3600,7 @@ teljjy_conn_silent ( struct peer *peer, struct refclockproc *pp, struct jjyunit 
 	if ( up->iClockCommandSeq >= 1
 	  && up->iClockCommandSeq < TELJJY_COMMAND_START_SKIP_LOOPBACK ) {
 		/* Loopback */
-#ifdef DEBUG
-		if ( debug ) {
-			printf( "refclock_jjy.c : teljjy_conn_silent : call teljjy_conn_send\n" ) ;
-		}
-#endif
+		DPRINT(1, ( "refclock_jjy.c : teljjy_conn_silent : call teljjy_conn_send\n" )) ;
 		if ( teljjy_command_sequence[up->iClockCommandSeq].iExpectedReplyType == TELJJY_REPLY_LOOPBACK ) {
 			up->bLoopbackTimeout[up->iLoopbackCount] = true ;
 		}
@@ -3970,7 +3927,7 @@ modem_receive ( struct recvbuf *rbufp )
 	else                                                              { up->iModemEvent = MODEM_EVENT_RESP_UNKNOWN     ; }
 
 #ifdef DEBUG
-	if ( debug ) {
+	if ( debug ) { /* SPECIAL DEBUG */
 		char	sResp [ 40 ] ;
 		size_t	iCopyLen ;
 		iCopyLen = iLen <= (int)sizeof(sResp)-1 ?
@@ -4036,12 +3993,8 @@ modem_control ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up )
 
 	if ( rc == CHANGE_MODEM_STATE ) {
 		iPostEvent = iModemPostEvent[up->iModemEvent][up->iModemState] ;
-#ifdef DEBUG
-		if ( debug ) {
-			printf( "refclock_jjy.c : modem_control : iModemState=%d -> %d  iPostEvent=%d\n",
-				 up->iModemState, iModemNextState[up->iModemEvent][up->iModemState], iPostEvent ) ;
-		}
-#endif
+		DPRINT(1, ( "refclock_jjy.c : modem_control : iModemState=%d -> %d  iPostEvent=%d\n",
+			    up->iModemState, iModemNextState[up->iModemEvent][up->iModemState], iPostEvent )) ;
 
 		if ( up->iModemState != iModemNextState[up->iModemEvent][up->iModemState] ) {
 			up->iModemSilentCount = 0 ;
@@ -4114,11 +4067,7 @@ modem_init_start ( struct peer *peer, struct refclockproc *pp, struct jjyunit *u
 
 	up->iModemCommandSeq = 0 ;
 
-#ifdef DEBUG
-	if ( debug ) {
-		printf( "refclock_jjy.c : modem_init_start : call modem_init_resp00\n" ) ;
-	}
-#endif
+	DPRINT(1, ( "refclock_jjy.c : modem_init_start : call modem_init_resp00\n" )) ;
 
 	return modem_init_resp00( peer, pp, up ) ;
 
@@ -4253,11 +4202,7 @@ modem_init_disc ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up
 	UNUSED_ARG(up);
 
 	DEBUG_MODEM_PRINTF( "modem_init_disc" ) ;
-#ifdef DEBUG
-	if ( debug ) {
-		printf( "refclock_jjy.c : modem_init_disc : call modem_esc_disc\n" ) ;
-	}
-#endif
+	DPRINT(1, ( "refclock_jjy.c : modem_init_disc : call modem_esc_disc\n" )) ;
 
 	return CHANGE_MODEM_STATE ;
 
@@ -4319,11 +4264,7 @@ modem_dial_escape ( struct peer *peer, struct refclockproc *pp, struct jjyunit *
 {
 
 	DEBUG_MODEM_PRINTF( "modem_dial_escape" ) ;
-#ifdef DEBUG
-	if ( debug ) {
-		printf( "refclock_jjy.c : modem_dial_escape : call modem_conn_escape\n" ) ;
-	}
-#endif
+	DPRINT(1, ( "refclock_jjy.c : modem_dial_escape : call modem_conn_escape\n" )) ;
 
 	return modem_conn_escape( peer, pp, up ) ;
 
@@ -4349,11 +4290,7 @@ modem_dial_disc ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up
 {
 
 	DEBUG_MODEM_PRINTF( "modem_dial_disc" ) ;
-#ifdef DEBUG
-	if ( debug ) {
-		printf( "refclock_jjy.c : modem_dial_disc : call modem_esc_disc\n" ) ;
-	}
-#endif
+	DPRINT(1, ( "refclock_jjy.c : modem_dial_disc : call modem_esc_disc\n" )) ;
 
 	modem_esc_disc( peer, pp, up ) ;
 
@@ -4453,21 +4390,13 @@ modem_esc_silent ( struct peer *peer, struct refclockproc *pp, struct jjyunit *u
 	up->iModemSilentCount ++ ;
 
 	if ( up->iModemSilentCount < iModemStateTimeout[up->iModemState] / iModemSilentTimeout[up->iModemState] ) {
-#ifdef DEBUG
-		if ( debug ) {
-			printf( "refclock_jjy.c : modem_esc_silent : call modem_esc_escape\n" ) ;
-		}
-#endif
+		DPRINT(1, ( "refclock_jjy.c : modem_esc_silent : call modem_esc_escape\n" )) ;
 		modem_esc_escape( peer, pp, up ) ;
 		up->iModemSilentTimer = 0 ;
 		return STAY_MODEM_STATE ;
 	}
 
-#ifdef DEBUG
-	if ( debug ) {
-		printf( "refclock_jjy.c : modem_esc_silent : call modem_esc_disc\n" ) ;
-	}
-#endif
+	DPRINT(1, ( "refclock_jjy.c : modem_esc_silent : call modem_esc_disc\n" )) ;
 	return modem_esc_disc( peer, pp, up ) ;
 
 }
@@ -4550,11 +4479,7 @@ jjy_write_clockstats ( struct peer *peer, int iMark, const char *pData )
 	printableString( sLog+iMarkLen, (int)sizeof(sLog)-iMarkLen,
                          pData, iDataLen ) ;
 
-#if defined(DEBUG) && DEBUG
-	if ( debug ) {
-		printf( "refclock_jjy.c : clockstats : %s\n", sLog ) ;
-	}
-#endif
+	DPRINT(1, ( "refclock_jjy.c : clockstats : %s\n", sLog )) ;
 	record_clock_stats( peer, sLog ) ;
 
 }


=====================================
ntpd/refclock_oncore.c
=====================================
--- a/ntpd/refclock_oncore.c
+++ b/ntpd/refclock_oncore.c
@@ -1438,7 +1438,7 @@ oncore_receive(
 	p = (uint8_t *) &rbufp->recv_space;
 
 #ifdef ONCORE_VERBOSE_RECEIVE
-	if (debug > 4) {
+	if (debug > 4) { /* SPECIAL DEBUG */
 		int i;
 		char	Msg[120], Msg2[10];
 
@@ -1489,7 +1489,7 @@ oncore_consume(
 				if (rcvbuf[i] == '@' && rcvbuf[i+1] == '@')
 					break;
 #ifdef ONCORE_VERBOSE_CONSUME
-			if (debug > 4)
+			if (debug > 4) /* SPECIAL DEBUG */
 				oncore_log_f(instance, LOG_DEBUG,
 					     ">>> skipping %d chars",
 					     i);
@@ -1507,7 +1507,7 @@ oncore_consume(
 				break;
 		if (m == l) {
 #ifdef ONCORE_VERBOSE_CONSUME
-			if (debug > 4)
+			if (debug > 4) /* SPECIAL DEBUG */
 				oncore_log_f(instance, LOG_DEBUG,
 					     ">>> Unknown MSG, skipping 4 (%c%c)",
 					     rcvbuf[2], rcvbuf[3]);
@@ -1519,7 +1519,7 @@ oncore_consume(
 
 		l = (unsigned int)oncore_messages[m].len;
 #ifdef ONCORE_VERBOSE_CONSUME
-		if (debug > 3)
+		if (debug > 3) /* SPECIAL DEBUG */
 			oncore_log_f(instance, LOG_DEBUG,
 				     "GOT: %c%c  %d of %d entry %d",
 				     instance->unit, rcvbuf[2],
@@ -1534,7 +1534,7 @@ oncore_consume(
 
 		if (rcvbuf[l-2] != '\r' || rcvbuf[l-1] != '\n') {
 #ifdef ONCORE_VERBOSE_CONSUME
-			if (debug)
+			if (debug) /* SPECIAL DEBUG */
 				oncore_log(instance, LOG_DEBUG, "NO <CR><LF> at end of message");
 #endif
 		} else {	/* check the CheckSum */
@@ -1550,7 +1550,7 @@ oncore_consume(
 					oncore_messages[m].handler(instance, rcvbuf, (size_t) (l-3));
 			}
 #ifdef ONCORE_VERBOSE_CONSUME
-			else if (debug) {
+			else if (debug) { /* SPECIAL DEBUG */
 				char	Msg[120], Msg2[10];
 
 				oncore_log(instance, LOG_ERR, "Checksum mismatch!");
@@ -1648,7 +1648,7 @@ oncore_get_timestamp(
 		tsp = &pps_i.assert_timestamp;
 
 #ifdef ONCORE_VERBOSE_GET_TIMESTAMP
-		if (debug > 2) {
+		if (debug > 2) { /* SPECIAL DEBUG */
 			u_long i;
 
 			i = (u_long) pps_i.assert_sequence;
@@ -1670,7 +1670,7 @@ oncore_get_timestamp(
 		tsp = &pps_i.clear_timestamp;
 
 #if 0
-		if (debug > 2) {
+		if (debug > 2) { /* SPECIAL DEBUG */
 			u_long i;
 
 			i = (u_long) pps_i.clear_sequence;
@@ -1896,7 +1896,7 @@ oncore_msg_any(
 	struct timespec ts;
 	char	Msg[120], Msg2[10];
 
-	if (debug > 3) {
+	if (debug > 3) { /* SPECIAL DEBUG */
 		(void) clock_gettime(CLOCK_REALTIME, &ts);
 		oncore_log(instance, LOG_DEBUG, "%ld.%09ld",
 			   (long)tv.tv_sec, tv.tv_nsec);
@@ -2702,7 +2702,7 @@ oncore_msg_CaFaIa(
 		instance->timeout = 0;
 
 #ifdef ONCORE_VERBOSE_SELF_TEST
-		if (debug > 2) {
+		if (debug > 2) { /* SPECIAL DEBUG */
 			if (buf[2] == 'I')
 				oncore_log_f(instance, LOG_DEBUG,
 					     ">>@@%ca %x %x %x", buf[2],
@@ -3782,7 +3782,7 @@ oncore_sendmsg(
 
 	fd = instance->ttyfd;
 #ifdef ONCORE_VERBOSE_SENDMSG
-	if (debug > 4) {
+	if (debug > 4) { /* SPECIAL DEBUG */
 		oncore_log_f(instance, LOG_DEBUG, "ONCORE: Send @@%c%c %d",
 			     ptr[0], ptr[1], (int)len);
 	}


=====================================
ntpd/refclock_spectracom.c
=====================================
--- a/ntpd/refclock_spectracom.c
+++ b/ntpd/refclock_spectracom.c
@@ -467,7 +467,7 @@ spectracom_timer(
 		refclock_report(peer, CEVNT_FAULT);
 #ifdef DEBUG
 	get_systime(&now);
-	if (debug)
+	if (debug) /* SPECIAL DEBUG */
 		printf("%c poll at %s\n", pollchar, prettydate(now));
 #endif
 #ifdef HAVE_PPSAPI
@@ -535,11 +535,8 @@ spectracom_poll(
 #endif /* HAVE_PPSAPI */
 	refclock_receive(peer);
 	record_clock_stats(peer, pp->a_lastcode);
-#ifdef DEBUG
-	if (debug)
-		printf("wwvb: timecode %d %s\n", pp->lencode,
-		    pp->a_lastcode);
-#endif
+	DPRINT(1, ("wwvb: timecode %d %s\n", pp->lencode,
+		   pp->a_lastcode));
 }
 
 


=====================================
ntpd/refclock_trimble.c
=====================================
--- a/ntpd/refclock_trimble.c
+++ b/ntpd/refclock_trimble.c
@@ -587,7 +587,7 @@ TSIP_decode (
 				return 0;
 		
 #ifdef DEBUG
-			if (debug > 1) {
+			if (debug > 1) { /* SPECIAL DEBUG */
 				int ts;
 				double lat, lon, alt;
 				lat = getdbl((uint8_t *) &mb(42)) * R2D;
@@ -634,7 +634,7 @@ TSIP_decode (
 			gpsweekadj(&up->week, up->build_week);
 			gpstocal(up->week, up->TOW, up->UTC_offset, &up->date);
 #ifdef DEBUG
-			if (debug > 1)
+			if (debug > 1) /* SPECIAL DEBUG */
 				printf("TSIP_decode: unit %d: %02X #%d %02d:%02d:%02d.%09ld %02d/%02d/%04d UTC %02d\n",
 				       up->unit, (u_int)(mb(0) & 0xff), event,
 				       up->date.hour, up->date.minute, up->date.second, pp->nsec,
@@ -723,14 +723,11 @@ TSIP_decode (
 			gpsweekadj(&up->week, up->build_week);
 			gpstocal(up->week, up->TOW, up->UTC_offset, &up->date);
 			up->UTC_offset = 0; /* don't re-use offset */
-#ifdef DEBUG
-			if (debug > 1)
-				printf("TSIP_decode: unit %d: %02X #%d %02d:%02d:%02d.%09ld %02d/%02d/%04d UTC %02x %s\n",
-				       up->unit, (u_int)(mb(0) & 0xff), event,
-				       up->date.hour, up->date.minute, up->date.second, pp->nsec,
-				       up->date.month, up->date.monthday, up->date.year,
-				       (u_int)mb(19), *Tracking_Status[st]);
-#endif
+			DPRINT(2, ("TSIP_decode: unit %d: %02X #%d %02d:%02d:%02d.%09ld %02d/%02d/%04d UTC %02x %s\n",
+				   up->unit, (u_int)(mb(0) & 0xff), event,
+				   up->date.hour, up->date.minute, up->date.second, pp->nsec,
+				   up->date.month, up->date.monthday, up->date.year,
+				   (u_int)mb(19), *Tracking_Status[st]));
 			return 1;
 			break;
 
@@ -742,7 +739,7 @@ TSIP_decode (
 				break;
 
 #ifdef DEBUG
-			if (debug > 1) {
+			if (debug > 1) { /* SPECIAL DEBUG */
 				double lat, lon, alt;
 				lat = getdbl((uint8_t *) &mb(36)) * R2D;
 				lon = getdbl((uint8_t *) &mb(44)) * R2D;
@@ -761,10 +758,10 @@ TSIP_decode (
 				pp->leap = LEAP_NOWARNING;
 
 #ifdef DEBUG
-			if (debug > 1) 
+			if (debug > 1) /* SPECIAL DEBUG */
 				printf("TSIP_decode: unit %d: 0x%02x leap %d\n",
 				       up->unit, (u_int)(mb(0) & 0xff), pp->leap);
-			if (debug > 1) {
+			if (debug > 1) { /* SPECIAL DEBUG */
 				printf("Receiver MODE: 0x%02X\n", (uint8_t)mb(1));
 				if (mb(1) == 0x00)
 					printf("                AUTOMATIC\n");
@@ -857,14 +854,10 @@ TSIP_decode (
 			up->week = (uint32_t)getint((uint8_t *) &mb(5));
 			gpsweekadj(&up->week, up->build_week);
 			gpstocal(up->week, up->TOW, up->UTC_offset, &up->date);
-#ifdef DEBUG		
-			if (debug > 1) {
-				printf("TSIP_decode: unit %d: %02X #%d TOW: %u  week: %u  adj.t: %02d:%02d:%02d.0 %02d/%02d/%04d\n",
-				        up->unit, (u_int)(mb(0) & 0xff), event, up->TOW, up->week, 
-					up->date.hour, up->date.minute, up->date.second,
-					up->date.month, up->date.monthday, up->date.year);
-			}
-#endif
+			DPRINT(2, ("TSIP_decode: unit %d: %02X #%d TOW: %u  week: %u  adj.t: %02d:%02d:%02d.0 %02d/%02d/%04d\n",
+				   up->unit, (u_int)(mb(0) & 0xff), event, up->TOW, up->week, 
+				   up->date.hour, up->date.minute, up->date.second,
+				   up->date.month, up->date.monthday, up->date.year));
 			return 1;
 			break;
 
@@ -898,7 +891,7 @@ TSIP_decode (
 	/* Health Status for Acutime Receiver */
 	else if ((up->rpt_buf[0] == PACKET_46) & (up->type == CLK_ACUTIME)) {
 #ifdef DEBUG
-		if (debug > 1)
+		if (debug > 1) /* SPECIAL DEBUG */
 		/* Status Codes */
 			switch (mb(0)) {
 			    case 0x00:
@@ -935,7 +928,7 @@ TSIP_decode (
 			refclock_report(peer, CEVNT_BADTIME);
 			up->polled = -1;
 #ifdef DEBUG
-			if (debug > 1) {
+			if (debug > 1) { /* SPECIAL DEBUG */
 				if (mb(1) & 0x01)
 					printf ("Signal Processor Error, reset unit.\n");
 				if (mb(1) & 0x02)
@@ -1015,13 +1008,9 @@ trimble_receive (
 	pp->hour = up->date.hour;
 	pp->minute = up->date.minute;
 	pp->second = up->date.second;
-#ifdef DEBUG
-	if (debug) 
-		printf(
-			"trimble_receive: unit %d: %4d %03d %02d:%02d:%02d.%09ld\n",
-			up->unit, pp->year, pp->day, pp->hour, pp->minute, 
-			pp->second, pp->nsec);
-#endif
+	DPRINT(1, ("trimble_receive: unit %d: %4d %03d %02d:%02d:%02d.%09ld\n",
+		   up->unit, pp->year, pp->day, pp->hour, pp->minute, 
+		   pp->second, pp->nsec));
 
 	/*
 	 * Process the sample
@@ -1047,11 +1036,8 @@ trimble_receive (
 
 	record_clock_stats(peer, pp->a_lastcode); 
 
-#ifdef DEBUG
-	if (debug)
-		printf("trimble_receive: unit %d: %s\n",
-		       up->unit, prettydate(pp->lastrec));
-#endif
+	DPRINT(1, ("trimble_receive: unit %d: %s\n",
+		   up->unit, prettydate(pp->lastrec)));
 	if (pp->hour == 0 && up->week > up->build_week + 1000)
 		msyslog(LOG_WARNING, "Trimble(%d) current GPS week number (%u) is more than 1000 weeks past ntpd's build date (%u), please update",
 		        up->unit, up->week, up->build_week);
@@ -1082,13 +1068,10 @@ trimble_poll (
 		refclock_report(peer, CEVNT_TIMEOUT);
 
 	up->polled = 2; /* synchronous packet + 1 event */
-	
-#ifdef DEBUG
-	if (debug)
-		printf("trimble_poll: unit %d: polling %s\n", unit,
-		       (pp->sloppyclockflag & CLK_FLAG2) ? 
-		       "synchronous packet" : "event");
-#endif 
+
+	DPRINT(1, ("trimble_poll: unit %d: polling %s\n", unit,
+		   (pp->sloppyclockflag & CLK_FLAG2) ? 
+		   "synchronous packet" : "event"));
 
 	if (pp->sloppyclockflag & CLK_FLAG2) 
 		return;  /* using synchronous packet input */
@@ -1269,11 +1252,8 @@ HW_poll (
 	if (up->type == CLK_ACUTIME)
 		IGNORE(write (pp->io.fd, "", 1));
 		
-	if (ioctl(pp->io.fd, TIOCMSET, &x) < 0) { 
-#ifdef DEBUG
-		if (debug)
-			printf("Trimble HW_poll: unit %d: SET \n", up->unit);
-#endif
+	if (ioctl(pp->io.fd, TIOCMSET, &x) < 0) {
+		DPRINT(1, printf("Trimble HW_poll: unit %d: SET \n", up->unit));
 		msyslog(LOG_ERR,
 			"Trimble(%d) HW_poll: ioctl(fd, SET, RTS_on): %m", 
 			up->unit);
@@ -1286,10 +1266,7 @@ HW_poll (
 	get_systime(&pp->lastrec);
 
 	if (ioctl(pp->io.fd, TIOCMSET, &x) == -1) {
-#ifdef DEBUG
-		if (debug)
-			printf("Trimble HW_poll: unit %d: UNSET \n", up->unit);
-#endif
+		DPRINT(1, printf("Trimble HW_poll: unit %d: UNSET \n", up->unit));
 		msyslog(LOG_ERR,
 			"Trimble(%d) HW_poll: ioctl(fd, UNSET, RTS_off): %m", 
 			up->unit);



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

---
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/632544d0c28cde07a3514619cb983b51eef1310b
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/20170604/f2dad262/attachment.html>


More information about the vc mailing list