From: Harlan Stenn Date: Tue, 8 Aug 2006 08:12:04 +0000 (-0400) Subject: [Bug 675]: Make sure we build even when we --disable-debugging X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5572e35babc50bba33bf8308d2eb074a061a3fd6;p=thirdparty%2Fntp.git [Bug 675]: Make sure we build even when we --disable-debugging bk: 44d84754eJ1ig9MBaazpRDJIu2vHOg --- diff --git a/ntpd/ntp_intres.c b/ntpd/ntp_intres.c index 6f529eb943..f2aabe83e8 100644 --- a/ntpd/ntp_intres.c +++ b/ntpd/ntp_intres.c @@ -249,7 +249,9 @@ ntp_intres(void) readconf(in, req_file); (void) fclose(in); +#ifdef DEBUG if (!debug ) +#endif (void) unlink(req_file); /* @@ -785,8 +787,10 @@ request( } else if (n == 0) { +#ifdef DEBUG if (debug) msyslog(LOG_INFO, "select() returned 0."); +#endif return 0; } diff --git a/ntpd/ntp_io.c b/ntpd/ntp_io.c index c7d9502a05..de2aa5e411 100644 --- a/ntpd/ntp_io.c +++ b/ntpd/ntp_io.c @@ -2253,7 +2253,11 @@ open_socket( /* * Don't log this under all conditions */ - if (turn_off_reuse == 0 || debug > 1) + if (turn_off_reuse == 0 +#ifdef DEBUG + || debug > 1 +#endif + ) netsyslog(LOG_ERR, buff); closesocket(fd); diff --git a/ntpd/refclock_jupiter.c b/ntpd/refclock_jupiter.c index 6aad0952f2..c10d9fa0df 100644 --- a/ntpd/refclock_jupiter.c +++ b/ntpd/refclock_jupiter.c @@ -902,12 +902,14 @@ jupiter_debug(peer, function, fmt, va_alist) */ vsnprintf(buffer, sizeof(buffer), fmt, ap); record_clock_stats(&(peer->srcadr), buffer); +#ifdef DEBUG if (debug) { fprintf(stdout, "%s: ", function); fprintf(stdout, buffer); fprintf(stdout, "\n"); fflush(stdout); } +#endif va_end(ap); } diff --git a/ntpd/refclock_leitch.c b/ntpd/refclock_leitch.c index b50fa05d1c..e1ba0c4095 100644 --- a/ntpd/refclock_leitch.c +++ b/ntpd/refclock_leitch.c @@ -48,14 +48,20 @@ #define LEITCH_DESCRIPTION "Leitch: CSD 5300 Master Clock System Driver" #define LEITCH232 "/dev/leitch%d" /* name of radio device */ #define SPEED232 B300 /* uart speed (300 baud) */ +#ifdef DEBUG #define leitch_send(A,M) \ if (debug) fprintf(stderr,"write leitch %s\n",M); \ if ((write(A->leitchio.fd,M,sizeof(M)) < 0)) {\ - if (debug) \ - fprintf(stderr, "leitch_send: unit %d send failed\n", A->unit); \ - else \ - msyslog(LOG_ERR, "leitch_send: unit %d send failed %m",A->unit);} - + if (debug) \ + fprintf(stderr, "leitch_send: unit %d send failed\n", A->unit); \ + else \ + msyslog(LOG_ERR, "leitch_send: unit %d send failed %m",A->unit);} +#else +#define leitch_send(A,M) \ +if ((write(A->leitchio.fd,M,sizeof(M)) < 0)) {\ + msyslog(LOG_ERR, "leitch_send: unit %d send failed %m",A->unit);} +#endif + #define STATE_IDLE 0 #define STATE_DATE 1 #define STATE_TIME1 2 diff --git a/ntpd/refclock_msfees.c b/ntpd/refclock_msfees.c index 5fe962fefc..98034b5870 100644 --- a/ntpd/refclock_msfees.c +++ b/ntpd/refclock_msfees.c @@ -40,12 +40,13 @@ #include "ntp_stdlib.h" +int dbg = 0; /* fudgefactor = fudgetime1; os_delay = fudgetime2; offset_fudge = os_delay + fudgefactor + inherent_delay; stratumtouse = fudgeval1 & 0xf - debug = fudgeval2; + dbg = fudgeval2; sloppyclockflag = flags & CLK_FLAG1; 1 log smoothing summary when processing sample 4 dump the buffer from the clock @@ -675,7 +676,7 @@ ees_receive( ees = (struct eesunit *)rbufp->recv_srcclock; dpt = (u_char *)&rbufp->recv_space; dpend = dpt + rbufp->recv_length; - if ((debug & DB_LOG_AWAITMORE) && (rbufp->recv_length != LENEESCODE)) + if ((dbg & DB_LOG_AWAITMORE) && (rbufp->recv_length != LENEESCODE)) printf("[%d] ", rbufp->recv_length); /* Check out our state and process appropriately */ @@ -718,7 +719,7 @@ ees_receive( /* Gave up because it was end of the buffer, rather than ff */ if (dpt == dpend) { /* Incomplete. Wait for more. */ - if (debug & DB_LOG_AWAITMORE) + if (dbg & DB_LOG_AWAITMORE) msyslog(LOG_INFO, "I: ees clock %d: %p == %p: await more", ees->unit, dpt, dpend); @@ -897,7 +898,7 @@ ees_receive( memset((char *) &ppsclockev, 0, sizeof ppsclockev); rc = ioctl(ees->io.fd, request, (char *) &ppsclockev); - if (debug & DB_PRINT_EV) fprintf(stderr, + if (dbg & DB_PRINT_EV) fprintf(stderr, "[%x] CIOGETEV u%d %d (%x %d) gave %d (%d): %08lx %08lx %ld\n", DB_PRINT_EV, ees->unit, ees->io.fd, request, is_pps(ees), rc, errno, ptr[0], ptr[1], ptr[2]); @@ -925,7 +926,7 @@ ees_receive( diff = pps_arrvstamp; conv = 0; L_SUB(&diff, &ees->arrvtime); - if (debug & DB_PRINT_CDT) + if (dbg & DB_PRINT_CDT) printf("[%x] Have %lx.%08lx and %lx.%08lx -> %lx.%08lx @ %s", DB_PRINT_CDT, (long)ees->arrvtime.l_ui, (long)ees->arrvtime.l_uf, (long)pps_arrvstamp.l_ui, (long)pps_arrvstamp.l_uf, @@ -962,7 +963,7 @@ ees_receive( } } ees->last_pps_no = ppsclockev.serial; - if (debug & DB_PRINT_CDTC) + if (dbg & DB_PRINT_CDTC) printf( "[%x] %08lx %08lx %d u%d (%d %d)\n", DB_PRINT_CDTC, (long)pps_arrvstamp.l_ui, @@ -985,7 +986,7 @@ ees_receive( if (delta_f_abs < 0) delta_f_abs = -delta_f_abs; /* Dump the deltas each minute */ - if (debug & DB_DUMP_DELTAS) + if (dbg & DB_DUMP_DELTAS) { if (/*0 <= ees->second && */ ees->second < ((sizeof deltas) / (sizeof deltas[0]))) deltas[ees->second] = delta_sfsec; /* Dump on second 1, as second 0 sometimes missed */ @@ -1147,12 +1148,12 @@ ees_receive( /* sec_of_ramp * ees->jump_fsecs may overflow 2**32 */ fsecs = sec_of_ramp * (ees->jump_fsecs / ees->last_step_secs); - if (debug & DB_LOG_DELTAS) msyslog(LOG_ERR, + if (dbg & DB_LOG_DELTAS) msyslog(LOG_ERR, "[%x] MSF%d: %3ld/%03d -> d=%11ld (%d|%ld)", DB_LOG_DELTAS, ees->unit, sec_of_ramp, ees->last_step_secs, fsecs, pps_arrvstamp.l_f, pps_arrvstamp.l_f + fsecs); - if (debug & DB_PRINT_DELTAS) printf( + if (dbg & DB_PRINT_DELTAS) printf( "MSF%d: %3ld/%03d -> d=%11ld (%ld|%ld)\n", ees->unit, sec_of_ramp, ees->last_step_secs, fsecs, (long)pps_arrvstamp.l_f, pps_arrvstamp.l_f + fsecs); @@ -1160,7 +1161,7 @@ ees_receive( /* Must sign extend the result */ inc.l_i = (fsecs < 0) ? -1 : 0; inc.l_f = fsecs; - if (debug & DB_INC_PPS) + if (dbg & DB_INC_PPS) { L_SUB(&pps_arrvstamp, &inc); L_SUB(&ees->arrvtime, &inc); } @@ -1170,14 +1171,14 @@ ees_receive( } } else { - if (debug & DB_LOG_DELTAS) msyslog(LOG_ERR, + if (dbg & DB_LOG_DELTAS) msyslog(LOG_ERR, "[%x] MSF%d: ees->using_ramp=%d, sincelast=%x / %x, ees->last_step_secs=%x", DB_LOG_DELTAS, ees->unit, ees->using_ramp, sincelast, (ees->last_step_secs)*2, ees->last_step_secs); - if (debug & DB_PRINT_DELTAS) printf( + if (dbg & DB_PRINT_DELTAS) printf( "[%x] MSF%d: ees->using_ramp=%d, sincelast=%x / %x, ees->last_step_secs=%x\n", DB_LOG_DELTAS, ees->unit, ees->using_ramp, @@ -1189,7 +1190,7 @@ ees_receive( L_SUB(&ees->arrvtime, &offset_fudge[ees->unit]); L_SUB(&pps_arrvstamp, &offset_fudge[ees->unit]); - if (call_pps_sample && !(debug & DB_NO_PPS)) { + if (call_pps_sample && !(dbg & DB_NO_PPS)) { /* Sigh -- it expects its args negated */ L_NEG(&pps_arrvstamp); /* @@ -1202,14 +1203,14 @@ ees_receive( /* Subtract off the local clock time stamp */ L_SUB(&ees->codeoffsets[n_sample], &ees->arrvtime); - if (debug & DB_LOG_SAMPLES) msyslog(LOG_ERR, + if (dbg & DB_LOG_SAMPLES) msyslog(LOG_ERR, "MSF%d: [%x] %d (ees: %d %d) (pps: %d %d)%s", ees->unit, DB_LOG_DELTAS, n_sample, ees->codeoffsets[n_sample].l_f, ees->codeoffsets[n_sample].l_f / 4295, pps_arrvstamp.l_f, pps_arrvstamp.l_f /4295, - (debug & DB_NO_PPS) ? " [no PPS]" : ""); + (dbg & DB_NO_PPS) ? " [no PPS]" : ""); if (ees->nsamples++ == NCODES-1) ees_process(ees); @@ -1334,10 +1335,10 @@ ees_process( L_SUB(&tmp, &coffs[i]); #define FRACT_SEC(n) ((1 << 30) / (n/2)) dispersion = LFPTOFP(&tmp) / 2; /* ++++ */ - if (debug & (DB_SYSLOG_SMPLI | DB_SYSLOG_SMPLE)) msyslog( - (debug & DB_SYSLOG_SMPLE) ? LOG_ERR : LOG_INFO, + if (dbg & (DB_SYSLOG_SMPLI | DB_SYSLOG_SMPLE)) msyslog( + (dbg & DB_SYSLOG_SMPLE) ? LOG_ERR : LOG_INFO, "I: [%x] Offset=%06d (%d), disp=%f%s [%d], %d %d=%d %d:%d %d=%d %d", - debug & (DB_SYSLOG_SMPLI | DB_SYSLOG_SMPLE), + dbg & (DB_SYSLOG_SMPLI | DB_SYSLOG_SMPLE), offset.l_f / 4295, offset.l_f, (dispersion * 1526) / 100, (sloppyclockflag[ees->unit]) ? " by averaging" : "", @@ -1377,24 +1378,24 @@ ees_process( offset.l_ui += (new < 0) ? -1 : 1; } dispersion /= 4; - if (debug & (DB_SYSLOG_SMTHI | DB_SYSLOG_SMTHE)) msyslog( - (debug & DB_SYSLOG_SMTHE) ? LOG_ERR : LOG_INFO, + if (dbg & (DB_SYSLOG_SMTHI | DB_SYSLOG_SMTHE)) msyslog( + (dbg & DB_SYSLOG_SMTHE) ? LOG_ERR : LOG_INFO, "I: [%x] Smooth data: %ld -> %ld, dispersion now %f", - debug & (DB_SYSLOG_SMTHI | DB_SYSLOG_SMTHE), + dbg & (DB_SYSLOG_SMTHI | DB_SYSLOG_SMTHE), ((long) offset.l_uf) / 4295, new / 4295, (dispersion * 1526) / 100); offset.l_uf = (unsigned long) new; } - else if (debug & (DB_SYSLOG_NSMTHI | DB_SYSLOG_NSMTHE)) msyslog( - (debug & DB_SYSLOG_NSMTHE) ? LOG_ERR : LOG_INFO, + else if (dbg & (DB_SYSLOG_NSMTHI | DB_SYSLOG_NSMTHE)) msyslog( + (dbg & DB_SYSLOG_NSMTHE) ? LOG_ERR : LOG_INFO, "[%x] No smooth as delta not %d < %ld < %d", - debug & (DB_SYSLOG_NSMTHI | DB_SYSLOG_NSMTHE), + dbg & (DB_SYSLOG_NSMTHI | DB_SYSLOG_NSMTHE), - FRACT_SEC(100), diff, FRACT_SEC(100)); } - else if (debug & (DB_SYSLOG_NSMTHI | DB_SYSLOG_NSMTHE)) msyslog( - (debug & DB_SYSLOG_NSMTHE) ? LOG_ERR : LOG_INFO, + else if (dbg & (DB_SYSLOG_NSMTHI | DB_SYSLOG_NSMTHE)) msyslog( + (dbg & DB_SYSLOG_NSMTHE) ? LOG_ERR : LOG_INFO, "I: [%x] No smooth as flag=%x and old=%x=%d (%d:%d)", - debug & (DB_SYSLOG_NSMTHI | DB_SYSLOG_NSMTHE), + dbg & (DB_SYSLOG_NSMTHI | DB_SYSLOG_NSMTHE), ees->usealldata, ees->offset.l_f, ees->offset.l_uf, offset.l_f, ees->offset.l_f - offset.l_f); diff --git a/ntpd/refclock_mx4200.c b/ntpd/refclock_mx4200.c index e2f2d13715..68150b7c42 100644 --- a/ntpd/refclock_mx4200.c +++ b/ntpd/refclock_mx4200.c @@ -1572,6 +1572,7 @@ mx4200_debug(peer, fmt, va_alist) char *fmt; #endif /* __STDC__ */ { +#ifdef DEBUG va_list ap; struct refclockproc *pp; struct mx4200unit *up; @@ -1596,6 +1597,7 @@ mx4200_debug(peer, fmt, va_alist) va_end(ap); } +#endif } /* diff --git a/ntpd/refclock_oncore.c b/ntpd/refclock_oncore.c index e9fd468fc1..c720add2ca 100644 --- a/ntpd/refclock_oncore.c +++ b/ntpd/refclock_oncore.c @@ -1433,8 +1433,10 @@ oncore_consume( for (i=1; i < rcvptr-1; i++) if (rcvbuf[i] == '@' && rcvbuf[i+1] == '@') break; +#ifdef DEBUG if (debug > 4) printf("ONCORE[%d]: >>> skipping %d chars\n", instance->unit, i); +#endif if (i != rcvptr) memcpy(rcvbuf, rcvbuf+i, (size_t)(rcvptr-i)); rcvptr -= i; @@ -1447,8 +1449,10 @@ oncore_consume( if (!strncmp(oncore_messages[m].flag, (char *)(rcvbuf+2), (size_t) 2)) break; if (m == l) { +#ifdef DEBUG if (debug > 4) printf("ONCORE[%d]: >>> Unknown MSG, skipping 4 (%c%c)\n", instance->unit, rcvbuf[2], rcvbuf[3]); +#endif memcpy(rcvbuf, rcvbuf+4, (size_t) 4); rcvptr -= 4; continue; @@ -1467,8 +1471,10 @@ oncore_consume( /* are we at the end of message? should be */ if (rcvbuf[l-2] != '\r' || rcvbuf[l-1] != '\n') { +#ifdef DEBUG if (debug) printf("ONCORE[%d]: NO at end of message\n", instance->unit); +#endif } else { /* check the CheckSum */ if (oncore_checksum_ok(rcvbuf, l)) { if (instance->shmem != NULL) { @@ -1479,13 +1485,16 @@ oncore_consume( oncore_msg_any(instance, rcvbuf, (size_t) (l-3), m); if (oncore_messages[m].handler) oncore_messages[m].handler(instance, rcvbuf, (size_t) (l-3)); - } else if (debug) { + } +#ifdef DEBUG + else if (debug) { printf("ONCORE[%d]: Checksum mismatch!\n", instance->unit); printf("ONCORE[%d]: @@%c%c ", instance->unit, rcvbuf[2], rcvbuf[3]); for (i=4; iassert) { tsp = &pps_i.assert_timestamp; +#ifdef DEBUG if (debug > 2) { i = (u_long) pps_i.assert_sequence; -#ifdef HAVE_STRUCT_TIMESPEC +# ifdef HAVE_STRUCT_TIMESPEC printf("ONCORE[%d]: serial/j (%lu, %lu) %ld.%09ld\n", instance->unit, i, j, (long)tsp->tv_sec, (long)tsp->tv_nsec); -#else +# else printf("ONCORE[%d]: serial/j (%lu, %lu) %ld.%06ld\n", instance->unit, i, j, (long)tsp->tv_sec, (long)tsp->tv_usec); -#endif +# endif } +#endif if (pps_i.assert_sequence == j) { printf("ONCORE: oncore_get_timestamp, error serial pps\n"); @@ -1582,16 +1593,18 @@ oncore_get_timestamp( } else { tsp = &pps_i.clear_timestamp; +#ifdef DEBUG if (debug > 2) { i = (u_long) pps_i.clear_sequence; -#ifdef HAVE_STRUCT_TIMESPEC +# ifdef HAVE_STRUCT_TIMESPEC printf("ONCORE[%d]: serial/j (%lu, %lu) %ld.%09ld\n", instance->unit, i, j, (long)tsp->tv_sec, (long)tsp->tv_nsec); -#else +# else printf("ONCORE[%d]: serial/j (%lu, %lu) %ld.%06ld\n", instance->unit, i, j, (long)tsp->tv_sec, (long)tsp->tv_usec); -#endif +# endif } +#endif if (pps_i.clear_sequence == j) { printf("ONCORE: oncore_get_timestamp, error serial pps\n"); @@ -1754,11 +1767,14 @@ oncore_get_timestamp( ); } +#ifdef DEBUG if (debug > 2) { int n; + n = strlen(instance->pp->a_lastcode); printf("ONCORE[%d]: len = %d %s\n", instance->unit, n, instance->pp->a_lastcode); } +#endif /* and some things I dont understand (magic ntp things) */ @@ -1802,14 +1818,15 @@ oncore_msg_any( #endif struct timeval tv; +#ifdef DEBUG if (debug > 3) { -#ifdef HAVE_GETCLOCK +# ifdef HAVE_GETCLOCK (void) getclock(TIMEOFDAY, &ts); tv.tv_sec = ts.tv_sec; tv.tv_usec = ts.tv_nsec / 1000; -#else +# else GETTIMEOFDAY(&tv, 0); -#endif +# endif printf("ONCORE[%d]: %ld.%06ld\n", instance->unit, (long) tv.tv_sec, (long) tv.tv_usec); if (!*fmt) { @@ -1832,6 +1849,7 @@ oncore_msg_any( printf("\n"); } } +#endif } @@ -2451,12 +2469,14 @@ oncore_msg_CaFaIa( instance->timeout = 0; +#ifdef DEBUG if (debug > 2) { if (buf[2] == 'I') printf("ONCORE[%d]: >>@@%ca %x %x %x\n", instance->unit, buf[2], buf[4], buf[5], buf[6]); else printf("ONCORE[%d]: >>@@%ca %x %x\n", instance->unit, buf[2], buf[4], buf[5]); } +#endif antenna = (buf[4] & 0xc0) >> 6; buf[4] &= ~0xc0; @@ -3478,8 +3498,10 @@ oncore_sendmsg( { u_char cs = 0; +#ifdef DEBUG if (debug > 4) printf("ONCORE: Send @@%c%c %d\n", ptr[0], ptr[1], (int) len); +#endif write(fd, "@@", (size_t) 2); write(fd, ptr, len); while (len--) @@ -3720,8 +3742,10 @@ oncore_wait_almanac( ) { if (instance->rsm.bad_almanac) { +#ifdef DEBUG if (debug) printf("ONCORE[%d]: waiting for almanac\n", instance->unit); +#endif /* * If we get here (first time) then we don't have an almanac in memory.