[Git][NTPsec/ntpsec][master] Remove dead code. libntp:numtohost() is no longer used.
Eric S. Raymond
gitlab at mg.gitlab.com
Thu Nov 10 12:38:23 UTC 2016
Eric S. Raymond pushed to branch master at NTPsec / ntpsec
Commits:
c30924e8 by Eric S. Raymond at 2016-11-10T07:37:35-05:00
Remove dead code. libntp:numtohost() is no longer used.
- - - - -
6 changed files:
- include/ntp_stdlib.h
- − libntp/numtohost.c
- libntp/wscript
- tests/common/tests_main.c
- − tests/libntp/numtohost.c
- tests/wscript
Changes:
=====================================
include/ntp_stdlib.h
=====================================
--- a/include/ntp_stdlib.h
+++ b/include/ntp_stdlib.h
@@ -152,7 +152,6 @@ extern const char * k_st_flags (uint32_t);
extern char * statustoa (int, int);
extern sockaddr_u * netof (sockaddr_u *);
extern char * numtoa (uint32_t);
-extern char * numtohost (uint32_t);
extern const char * socktoa (const sockaddr_u *);
extern const char * sockporttoa(const sockaddr_u *);
extern unsigned short sock_hash (const sockaddr_u *);
=====================================
libntp/numtohost.c deleted
=====================================
--- a/libntp/numtohost.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * numtohost - convert network number to host name.
- */
-#include <config.h>
-
-#include <sys/types.h>
-#include <netinet/in.h> /* ntohl */
-
-#include "ntp_fp.h"
-#include "ntp_stdlib.h"
-#include "lib_strbuf.h"
-
-#define LOOPBACKNET 0x7f000000
-#define LOOPBACKHOST 0x7f000001
-#define LOOPBACKNETMASK 0xff000000
-
-char *
-numtohost(
- uint32_t netnum
- )
-{
- char *bp;
- struct hostent *hp;
-
- /*
- * This is really gross, but saves lots of hanging looking for
- * hostnames for the radio clocks. Don't bother looking up
- * addresses on the loopback network except for the loopback
- * host itself.
- */
- if ((((ntohl(netnum) & LOOPBACKNETMASK) == LOOPBACKNET)
- && (ntohl(netnum) != LOOPBACKHOST))
- || ((hp = gethostbyaddr((char *)&netnum, sizeof netnum, AF_INET))
- == 0))
- return numtoa(netnum);
-
- LIB_GETBUF(bp);
- strlcpy(bp, hp->h_name, LIB_BUFLENGTH);
-
- return bp;
-}
=====================================
libntp/wscript
=====================================
--- a/libntp/wscript
+++ b/libntp/wscript
@@ -24,7 +24,6 @@ def build(ctx):
"ntp_random.c",
"ntp_worker.c",
"numtoa.c",
- "numtohost.c",
"recvbuff.c",
"refidsmear.c",
"socket.c",
=====================================
tests/common/tests_main.c
=====================================
--- a/tests/common/tests_main.c
+++ b/tests/common/tests_main.c
@@ -51,7 +51,6 @@ static void RunAllTests(void)
RUN_TEST_GROUP(msyslog);
RUN_TEST_GROUP(netof);
RUN_TEST_GROUP(numtoa);
- RUN_TEST_GROUP(numtohost);
RUN_TEST_GROUP(prettydate);
RUN_TEST_GROUP(recvbuff);
RUN_TEST_GROUP(refidsmear);
=====================================
tests/libntp/numtohost.c deleted
=====================================
--- a/tests/libntp/numtohost.c
+++ /dev/null
@@ -1,29 +0,0 @@
-#include "config.h"
-#include "ntp_stdlib.h"
-
-#include "unity.h"
-#include "unity_fixture.h"
-
-
-TEST_GROUP(numtohost);
-
-TEST_SETUP(numtohost) {}
-
-TEST_TEAR_DOWN(numtohost) {}
-
-
-
-TEST(numtohost, LoopbackNetNonResolve) {
- /* A loopback address in 127.0.0.0/8 is chosen, and
- * numtohost() should not try to resolve it unless
- * it is 127.0.0.1
- */
-
- u_int32_t input = 127*256*256*256 + 1*256 + 1; // 127.0.1.1
-
- TEST_ASSERT_EQUAL_STRING("127.0.1.1", numtohost(htonl(input)));
-}
-
-TEST_GROUP_RUNNER(numtohost) {
- RUN_TEST_CASE(numtohost, LoopbackNetNonResolve);
-}
=====================================
tests/wscript
=====================================
--- a/tests/wscript
+++ b/tests/wscript
@@ -66,7 +66,6 @@ def build(ctx):
"libntp/msyslog.c",
"libntp/netof.c",
"libntp/numtoa.c",
- "libntp/numtohost.c",
"libntp/prettydate.c",
"libntp/recvbuff.c",
"libntp/refidsmear.c",
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/c30924e841f8c8b7084ee85d4f6151046c5b6653
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20161110/1fb4280a/attachment.html>
More information about the vc
mailing list