Mercurial > hg > dhcpcd
changeset 5172:6efcf294d3a0 draft
Align more CMSG foo.
| author | Roy Marples <roy@marples.name> |
|---|---|
| date | Sun, 26 Apr 2020 21:05:06 +0100 |
| parents | 5943646f9dd3 |
| children | 81f78bbc8d48 |
| files | src/dhcp6.c src/if-linux.c src/ipv6nd.c |
| diffstat | 3 files changed, 22 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/src/dhcp6.c Sun Apr 26 17:22:42 2020 +0100 +++ b/src/dhcp6.c Sun Apr 26 21:05:06 2020 +0100 @@ -1219,7 +1219,10 @@ 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 @@ 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;
--- a/src/if-linux.c Sun Apr 26 17:22:42 2020 +0100 +++ b/src/if-linux.c Sun Apr 26 21:05:06 2020 +0100 @@ -1673,14 +1673,17 @@ }; 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);
--- a/src/ipv6nd.c Sun Apr 26 17:22:42 2020 +0100 +++ b/src/ipv6nd.c Sun Apr 26 21:05:06 2020 +0100 @@ -328,11 +328,14 @@ .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 @@ .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 };
