From: Dmitry V. Levin Date: Mon, 20 Jun 2016 22:52:49 +0000 (+0000) Subject: Consistently use AF_UNIX over AF_LOCAL X-Git-Tag: v4.13~122 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e139cbe96968a0db32fa5a01c1619483df3e92bd;p=strace Consistently use AF_UNIX over AF_LOCAL As these constants have the same value 1, let's use and print only one of them, e.g. AF_UNIX. * xlat/addrfams.in (AF_LOCAL): Remove. * tests/net-accept-connect.c (main): Replace AF_LOCAL with AF_UNIX. * tests/net-y-unix.c: Likewise. * tests/net-yy-unix.c: Likewise. * tests/netlink_unix_diag.c: Likewise. --- diff --git a/tests/net-accept-connect.c b/tests/net-accept-connect.c index b7f7c20a..04c05a60 100644 --- a/tests/net-accept-connect.c +++ b/tests/net-accept-connect.c @@ -62,7 +62,7 @@ main(int ac, const char **av) close(0); close(1); - if (socket(AF_LOCAL, SOCK_STREAM, 0)) + if (socket(AF_UNIX, SOCK_STREAM, 0)) perror_msg_and_skip("socket"); if (bind(0, (struct sockaddr *) &addr, len)) perror_msg_and_skip("bind"); @@ -93,7 +93,7 @@ main(int ac, const char **av) assert(sigprocmask(SIG_BLOCK, &set, NULL) == 0); assert(signal(SIGUSR1, handler) != SIG_ERR); - assert(socket(AF_LOCAL, SOCK_STREAM, 0) == 1); + assert(socket(AF_UNIX, SOCK_STREAM, 0) == 1); assert(close(0) == 0); assert(connect(1, (struct sockaddr *) &addr, len) == 0); assert(sigprocmask(SIG_UNBLOCK, &set, NULL) == 0); diff --git a/tests/net-y-unix.c b/tests/net-y-unix.c index 28212a3e..499ae8ea 100644 --- a/tests/net-y-unix.c +++ b/tests/net-y-unix.c @@ -54,17 +54,17 @@ main(int ac, const char **av) if (*len > sizeof(addr)) *len = sizeof(addr); - int listen_fd = socket(AF_LOCAL, SOCK_STREAM, 0); + int listen_fd = socket(AF_UNIX, SOCK_STREAM, 0); if (listen_fd < 0) perror_msg_and_skip("socket"); unsigned long listen_inode = inode_of_sockfd(listen_fd); - printf("socket(AF_LOCAL, SOCK_STREAM, 0) = %d\n", + printf("socket(AF_UNIX, SOCK_STREAM, 0) = %d\n", listen_fd, listen_inode); (void) unlink(av[1]); if (bind(listen_fd, listen_sa, *len)) perror_msg_and_skip("bind"); - printf("bind(%d, {sa_family=AF_LOCAL, sun_path=\"%s\"}" + printf("bind(%d, {sa_family=AF_UNIX, sun_path=\"%s\"}" ", %u) = 0\n", listen_fd, listen_inode, av[1], (unsigned) *len); if (listen(listen_fd, 1)) @@ -83,20 +83,20 @@ main(int ac, const char **av) *len = sizeof(addr); if (getsockname(listen_fd, listen_sa, len)) perror_msg_and_fail("getsockname"); - printf("getsockname(%d, {sa_family=AF_LOCAL" + printf("getsockname(%d, {sa_family=AF_UNIX" ", sun_path=\"%s\"}, [%u]) = 0\n", listen_fd, listen_inode, av[1], (unsigned) *len); - int connect_fd = socket(AF_LOCAL, SOCK_STREAM, 0); + int connect_fd = socket(AF_UNIX, SOCK_STREAM, 0); if (connect_fd < 0) perror_msg_and_fail("socket"); unsigned long connect_inode = inode_of_sockfd(connect_fd); - printf("socket(AF_LOCAL, SOCK_STREAM, 0) = %d\n", + printf("socket(AF_UNIX, SOCK_STREAM, 0) = %d\n", connect_fd, connect_inode); if (connect(connect_fd, listen_sa, *len)) perror_msg_and_fail("connect"); - printf("connect(%d, {sa_family=AF_LOCAL" + printf("connect(%d, {sa_family=AF_UNIX" ", sun_path=\"%s\"}, %u) = 0\n", connect_fd, connect_inode, av[1], (unsigned) *len); @@ -107,7 +107,7 @@ main(int ac, const char **av) if (accept_fd < 0) perror_msg_and_fail("accept"); unsigned long accept_inode = inode_of_sockfd(accept_fd); - printf("accept(%d, {sa_family=AF_LOCAL, NULL}" + printf("accept(%d, {sa_family=AF_UNIX, NULL}" ", [%u]) = %d\n", listen_fd, listen_inode, (unsigned) *len, accept_fd, accept_inode); @@ -116,7 +116,7 @@ main(int ac, const char **av) *len = sizeof(addr); if (getpeername(connect_fd, listen_sa, len)) perror_msg_and_fail("getpeername"); - printf("getpeername(%d, {sa_family=AF_LOCAL" + printf("getpeername(%d, {sa_family=AF_UNIX" ", sun_path=\"%s\"}, [%u]) = 0\n", connect_fd, connect_inode, av[1], (unsigned) *len); @@ -141,11 +141,11 @@ main(int ac, const char **av) assert(close(accept_fd) == 0); printf("close(%d) = 0\n", accept_fd, accept_inode); - connect_fd = socket(AF_LOCAL, SOCK_STREAM, 0); + connect_fd = socket(AF_UNIX, SOCK_STREAM, 0); if (connect_fd < 0) perror_msg_and_fail("socket"); connect_inode = inode_of_sockfd(connect_fd); - printf("socket(AF_LOCAL, SOCK_STREAM, 0) = %d\n", + printf("socket(AF_UNIX, SOCK_STREAM, 0) = %d\n", connect_fd, connect_inode); *optval = 1; @@ -160,13 +160,13 @@ main(int ac, const char **av) *len = sizeof(addr); if (getsockname(listen_fd, listen_sa, len)) perror_msg_and_fail("getsockname"); - printf("getsockname(%d, {sa_family=AF_LOCAL" + printf("getsockname(%d, {sa_family=AF_UNIX" ", sun_path=\"%s\"}, [%u]) = 0\n", listen_fd, listen_inode, av[1], (unsigned) *len); if (connect(connect_fd, listen_sa, *len)) perror_msg_and_fail("connect"); - printf("connect(%d, {sa_family=AF_LOCAL" + printf("connect(%d, {sa_family=AF_UNIX" ", sun_path=\"%s\"}, %u) = 0\n", connect_fd, connect_inode, av[1], (unsigned) *len); @@ -178,7 +178,7 @@ main(int ac, const char **av) accept_inode = inode_of_sockfd(accept_fd); const char * const sun_path1 = ((struct sockaddr_un *) accept_sa) -> sun_path + 1; - printf("accept(%d, {sa_family=AF_LOCAL" + printf("accept(%d, {sa_family=AF_UNIX" ", sun_path=@\"%s\"}, [%u]) = %d\n", listen_fd, listen_inode, sun_path1, (unsigned) *len, accept_fd, accept_inode); @@ -187,7 +187,7 @@ main(int ac, const char **av) *len = sizeof(addr); if (getpeername(connect_fd, listen_sa, len)) perror_msg_and_fail("getpeername"); - printf("getpeername(%d, {sa_family=AF_LOCAL" + printf("getpeername(%d, {sa_family=AF_UNIX" ", sun_path=\"%s\"}, [%u]) = 0\n", connect_fd, connect_inode, av[1], (unsigned) *len); @@ -195,7 +195,7 @@ main(int ac, const char **av) *len = sizeof(addr); if (getsockname(connect_fd, accept_sa, len)) perror_msg_and_fail("getsockname"); - printf("getsockname(%d, {sa_family=AF_LOCAL" + printf("getsockname(%d, {sa_family=AF_UNIX" ", sun_path=@\"%s\"}, [%u]) = 0\n", connect_fd, connect_inode, sun_path1, (unsigned) *len); diff --git a/tests/net-yy-unix.c b/tests/net-yy-unix.c index 7bad0032..78fc876d 100644 --- a/tests/net-yy-unix.c +++ b/tests/net-yy-unix.c @@ -54,17 +54,17 @@ main(int ac, const char **av) if (*len > sizeof(addr)) *len = sizeof(addr); - int listen_fd = socket(AF_LOCAL, SOCK_STREAM, 0); + int listen_fd = socket(AF_UNIX, SOCK_STREAM, 0); if (listen_fd < 0) perror_msg_and_skip("socket"); unsigned long listen_inode = inode_of_sockfd(listen_fd); - printf("socket(AF_LOCAL, SOCK_STREAM, 0) = %d\n", + printf("socket(AF_UNIX, SOCK_STREAM, 0) = %d\n", listen_fd, listen_inode); (void) unlink(av[1]); if (bind(listen_fd, listen_sa, *len)) perror_msg_and_skip("bind"); - printf("bind(%d, {sa_family=AF_LOCAL, sun_path=\"%s\"}" + printf("bind(%d, {sa_family=AF_UNIX, sun_path=\"%s\"}" ", %u) = 0\n", listen_fd, listen_inode, av[1], (unsigned) *len); if (listen(listen_fd, 1)) @@ -84,20 +84,20 @@ main(int ac, const char **av) *len = sizeof(addr); if (getsockname(listen_fd, listen_sa, len)) perror_msg_and_fail("getsockname"); - printf("getsockname(%d, {sa_family=AF_LOCAL" + printf("getsockname(%d, {sa_family=AF_UNIX" ", sun_path=\"%s\"}, [%u]) = 0\n", listen_fd, listen_inode, av[1], av[1], (unsigned) *len); - int connect_fd = socket(AF_LOCAL, SOCK_STREAM, 0); + int connect_fd = socket(AF_UNIX, SOCK_STREAM, 0); if (connect_fd < 0) perror_msg_and_fail("socket"); unsigned long connect_inode = inode_of_sockfd(connect_fd); - printf("socket(AF_LOCAL, SOCK_STREAM, 0) = %d\n", + printf("socket(AF_UNIX, SOCK_STREAM, 0) = %d\n", connect_fd, connect_inode); if (connect(connect_fd, listen_sa, *len)) perror_msg_and_fail("connect"); - printf("connect(%d, {sa_family=AF_LOCAL" + printf("connect(%d, {sa_family=AF_UNIX" ", sun_path=\"%s\"}, %u) = 0\n", connect_fd, connect_inode, av[1], (unsigned) *len); @@ -108,7 +108,7 @@ main(int ac, const char **av) if (accept_fd < 0) perror_msg_and_fail("accept"); unsigned long accept_inode = inode_of_sockfd(accept_fd); - printf("accept(%d, {sa_family=AF_LOCAL, NULL}" + printf("accept(%d, {sa_family=AF_UNIX, NULL}" ", [%u]) = %d%lu,\"%s\"]>\n", listen_fd, listen_inode, av[1], (unsigned) *len, accept_fd, accept_inode, connect_inode, av[1]); @@ -117,7 +117,7 @@ main(int ac, const char **av) *len = sizeof(addr); if (getpeername(connect_fd, listen_sa, len)) perror_msg_and_fail("getpeername"); - printf("getpeername(%d%lu]>, {sa_family=AF_LOCAL" + printf("getpeername(%d%lu]>, {sa_family=AF_UNIX" ", sun_path=\"%s\"}, [%u]) = 0\n", connect_fd, connect_inode, accept_inode, av[1], (unsigned) *len); @@ -144,11 +144,11 @@ main(int ac, const char **av) printf("close(%d%lu,\"%s\"]>) = 0\n", accept_fd, accept_inode, connect_inode, av[1]); - connect_fd = socket(AF_LOCAL, SOCK_STREAM, 0); + connect_fd = socket(AF_UNIX, SOCK_STREAM, 0); if (connect_fd < 0) perror_msg_and_fail("socket"); connect_inode = inode_of_sockfd(connect_fd); - printf("socket(AF_LOCAL, SOCK_STREAM, 0) = %d\n", + printf("socket(AF_UNIX, SOCK_STREAM, 0) = %d\n", connect_fd, connect_inode); *optval = 1; @@ -163,13 +163,13 @@ main(int ac, const char **av) *len = sizeof(addr); if (getsockname(listen_fd, listen_sa, len)) perror_msg_and_fail("getsockname"); - printf("getsockname(%d, {sa_family=AF_LOCAL" + printf("getsockname(%d, {sa_family=AF_UNIX" ", sun_path=\"%s\"}, [%u]) = 0\n", listen_fd, listen_inode, av[1], av[1], (unsigned) *len); if (connect(connect_fd, listen_sa, *len)) perror_msg_and_fail("connect"); - printf("connect(%d, {sa_family=AF_LOCAL" + printf("connect(%d, {sa_family=AF_UNIX" ", sun_path=\"%s\"}, %u) = 0\n", connect_fd, connect_inode, av[1], (unsigned) *len); @@ -181,7 +181,7 @@ main(int ac, const char **av) accept_inode = inode_of_sockfd(accept_fd); const char * const sun_path1 = ((struct sockaddr_un *) accept_sa) -> sun_path + 1; - printf("accept(%d, {sa_family=AF_LOCAL" + printf("accept(%d, {sa_family=AF_UNIX" ", sun_path=@\"%s\"}, [%u]) = %d%lu,\"%s\"]>\n", listen_fd, listen_inode, av[1], sun_path1, (unsigned) *len, accept_fd, accept_inode, connect_inode, av[1]); @@ -190,7 +190,7 @@ main(int ac, const char **av) *len = sizeof(addr); if (getpeername(connect_fd, listen_sa, len)) perror_msg_and_fail("getpeername"); - printf("getpeername(%d%lu,@\"%s\"]>, {sa_family=AF_LOCAL" + printf("getpeername(%d%lu,@\"%s\"]>, {sa_family=AF_UNIX" ", sun_path=\"%s\"}, [%u]) = 0\n", connect_fd, connect_inode, accept_inode, sun_path1, av[1], (unsigned) *len); diff --git a/tests/netlink_unix_diag.c b/tests/netlink_unix_diag.c index b91cbbbe..269adc6f 100644 --- a/tests/netlink_unix_diag.c +++ b/tests/netlink_unix_diag.c @@ -138,8 +138,8 @@ int main(void) close(1); (void) unlink(SUN_PATH); - if (socket(AF_LOCAL, SOCK_STREAM, 0)) - perror_msg_and_skip("socket AF_LOCAL"); + if (socket(AF_UNIX, SOCK_STREAM, 0)) + perror_msg_and_skip("socket AF_UNIX"); if (bind(0, (struct sockaddr *) &addr, len)) perror_msg_and_skip("bind"); if (listen(0, 5)) diff --git a/xlat/addrfams.in b/xlat/addrfams.in index f8c49d77..ce3a9855 100644 --- a/xlat/addrfams.in +++ b/xlat/addrfams.in @@ -1,5 +1,4 @@ AF_UNSPEC -AF_LOCAL AF_UNIX AF_INET AF_AX25