From bf8ebbac81a91977bb38931da87f5e8743cfcded Mon Sep 17 00:00:00 2001 From: Martine Lenders <m.lenders@fu-berlin.de> Date: Tue, 16 Oct 2018 12:07:03 +0200 Subject: [PATCH] tests/lwip_sock_{i,ud}p: correctly get array address We want the address of the start of the array. --- tests/lwip_sock_ip/stack.c | 11 +++++++++-- tests/lwip_sock_udp/stack.c | 11 +++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/tests/lwip_sock_ip/stack.c b/tests/lwip_sock_ip/stack.c index e4c91671eb..ad6c8a4592 100644 --- a/tests/lwip_sock_ip/stack.c +++ b/tests/lwip_sock_ip/stack.c @@ -197,9 +197,16 @@ void _net_init(void) netif_add(&netif, &netdev, lwip_netdev_init, tcpip_input); #endif #if LWIP_IPV6 - static const uint8_t local6[] = _TEST_ADDR6_LOCAL; + static const uint8_t local6_a[] = _TEST_ADDR6_LOCAL; + /* XXX need to copy into a stack variable. Otherwise, when just using + * `local6_a` this leads to weird alignment problems on some platforms with + * netif_add_ip6_address() below */ + ip6_addr_t local6; s8_t idx; - netif_add_ip6_address(&netif, (ip6_addr_t *)&local6, &idx); + + memcpy(&local6.addr, local6_a, sizeof(local6)); + ip6_addr_clear_zone(&local6); + netif_add_ip6_address(&netif, &local6, &idx); for (int i = 0; i <= idx; i++) { netif.ip6_addr_state[i] |= IP6_ADDR_VALID; } diff --git a/tests/lwip_sock_udp/stack.c b/tests/lwip_sock_udp/stack.c index 4ac890b6e3..16be189c03 100644 --- a/tests/lwip_sock_udp/stack.c +++ b/tests/lwip_sock_udp/stack.c @@ -199,9 +199,16 @@ void _net_init(void) netif_add(&netif, &netdev, lwip_netdev_init, tcpip_input); #endif #if LWIP_IPV6 - static const uint8_t local6[] = _TEST_ADDR6_LOCAL; + static const uint8_t local6_a[] = _TEST_ADDR6_LOCAL; + /* XXX need to copy into a stack variable. Otherwise, when just using + * `local6_a` this leads to weird alignment problems on some platforms with + * netif_add_ip6_address() below */ + ip6_addr_t local6; s8_t idx; - netif_add_ip6_address(&netif, (ip6_addr_t *)&local6, &idx); + + memcpy(&local6.addr, local6_a, sizeof(local6)); + ip6_addr_clear_zone(&local6); + netif_add_ip6_address(&netif, &local6, &idx); for (int i = 0; i <= idx; i++) { netif.ip6_addr_state[i] |= IP6_ADDR_VALID; } -- GitLab