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: 06aafabf14 ('platform/test: add test adding IPv4 addresses that only differ by their peer-address')
(cherry picked from commit 40dd8bf93a)
This commit is contained in:
Thomas Haller 2023-03-03 19:15:06 +01:00
parent fb4de0013a
commit adca87aba9
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -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,