]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD: quic: fix warning during compilation using gcc-6.5
authorEmeric Brun <ebrun@haproxy.com>
Mon, 17 Jul 2023 16:33:44 +0000 (18:33 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 19 Jul 2023 06:58:55 +0000 (08:58 +0200)
Building with gcc-6.5:

src/quic_conn.c: In function 'send_retry':
src/quic_conn.c:6554:2: error: dereferencing type-punned pointer will break
strict-aliasing rules [-Werror=strict-aliasing]
   *((uint32_t *)((unsigned char *)&buf[i])) = htonl(qv->num);

This patch use write_n32 to set the value.

This could be backported until v2.6

src/quic_conn.c

index 5ec8f0d9e092ed5a2d0c9e4333fb4e656f731b42..8a9f8ebd30a036479ae3f01c2dcc495e39c9d501 100644 (file)
@@ -6552,7 +6552,7 @@ static int send_retry(int fd, struct sockaddr_storage *addr,
                (quic_pkt_type(QUIC_PACKET_TYPE_RETRY, qv->num) << QUIC_PACKET_TYPE_SHIFT) |
                statistical_prng_range(16);
        /* version */
-       *(uint32_t *)&buf[i] = htonl(qv->num);
+       write_n32(&buf[i], qv->num);
        i += sizeof(uint32_t);
 
        /* Use the SCID from <pkt> for Retry DCID. */