[Git][NTPsec/ntpsec][master] Eliminate unused netof6() function

Hal Murray gitlab at mg.gitlab.com
Wed Sep 18 07:54:13 UTC 2019



Hal Murray pushed to branch master at NTPsec / ntpsec


Commits:
b1bb7919 by Matt Selsky at 2019-09-18T06:41:25Z
Eliminate unused netof6() function

- - - - -


6 changed files:

- include/ntp_stdlib.h
- − libntp/netof.c
- libntp/wscript
- tests/common/tests_main.c
- − tests/libntp/netof.c
- tests/wscript


Changes:

=====================================
include/ntp_stdlib.h
=====================================
@@ -98,7 +98,6 @@ extern	const char * res_match_flags(unsigned short);
 extern	const char * res_access_flags(unsigned short);
 extern	const char * k_st_flags	(uint32_t);
 extern	char *	statustoa	(int, int);
-extern	sockaddr_u * netof6	(sockaddr_u *);
 extern	const char * socktoa	(const sockaddr_u *);
 extern	const char * socktoa_r	(const sockaddr_u *sock, char *buf, size_t buflen);
 extern	const char * sockporttoa(const sockaddr_u *);


=====================================
libntp/netof.c deleted
=====================================
@@ -1,44 +0,0 @@
-/*
- * netof6 - return the net address part of an IPv6 address
- *  in a sockaddr_storage structure (zero out host part)
- *
- * except it does not really do that, it ASSumes /64
- *
- * returns points to a 8 position static array.  Each
- * position used in turn.
- *
- */
-#include "config.h"
-#include <stdio.h>
-#include <syslog.h>
-
-#include "ntp_net.h"
-#include "ntp_stdlib.h"
-#include "ntp.h"
-
-sockaddr_u *
-netof6(
-	sockaddr_u *hostaddr
-	)
-{
-	static sockaddr_u	netofbuf[8];
-	static int		next_netofbuf;
-	sockaddr_u *		netaddr;
-
-	netaddr = &netofbuf[next_netofbuf];
-	next_netofbuf = (next_netofbuf + 1) % (int)COUNTOF(netofbuf);
-
-	memcpy(netaddr, hostaddr, sizeof(*netaddr));
-
-	if (IS_IPV6(netaddr))
-		/* assume the typical /64 subnet size */
-		memset(&NSRCADR6(netaddr)[8], '\0', 8);
-#ifdef DEBUG
-	else {
-		msyslog(LOG_ERR, "ERR: Not IPv6, AF %d", AF(netaddr));
-		exit(1);
-	}
-#endif
-
-	return netaddr;
-}


=====================================
libntp/wscript
=====================================
@@ -13,7 +13,6 @@ def build(ctx):
         "isc_interfaceiter.c",
         "isc_net.c",
         "macencrypt.c",
-        "netof.c",
         "ntp_endian.c",
         "numtoa.c",
         "refidsmear.c",


=====================================
tests/common/tests_main.c
=====================================
@@ -49,7 +49,6 @@ static void RunAllTests(void)
 	RUN_TEST_GROUP(lfpfunc);
 	RUN_TEST_GROUP(lfptostr);
 	RUN_TEST_GROUP(macencrypt);
-	RUN_TEST_GROUP(netof6);
 	RUN_TEST_GROUP(numtoa);
 	RUN_TEST_GROUP(prettydate);
 	RUN_TEST_GROUP(random);


=====================================
tests/libntp/netof.c deleted
=====================================
@@ -1,52 +0,0 @@
-#include "config.h"
-#include "ntp_stdlib.h"
-
-#include "unity.h"
-#include "unity_fixture.h"
-
-TEST_GROUP(netof6);
-
-TEST_SETUP(netof6) {}
-
-TEST_TEAR_DOWN(netof6) {}
-
-#include "sockaddrtest.h"
-
-
-TEST(netof6, IPv6Address) {
-	/* IPv6 addresses are assumed to have 64-bit host
-         * and 64-bit network parts.
-         */
-	const struct in6_addr input_address = {{{
-		0x20, 0x01, 0x0d, 0xb8,
-        0x85, 0xa3, 0x08, 0xd3,
-        0x13, 0x19, 0x8a, 0x2e,
-        0x03, 0x70, 0x73, 0x34
-	}}}; // 2001:0db8:85a3:08d3:1319:8a2e:0370:7334
-
-	const struct in6_addr expected_address = {{{
-		0x20, 0x01, 0x0d, 0xb8,
-        0x85, 0xa3, 0x08, 0xd3,
-        0x00, 0x00, 0x00, 0x00,
-        0x00, 0x00, 0x00, 0x00
-	}}}; // 2001:0db8:85a3:08d3:0000:0000:0000:0000
-
-	sockaddr_u input;
-	SET_AF(&input, AF_INET6);
-	SET_SOCK_ADDR6(&input, input_address);
-	SET_PORT(&input, 3000);
-
-	sockaddr_u expected;
-	SET_AF(&expected, AF_INET6);
-	SET_SOCK_ADDR6(&expected, expected_address);
-	SET_PORT(&expected, 3000);
-
-	sockaddr_u* actual = netof6(&input);
-
-	TEST_ASSERT_NOT_NULL(actual);
-	TEST_ASSERT_TRUE(IsEqualS(&expected, actual));
-}
-
-TEST_GROUP_RUNNER(netof6) {
-	RUN_TEST_CASE(netof6, IPv6Address);
-}


=====================================
tests/wscript
=====================================
@@ -43,7 +43,6 @@ def build(ctx):
         "libntp/lfpfunc.c",
         "libntp/lfptostr.c",
         "libntp/macencrypt.c",
-        "libntp/netof.c",
         "libntp/numtoa.c",
         "libntp/prettydate.c",
         "libntp/refidsmear.c",



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/b1bb7919ed390fecec56c7fe152e5e555429829c

-- 
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/b1bb7919ed390fecec56c7fe152e5e555429829c
You're receiving this email because of your account on gitlab.com.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20190918/546ff05b/attachment-0001.htm>


More information about the vc mailing list