[Git][NTPsec/ntpsec][master] Delete libntp/ntp_rfc2553.c; we don't need what used to be there...

Eric S. Raymond gitlab at mg.gitlab.com
Tue Sep 13 11:12:45 UTC 2016


Eric S. Raymond pushed to branch master at NTPsec / ntpsec


Commits:
af6cc32c by Eric S. Raymond at 2016-09-13T07:12:28-04:00
Delete libntp/ntp_rfc2553.c; we don't need what used to be there...

...(since we assume an RFC2553-conformant API) except for one function
that never belonged there in the first place.

Also, fix broken guard comments in include/ntp_rfc2553.h and a couple
of similarly broken guards in other files.

- - - - -


7 changed files:

- include/ntp_config.h
- include/ntp_rfc2553.h
- include/ntp_workimpl.h
- include/timetoa.h
- libntp/ntp_intres.c
- − libntp/ntp_rfc2553.c
- libntp/wscript


Changes:

=====================================
include/ntp_config.h
=====================================
--- a/include/ntp_config.h
+++ b/include/ntp_config.h
@@ -292,4 +292,4 @@ extern bool have_interface_option;
 
 void ntp_rlimit(int, rlim_t, int, const char *);
 
-#endif	/* GUARD_!defined(NTP_CONFIG_H) */
+#endif	/* GUARD_NTP_CONFIG_H */


