CVS commit: src/external/bsd/ntp/dist/libntp

2020-10-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Oct 10 13:41:14 UTC 2020

Modified Files:
src/external/bsd/ntp/dist/libntp: work_fork.c

Log Message:
Wait for the asynchronous dns resolver child to be done (and close the
socket descriptors) before returning. Otherwise we might get bind errors.
Reported by kim@, fixed by mlelstv@.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/external/bsd/ntp/dist/libntp/work_fork.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/ntp/dist/libntp/work_fork.c
diff -u src/external/bsd/ntp/dist/libntp/work_fork.c:1.14 src/external/bsd/ntp/dist/libntp/work_fork.c:1.15
--- src/external/bsd/ntp/dist/libntp/work_fork.c:1.14	Mon May 25 16:47:24 2020
+++ src/external/bsd/ntp/dist/libntp/work_fork.c	Sat Oct 10 09:41:14 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: work_fork.c,v 1.14 2020/05/25 20:47:24 christos Exp $	*/
+/*	$NetBSD: work_fork.c,v 1.15 2020/10/10 13:41:14 christos Exp $	*/
 
 /*
  * work_fork.c - fork implementation for blocking worker child.
@@ -559,6 +559,9 @@ fork_blocking_child(
 		/* wire into I/O loop */
 		(*addremove_io_fd)(c->resp_read_pipe, is_pipe, FALSE);
 
+		/* wait until child is done */
+		rc = netread(c->resp_read_pipe, , sizeof(rc));
+
 		return;		/* parent returns */
 	}
 
@@ -585,6 +588,10 @@ fork_blocking_child(
 	c->resp_write_pipe = blocking_pipes[3];
 
 	kill_asyncio(0);
+
+	/* Tell parent we are ready */
+	rc = netwrite(c->resp_write_pipe, , sizeof(rc));
+
 	closelog();
 	if (syslog_file != NULL) {
 		fclose(syslog_file);



CVS commit: src/external/bsd/ntp/dist/libntp

2020-05-29 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri May 29 20:15:14 UTC 2020

Modified Files:
src/external/bsd/ntp/dist/libntp: timexsup.c

Log Message:
Add explicit casts


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/external/bsd/ntp/dist/libntp/timexsup.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/ntp/dist/libntp/timexsup.c
diff -u src/external/bsd/ntp/dist/libntp/timexsup.c:1.2 src/external/bsd/ntp/dist/libntp/timexsup.c:1.3
--- src/external/bsd/ntp/dist/libntp/timexsup.c:1.2	Mon May 25 16:47:24 2020
+++ src/external/bsd/ntp/dist/libntp/timexsup.c	Fri May 29 16:15:14 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: timexsup.c,v 1.2 2020/05/25 20:47:24 christos Exp $	*/
+/*	$NetBSD: timexsup.c,v 1.3 2020/05/29 20:15:14 christos Exp $	*/
 
 /*
  * timexsup.c - 'struct timex' support functions
@@ -30,9 +30,9 @@ clamp_rounded(
 	dval = floor(dval + 0.5);
 
 	/* clamp / saturate */
-	if (dval >= LONG_MAX)
+	if (dval >= (double)LONG_MAX)
 		return LONG_MAX;
-	if (dval <= LONG_MIN)
+	if (dval <= (double)LONG_MIN)
 		return LONG_MIN;
 	return (long)dval;
 	



CVS commit: src/external/bsd/ntp/dist/libntp

2015-12-01 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Dec  2 02:04:06 UTC 2015

Modified Files:
src/external/bsd/ntp/dist/libntp: authkeys.c

Log Message:
Don't bother calling log for values <= 1... XXX: should use ilog() instead.
Fixes vax.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/external/bsd/ntp/dist/libntp/authkeys.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/ntp/dist/libntp/authkeys.c
diff -u src/external/bsd/ntp/dist/libntp/authkeys.c:1.7 src/external/bsd/ntp/dist/libntp/authkeys.c:1.8
--- src/external/bsd/ntp/dist/libntp/authkeys.c:1.7	Fri Oct 23 14:06:19 2015
+++ src/external/bsd/ntp/dist/libntp/authkeys.c	Tue Dec  1 21:04:06 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: authkeys.c,v 1.7 2015/10/23 18:06:19 christos Exp $	*/
+/*	$NetBSD: authkeys.c,v 1.8 2015/12/02 02:04:06 christos Exp $	*/
 
 /*
  * authkeys.c - routines to manage the storage of authentication keys
@@ -236,7 +236,7 @@ auth_resize_hashtable(void)
 	symkey *	sk;
 
 	totalkeys = authnumkeys + authnumfreekeys;
-	hashbits = auth_log2(totalkeys / 4.0) + 1;
+	hashbits = (totalkeys <= 4 ? 0 : auth_log2(totalkeys / 4.0)) + 1;
 	hashbits = max(4, hashbits);
 	hashbits = min(15, hashbits);
 



CVS commit: src/external/bsd/ntp/dist/libntp

2015-07-20 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Jul 20 15:35:00 UTC 2015

Modified Files:
src/external/bsd/ntp/dist/libntp: work_fork.c

Log Message:
we set SIGCHLD to SIG_IGN so we are not going to generate zombies so it
will be an error to wait.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/external/bsd/ntp/dist/libntp/work_fork.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/ntp/dist/libntp/work_fork.c
diff -u src/external/bsd/ntp/dist/libntp/work_fork.c:1.6 src/external/bsd/ntp/dist/libntp/work_fork.c:1.7
--- src/external/bsd/ntp/dist/libntp/work_fork.c:1.6	Fri Jul 17 11:17:07 2015
+++ src/external/bsd/ntp/dist/libntp/work_fork.c	Mon Jul 20 11:35:00 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: work_fork.c,v 1.6 2015/07/17 15:17:07 christos Exp $	*/
+/*	$NetBSD: work_fork.c,v 1.7 2015/07/20 15:35:00 christos Exp $	*/
 
 /*
  * work_fork.c - fork implementation for blocking worker child.
@@ -127,7 +127,13 @@ harvest_child_status(
 		/* Wait on the child so it can finish terminating */
 		if (waitpid(c-pid, NULL, 0) == c-pid)
 			TRACE(4, (harvested child %d\n, c-pid));
-		else msyslog(LOG_ERR, error waiting on child %d: %m, c-pid);
+		else if (errno != ECHILD) {
+			/*
+			 * SIG_IGN on SIGCHLD on some os's means do not wait
+			 * but reap automaticallyi
+			 */
+			msyslog(LOG_ERR, error waiting on child %d: %m, c-pid);
+		}
 		c-pid = 0;
 	}
 }



