]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
socket-util: drop getnameinfo_pretty() 8143/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 9 Feb 2018 08:52:05 +0000 (17:52 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 10 Feb 2018 02:10:07 +0000 (11:10 +0900)
src/basic/socket-util.c
src/basic/socket-util.h
src/test/test-socket-util.c

index bd3cf6f86982e413f35bb572f5598775f4de0ad4..22f5c60c71f0b43095ae3c9d26f4f3fbd02c21fd 100644 (file)
@@ -758,19 +758,6 @@ int socknameinfo_pretty(union sockaddr_union *sa, socklen_t salen, char **_ret)
         return 0;
 }
 
-int getnameinfo_pretty(int fd, char **ret) {
-        union sockaddr_union sa;
-        socklen_t salen = sizeof(sa);
-
-        assert(fd >= 0);
-        assert(ret);
-
-        if (getsockname(fd, &sa.sa, &salen) < 0)
-                return -errno;
-
-        return socknameinfo_pretty(&sa, salen, ret);
-}
-
 int socket_address_unlink(SocketAddress *a) {
         assert(a);
 
index 49c937aef59baa89be5f497aa15d813ed330cce7..2e5694b126931721bac4dc6f800a31281ff71030 100644 (file)
@@ -126,7 +126,6 @@ int getpeername_pretty(int fd, bool include_port, char **ret);
 int getsockname_pretty(int fd, char **ret);
 
 int socknameinfo_pretty(union sockaddr_union *sa, socklen_t salen, char **_ret);
-int getnameinfo_pretty(int fd, char **ret);
 
 const char* socket_address_bind_ipv6_only_to_string(SocketAddressBindIPv6Only b) _const_;
 SocketAddressBindIPv6Only socket_address_bind_ipv6_only_from_string(const char *s) _pure_;
index d1ab7486ed92f4d220cef85bdfd548cb59dfc853..e35a27fa61a5b2eee30f768828b78854decb15ec 100644 (file)
@@ -360,58 +360,6 @@ static void test_in_addr_ifindex_from_string_auto(void) {
         assert_se(in_addr_ifindex_from_string_auto("fe80::19%thisinterfacecantexist", &family, &ua, &ifindex) == -ENODEV);
 }
 
-static void *connect_thread(void *arg) {
-        union sockaddr_union *sa = arg;
-        _cleanup_close_ int fd = -1;
-
-        fd = socket(AF_INET, SOCK_STREAM | SOCK_CLOEXEC, 0);
-        assert_se(fd >= 0);
-
-        assert_se(connect(fd, &sa->sa, sizeof(sa->in)) == 0);
-
-        return NULL;
-}
-
-static void test_nameinfo_pretty(void) {
-        _cleanup_free_ char *stdin_name = NULL, *localhost = NULL;
-
-        union sockaddr_union s = {
-                .in.sin_family = AF_INET,
-                .in.sin_port = 0,
-                .in.sin_addr.s_addr = htobe32(INADDR_ANY),
-        };
-        int r;
-
-        union sockaddr_union c = {};
-        socklen_t slen = sizeof(c.in), clen = sizeof(c.in);
-
-        _cleanup_close_ int sfd = -1, cfd = -1;
-        r = getnameinfo_pretty(STDIN_FILENO, &stdin_name);
-        log_info_errno(r, "No connection remote: %m");
-
-        assert_se(r < 0);
-
-        sfd = socket(AF_INET, SOCK_STREAM|SOCK_CLOEXEC, 0);
-        assert_se(sfd >= 0);
-
-        assert_se(bind(sfd, &s.sa, sizeof(s.in)) == 0);
-
-        /* find out the port number */
-        assert_se(getsockname(sfd, &s.sa, &slen) == 0);
-
-        assert_se(listen(sfd, 1) == 0);
-
-        assert_se(asynchronous_job(connect_thread, &s) == 0);
-
-        log_debug("Accepting new connection on fd:%d", sfd);
-        cfd = accept4(sfd, &c.sa, &clen, SOCK_CLOEXEC);
-        assert_se(cfd >= 0);
-
-        r = getnameinfo_pretty(cfd, &localhost);
-        log_info("Connection from %s", localhost);
-        assert_se(r == 0);
-}
-
 static void test_sockaddr_equal(void) {
         union sockaddr_union a = {
                 .in.sin_family = AF_INET,
@@ -561,8 +509,6 @@ int main(int argc, char *argv[]) {
         test_in_addr_ifindex_to_string();
         test_in_addr_ifindex_from_string_auto();
 
-        test_nameinfo_pretty();
-
         test_sockaddr_equal();
 
         test_sockaddr_un_len();