=====================================
include/ntp_rfc2553.h
=====================================
--- a/include/ntp_rfc2553.h
+++ b/include/ntp_rfc2553.h
@@ -159,4 +159,4 @@ struct addrinfo *copy_addrinfo_list_impl(const struct addrinfo *
 #  define USE_IPV6_MULTICAST_SUPPORT
 #endif	/* IPV6 Multicast Support */
 
-#endif /* GUARD_!NTP_RFC2553_H */
+#endif /* !GUARD_NTP_RFC2553_H */


=====================================
include/ntp_workimpl.h
=====================================
--- a/include/ntp_workimpl.h
+++ b/include/ntp_workimpl.h
@@ -17,4 +17,4 @@
 # define USE_WORKER
 #endif
 
-#endif	/* GUARD_!NTP_WORKIMPL_H */
+#endif	/* !GUARD_NTP_WORKIMPL_H */


=====================================
include/timetoa.h
=====================================
--- a/include/timetoa.h
+++ b/include/timetoa.h
@@ -82,4 +82,4 @@ typedef unsigned long long u_time;
 extern const char *
 format_time_fraction(time_t secs, long frac, int prec);
 
-#endif /* GUARD_!defined(TIMETOA_H) */
+#endif /* GUARD_TIMETOA_H */


=====================================
libntp/ntp_intres.c
=====================================
--- a/libntp/ntp_intres.c
+++ b/libntp/ntp_intres.c
@@ -1048,6 +1048,145 @@ should_retry_dns(
 	return again;
 }
 
+/*
+ * copy_addrinfo()	- copy a single addrinfo to malloc()'d block.
+ * copy_addrinfo_list() - copy an addrinfo list to malloc()'d block.
+ *
+ * Copies an addrinfo list and its associated data to a contiguous block
+ * of storage from emalloc().  Callback routines invoked via
+ * getaddrinfo_sometime() have access to the resulting addrinfo list
+ * only until they return.  This routine provides an easy way to make a
+ * persistent copy.  Although the list provided to gai_sometime_callback
+ * routines is similarly contiguous, to keep this code usable in any
+ * context where we might want to duplicate an addrinfo list, it does
+ * not require the input list be contiguous.
+ *
+ * The returned list head pointer is passed to free() to release the
+ * entire list.
+ *
+ * In keeping with the rest of the NTP distribution, sockaddr_u is used
+ * in preference to struct sockaddr_storage, which is a member of the
+ * former union and so compatible.
+ */
+struct addrinfo * copy_addrinfo_common(const struct addrinfo *, int
+#ifdef EREALLOC_CALLSITE
+								   ,
+				       const char *, int
+#endif
+				       );
+
+
+struct addrinfo *
+copy_addrinfo_impl(
+	const struct addrinfo *	src
+#ifdef EREALLOC_CALLSITE
+				   ,
+	const char *		caller_file,
+	int			caller_line
+#endif
+	)
+{
+	return copy_addrinfo_common(src, true
+#ifdef EREALLOC_CALLSITE
+					      ,
+				    caller_file, caller_line
+#endif
+				    );
+}
+
+
+struct addrinfo *
+copy_addrinfo_list_impl(
+	const struct addrinfo *	src
+#ifdef EREALLOC_CALLSITE
+				   ,
+	const char *		caller_file,
+	int			caller_line
+#endif
+	)
+{
+	return copy_addrinfo_common(src, false
+#ifdef EREALLOC_CALLSITE
+					      ,
+				    caller_file, caller_line
+#endif
+				    );
+}
+
+
+struct addrinfo *
+copy_addrinfo_common(
+	const struct addrinfo *	src,
+	int			just_one
+#ifdef EREALLOC_CALLSITE
+					,
+	const char *		caller_file,
+	int			caller_line
+#endif
+	)
+{
+	const struct addrinfo *	ai_src;
+	const struct addrinfo *	ai_nxt;
+	struct addrinfo *	ai_cpy;
+	struct addrinfo *	dst;
+	sockaddr_u *		psau;
+	char *			pcanon;
+	u_int			elements;
+	size_t			octets;
+	size_t			canons_octets;
+	size_t			str_octets;
+
+	elements = 0;
+	canons_octets = 0;
+
+	for (ai_src = src; NULL != ai_src; ai_src = ai_nxt) {
+		if (just_one)
+			ai_nxt = NULL;
+		else
+			ai_nxt = ai_src->ai_next;
+		++elements;
+		if (NULL != ai_src->ai_canonname)
+			canons_octets += 1 + strlen(ai_src->ai_canonname);
+	}
+
+	octets = elements * (sizeof(*ai_cpy) + sizeof(*psau));
+	octets += canons_octets;
+
+	dst = erealloczsite(NULL, octets, 0, true, caller_file,
+			    caller_line);
+	ai_cpy = dst;
+	psau = (void *)(ai_cpy + elements);
+	pcanon = (void *)(psau + elements);
+
+	for (ai_src = src; NULL != ai_src; ai_src = ai_nxt) {
+		if (just_one)
+			ai_nxt = NULL;
+		else
+			ai_nxt = ai_src->ai_next;
+		*ai_cpy = *ai_src;
+		REQUIRE(ai_src->ai_addrlen <= sizeof(sockaddr_u));
+		memcpy(psau, ai_src->ai_addr, ai_src->ai_addrlen);
+		ai_cpy->ai_addr = &psau->sa;
+		++psau;
+		if (NULL != ai_cpy->ai_canonname) {
+			ai_cpy->ai_canonname = pcanon;
+			str_octets = 1 + strlen(ai_src->ai_canonname);
+			memcpy(pcanon, ai_src->ai_canonname, str_octets);
+			pcanon += str_octets;
+		}
+		if (NULL != ai_cpy->ai_next) {
+			if (just_one)
+				ai_cpy->ai_next = NULL;
+			else
+				ai_cpy->ai_next = ai_cpy + 1;
+		}
+		++ai_cpy;
+	}
+	NTP_ENSURE(pcanon == ((char *)dst + octets));
+
+	return dst;
+}
+
 #else	/* !USE_WORKER follows */
 int ntp_intres_nonempty_compilation_unit;
 #endif


=====================================
libntp/ntp_rfc2553.c deleted
=====================================
--- a/libntp/ntp_rfc2553.c
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * Compatibility shims with the rfc2553 API to simplify ntp.
- *
- * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
- *
- * Copyright (c) 1982, 1986, 1990, 1993
- *	The Regents of the University of California.
- *
- * SPDX-License-Identifier: BSD-2-clause
- */
-
-#include <config.h>
-
-#include <sys/types.h>
-#include <ctype.h>
-#include <sys/socket.h>
-#include <isc/net.h>
-#include <netinet/in.h>
-#include <string.h>
-
-#include "ntp_rfc2553.h"
-
-#include "ntpd.h"
-#include "ntp_malloc.h"
-#include "ntp_debug.h"
-
-
-/*
- * copy_addrinfo()	- copy a single addrinfo to malloc()'d block.
- * copy_addrinfo_list() - copy an addrinfo list to malloc()'d block.
- *
- * Copies an addrinfo list and its associated data to a contiguous block
- * of storage from emalloc().  Callback routines invoked via
- * getaddrinfo_sometime() have access to the resulting addrinfo list
- * only until they return.  This routine provides an easy way to make a
- * persistent copy.  Although the list provided to gai_sometime_callback
- * routines is similarly contiguous, to keep this code usable in any
- * context where we might want to duplicate an addrinfo list, it does
- * not require the input list be contiguous.
- *
- * The returned list head pointer is passed to free() to release the
- * entire list.
- *
- * In keeping with the rest of the NTP distribution, sockaddr_u is used
- * in preference to struct sockaddr_storage, which is a member of the
- * former union and so compatible.
- */
-struct addrinfo * copy_addrinfo_common(const struct addrinfo *, int
-#ifdef EREALLOC_CALLSITE
-								   ,
-				       const char *, int
-#endif
-				       );
-
-
-struct addrinfo *
-copy_addrinfo_impl(
-	const struct addrinfo *	src
-#ifdef EREALLOC_CALLSITE
-				   ,
-	const char *		caller_file,
-	int			caller_line
-#endif
-	)
-{
-	return copy_addrinfo_common(src, true
-#ifdef EREALLOC_CALLSITE
-					      ,
-				    caller_file, caller_line
-#endif
-				    );
-}
-
-
-struct addrinfo *
-copy_addrinfo_list_impl(
-	const struct addrinfo *	src
-#ifdef EREALLOC_CALLSITE
-				   ,
-	const char *		caller_file,
-	int			caller_line
-#endif
-	)
-{
-	return copy_addrinfo_common(src, false
-#ifdef EREALLOC_CALLSITE
-					      ,
-				    caller_file, caller_line
-#endif
-				    );
-}
-
-
-struct addrinfo *
-copy_addrinfo_common(
-	const struct addrinfo *	src,
-	int			just_one
-#ifdef EREALLOC_CALLSITE
-					,
-	const char *		caller_file,
-	int			caller_line
-#endif
-	)
-{
-	const struct addrinfo *	ai_src;
-	const struct addrinfo *	ai_nxt;
-	struct addrinfo *	ai_cpy;
-	struct addrinfo *	dst;
-	sockaddr_u *		psau;
-	char *			pcanon;
-	u_int			elements;
-	size_t			octets;
-	size_t			canons_octets;
-	size_t			str_octets;
-
-	elements = 0;
-	canons_octets = 0;
-
-	for (ai_src = src; NULL != ai_src; ai_src = ai_nxt) {
-		if (just_one)
-			ai_nxt = NULL;
-		else
-			ai_nxt = ai_src->ai_next;
-		++elements;
-		if (NULL != ai_src->ai_canonname)
-			canons_octets += 1 + strlen(ai_src->ai_canonname);
-	}
-
-	octets = elements * (sizeof(*ai_cpy) + sizeof(*psau));
-	octets += canons_octets;
-
-	dst = erealloczsite(NULL, octets, 0, true, caller_file,
-			    caller_line);
-	ai_cpy = dst;
-	psau = (void *)(ai_cpy + elements);
-	pcanon = (void *)(psau + elements);
-
-	for (ai_src = src; NULL != ai_src; ai_src = ai_nxt) {
-		if (just_one)
-			ai_nxt = NULL;
-		else
-			ai_nxt = ai_src->ai_next;
-		*ai_cpy = *ai_src;
-		REQUIRE(ai_src->ai_addrlen <= sizeof(sockaddr_u));
-		memcpy(psau, ai_src->ai_addr, ai_src->ai_addrlen);
-		ai_cpy->ai_addr = &psau->sa;
-		++psau;
-		if (NULL != ai_cpy->ai_canonname) {
-			ai_cpy->ai_canonname = pcanon;
-			str_octets = 1 + strlen(ai_src->ai_canonname);
-			memcpy(pcanon, ai_src->ai_canonname, str_octets);
-			pcanon += str_octets;
-		}
-		if (NULL != ai_cpy->ai_next) {
-			if (just_one)
-				ai_cpy->ai_next = NULL;
-			else
-				ai_cpy->ai_next = ai_cpy + 1;
-		}
-		++ai_cpy;
-	}
-	NTP_ENSURE(pcanon == ((char *)dst + octets));
-
-	return dst;
-}
-
-


=====================================
libntp/wscript
=====================================
--- a/libntp/wscript
+++ b/libntp/wscript
@@ -26,7 +26,6 @@ def build(ctx):
 		"ntp_intres.c",
 		"ntp_lineedit.c",
 		"ntp_random.c",
-		"ntp_rfc2553.c",
 		"ntp_worker.c",
 		"numtoa.c",
 		"numtohost.c",



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/af6cc32c3af1b1c9b8b9d8d9569ddd1bbcc77301
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20160913/2c3dbc81/attachment.html>


More information about the vc mailing list