From: Emeric Brun Date: Mon, 17 Jul 2023 16:33:44 +0000 (+0200) Subject: BUILD: quic: fix warning during compilation using gcc-6.5 X-Git-Tag: v2.9-dev2~43 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c0456f45c8aa3173a503dc8d4cd0d4e4f1b29a3b;p=thirdparty%2Fhaproxy.git BUILD: quic: fix warning during compilation using gcc-6.5 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 --- diff --git a/src/quic_conn.c b/src/quic_conn.c index 5ec8f0d9e0..8a9f8ebd30 100644 --- a/src/quic_conn.c +++ b/src/quic_conn.c @@ -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 for Retry DCID. */