]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
Correct ntpq handling of &1 with multiple servers on cmd line.
authorDave Hart <hart@ntp.org>
Thu, 23 Dec 2010 19:18:14 +0000 (19:18 +0000)
committerDave Hart <hart@ntp.org>
Thu, 23 Dec 2010 19:18:14 +0000 (19:18 +0000)
bk: 4d13a076k2U6eXvK8xQbG5A-kTs7CA

include/ntp_calendar.h
libntp/prettydate.c
ntpq/ntpq-subs.c
ntpq/ntpq.c

index 8e227387fbb109df68173769732e484c52db8bdf..6804a184bb50f762dcc005631dbad2e433b690e4 100644 (file)
@@ -92,8 +92,9 @@ typedef struct {
                        + ((val)<<4) + ((val)<<2) + (val))      /* *big* hack */
 
 
-extern const char *months[12];
-extern const char *daynames[7];
+extern const char * const months[12];
+extern const char * const daynames[7];
+
 extern void    caljulian       (u_int32, struct calendar *);
 extern u_int32 caltontp        (const struct calendar *);
 
@@ -145,14 +146,14 @@ ntpcal_days_in_years(int32 years);
  * excess! But then, we need no leap year flag, either...)
  */
 extern ntpcal_split
-ntpcal_days_in_months(int32 months);
+ntpcal_days_in_months(int32 mons);
 
 /*
  * Convert ELAPSED years/months/days of gregorian calendar to elapsed
  * days in Gregorian epoch. No range checks done here!
  */
 extern int32
-ntpcal_edate_to_eradays(int32 years, int32 months, int32 mdays);
+ntpcal_edate_to_eradays(int32 years, int32 mons, int32 mdays);
 
 /*
  * Convert a time spec to seconds. No range checks done here!
@@ -168,7 +169,7 @@ ntpcal_etime_to_seconds(int32 hours, int32 minutes, int32 seconds);
  * even if months & days are off-scale.
  */
 extern int32
-ntpcal_edate_to_yeardays(int32 years, int32 months, int32 mdays);
+ntpcal_edate_to_yeardays(int32 years, int32 mons, int32 mdays);
 
 /*
  * Convert the date part of a 'struct tm' (that is, year, month,
index cdac5840b8e89ce0c8595738fbae91bfc5559a97..f121297161997f40d8a93052f57db72e49ff93bc 100644 (file)
 
 static char *common_prettydate(l_fp *, int);
 
-const char * months[12] = {
+const char * const months[12] = {
   "Jan", "Feb", "Mar", "Apr", "May", "Jun",
   "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
 };
 
-const char * daynames[7] = {
+const char * const daynames[7] = {
   "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
 };
 
index b0f55796f0a75ba3e1abb8ebd7ede2f11fbffcae..aa8f9cd5e745f529a97bd73223ac35181544717d 100644 (file)
@@ -12,7 +12,7 @@
 
 extern char *  chosts[];
 extern char    currenthost[];
-int            maxhostlen;
+size_t         maxhostlen;
 
 /*
  * Declarations for command handlers in here
@@ -1973,7 +1973,7 @@ doopeers(
        int af
        )
 {
-       register int i;
+       u_int i;
        char fullname[LENHOSTNAME];
        sockaddr_u netnum;
 
index fedc47072330f524078d04ac296ab0e7f89d5422..bab61722f5132f451ccc9b89b1fbdf88764aa5f7 100644 (file)
@@ -425,7 +425,7 @@ long pktdata[DATASIZE/sizeof(long)];
  * Holds association data for use with the &n operator.
  */
 struct association assoc_cache[MAXASSOC];
-u_int numassoc = 0;            /* number of cached associations */
+u_int numassoc;                /* number of cached associations */
 
 /*
  * For commands typed on the command line (with the -c option)
@@ -736,6 +736,8 @@ openhost(
        if (a_info == 0)
                freeaddrinfo(ai);
        havehost = 1;
+       numassoc = 0;
+
        return 1;
 }
 
@@ -2287,27 +2289,19 @@ host(
                        ai_fam_templ = AF_INET;
                else if (!strcmp("-6", pcmd->argval[i].string))
                        ai_fam_templ = AF_INET6;
-               else {
-                       if (havehost)
-                               (void) fprintf(fp,
-                                              "current host remains %s\n",
-                                              currenthost);
-                       else
-                               (void) fprintf(fp, "still no current host\n");
-                       return;
-               }
+               else
+                       goto no_change;
                i = 1;
        }
        if (openhost(pcmd->argval[i].string)) {
-               (void) fprintf(fp, "current host set to %s\n", currenthost);
-               numassoc = 0;
+               fprintf(fp, "current host set to %s\n", currenthost);
        } else {
+    no_change:
                if (havehost)
-                       (void) fprintf(fp,
-                                      "current host remains %s\n", 
-                                      currenthost);
+                       fprintf(fp, "current host remains %s\n",
+                               currenthost);
                else
-                       (void) fprintf(fp, "still no current host\n");
+                       fprintf(fp, "still no current host\n");
        }
 }