[ntp:bk-ntp-stable-send] BitKeeper diffs

Harlan Stenn stenn at deacon.udel.edu
Fri Oct 15 06:09:53 UTC 2010


#### ChangeSet ####
2010-10-14 19:13:29+00:00, davehart at shiny.ad.hartbrothers.com 
  [Bug 1659] Need CLOCK_TRUETIME not CLOCK_TRUE.

==== ChangeLog ====
2010-10-14 19:13:28+00:00, davehart at shiny.ad.hartbrothers.com +1 -0
  [Bug 1659] Need CLOCK_TRUETIME not CLOCK_TRUE.

--- 1.652/ChangeLog	2010-10-14 10:07:20 -04:00
+++ 1.653/ChangeLog	2010-10-14 15:13:28 -04:00
@@ -1,5 +1,6 @@
 ---
 
+* [Bug 1659] Need CLOCK_TRUETIME not CLOCK_TRUE.
 * [Bug 1665] is_anycast() u_int32_t should be u_int32.
 * ntpsnmpd, libntpq warning cleanup.
 

==== ports/winnt/include/config.h ====
2010-10-14 19:13:28+00:00, davehart at shiny.ad.hartbrothers.com +1 -1
  [Bug 1659] Need CLOCK_TRUETIME not CLOCK_TRUE.

--- 1.81/ports/winnt/include/config.h	2010-10-09 06:10:08 -04:00
+++ 1.82/ports/winnt/include/config.h	2010-10-14 15:13:28 -04:00
@@ -322,7 +322,7 @@ typedef __int32 int32_t;	/* define a typ
 # define CLOCK_SPECTRACOM	/* refclock_wwvb.c */
 # define CLOCK_TRIMBLEDC
 # define CLOCK_TRIMTSIP 1
-# define CLOCK_TRUE
+# define CLOCK_TRUETIME
 
 # define NTP_LITTLE_ENDIAN		/* from libntp.mak */
 # define NTP_POSIX_SOURCE

#### ChangeSet ####
2010-10-14 14:47:37+00:00, davehart at shiny.ad.hartbrothers.com 
  constantly more fun

==== ntpq/libntpq.c ====
2010-10-14 14:47:37+00:00, davehart at shiny.ad.hartbrothers.com +6 -6
  constantly more fun

