From: Dmitry V. Levin Date: Mon, 5 Jun 2017 13:11:44 +0000 (+0000) Subject: tests: use create_nl_socket in netlink_protocol.test X-Git-Tag: v4.18~112 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0d6d52052124ffd1d31d677f6779b556bf430fc4;p=strace tests: use create_nl_socket in netlink_protocol.test * tests/netlink_protocol.c (main): Use create_nl_socket. --- diff --git a/tests/netlink_protocol.c b/tests/netlink_protocol.c index 64536003..9f796cf2 100644 --- a/tests/netlink_protocol.c +++ b/tests/netlink_protocol.c @@ -365,18 +365,7 @@ test_nlmsg_done(const int fd) int main(void) { - struct sockaddr_nl addr; - socklen_t len = sizeof(addr); - int fd; - - memset(&addr, 0, sizeof(addr)); - addr.nl_family = AF_NETLINK; - - if ((fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_SOCK_DIAG)) == -1) - perror_msg_and_skip("socket AF_NETLINK"); - - if (bind(fd, (struct sockaddr *) &addr, len)) - perror_msg_and_skip("bind"); + const int fd = create_nl_socket(NETLINK_SOCK_DIAG); char *path; if (asprintf(&path, "/proc/self/fd/%u", fd) < 0) @@ -390,8 +379,7 @@ int main(void) test_nlmsgerr(fd); test_nlmsg_done(fd); - printf("+++ exited with 0 +++\n"); - + puts("+++ exited with 0 +++"); return 0; }