From: Roy Marples Date: Sun, 26 Apr 2020 20:05:06 +0000 (+0100) Subject: Align more CMSG foo. X-Git-Tag: v9.1.0~109 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=29024d0ba64010eb85ad0d164898b7751d47d1cb;p=thirdparty%2Fdhcpcd.git Align more CMSG foo. --- diff --git a/src/dhcp6.c b/src/dhcp6.c index 2956f683..0f2f324b 100644 --- a/src/dhcp6.c +++ b/src/dhcp6.c @@ -1219,7 +1219,10 @@ dhcp6_sendmessage(struct interface *ifp, void (*callback)(void *)) struct iovec iov = { .iov_base = state->send, .iov_len = state->send_len, }; - unsigned char ctl[CMSG_SPACE(sizeof(struct in6_pktinfo))] = { 0 }; + union { + struct cmsghdr hdr; + uint8_t buf[CMSG_SPACE(sizeof(struct in6_pktinfo))]; + } cmsgbuf = { .buf = { 0 } }; struct msghdr msg = { .msg_name = &dst, .msg_namelen = sizeof(dst), .msg_iov = &iov, .msg_iovlen = 1, @@ -1328,8 +1331,8 @@ dhcp6_sendmessage(struct interface *ifp, void (*callback)(void *)) struct in6_pktinfo pi = { .ipi6_ifindex = ifp->index }; dst.sin6_scope_id = ifp->index; - msg.msg_control = ctl; - msg.msg_controllen = sizeof(ctl); + msg.msg_control = cmsgbuf.buf; + msg.msg_controllen = sizeof(cmsgbuf.buf); cm = CMSG_FIRSTHDR(&msg); if (cm == NULL) /* unlikely */ return -1; diff --git a/src/if-linux.c b/src/if-linux.c index 8d397ebc..c2e7b9a7 100644 --- a/src/if-linux.c +++ b/src/if-linux.c @@ -1673,14 +1673,17 @@ bpf_read(struct interface *ifp, int s, void *data, size_t len, }; struct msghdr msg = { .msg_iov = &iov, .msg_iovlen = 1 }; #ifdef PACKET_AUXDATA - unsigned char cmsgbuf[CMSG_LEN(sizeof(struct tpacket_auxdata))] = { 0 }; + union { + struct cmsghdr hdr; + uint8_t buf[CMSG_SPACE(sizeof(struct tpacket_auxdata))]; + } cmsgbuf = { .buf = { 0 } }; struct cmsghdr *cmsg; struct tpacket_auxdata *aux; #endif #ifdef PACKET_AUXDATA - msg.msg_control = cmsgbuf; - msg.msg_controllen = sizeof(cmsgbuf); + msg.msg_control = cmsgbuf.buf; + msg.msg_controllen = sizeof(cmsgbuf.buf); #endif bytes = recvmsg(s, &msg, 0); diff --git a/src/ipv6nd.c b/src/ipv6nd.c index faf31561..99e92aaf 100644 --- a/src/ipv6nd.c +++ b/src/ipv6nd.c @@ -328,11 +328,14 @@ ipv6nd_sendrsprobe(void *arg) .sin6_scope_id = ifp->index, }; struct iovec iov = { .iov_base = state->rs, .iov_len = state->rslen }; - unsigned char ctl[CMSG_SPACE(sizeof(struct in6_pktinfo))] = { 0 }; + union { + struct cmsghdr hdr; + uint8_t buf[CMSG_SPACE(sizeof(struct in6_pktinfo))]; + } cmsgbuf = { .buf = { 0 } }; struct msghdr msg = { .msg_name = &dst, .msg_namelen = sizeof(dst), .msg_iov = &iov, .msg_iovlen = 1, - .msg_control = ctl, .msg_controllen = sizeof(ctl), + .msg_control = cmsgbuf.buf, .msg_controllen = sizeof(cmsgbuf.buf), }; struct cmsghdr *cm; struct in6_pktinfo pi = { .ipi6_ifindex = ifp->index }; @@ -402,11 +405,14 @@ ipv6nd_sendadvertisement(void *arg) .sin6_scope_id = ifp->index, }; struct iovec iov = { .iov_base = ia->na, .iov_len = ia->na_len }; - unsigned char ctl[CMSG_SPACE(sizeof(struct in6_pktinfo))] = { 0 }; + union { + struct cmsghdr hdr; + uint8_t buf[CMSG_SPACE(sizeof(struct in6_pktinfo))]; + } cmsgbuf = { .buf = { 0 } }; struct msghdr msg = { .msg_name = &dst, .msg_namelen = sizeof(dst), .msg_iov = &iov, .msg_iovlen = 1, - .msg_control = ctl, .msg_controllen = sizeof(ctl), + .msg_control = cmsgbuf.buf, .msg_controllen = sizeof(cmsgbuf.buf), }; struct cmsghdr *cm; struct in6_pktinfo pi = { .ipi6_ifindex = ifp->index };