From: Harlan Stenn Date: Fri, 2 Jan 2015 07:59:13 +0000 (+0000) Subject: [Bug 2713] variable type/cast, parameter name, general cleanup from NetBSD X-Git-Tag: NTP_4_2_8P1_BETA3~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b286e65bad4f238a977c7899d4f8ec23a19b94b3;p=thirdparty%2Fntp.git [Bug 2713] variable type/cast, parameter name, general cleanup from NetBSD bk: 54a64fd1p-8Ar9YkWCfbJx_YCJn8qw --- diff --git a/ntpd/Makefile.am b/ntpd/Makefile.am index b3af52738..344ac8eb2 100644 --- a/ntpd/Makefile.am +++ b/ntpd/Makefile.am @@ -90,7 +90,7 @@ man_MANS= ntpd.$(NTPD_MS) LDADD_NTPD_COMMON = $(LDADD_LIBNTP) $(LIBOPTS_LDADD) $(PTHREAD_LIBS) LDADD_NTPD_COMMON += $(LIBM) $(LDADD_NTP) $(LSCF) -ntpd_LDADD = $(LDADD) ../libntp/libntp.a $(LDADD_LIBNTP) $(LIBM) $(LDADD_NTPD_COMMON) +ntpd_LDADD = $(LDADD) ../libntp/libntp.a $(LDADD_NTPD_COMMON) $(LDADD_LIBUTIL) ntpdsim_LDADD = $(LDADD) ../libntp/libntpsim.a $(LDADD_NTPD_COMMON) ntpdsim_CPPFLAGS = $(AM_CPPFLAGS) -DSIM check_y2k_LDADD = $(LDADD) ../libntp/libntp.a $(LDADD_LIBNTP) $(LIBM) $(LDADD_LIBNTP) $(PTHREAD_LIBS) diff --git a/ntpd/ntp_loopfilter.c b/ntpd/ntp_loopfilter.c index 87db726e4..82ff1632e 100644 --- a/ntpd/ntp_loopfilter.c +++ b/ntpd/ntp_loopfilter.c @@ -8,6 +8,9 @@ # include #endif +#ifdef USE_SNPRINTB +# include +#endif #include "ntpd.h" #include "ntp_io.h" #include "ntp_unixtime.h" @@ -182,6 +185,21 @@ static sigjmp_buf env; /* environment var. for pll_trap() */ #endif /* SIGSYS */ #endif /* KERNEL_PLL */ +static void +sync_status(const char *what, int ostatus, int nstatus) +{ + char obuf[256], nbuf[256], tbuf[1024]; +#if defined(USE_SNPRINTB) && defined (STA_FMT) + snprintb(obuf, sizeof(obuf), STA_FMT, ostatus); + snprintb(nbuf, sizeof(nbuf), STA_FMT, nstatus); +#else + snprintf(obuf, sizeof(obuf), "%04x", ostatus); + snprintf(nbuf, sizeof(nbuf), "%04x", nstatus); +#endif + snprintf(tbuf, sizeof(tbuf), "%s status: %s -> %s", what, obuf, nbuf); + report_event(EVNT_KERN, NULL, tbuf); +} + /* * file_name - return pointer to non-relative portion of this C file pathname */ @@ -189,7 +207,9 @@ static char *file_name(void) { if (this_file == NULL) { (void)strncpy(relative_path, __FILE__, PATH_MAX); - for (this_file=relative_path; *this_file && ! isalnum(*this_file); this_file++) ; + for (this_file=relative_path; + *this_file && ! isalnum((unsigned char)*this_file); + this_file++) ; } return this_file; } @@ -663,16 +683,17 @@ local_clock( * Enable/disable the PPS if requested. */ if (hardpps_enable) { + ntv.status |= (STA_PPSTIME | STA_PPSFREQ); if (!(pll_status & STA_PPSTIME)) - report_event(EVNT_KERN, - NULL, "PPS enabled"); - ntv.status |= STA_PPSTIME | STA_PPSFREQ; + sync_status("PPS enabled", + pll_status, + ntv.status); } else { + ntv.status &= ~(STA_PPSTIME | STA_PPSFREQ); if (pll_status & STA_PPSTIME) - report_event(EVNT_KERN, - NULL, "PPS disabled"); - ntv.status &= ~(STA_PPSTIME | - STA_PPSFREQ); + sync_status("PPS disabled", + pll_status, + ntv.status); } if (sys_leap == LEAP_ADDSECOND) ntv.status |= STA_INS; @@ -1142,6 +1163,21 @@ loop_config( break; case LOOP_KERN_CLEAR: +#if 0 /* XXX: needs more review, and how can we get here? */ +#ifndef LOCKCLOCK +# ifdef KERNEL_PLL + if (pll_control && kern_enable) { + memset((char *)&ntv, 0, sizeof(ntv)); + ntv.modes = MOD_STATUS; + ntv.status = STA_UNSYNC; + ntp_adjtime(&ntv); + sync_status("kernel time sync disabled", + pll_status, + ntv.status); + } +# endif /* KERNEL_PLL */ +#endif /* LOCKCLOCK */ +#endif break; /* diff --git a/sntp/m4/hms_search_lib.m4 b/sntp/m4/hms_search_lib.m4 index e6dd60140..d09ea3b74 100644 --- a/sntp/m4/hms_search_lib.m4 +++ b/sntp/m4/hms_search_lib.m4 @@ -25,6 +25,6 @@ AC_DEFUN([HMS_SEARCH_LIBS], no) ;; *) $1[]="$ac_cv_search_$2[] $[]$1" ;; esac - [$4]], - [$5], + $4], + $5, [$6])]) diff --git a/sntp/m4/ntp_libntp.m4 b/sntp/m4/ntp_libntp.m4 index 13a621d1c..8842c4a81 100644 --- a/sntp/m4/ntp_libntp.m4 +++ b/sntp/m4/ntp_libntp.m4 @@ -78,6 +78,12 @@ esac AC_CHECK_FUNCS([getclock stime timegm strlcpy strlcat]) +# Bug 2713 +LDADD_LIBUTIL= +AC_SUBST([LDADD_LIBUTIL]) +HMS_SEARCH_LIBS([LDADD_LIBUTIL], [snprintb], [util], + [AC_DEFINE([USE_SNPRINTB], 1, [OK to use snprintb()?])]) + dnl HP-UX 11.31 on HPPA has a net/if.h that can't be compiled with gcc4 dnl due to an incomplete type (a union) mpinfou used in an array. gcc3 dnl compiles it without complaint. The mpinfou union is defined later