CVS commit: src/external/bsd/ntp/dist/libntp

2015-07-17 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Jul 17 15:17:07 UTC 2015

Modified Files:
src/external/bsd/ntp/dist/libntp: work_fork.c

Log Message:
PR/50048: Martin Husemann: Avoid reaping the child twice by setting c-pid = 0
after the wait.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/external/bsd/ntp/dist/libntp/work_fork.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/ntp/dist/libntp/work_fork.c
diff -u src/external/bsd/ntp/dist/libntp/work_fork.c:1.5 src/external/bsd/ntp/dist/libntp/work_fork.c:1.6
--- src/external/bsd/ntp/dist/libntp/work_fork.c:1.5	Fri Jul 10 10:20:32 2015
+++ src/external/bsd/ntp/dist/libntp/work_fork.c	Fri Jul 17 11:17:07 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: work_fork.c,v 1.5 2015/07/10 14:20:32 christos Exp $	*/
+/*	$NetBSD: work_fork.c,v 1.6 2015/07/17 15:17:07 christos Exp $	*/
 
 /*
  * work_fork.c - fork implementation for blocking worker child.
@@ -128,6 +128,7 @@ harvest_child_status(
 		if (waitpid(c-pid, NULL, 0) == c-pid)
 			TRACE(4, (harvested child %d\n, c-pid));
 		else msyslog(LOG_ERR, error waiting on child %d: %m, c-pid);
+		c-pid = 0;
 	}
 }
 
@@ -164,7 +165,6 @@ cleanup_after_child(
 		close(c-resp_read_pipe);
 		c-resp_read_pipe = -1;
 	}
-	c-pid = 0;
 	c-resp_read_ctx = NULL;
 	DEBUG_INSIST(-1 == c-req_read_pipe);
 	DEBUG_INSIST(-1 == c-resp_write_pipe);



CVS commit: src/external/bsd/ntp/dist/libntp

2014-04-01 Thread Frank Kardel
Module Name:src
Committed By:   kardel
Date:   Tue Apr  1 17:34:44 UTC 2014

Modified Files:
src/external/bsd/ntp/dist/libntp: atouint.c

Log Message:
remove stray 'return 0;' that effectively disabled atouint().

Hi Christos!


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/external/bsd/ntp/dist/libntp/atouint.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/ntp/dist/libntp/atouint.c
diff -u src/external/bsd/ntp/dist/libntp/atouint.c:1.3 src/external/bsd/ntp/dist/libntp/atouint.c:1.4
--- src/external/bsd/ntp/dist/libntp/atouint.c:1.3	Sat Dec 28 03:20:13 2013
+++ src/external/bsd/ntp/dist/libntp/atouint.c	Tue Apr  1 17:34:44 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: atouint.c,v 1.3 2013/12/28 03:20:13 christos Exp $	*/
+/*	$NetBSD: atouint.c,v 1.4 2014/04/01 17:34:44 kardel Exp $	*/
 
 #include config.h
 #include sys/types.h
