]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Align more CMSG foo.
authorRoy Marples <roy@marples.name>
Sun, 26 Apr 2020 20:05:06 +0000 (21:05 +0100)
committerRoy Marples <roy@marples.name>
Sun, 26 Apr 2020 20:05:06 +0000 (21:05 +0100)
src/dhcp6.c
src/if-linux.c
src/ipv6nd.c

index 2956f6831433a27dacfccd7933d4bbe93c3efc73..0f2f324b760c09a1057f19a2f545ae09c57a3685 100644 (file)
@@ -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;
index 8d397ebccd99f9d142a32ec4d129451b3301094d..c2e7b9a744ff3b396ba56799b65ea5cc39f2ac76 100644 (file)
@@ -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);
index faf31561131f1a1fcae84e8f77875eefe1916e5c..99e92aaf7844b274daebb85bbaed06f0ff9f79cb 100644 (file)
@@ -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 };