From 3e4512bc80580776423680ea75bba924f7a6c2e0 Mon Sep 17 00:00:00 2001 From: Christian Kreibich Date: Fri, 2 Sep 2022 16:10:55 -0700 Subject: [PATCH] src/3rdparty: Fix GCC 12.2 warning in access to patricia_t members Access to members of the larger prefix_t, while safe, throws warnings when the compiler knows it previously allocated the smaller prefix4_t. Adapted from 11ae12079ca716f8cfac42cccfd905dad45da18f in the upstream repo. --- src/3rdparty/patricia.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/3rdparty/patricia.c b/src/3rdparty/patricia.c index 5dde49bda7..2384bfc49a 100644 --- a/src/3rdparty/patricia.c +++ b/src/3rdparty/patricia.c @@ -209,6 +209,7 @@ prefix_t *New_Prefix2(int family, void *dest, int bitlen, prefix_t *prefix) { int dynamic_allocated = 0; int default_bitlen = sizeof(struct in_addr) * 8; + prefix4_t *p4 = NULL; #ifdef HAVE_IPV6 if (family == AF_INET6) { @@ -243,11 +244,12 @@ prefix_t *New_Prefix2(int family, void *dest, int bitlen, prefix_t *prefix) return (NULL); } - prefix->bitlen = (bitlen >= 0) ? bitlen : default_bitlen; - prefix->family = family; - prefix->ref_count = 0; + p4 = (prefix4_t*) prefix; + p4->bitlen = (bitlen >= 0) ? bitlen : default_bitlen; + p4->family = family; + p4->ref_count = 0; if (dynamic_allocated) { - prefix->ref_count++; + p4->ref_count++; } /* fprintf(stderr, "[C %s, %d]\n", prefix_toa (prefix), prefix->ref_count); */