]> granicus.if.org Git - strace/commitdiff
tests/net-yy-netlink.c: robustify against os specific issues
authorDmitry V. Levin <ldv@altlinux.org>
Mon, 23 May 2016 10:26:46 +0000 (10:26 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Mon, 23 May 2016 10:26:46 +0000 (10:26 +0000)
* tests/net-yy-netlink.c (main): Pass a pointer to a real struct msghdr
as NULL doesn't work well on some systems.

tests/net-yy-netlink.c

index 60770381b6c2224dcfe800b53190059ba4b874cc..2b9d96fc3c0f2c77a8b1a3a9dd1852890ce3c872 100644 (file)
@@ -56,6 +56,7 @@ main(void)
        };
        struct sockaddr *const sa = tail_memdup(&addr, sizeof(addr));
        socklen_t * const len = tail_alloc(sizeof(socklen_t));
+       struct msghdr *const mh = tail_alloc(sizeof(*mh));
        *len = sizeof(addr);
 
        const int fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_SOCK_DIAG);
@@ -71,9 +72,9 @@ main(void)
               "groups=00000000}, %u) = 0\n", fd, inode, magic,
               (unsigned) *len);
 
-       assert(recvmsg(fd, NULL, MSG_DONTWAIT) == -1);
-       printf("recvmsg(%d<NETLINK:[SOCK_DIAG:%u]>, NULL, MSG_DONTWAIT)"
-              " = -1 %s (%m)\n", fd, magic, errno2name());
+       assert(recvmsg(fd, mh, MSG_DONTWAIT) == -1);
+       printf("recvmsg(%d<NETLINK:[SOCK_DIAG:%u]>, %p, MSG_DONTWAIT)"
+              " = -1 %s (%m)\n", fd, magic, mh, errno2name());
 
        assert(close(fd) == 0);
        printf("close(%d<NETLINK:[SOCK_DIAG:%u]>) = 0\n", fd, magic);