From 57622fffb7e74065f4a7b32d37acd44299fe9759 Mon Sep 17 00:00:00 2001 From: Vladislav Grishenko Date: Sun, 31 Jan 2016 21:03:00 +0500 Subject: [PATCH] Use more conventional way for the alignment --- src/dhcpv6.c | 8 +++++--- src/ra.c | 7 +++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/dhcpv6.c b/src/dhcpv6.c index 3e128bc..5998b75 100644 --- a/src/dhcpv6.c +++ b/src/dhcpv6.c @@ -586,12 +586,14 @@ int dhcpv6_request(enum dhcpv6_msg type) for (; len < 0 && (round_start < round_end); round_start = odhcp6c_get_milli_time()) { uint8_t buf[1536]; - uint8_t cmsg_buf[CMSG_SPACE(sizeof(struct in6_pktinfo))] - __aligned(__alignof__(struct cmsghdr)); + union { + struct cmsghdr hdr; + uint8_t buf[CMSG_SPACE(sizeof(struct in6_pktinfo))]; + } cmsg_buf; struct iovec iov = {buf, sizeof(buf)}; struct sockaddr_in6 addr; struct msghdr msg = {.msg_name = &addr, .msg_namelen = sizeof(addr), - .msg_iov = &iov, .msg_iovlen = 1, .msg_control = cmsg_buf, + .msg_iov = &iov, .msg_iovlen = 1, .msg_control = cmsg_buf.buf, .msg_controllen = sizeof(cmsg_buf)}; struct in6_pktinfo *pktinfo = NULL; diff --git a/src/ra.c b/src/ra.c index dd5962a..f1b102d 100644 --- a/src/ra.c +++ b/src/ra.c @@ -275,7 +275,10 @@ bool ra_process(void) bool found = false; bool changed = false; uint8_t buf[1500] __aligned(4); - uint8_t cmsg_buf[128] __aligned(__alignof__(struct cmsghdr)); + union { + struct cmsghdr hdr; + uint8_t buf[CMSG_SPACE(sizeof(int))]; + } cmsg_buf; struct nd_router_advert *adv = (struct nd_router_advert*)buf; struct odhcp6c_entry *entry = alloca(sizeof(*entry) + 256); const struct in6_addr any = IN6ADDR_ANY_INIT; @@ -302,7 +305,7 @@ bool ra_process(void) .msg_namelen = sizeof(from), .msg_iov = &iov, .msg_iovlen = 1, - .msg_control = cmsg_buf, + .msg_control = cmsg_buf.buf, .msg_controllen = sizeof(cmsg_buf), .msg_flags = 0 }; -- 2.25.1