]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 2713] variable type/cast, parameter name, general cleanup from NetBSD
authorHarlan Stenn <stenn@ntp.org>
Fri, 2 Jan 2015 07:59:13 +0000 (07:59 +0000)
committerHarlan Stenn <stenn@ntp.org>
Fri, 2 Jan 2015 07:59:13 +0000 (07:59 +0000)
bk: 54a64fd1p-8Ar9YkWCfbJx_YCJn8qw

ntpd/Makefile.am
ntpd/ntp_loopfilter.c
sntp/m4/hms_search_lib.m4
sntp/m4/ntp_libntp.m4

index b3af52738c12e5d72ca3c001e4db4207dcceab7a..344ac8eb2ce7d46e0f8626bf01b4380351e8712e 100644 (file)
@@ -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)
index 87db726e417e8257c4829401c473a1056b396c03..82ff1632e518d6c19c9bb4295e1efd491221edd0 100644 (file)
@@ -8,6 +8,9 @@
 # include <config.h>
 #endif
 
+#ifdef USE_SNPRINTB
+# include <util.h>
+#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;
 
        /*
index e6dd601403b116e085a6b6d8b663d7ea4696d0a6..d09ea3b74a75ee98f88207f98c6adf18c3df4c11 100644 (file)
@@ -25,6 +25,6 @@ AC_DEFUN([HMS_SEARCH_LIBS],
  no) ;;
  *) $1[]="$ac_cv_search_$2[] $[]$1" ;;
  esac
[$4]],
[$5],
$4],
$5,
  [$6])])
index 13a621d1ceb77e6fda29f38a93b4706c6ebe45bb..8842c4a81125c272a647d71b8379351c3da5584c 100644 (file)
@@ -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