From 9c77370f6eba59e5bd05a1fa67af1393a039f435 Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke Date: Fri, 14 Aug 2020 13:28:45 +0200 Subject: [PATCH] fixup! sys/net/ipv6: Simplify type ipv6_addr_t --- sys/net/network_layer/ipv6/addr/ipv6_addr_to_str.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/sys/net/network_layer/ipv6/addr/ipv6_addr_to_str.c b/sys/net/network_layer/ipv6/addr/ipv6_addr_to_str.c index 904a8ec892818..db2cf4339e801 100644 --- a/sys/net/network_layer/ipv6/addr/ipv6_addr_to_str.c +++ b/sys/net/network_layer/ipv6/addr/ipv6_addr_to_str.c @@ -54,8 +54,8 @@ char *ipv6_addr_to_str(char *result, const ipv6_addr_t *addr, uint8_t result_len * Preprocess: * Find the longest run of 0x0000's in address for :: shorthanding. */ - for (uint8_t i = 0; i < sizeof(*addr); i += 2) { - if ((addr->u8[i] == 0) && (addr->u8[i+1] == 0)) { + for (uint8_t i = 0; i < IPV6_ADDR_WORD_LEN; i++) { + if ((addr->u8[2 * i] == 0) && (addr->u8[2 * i+1] == 0)) { if (cur.base == -1) { cur.base = i; cur.len = 1; @@ -106,8 +106,9 @@ char *ipv6_addr_to_str(char *result, const ipv6_addr_t *addr, uint8_t result_len #ifdef MODULE_IPV4_ADDR /* Is this address an encapsulated IPv4? */ if (i == 6 && best.base == 0 && - (best.len == 6 || (best.len == 5 && addr->u16[5].u16 == 0xffff))) { - if (!ipv4_addr_to_str(tp, (const ipv4_addr_t *)&addr->u32[3], + (best.len == 6 || (best.len == 5 && addr->u8[10] == 0xff && + addr->u8[11] == 0xff))) { + if (!ipv4_addr_to_str(tp, (const ipv4_addr_t *)&addr->u8[12], sizeof(tmp) - (tp - tmp))) { return (NULL); }