From adca87aba9226c70470e3789f8dc6f393e348014 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 3 Mar 2023 19:15:06 +0100 Subject: [PATCH] platform/tests: avoid accessing in_addr_t via NMIPAddr union The compiler may dislike this: CC src/core/platform/tests/libNetworkManagerTest_la-test-common.lo In function '_ip_address_add', inlined from 'nmtstp_ip4_address_add' at ../src/core/platform/tests/test-common.c:1892:5: ../src/core/platform/tests/test-common.c:1807:63: error: array subscript 'NMIPAddr {aka const struct _NMIPAddr}[0]' is partly outside array bounds of 'in_addr_t[1]' {aka 'unsigned int[1]'} [-Werror=array-bounds] 1807 | peer_address->addr4, | ~~~~~~~~~~~~^~~~~~~ ../src/core/platform/tests/test-common.c: In function 'nmtstp_ip4_address_add': ../src/core/platform/tests/test-common.c:1886:36: note: object 'peer_address' of size 4 1886 | in_addr_t peer_address, | ~~~~~~~~~~~~^~~~~~~~~~~~ ... Fixes: 06aafabf14e6 ('platform/test: add test adding IPv4 addresses that only differ by their peer-address') (cherry picked from commit 40dd8bf93a2757c4ccc2d3c354cfc1fefb05839a) --- src/core/platform/tests/test-common.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/core/platform/tests/test-common.c b/src/core/platform/tests/test-common.c index a37982fc69..571fedfee5 100644 --- a/src/core/platform/tests/test-common.c +++ b/src/core/platform/tests/test-common.c @@ -1891,9 +1891,13 @@ nmtstp_ip4_address_add(NMPlatform *platform, external_command, TRUE, ifindex, - (NMIPAddr *) &address, + &((NMIPAddr){ + .addr4 = address, + }), plen, - (NMIPAddr *) &peer_address, + &((NMIPAddr){ + .addr4 = peer_address, + }), lifetime, preferred, flags,