--- 1.6/ntpq/libntpq.c	2010-10-14 10:07:20 -04:00
+++ 1.7/ntpq/libntpq.c	2010-10-14 10:47:37 -04:00
@@ -124,7 +124,7 @@ int ntpq_stripquotes ( char *resultbuf, 
 
 size_t
 ntpq_getvar(
-	char *		resultbuf,
+	const char *	resultbuf,
 	size_t		datalen,
 	const char *	varname,
 	char *		varvalue,
@@ -485,11 +485,11 @@ ntpq_read_sysvars(
 	char *	resultbuf,
 	size_t	maxsize)
 {
-	char *	datap;
-	int	res;
-	int	i_dsize;
-	size_t	dsize;
-	u_short	rstatus;
+	const char *	datap;
+	int		res;
+	int		i_dsize;
+	size_t		dsize;
+	u_short		rstatus;
 
 	res = doquery(CTL_OP_READVAR, 0, 0, 0, NULL, &rstatus,
 		      &i_dsize, &datap);

#### ChangeSet ####
2010-10-14 14:07:21+00:00, davehart at shiny.ad.hartbrothers.com 
  const additions needed for ntp-dev

==== ChangeLog ====
2010-10-14 14:07:20+00:00, davehart at shiny.ad.hartbrothers.com +1 -0
  [Bug 1665] is_anycast() u_int32_t should be u_int32.
  const additions needed for ntp-dev

--- 1.651/ChangeLog	2010-10-14 05:38:41 -04:00
+++ 1.652/ChangeLog	2010-10-14 10:07:20 -04:00
@@ -1,5 +1,6 @@
 ---
 
+* [Bug 1665] is_anycast() u_int32_t should be u_int32.
 * ntpsnmpd, libntpq warning cleanup.
 
 ---

==== ntpd/ntp_io.c ====
2010-10-14 14:07:20+00:00, davehart at shiny.ad.hartbrothers.com +1 -1
  [Bug 1665] is_anycast() u_int32_t should be u_int32.

--- 1.311/ntpd/ntp_io.c	2010-10-12 10:27:42 -04:00
+++ 1.312/ntpd/ntp_io.c	2010-10-14 10:07:20 -04:00
@@ -1484,7 +1484,7 @@ is_anycast(
     defined(IN6_IFF_ANYCAST)
 	struct in6_ifreq ifr6;
 	int fd;
-	u_int32_t flags6;
+	u_int32 flags6;
 
 	if (psau->sa.sa_family != AF_INET6)
 		return ISC_FALSE;

==== ntpq/libntpq.c ====
2010-10-14 14:07:20+00:00, davehart at shiny.ad.hartbrothers.com +66 -62
  const additions needed for ntp-dev

--- 1.5/ntpq/libntpq.c	2010-10-14 05:38:41 -04:00
+++ 1.6/ntpq/libntpq.c	2010-10-14 10:07:20 -04:00
@@ -179,7 +179,7 @@ ntpq_getvar(
 
 int ntpq_queryhost(unsigned short VARSET, unsigned short association, char *resultbuf, int maxlen)
 {
-	char *datap;
+	const char *datap;
 	int res;
 	int dsize;
 	u_short rstatus;
@@ -403,53 +403,55 @@ int ntpq_get_assoc_number ( int associd 
  *			0 (zero) if an error occured
  ****************************************************************************/
 
-  int ntpq_read_assoc_peervars( int associd, char *resultbuf, int maxsize )
+int
+ntpq_read_assoc_peervars(
+	int associd,
+	char *resultbuf,
+	int maxsize
+	)
 {
+	const char *datap;
+	int res;
+	int dsize;
+	u_short rstatus;
+	l_fp rec;
+	l_fp ts;
+	char value[NTPQ_BUFLEN];
 
-    char *datap;
-    int res;
-    int dsize;
-    u_short rstatus;
-   	l_fp rec;
-	  l_fp ts;
-    char value[NTPQ_BUFLEN];
-
-
-    res = doquery(CTL_OP_READVAR, associd, 0, 0, (char *)0, &rstatus,
-              &dsize, &datap);
-    
-    if (res != 0)
-        return 0;
-
-   	get_systime(&ts);
-
-    if (dsize == 0) {
-        if (numhosts > 1)
-            (void) fprintf(stderr, "server=%s ", currenthost);
-        (void) fprintf(stderr,
-                   "***No information returned for association %d\n",
-                   associd);
-        return 0;
-    } else {
-        if ( dsize > maxsize ) 
-            dsize = maxsize;
 
-        memcpy(resultbuf,datap,dsize);        
-        resultbuf[dsize]=0x0;
-        
-        ntpq_getvar(resultbuf, dsize, "rec", value, sizeof (value) );
+	res = doquery(CTL_OP_READVAR, associd, 0, 0, NULL, &rstatus,
+		      &dsize, &datap);
 
-        if (!decodets(value, &rec))
-				  L_CLR(&rec);
+	if (res != 0)
+		return 0;
 
-        memcpy(resultbuf,value,maxsize);        
-        resultbuf[dsize]=0x0;
-        dsize=strlen(resultbuf);
-        
+	get_systime(&ts);
 
-    }
-    return dsize;
+	if (dsize == 0) {
+		if (numhosts > 1)
+			fprintf(stderr, "server=%s ", currenthost);
+		fprintf(stderr,
+			"***No information returned for association %d\n",
+			associd);
+		return 0;
+	} else {
+		if ( dsize > maxsize ) 
+			dsize = maxsize;
+		memcpy(resultbuf, datap, dsize);
+		resultbuf[dsize] = '\0';
+ 
+		ntpq_getvar(resultbuf, dsize, "rec", value,
+			    sizeof(value));
+
+		if (!decodets(value, &rec))
+			L_CLR(&rec);
+
+		memcpy(resultbuf, value, maxsize);
+		resultbuf[dsize] = '\0';
+		dsize = strlen(resultbuf);
+	}
 
+	return dsize;
 }
 
 
@@ -483,7 +485,6 @@ ntpq_read_sysvars(
 	char *	resultbuf,
 	size_t	maxsize)
 {
-
 	char *	datap;
 	int	res;
 	int	i_dsize;
@@ -658,30 +659,33 @@ int ntpq_get_peervar( const char *varnam
  *			0 (zero) if an error occured
  ****************************************************************************/
 
-int ntpq_read_assoc_clockvars( int associd, char *resultbuf, int maxsize )
+int
+ntpq_read_assoc_clockvars(
+	int	associd,
+	char *	resultbuf,
+	int	maxsize
+	)
 {
+	const char *datap;
+	int res;
+	int dsize;
+	u_short rstatus;
 
-    char *datap;
-    int res;
-    int dsize;
-    u_short rstatus;
-    
-    res = ntpq_doquerylist(ntpq_varlist, CTL_OP_READCLOCK, associd, 0, &rstatus, &dsize, &datap);
-    
-    if (res != 0)
-        return 0;
-
-    if (dsize == 0) {
-        if (numhosts > 1) /* no information returned from server */
-	return 0;
-    } else {
-        if ( dsize > maxsize ) 
-            dsize = maxsize;
+	res = ntpq_doquerylist(ntpq_varlist, CTL_OP_READCLOCK, associd,
+			       0, &rstatus, &dsize, &datap);
+	if (res != 0)
+		return 0;
 
-        memcpy(resultbuf,datap,dsize);
-    }
+	if (dsize == 0) {
+		if (numhosts > 1) /* no information returned from server */
+			return 0;
+	} else {
+		if (dsize > maxsize) 
+			dsize = maxsize;
+		memcpy(resultbuf, datap, dsize);
+	}
 
-    return dsize;
+	return dsize;
 }
 
 

==== ntpq/libntpq.h ====
2010-10-14 14:07:20+00:00, davehart at shiny.ad.hartbrothers.com +2 -2
  const additions needed for ntp-dev

--- 1.4/ntpq/libntpq.h	2010-10-11 21:16:12 -04:00
+++ 1.5/ntpq/libntpq.h	2010-10-14 10:07:20 -04:00
@@ -83,7 +83,7 @@ extern struct ntpq_varlist ntpq_varlist[
 extern int ntpq_openhost(char *);
 extern int ntpq_closehost(void);
 extern int ntpq_queryhost(unsigned short VARSET, unsigned short association, char *resultbuf, int maxlen);
-extern size_t ntpq_getvar(char *resultbuf, size_t datalen,
+extern size_t ntpq_getvar(const char *resultbuf, size_t datalen,
 			  const char *varname, char *varvalue,
 			  size_t maxlen);
 extern int ntpq_stripquotes ( char *resultbuf, char *srcbuf, int datalen, int maxlen );
@@ -105,6 +105,6 @@ extern int ntpq_read_assoc_clockvars( in
 #ifndef _LIBNTPQSUBSC
 extern int ntpq_dogetassoc(void);
 extern char ntpq_decodeaddrtype(sockaddr_u *sock);
-extern int ntpq_doquerylist(struct ntpq_varlist *, int , int , int , u_short *, int *, char **datap );
+extern int ntpq_doquerylist(struct ntpq_varlist *, int , int , int , u_short *, int *, const char **datap );
 #endif
 

==== ntpq/libntpq_subs.c ====
2010-10-14 14:07:20+00:00, davehart at shiny.ad.hartbrothers.com +13 -3
  const additions needed for ntp-dev

--- 1.2/ntpq/libntpq_subs.c	2009-06-14 23:46:10 -04:00
+++ 1.3/ntpq/libntpq_subs.c	2010-10-14 10:07:20 -04:00
@@ -20,7 +20,7 @@
 /* Function Prototypes */
 int ntpq_dogetassoc(void);
 char ntpq_decodeaddrtype(sockaddr_u *sock);
-int ntpq_doquerylist(struct varlist *, int , int , int , u_short *, int *, char **datap );
+int ntpq_doquerylist(struct varlist *, int , int , int , u_short *, int *, const char **datap);
 
 
 /* the following functions are required internally by a number of libntpq functions 
@@ -43,8 +43,18 @@ char ntpq_decodeaddrtype(sockaddr_u *soc
 	return decodeaddrtype(sock);
 }
 
-int ntpq_doquerylist(struct varlist *vlist, int op, int associd, int auth, u_short *rstatus, int *dsize, char **datap )
+int
+ntpq_doquerylist(
+	struct varlist *vlist,
+	int op,
+	int associd,
+	int auth,
+	u_short *rstatus,
+	int *dsize,
+	const char **datap
+	)
 {
-    return doquerylist(vlist, op, associd, auth, rstatus, dsize,  &*datap );
+	return doquerylist(vlist, op, associd, auth, rstatus, dsize,
+			   datap);
 }
 

==== ntpq/ntpq-subs.c ====
2010-10-14 14:07:20+00:00, davehart at shiny.ad.hartbrothers.com +42 -38
  const additions needed for ntp-dev

--- 1.44/ntpq/ntpq-subs.c	2010-05-09 04:12:19 -04:00
+++ 1.45/ntpq/ntpq-subs.c	2010-10-14 10:07:20 -04:00
@@ -21,12 +21,12 @@ int 	maxhostlen;
  */
 static	int	checkassocid	(u_int32);
 static	struct varlist *findlistvar (struct varlist *, char *);
-static	void	doaddvlist	(struct varlist *, char *);
-static	void	dormvlist	(struct varlist *, char *);
+static	void	doaddvlist	(struct varlist *, const char *);
+static	void	dormvlist	(struct varlist *, const char *);
 static	void	doclearvlist	(struct varlist *);
 static	void	makequerydata	(struct varlist *, int *, char *);
 static	int	doquerylist	(struct varlist *, int, int, int, 
-				 u_short *, int *, char **);
+				 u_short *, int *, const char **);
 static	void	doprintvlist	(struct varlist *, FILE *);
 static	void	addvars 	(struct parse *, FILE *);
 static	void	rmvars		(struct parse *, FILE *);
@@ -57,7 +57,7 @@ static	void	radiostatus (struct parse *,
 static	void	pstatus 	(struct parse *, FILE *);
 static	long	when		(l_fp *, l_fp *, l_fp *);
 static	char *	prettyinterval	(char *, size_t, long);
-static	int	doprintpeers	(struct varlist *, int, int, int, char *, FILE *, int);
+static	int	doprintpeers	(struct varlist *, int, int, int, const char *, FILE *, int);
 static	int	dogetpeers	(struct varlist *, int, FILE *, int);
 static	void	dopeers 	(int, FILE *, int);
 static	void	peers		(struct parse *, FILE *);
@@ -257,7 +257,7 @@ findlistvar(
 static void
 doaddvlist(
 	struct varlist *vlist,
-	char *vars
+	const char *vars
 	)
 {
 	register struct varlist *vl;
@@ -292,7 +292,7 @@ doaddvlist(
 static void
 dormvlist(
 	struct varlist *vlist,
-	char *vars
+	const char *vars
 	)
 {
 	register struct varlist *vl;
@@ -395,7 +395,7 @@ doquerylist(
 	int auth,
 	u_short *rstatus,
 	int *dsize,
-	char **datap
+	const char **datap
 	)
 {
 	char data[CTL_MAX_DATA_LEN];
@@ -502,7 +502,7 @@ dolist(
 	FILE *fp
 	)
 {
-	char *datap;
+	const char *datap;
 	int res;
 	int dsize;
 	u_short rstatus;
@@ -577,7 +577,7 @@ writelist(
 	FILE *fp
 	)
 {
-	char *datap;
+	const char *datap;
 	int res;
 	int associd;
 	int dsize;
@@ -650,7 +650,7 @@ writevar(
 	FILE *fp
 	)
 {
-	char *datap;
+	const char *datap;
 	int res;
 	int associd;
 	int dsize;
@@ -874,7 +874,7 @@ dogetassoc(
 	FILE *fp
 	)
 {
-	char *datap;
+	const char *datap;
 	int res;
 	int dsize;
 	u_short rstatus;
@@ -903,9 +903,9 @@ dogetassoc(
 
 	numassoc = 0;
 	while (dsize > 0) {
-		assoc_cache[numassoc].assid = ntohs(*((u_short *)datap));
+		assoc_cache[numassoc].assid = ntohs(*((const u_short *)datap));
 		datap += sizeof(u_short);
-		assoc_cache[numassoc].status = ntohs(*((u_short *)datap));
+		assoc_cache[numassoc].status = ntohs(*((const u_short *)datap));
 		datap += sizeof(u_short);
 		if (++numassoc >= MAXASSOC)
 			break;
@@ -1172,7 +1172,7 @@ saveconfig(
 	FILE *fp
 	)
 {
-	char *datap;
+	const char *datap;
 	int res;
 	int dsize;
 	u_short rstatus;
@@ -1190,10 +1190,8 @@ saveconfig(
 
 	if (0 == dsize)
 		fprintf(fp, "(no response message, curiously)");
-	else {
-		datap[dsize] = '\0';
-		fprintf(fp, "%s", datap);
-	}
+	else
+		fprintf(fp, "%.*s", dsize, datap);
 }
 
 
@@ -1239,7 +1237,7 @@ pstatus(
 	FILE *fp
 	)
 {
-	char *datap;
+	const char *datap;
 	int res;
 	int associd;
 	int dsize;
@@ -1422,7 +1420,7 @@ doprintpeers(
 	int associd,
 	int rstatus,
 	int datalen,
-	char *data,
+	const char *data,
 	FILE *fp,
 	int af
 	)
@@ -1643,7 +1641,7 @@ dogetpeers(
 	int af
 	)
 {
-	char *datap;
+	const char *datap;
 	int res;
 	int dsize;
 	u_short rstatus;
@@ -1865,18 +1863,19 @@ config (
 	char *cfgcmd;
 	u_short rstatus;
 	int rsize;
-	char *rdata;
+	const char *rdata;
+	char *resp;
 	int res;
 	int col;
 	int i;
 
 	cfgcmd = pcmd->argval[0].string;
 
-	if (debug > 2) {
-		printf("In Config\n");
-		printf("Keyword = %s\n", pcmd->keyword);
-		printf("Command = %s\n", cfgcmd);
-	}
+	if (debug > 2)
+		fprintf(stderr, 
+			"In Config\n"
+			"Keyword = %s\n"
+			"Command = %s\n", pcmd->keyword, cfgcmd);
 
 	res = doquery(CTL_OP_CONFIGURE, 0, 1, strlen(cfgcmd), cfgcmd,
 		      &rstatus, &rsize, &rdata);
@@ -1886,10 +1885,13 @@ config (
 
 	if (rsize > 0 && '\n' == rdata[rsize - 1])
 		rsize--;
-	rdata[rsize] = '\0';
+
+	resp = emalloc(rsize + 1);
+	memcpy(resp, rdata, rsize);
+	resp[rsize] = '\0';
 
 	col = -1;
-	if (1 == sscanf(rdata, "column %d syntax error", &col)
+	if (1 == sscanf(resp, "column %d syntax error", &col)
 	    && col >= 0 && (size_t)col <= strlen(cfgcmd) + 1) {
 		if (interactive) {
 			printf("______");	/* "ntpq> " */
@@ -1900,7 +1902,8 @@ config (
 			putchar('_');
 		printf("^\n");
 	}
-	printf("%s\n", rdata);
+	printf("%s\n", resp);
+	free(resp);
 }
 
 
@@ -1925,7 +1928,7 @@ config_from_file (
 {
 	u_short rstatus;
 	int rsize;
-	char *rdata;
+	const char *rdata;
 	int res;
 	FILE *config_fd;
 	char config_cmd[MAXLINE];
@@ -1933,11 +1936,12 @@ config_from_file (
 	int i;
 	int retry_limit;
 
-	if (debug > 2) {
-		printf("In Config\n");
-		printf("Keyword = %s\n", pcmd->keyword);
-		printf("Filename = %s\n", pcmd->argval[0].string);
-	}
+	if (debug > 2)
+		fprintf(stderr,
+			"In Config\n"
+			"Keyword = %s\n"
+			"Filename = %s\n", pcmd->keyword,
+			pcmd->argval[0].string);
 
 	config_fd = fopen(pcmd->argval[0].string, "r");
 	if (NULL == config_fd) {
@@ -1974,8 +1978,8 @@ config_from_file (
 			rsize--;
 		if (rsize > 0 && '\r' == rdata[rsize - 1])
 			rsize--;
-		rdata[rsize] = '\0';
-		printf("Line No: %d %s: %s", i, rdata, config_cmd);
+		printf("Line No: %d %.*s: %s", i, rsize, rdata,
+		       config_cmd);
 	}
 	printf("Done sending file\n");
 	fclose(config_fd);

==== ntpq/ntpq.c ====
2010-10-14 14:07:20+00:00, davehart at shiny.ad.hartbrothers.com +144 -84
  const additions needed for ntp-dev

--- 1.102/ntpq/ntpq.c	2010-07-02 02:43:20 -04:00
+++ 1.103/ntpq/ntpq.c	2010-10-14 10:07:20 -04:00
@@ -244,7 +244,7 @@ int		ntpqmain	(int,	char **);
 static	int	openhost	(const char *);
 
 static	int	sendpkt		(void *, size_t);
-static	int	getresponse	(int, int, u_short *, int *, char **, int);
+static	int	getresponse	(int, int, u_short *, int *, const char **, int);
 static	int	sendrequest	(int, int, int, int, char *);
 static	char *	tstflags	(u_long);
 #ifndef BUILD_AS_LIB
@@ -285,8 +285,8 @@ static	void	warning		(const char *, cons
 static	void	error		(const char *, const char *, const char *);
 static	u_long	getkeyid	(const char *);
 static	void	atoascii	(const char *, size_t, char *, size_t);
-static	void	cookedprint	(int, int, char *, int, int, FILE *);
-static	void	rawprint	(int, int, char *, int, int, FILE *);
+static	void	cookedprint	(int, int, const char *, int, int, FILE *);
+static	void	rawprint	(int, int, const char *, int, int, FILE *);
 static	void	startoutput	(void);
 static	void	output		(FILE *, char *, char *);
 static	void	endoutput	(FILE *);
@@ -821,7 +821,7 @@ getresponse(
 	int associd,
 	u_short *rstatus,
 	int *rsize,
-	char **rdata,
+	const char **rdata,
 	int timeo
 	)
 {
@@ -856,17 +856,17 @@ getresponse(
 
 	/*
 	 * Loop until we have an error or a complete response.  Nearly all
-	 * aths to loop again use continue.
+	 * code paths to loop again use continue.
 	 */
 	for (;;) {
 
 		if (numfrags == 0)
-		    tvo = tvout;
+			tvo = tvout;
 		else
-		    tvo = tvsout;
+			tvo = tvsout;
 		
 		FD_SET(sockfd, &fds);
-		n = select(sockfd+1, &fds, (fd_set *)0, (fd_set *)0, &tvo);
+		n = select(sockfd + 1, &fds, NULL, NULL, &tvo);
 
 		if (n == -1) {
 			warning("select fails", "", "");
@@ -878,24 +878,30 @@ getresponse(
 			 */
 			if (numfrags == 0) {
 				if (timeo)
-				    (void) fprintf(stderr,
-						   "%s: timed out, nothing received\n",
-						   currenthost);
+					fprintf(stderr,
+						"%s: timed out, nothing received\n",
+						currenthost);
 				return ERR_TIMEOUT;
 			} else {
 				if (timeo)
-				    (void) fprintf(stderr,
+					fprintf(stderr,
 						   "%s: timed out with incomplete data\n",
 						   currenthost);
 				if (debug) {
-					printf("Received fragments:\n");
+					fprintf(stderr,
+						"ERR_INCOMPLETE: Received fragments:\n");
 					for (n = 0; n < numfrags; n++)
-					    printf("%4d %d\n", offsets[n],
-						   counts[n]);
-					if (seenlastfrag)
-					    printf("last fragment received\n");
-					else
-					    printf("last fragment not received\n");
+						fprintf(stderr,
+							"%2d: %5d %5d\t%3d octets\n",
+							n, offsets[n],
+							offsets[n] +
+							counts[n],
+							counts[n]);
+					fprintf(stderr,
+						"last fragment %sreceived\n",
+						(seenlastfrag)
+						    ? ""
+						    : "not ");
 				}
 				return ERR_INCOMPLETE;
 			}
@@ -1177,7 +1183,7 @@ getresponse(
 		/*
 		 * Copy the data into the data buffer.
 		 */
-		memmove((char *)pktdata + offset, (char *)rpkt.data, count);
+		memcpy((char *)pktdata + offset, rpkt.data, count);
 
 		/*
 		 * If we've seen the last fragment, look for holes in the sequence.
@@ -1190,6 +1196,10 @@ getresponse(
 			}
 			if (n == numfrags) {
 				*rsize = offsets[numfrags-1] + counts[numfrags-1];
+				if (debug)
+					fprintf(stderr,
+						"%d packets reassembled into response\n",
+						numfrags);
 				return 0;
 			}
 		}
@@ -1310,18 +1320,112 @@ sendrequest(
 
 
 /*
- * doquery - send a request and process the response
+ * show_error_msg - display the error text for a mode 6 error response.
+ */
+void
+show_error_msg(
+	int		m6resp,
+	associd_t	associd
+	)
+{
+	if (numhosts > 1)
+		fprintf(stderr, "server=%s ", currenthost);
+
+	switch(m6resp) {
+
+	case CERR_BADFMT:
+		fprintf(stderr,
+		    "***Server reports a bad format request packet\n");
+		break;
+
+	case CERR_PERMISSION:
+		fprintf(stderr,
+		    "***Server disallowed request (authentication?)\n");
+		break;
+
+	case CERR_BADOP:
+		fprintf(stderr,
+		    "***Server reports a bad opcode in request\n");
+		break;
+
+	case CERR_BADASSOC:
+		fprintf(stderr,
+		    "***Association ID %d unknown to server\n",
+		    associd);
+		break;
+
+	case CERR_UNKNOWNVAR:
+		fprintf(stderr,
+		    "***A request variable unknown to the server\n");
+		break;
+
+	case CERR_BADVALUE:
+		fprintf(stderr,
+		    "***Server indicates a request variable was bad\n");
+		break;
+
+	case ERR_UNSPEC:
+		fprintf(stderr,
+		    "***Server returned an unspecified error\n");
+		break;
+
+	case ERR_TIMEOUT:
+		fprintf(stderr, "***Request timed out\n");
+		break;
+
+	case ERR_INCOMPLETE:
+		fprintf(stderr,
+		    "***Response from server was incomplete\n");
+		break;
+
+	case ERR_TOOMUCH:
+		fprintf(stderr,
+		    "***Buffer size exceeded for returned data\n");
+		break;
+
+	default:
+		fprintf(stderr,
+		    "***Server returns unknown error code %d\n",
+		    m6resp);
+	}
+}
+
+/*
+ * doquery - send a request and process the response, displaying
+ *	     error messages for any error responses.
  */
 int
 doquery(
 	int opcode,
-	int associd,
+	associd_t associd,
+	int auth,
+	int qsize,
+	char *qdata,
+	u_short *rstatus,
+	int *rsize,
+	const char **rdata
+	)
+{
+	return doqueryex(opcode, associd, auth, qsize, qdata, rstatus,
+			 rsize, rdata, FALSE);
+}
+
+
+/*
+ * doqueryex - send a request and process the response, optionally
+ *	       displaying error messages for any error responses.
+ */
+int
+doqueryex(
+	int opcode,
+	associd_t associd,
 	int auth,
 	int qsize,
 	char *qdata,
 	u_short *rstatus,
 	int *rsize,
-	char **rdata
+	const char **rdata,
+	int quiet
 	)
 {
 	int res;
@@ -1331,7 +1435,7 @@ doquery(
 	 * Check to make sure host is open
 	 */
 	if (!havehost) {
-		(void) fprintf(stderr, "***No host open, use `host' command\n");
+		fprintf(stderr, "***No host open, use `host' command\n");
 		return -1;
 	}
 
@@ -1344,7 +1448,7 @@ doquery(
 	 */
 	res = sendrequest(opcode, associd, auth, qsize, qdata);
 	if (res != 0)
-	    return res;
+		return res;
 	
 	/*
 	 * Get the response.  If we got a standard error, print a message
@@ -1363,53 +1467,9 @@ doquery(
 			done = 1;
 			goto again;
 		}
-		if (numhosts > 1)
-			(void) fprintf(stderr, "server=%s ", currenthost);
-		switch(res) {
-		    case CERR_BADFMT:
-			(void) fprintf(stderr,
-			    "***Server reports a bad format request packet\n");
-			break;
-		    case CERR_PERMISSION:
-			(void) fprintf(stderr,
-			    "***Server disallowed request (authentication?)\n");
-			break;
-		    case CERR_BADOP:
-			(void) fprintf(stderr,
-			    "***Server reports a bad opcode in request\n");
-			break;
-		    case CERR_BADASSOC:
-			(void) fprintf(stderr,
-			    "***Association ID %d unknown to server\n",associd);
-			break;
-		    case CERR_UNKNOWNVAR:
-			(void) fprintf(stderr,
-			    "***A request variable unknown to the server\n");
-			break;
-		    case CERR_BADVALUE:
-			(void) fprintf(stderr,
-			    "***Server indicates a request variable was bad\n");
-			break;
-		    case ERR_UNSPEC:
-			(void) fprintf(stderr,
-			    "***Server returned an unspecified error\n");
-			break;
-		    case ERR_TIMEOUT:
-			(void) fprintf(stderr, "***Request timed out\n");
-			break;
-		    case ERR_INCOMPLETE:
-			(void) fprintf(stderr,
-			    "***Response from server was incomplete\n");
-			break;
-		    case ERR_TOOMUCH:
-			(void) fprintf(stderr,
-			    "***Buffer size exceeded for returned data\n");
-			break;
-		    default:
-			(void) fprintf(stderr,
-			    "***Server returns unknown error code %d\n", res);
-			break;
-		}
+		if (!quiet)
+			show_error_msg(res, associd);
+
 	}
 	return res;
 }
@@ -2799,15 +2859,15 @@ int nextcb = 0;
 int
 nextvar(
 	int *datalen,
-	char **datap,
+	const char **datap,
 	char **vname,
 	char **vvalue
 	)
 {
-	register char *cp;
-	register char *np;
-	register char *cpend;
-	register char *npend;	/* character after last */
+	const char *cp;
+	char *np;
+	const char *cpend;
+	char *npend;	/* character after last */
 	int quoted = 0;
 	static char name[MAXVARLEN];
 	static char value[MAXVALLEN];
@@ -2819,9 +2879,9 @@ nextvar(
 	 * Space past commas and white space
 	 */
 	while (cp < cpend && (*cp == ',' || isspace((int)*cp)))
-	    cp++;
+		cp++;
 	if (cp == cpend)
-	    return 0;
+		return 0;
 	
 	/*
 	 * Copy name until we hit a ',', an '=', a '\r' or a '\n'.  Backspace
@@ -2930,7 +2990,7 @@ findvar(
 void
 printvars(
 	int length,
-	char *data,
+	const char *data,
 	int status,
 	int sttype,
 	int quiet,
@@ -2951,14 +3011,14 @@ static void
 rawprint(
 	int datatype,
 	int length,
-	char *data,
+	const char *data,
 	int status,
 	int quiet,
 	FILE *fp
 	)
 {
-	register char *cp;
-	register char *cpend;
+	const char *cp;
+	const char *cpend;
 
 	/*
 	 * Essentially print the data as is.  We reformat unprintables, though.
@@ -3150,7 +3210,7 @@ static void
 cookedprint(
 	int datatype,
 	int length,
-	char *data,
+	const char *data,
 	int status,
 	int quiet,
 	FILE *fp

==== ntpq/ntpq.h ====
2010-10-14 14:07:20+00:00, davehart at shiny.ad.hartbrothers.com +7 -3
  const additions needed for ntp-dev

--- 1.12/ntpq/ntpq.h	2010-05-09 04:12:19 -04:00
+++ 1.13/ntpq/ntpq.h	2010-10-14 10:07:20 -04:00
@@ -85,13 +85,17 @@ extern int	old_rv;		/* use old rv behavi
 extern	void	asciize		(int, char *, FILE *);
 extern	int	getnetnum	(const char *, sockaddr_u *, char *, int);
 extern	void	sortassoc	(void);
-extern	int	doquery		(int, int, int, int, char *, u_short *, int *, char **);
+extern	void	show_error_msg	(int, associd_t);
+extern	int	doquery		(int, associd_t, int, int, char *,
+				 u_short *, int *, const char **);
+extern	int	doqueryex	(int, associd_t, int, int, char *,
+				 u_short *, int *, const char **, int);
 extern	char *	nntohost	(sockaddr_u *);
 extern	int	decodets	(char *, l_fp *);
 extern	int	decodeuint	(char *, u_long *);
-extern	int	nextvar		(int *, char **, char **, char **);
+extern	int	nextvar		(int *, const char **, char **, char **);
 extern	int	decodetime	(char *, l_fp *);
-extern	void	printvars	(int, char *, int, int, int, FILE *);
+extern	void	printvars	(int, const char *, int, int, int, FILE *);
 extern	int	decodeint	(char *, long *);
 extern	int	findvar		(char *, struct ctl_var *, int code);
 extern	void	makeascii	(int, const char *, FILE *);

#### ChangeSet ####
2010-10-14 09:38:42+00:00, davehart at shiny.ad.hartbrothers.com 
  ntpsnmpd, libntpq warning cleanup.
  

==== ChangeLog ====
2010-10-14 09:38:41+00:00, davehart at shiny.ad.hartbrothers.com +5 -1
  ntpsnmpd, libntpq warning cleanup.
  

--- 1.650/ChangeLog	2010-10-14 03:51:01 -04:00
+++ 1.651/ChangeLog	2010-10-14 05:38:41 -04:00
@@ -1,11 +1,15 @@
 ---
+
+* ntpsnmpd, libntpq warning cleanup.
+
+---
 (4.2.6p3-RC3) 2010/10/14 Released by Harlan Stenn <stenn at ntp.org>
 
 * [Bug 750] Non-existing device causes coredump with RIPE-NCC driver.
 * [Bug 1080] ntpd on ipv6 routers very chatty.
 * [Bug 1567] Support Arbiter 1093C Satellite Clock on Windows.
 * [Bug 1581] printf format string mismatch leftover.
-* [Bug 1584]: ntpsnmpd OID must be mib-2.197.
+* [Bug 1584] ntpsnmpd OID must be mib-2.197.
 * [Bug 1643] Range-check the decoding of the RIPE-NCC status codes.
 * [Bug 1644] cvo.sh should use lsb_release to identify linux distros.
 * [Bug 1659] Support Truetime Satellite Clocks on Windows.

==== ntpq/libntpq.c ====
2010-10-14 09:38:41+00:00, davehart at shiny.ad.hartbrothers.com +1 -1
  ntpsnmpd, libntpq warning cleanup.
  

--- 1.4/ntpq/libntpq.c	2010-10-11 21:16:12 -04:00
+++ 1.5/ntpq/libntpq.c	2010-10-14 05:38:41 -04:00
@@ -496,7 +496,7 @@ ntpq_read_sysvars(
 	if (res != 0)
 		return 0;
 
-	if (dsize == 0) {
+	if (i_dsize == 0) {
 		if (numhosts > 1)
 			fprintf(stderr, "server=%s ", currenthost);
 		fprintf(stderr, "***No sysvar information returned\n");

==== ntpsnmpd/ntpsnmpd.c ====
2010-10-14 09:38:41+00:00, davehart at shiny.ad.hartbrothers.com +1 -2
  ntpsnmpd, libntpq warning cleanup.
  

--- 1.5/ntpsnmpd/ntpsnmpd.c	2010-10-11 21:16:12 -04:00
+++ 1.6/ntpsnmpd/ntpsnmpd.c	2010-10-14 05:38:41 -04:00
@@ -32,6 +32,7 @@
 #include <ntpsnmpd-opts.h>
 
 static int keep_running;
+RETSIGTYPE stop_server(int);
 
 RETSIGTYPE
 stop_server(int a) {
@@ -46,8 +47,6 @@ int
 main (int argc, char **argv) {
   int background = 0; /* start as background process */
   int use_syslog = 1; /* use syslog for logging */
-  char varvalue[1024];
-	
 
 	{
 		int optct = optionProcess(&ntpsnmpdOptions, argc, argv);


More information about the bk-ntp-stable-send mailing list