]> granicus.if.org Git - strace/commitdiff
tests: fix netlink_protocol on sparc
authorDmitry V. Levin <ldv@altlinux.org>
Fri, 21 Apr 2017 23:01:22 +0000 (23:01 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Fri, 21 Apr 2017 23:01:22 +0000 (23:01 +0000)
* tests/netlink_protocol.c (test_nlmsgerr): Do not access fields of an
unaligned structure, this makes architectures like sparc very unhappy.

tests/netlink_protocol.c

index 03cff929e541bb046abbef16f3279c96d7b61a01..35f954fdb755a8b5aacb766330878b2c47ef77b9 100644 (file)
@@ -221,18 +221,15 @@ test_nlmsgerr(const int fd)
               fd, nlh->nlmsg_len, nlh0 + NLMSG_HDRLEN,
               nlh->nlmsg_len, sprintrc(rc));
 
-       nlh = nlh0 - 2;
        nlh->nlmsg_len = NLMSG_HDRLEN + 2;
-       nlh->nlmsg_type = NLMSG_ERROR;
-       nlh->nlmsg_flags = NLM_F_REQUEST;
-       nlh->nlmsg_seq = 0;
-       nlh->nlmsg_pid = 0;
+       nlh = nlh0 - 2;
+       memmove(nlh, nlh0, sizeof(*nlh));
        memcpy(NLMSG_DATA(nlh), "42", 2);
 
-       rc = sendto(fd, nlh, nlh->nlmsg_len, MSG_DONTWAIT, NULL, 0);
+       rc = sendto(fd, nlh, NLMSG_HDRLEN + 2, MSG_DONTWAIT, NULL, 0);
        printf("sendto(%d, {{len=%u, type=NLMSG_ERROR, flags=NLM_F_REQUEST"
               ", seq=0, pid=0}, \"42\"}, %u, MSG_DONTWAIT, NULL, 0) = %s\n",
-              fd, nlh->nlmsg_len, nlh->nlmsg_len, sprintrc(rc));
+              fd, NLMSG_HDRLEN + 2, NLMSG_HDRLEN + 2, sprintrc(rc));
 
        /* error message with room for the error code only */
        nlh = nlh0 - sizeof(err->error);