@@ -29,7 +29,6 @@ atouint(
 		return 0;
 
 	u = 0;
-		return 0;
 	while ('\0' != *cp) {
 		if (!isdigit((unsigned char)*cp))
 			return 0;



CVS commit: src/external/bsd/ntp/dist/libntp

2014-01-20 Thread Frank Kardel
Module Name:src
Committed By:   kardel
Date:   Mon Jan 20 19:03:33 UTC 2014

Modified Files:
src/external/bsd/ntp/dist/libntp: work_fork.c

Log Message:
fix voluntary self-destruct (kill(0, SIGUP)) after successful int_res run and 
interface change


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r1.2 src/external/bsd/ntp/dist/libntp/work_fork.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/ntp/dist/libntp/work_fork.c
diff -u src/external/bsd/ntp/dist/libntp/work_fork.c:1.1.1.1 src/external/bsd/ntp/dist/libntp/work_fork.c:1.2
--- src/external/bsd/ntp/dist/libntp/work_fork.c:1.1.1.1	Fri Dec 27 23:30:48 2013
+++ src/external/bsd/ntp/dist/libntp/work_fork.c	Mon Jan 20 19:03:33 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: work_fork.c,v 1.1.1.1 2013/12/27 23:30:48 christos Exp $	*/
+/*	$NetBSD: work_fork.c,v 1.2 2014/01/20 19:03:33 kardel Exp $	*/
 
 /*
  * work_fork.c - fork implementation for blocking worker child.
@@ -100,8 +100,10 @@ interrupt_worker_sleep(void)
 
 	for (idx = 0; idx  blocking_children_alloc; idx++) {
 		c = blocking_children[idx];
-		if (NULL == c)
+
+		if (NULL == c || c-reusable == TRUE)
 			continue;
+
 		rc = kill(c-pid, SIGHUP);
 		if (rc  0)
 			msyslog(LOG_ERR,



CVS commit: src/external/bsd/ntp/dist/libntp

2014-01-02 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Thu Jan  2 18:26:03 UTC 2014

Modified Files:
src/external/bsd/ntp/dist/libntp: prettydate.c

Log Message:
Use separate variables for the format strings to get working format
string checking with both GCC and Clang.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/external/bsd/ntp/dist/libntp/prettydate.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/ntp/dist/libntp/prettydate.c
diff -u src/external/bsd/ntp/dist/libntp/prettydate.c:1.2 src/external/bsd/ntp/dist/libntp/prettydate.c:1.3
--- src/external/bsd/ntp/dist/libntp/prettydate.c:1.2	Sat Dec 28 03:20:13 2013
+++ src/external/bsd/ntp/dist/libntp/prettydate.c	Thu Jan  2 18:26:03 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: prettydate.c,v 1.2 2013/12/28 03:20:13 christos Exp $	*/
+/*	$NetBSD: prettydate.c,v 1.3 2014/01/02 18:26:03 joerg Exp $	*/
 
 /*
  * prettydate - convert a time stamp to something readable
@@ -159,10 +159,10 @@ common_prettydate(
 	int local
 	)
 {
-	static const char* pfmt[2] = {
-		%08lx.%08lx  %s, %s %2d %4d %2d:%02d:%02d.%03u,
-		%08lx.%08lx [%s, %s %2d %4d %2d:%02d:%02d.%03u UTC]
-	};
+	static const char pfmt0[] =
+	%08lx.%08lx  %s, %s %2d %4d %2d:%02d:%02d.%03u;
+	static const char pfmt1[] =
+	%08lx.%08lx [%s, %s %2d %4d %2d:%02d:%02d.%03u UTC];
 
 	char	*bp;
 	struct tm   *tm;
@@ -188,13 +188,13 @@ common_prettydate(
 		 */
 		struct calendar jd;
 		ntpcal_time_to_date(jd, sec);
-		snprintf(bp, LIB_BUFLENGTH, pfmt[local != 0],
+		snprintf(bp, LIB_BUFLENGTH, local ? pfmt1 : pfmt0,
 			 (u_long)ts-l_ui, (u_long)ts-l_uf,
 			 daynames[jd.weekday], months[jd.month-1],
 			 jd.monthday, jd.year, jd.hour,
 			 jd.minute, jd.second, msec);
 	} else		
-		snprintf(bp, LIB_BUFLENGTH, pfmt[0],
+		snprintf(bp, LIB_BUFLENGTH, pfmt0,
 			 (u_long)ts-l_ui, (u_long)ts-l_uf,
 			 daynames[tm-tm_wday], months[tm-tm_mon],
 			 tm-tm_mday, 1900 + tm-tm_year, tm-tm_hour,



CVS commit: src/external/bsd/ntp/dist/libntp

2014-01-02 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Thu Jan  2 21:35:19 UTC 2014

Modified Files:
src/external/bsd/ntp/dist/libntp: timetoa.c

Log Message:
Avoid pointer operations on the format string.


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r1.2 src/external/bsd/ntp/dist/libntp/timetoa.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/ntp/dist/libntp/timetoa.c
diff -u src/external/bsd/ntp/dist/libntp/timetoa.c:1.1.1.1 src/external/bsd/ntp/dist/libntp/timetoa.c:1.2
--- src/external/bsd/ntp/dist/libntp/timetoa.c:1.1.1.1	Fri Dec 27 23:30:48 2013
+++ src/external/bsd/ntp/dist/libntp/timetoa.c	Thu Jan  2 21:35:19 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: timetoa.c,v 1.1.1.1 2013/12/27 23:30:48 christos Exp $	*/
+/*	$NetBSD: timetoa.c,v 1.2 2014/01/02 21:35:19 joerg Exp $	*/
 
 /*
  * timetoa.c -- time_t related string formatting
@@ -59,14 +59,12 @@ format_time_fraction(
 	u_int		u;
 	long		fraclimit;
 	int		notneg;	/* flag for non-negative value	*/
-	const char *	fmt;
 	ldiv_t		qr;
 
 	DEBUG_REQUIRE(prec != 0);
 
 	LIB_GETBUF(cp);
 	secs_u = (u_time)secs;
-	fmt = -% UTIME_FORMAT .%0*ld;
 	
 	/* check if we need signed or unsigned mode */
 	notneg = (prec  0);
@@ -94,9 +92,7 @@ format_time_fraction(
 
 	/* Get the absolute value of the split representation time. */
 	notneg = notneg || ((time_t)secs_u = 0);
-	if (notneg) {
-		fmt++;		/* skip '-' */
-	} else {
+	if (!notneg) {
 		secs_u = ~secs_u;
 		if (0 == frac)
 			secs_u++;
@@ -105,7 +101,8 @@ format_time_fraction(
 	}
 
 	/* finally format the data and return the result */
-	snprintf(cp, LIB_BUFLENGTH, fmt, secs_u, prec_u, frac);
+	snprintf(cp, LIB_BUFLENGTH, %s% UTIME_FORMAT .%0*ld,
+	notneg?  : -, secs_u, prec_u, frac);
 	
 	return cp;
 }



CVS commit: src/external/bsd/ntp/dist/libntp

2013-12-31 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Dec 31 20:56:29 UTC 2013

Modified Files:
src/external/bsd/ntp/dist/libntp: ntp_intres.c

Log Message:
pointless to call alloca for a 1K path string... Just allocate it on the stack!


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r1.2 src/external/bsd/ntp/dist/libntp/ntp_intres.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/ntp/dist/libntp/ntp_intres.c
diff -u src/external/bsd/ntp/dist/libntp/ntp_intres.c:1.1.1.1 src/external/bsd/ntp/dist/libntp/ntp_intres.c:1.2
--- src/external/bsd/ntp/dist/libntp/ntp_intres.c:1.1.1.1	Fri Dec 27 18:30:47 2013
+++ src/external/bsd/ntp/dist/libntp/ntp_intres.c	Tue Dec 31 15:56:29 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: ntp_intres.c,v 1.1.1.1 2013/12/27 23:30:47 christos Exp $	*/
+/*	$NetBSD: ntp_intres.c,v 1.2 2013/12/31 20:56:29 christos Exp $	*/
 
 /*
  * ntp_intres.c - Implements a generic blocking worker child or thread,
@@ -691,6 +691,7 @@ blocking_getnameinfo(
 	char *			cp;
 	int			rc;
 	time_t			time_now;
+	char			host[1024];
 
 	gni_req = (void *)((char *)req + sizeof(*req));
 
@@ -701,19 +702,7 @@ blocking_getnameinfo(
 	 * large allocations.  We only need room for the host
 	 * and service names.
 	 */
-	NTP_REQUIRE(octets  1024);
-
-#ifndef HAVE_ALLOCA
-	host = emalloc(octets);
-#else
-	host = alloca(octets);
-	if (NULL == host) {
-		msyslog(LOG_ERR,
-			blocking_getnameinfo unable to allocate %lu octets on stack,
-			(u_long)octets);
-		exit(1);
-	}
-#endif
+	NTP_REQUIRE(octets  sizeof(host));
 	service = host + gni_req-hostoctets;
 
 	worker_ctx = get_worker_context(c, gni_req-dns_idx);
@@ -795,9 +784,6 @@ blocking_getnameinfo(
 	rc = queue_blocking_response(c, resp, resp_octets, req);
 	if (rc)
 		msyslog(LOG_ERR, blocking_getnameinfo unable to queue response);
-#ifndef HAVE_ALLOCA
-	free(host);
-#endif
 	return rc;
 }
 



CVS commit: src/external/bsd/ntp/dist/libntp

2013-12-31 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Tue Dec 31 21:37:01 UTC 2013

Modified Files:
src/external/bsd/ntp/dist/libntp: ntp_intres.c

Log Message:
Remove duplicate/old declaration of 'host' now that we allocate it on stack.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/external/bsd/ntp/dist/libntp/ntp_intres.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/ntp/dist/libntp/ntp_intres.c
diff -u src/external/bsd/ntp/dist/libntp/ntp_intres.c:1.2 src/external/bsd/ntp/dist/libntp/ntp_intres.c:1.3
--- src/external/bsd/ntp/dist/libntp/ntp_intres.c:1.2	Tue Dec 31 20:56:29 2013
+++ src/external/bsd/ntp/dist/libntp/ntp_intres.c	Tue Dec 31 21:37:01 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: ntp_intres.c,v 1.2 2013/12/31 20:56:29 christos Exp $	*/
+/*	$NetBSD: ntp_intres.c,v 1.3 2013/12/31 21:37:01 pgoyette Exp $	*/
 
 /*
  * ntp_intres.c - Implements a generic blocking worker child or thread,
@@ -686,7 +686,6 @@ blocking_getnameinfo(
 	blocking_gni_resp *	gni_resp;
 	size_t			octets;
 	size_t			resp_octets;
-	char *			host;
 	char *			service;
 	char *			cp;
 	int			rc;



CVS commit: src/external/bsd/ntp/dist/libntp

2011-06-19 Thread Frank Kardel
Module Name:src
Committed By:   kardel
Date:   Sun Jun 19 15:58:07 UTC 2011

Modified Files:
src/external/bsd/ntp/dist/libntp: ntp_lineedit.c

Log Message:
fix lineedit functionality. ntpq and friends would just exit on empty lines
which is not intended - there is a quit command for that purpose.


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r1.2 src/external/bsd/ntp/dist/libntp/ntp_lineedit.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/ntp/dist/libntp/ntp_lineedit.c
diff -u src/external/bsd/ntp/dist/libntp/ntp_lineedit.c:1.1.1.1 src/external/bsd/ntp/dist/libntp/ntp_lineedit.c:1.2
--- src/external/bsd/ntp/dist/libntp/ntp_lineedit.c:1.1.1.1	Sun Dec 13 16:55:02 2009
+++ src/external/bsd/ntp/dist/libntp/ntp_lineedit.c	Sun Jun 19 15:58:07 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: ntp_lineedit.c,v 1.1.1.1 2009/12/13 16:55:02 kardel Exp $	*/
+/*	$NetBSD: ntp_lineedit.c,v 1.2 2011/06/19 15:58:07 kardel Exp $	*/
 
 /*
  * ntp_lineedit.c - generic interface to various line editing libs
@@ -174,11 +174,8 @@
 	if (NULL != line) {
 		if (*line) {
 			add_history(line);
-			*pcount = strlen(line);
-		} else {
-			free(line);
-			line = NULL;
 		}
+		*pcount = strlen(line);
 	}
 
 #endif	/* HAVE_READLINE_HISTORY */
@@ -187,12 +184,14 @@
 
 	cline = el_gets(ntp_el, pcount);
 
-	if (NULL != cline  *cline) {
+	if (NULL != cline) {
 		history(ntp_hist, hev, H_ENTER, cline);
-		*pcount = strlen(cline);
 		line = estrdup(cline);
-	} else
+	} else if (*pcount == -1) {
 		line = NULL;
+	} else {
+		line = estrdup();
+	}
 
 #endif	/* !HAVE_READLINE_HISTORY  HAVE_HISTEDIT_H */
 



CVS commit: src/external/bsd/ntp/dist/libntp

2009-12-13 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Dec 14 00:38:48 UTC 2009

Modified Files:
src/external/bsd/ntp/dist/libntp: atoint.c atolfp.c atouint.c audio.c
hextolfp.c mstolfp.c octtoint.c

Log Message:
fix bogus ctype casts


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r1.2 src/external/bsd/ntp/dist/libntp/atoint.c \
src/external/bsd/ntp/dist/libntp/atolfp.c \
src/external/bsd/ntp/dist/libntp/atouint.c \
src/external/bsd/ntp/dist/libntp/audio.c \
src/external/bsd/ntp/dist/libntp/hextolfp.c \
src/external/bsd/ntp/dist/libntp/mstolfp.c \
src/external/bsd/ntp/dist/libntp/octtoint.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/ntp/dist/libntp/atoint.c
diff -u src/external/bsd/ntp/dist/libntp/atoint.c:1.1.1.1 src/external/bsd/ntp/dist/libntp/atoint.c:1.2
--- src/external/bsd/ntp/dist/libntp/atoint.c:1.1.1.1	Sun Dec 13 11:55:01 2009
+++ src/external/bsd/ntp/dist/libntp/atoint.c	Sun Dec 13 19:38:48 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: atoint.c,v 1.1.1.1 2009/12/13 16:55:01 kardel Exp $	*/
+/*	$NetBSD: atoint.c,v 1.2 2009/12/14 00:38:48 christos Exp $	*/
 
 /*
  * atoint - convert an ascii string to a signed long, with error checking
@@ -36,7 +36,7 @@
 
 	u = 0;
 	while (*cp != '\0') {
-		if (!isdigit((int)*cp))
+		if (!isdigit((unsigned char)*cp))
 		return 0;
 		if (u  214748364 || (u == 214748364  *cp  oflow_digit))
 		return 0;	/* overflow */
Index: src/external/bsd/ntp/dist/libntp/atolfp.c
diff -u src/external/bsd/ntp/dist/libntp/atolfp.c:1.1.1.1 src/external/bsd/ntp/dist/libntp/atolfp.c:1.2
--- src/external/bsd/ntp/dist/libntp/atolfp.c:1.1.1.1	Sun Dec 13 11:55:01 2009
+++ src/external/bsd/ntp/dist/libntp/atolfp.c	Sun Dec 13 19:38:48 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: atolfp.c,v 1.1.1.1 2009/12/13 16:55:01 kardel Exp $	*/
+/*	$NetBSD: atolfp.c,v 1.2 2009/12/14 00:38:48 christos Exp $	*/
 
 /*
  * atolfp - convert an ascii string to an l_fp number
@@ -53,7 +53,7 @@
 	 *
 	 * [spaces][-|+][digits][.][digits][spaces|\n|\0]
 	 */
-	while (isspace((int)*cp))
+	while (isspace((unsigned char)*cp))
 	cp++;
 	
 	if (*cp == '-') {
@@ -64,7 +64,7 @@
 	if (*cp == '+')
 	cp++;
 
-	if (*cp != '.'  !isdigit((int)*cp))
+	if (*cp != '.'  !isdigit((unsigned char)*cp))
 	return 0;
 
 	while (*cp != '\0'  (ind = strchr(digits, *cp)) != NULL) {
@@ -73,7 +73,7 @@
 		cp++;
 	}
 
-	if (*cp != '\0'  !isspace((int)*cp)) {
+	if (*cp != '\0'  !isspace((unsigned char)*cp)) {
 		if (*cp++ != '.')
 		return 0;
 	
@@ -85,10 +85,10 @@
 			cp++;
 		}
 
-		while (isdigit((int)*cp))
+		while (isdigit((unsigned char)*cp))
 		cp++;
 		
-		if (*cp != '\0'  !isspace((int)*cp))
+		if (*cp != '\0'  !isspace((unsigned char)*cp))
 		return 0;
 	}
 
Index: src/external/bsd/ntp/dist/libntp/atouint.c
diff -u src/external/bsd/ntp/dist/libntp/atouint.c:1.1.1.1 src/external/bsd/ntp/dist/libntp/atouint.c:1.2
--- src/external/bsd/ntp/dist/libntp/atouint.c:1.1.1.1	Sun Dec 13 11:55:01 2009
+++ src/external/bsd/ntp/dist/libntp/atouint.c	Sun Dec 13 19:38:48 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: atouint.c,v 1.1.1.1 2009/12/13 16:55:01 kardel Exp $	*/
+/*	$NetBSD: atouint.c,v 1.2 2009/12/14 00:38:48 christos Exp $	*/
 
 /*
  * atouint - convert an ascii string to an unsigned long, with error checking
@@ -24,7 +24,7 @@
 
 	u = 0;
 	while (*cp != '\0') {
-		if (!isdigit((int)*cp))
+		if (!isdigit((unsigned char)*cp))
 		return 0;
 		if (u  429496729 || (u == 429496729  *cp = '6'))
 		return 0;	/* overflow */
Index: src/external/bsd/ntp/dist/libntp/audio.c
diff -u src/external/bsd/ntp/dist/libntp/audio.c:1.1.1.1 src/external/bsd/ntp/dist/libntp/audio.c:1.2
--- src/external/bsd/ntp/dist/libntp/audio.c:1.1.1.1	Sun Dec 13 11:55:01 2009
+++ src/external/bsd/ntp/dist/libntp/audio.c	Sun Dec 13 19:38:48 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.1.1.1 2009/12/13 16:55:01 kardel Exp $	*/
+/*	$NetBSD: audio.c,v 1.2 2009/12/14 00:38:48 christos Exp $	*/
 
 /*
  * audio.c - audio interface for reference clock audio drivers
@@ -147,12 +147,12 @@
 
 		/* Remove any trailing spaces */
 		for (i = strlen(line);
-		 i  0  isascii((int)line[i - 1])  isspace((int)line[i - 1]);
+		 i  0  isascii((unsigned char)line[i - 1])  isspace((unsigned char)line[i - 1]);
 			)
 			line[--i] = '\0';
 
 		/* Remove leading space */
-		for (cc = line; *cc  isascii((int)*cc)  isspace((int)*cc); cc++)
+		for (cc = line; *cc  isascii((unsigned char)*cc)  isspace((unsigned char)*cc); cc++)
 			continue;
 
 		/* Stop if nothing left */
@@ -161,16 +161,16 @@
 
 		/* Uppercase the command and find the arg */
 		for (ca = cc; *ca; ca++) {
-			if (isascii((int)*ca)) {
-if (islower((int)*ca)) {
-	*ca = toupper(*ca);
-} else if (isspace((int)*ca) || (*ca == '='))
+			if (isascii((unsigned char)*ca)) {
+if (islower((unsigned char)*ca)) {
+	*ca = toupper((unsigned