From 087ecab8913dc3e17a4ba22633ef7b78a80b8a56 Mon Sep 17 00:00:00 2001 From: Dirk Ziegelmeier Date: Thu, 7 Jul 2016 21:56:43 +0200 Subject: [PATCH] Add some comments to places where we cast through a void* to get rid of alignment warnings --- src/api/netdb.c | 1 + src/core/mem.c | 3 +++ src/core/tcp_out.c | 1 + 3 files changed, 5 insertions(+) diff --git a/src/api/netdb.c b/src/api/netdb.c index c6edf837..6aeab9a5 100644 --- a/src/api/netdb.c +++ b/src/api/netdb.c @@ -364,6 +364,7 @@ lwip_getaddrinfo(const char *nodename, const char *servname, return EAI_MEMORY; } memset(ai, 0, total_size); + /* cast through void* to get rid of alignment warnings */ sa = (struct sockaddr_storage *)(void*)((u8_t*)ai + sizeof(struct addrinfo)); if (IP_IS_V6_VAL(addr)) { #if LWIP_IPV6 diff --git a/src/core/mem.c b/src/core/mem.c index d3d97e35..7f6f2ffe 100644 --- a/src/core/mem.c +++ b/src/core/mem.c @@ -145,6 +145,7 @@ mem_free(void *rmem) LWIP_ASSERT("rmem == MEM_ALIGN(rmem)", (rmem == LWIP_MEM_ALIGN(rmem))); /* get the original struct memp_malloc_helper */ + /* cast through void* to get rid of alignment warnings */ hmem = (struct memp_malloc_helper*)(void*)((u8_t*)rmem - LWIP_MEM_ALIGN_SIZE(sizeof(struct memp_malloc_helper))); LWIP_ASSERT("hmem != NULL", (hmem != NULL)); @@ -357,6 +358,7 @@ mem_free(void *rmem) /* protect the heap from concurrent access */ LWIP_MEM_FREE_PROTECT(); /* Get the corresponding struct mem ... */ + /* cast through void* to get rid of alignment warnings */ mem = (struct mem *)(void *)((u8_t *)rmem - SIZEOF_STRUCT_MEM); /* ... which has to be in a used state ... */ LWIP_ASSERT("mem_free: mem->used", mem->used); @@ -423,6 +425,7 @@ mem_trim(void *rmem, mem_size_t newsize) return rmem; } /* Get the corresponding struct mem ... */ + /* cast through void* to get rid of alignment warnings */ mem = (struct mem *)(void *)((u8_t *)rmem - SIZEOF_STRUCT_MEM); /* ... and its offset pointer */ ptr = (mem_size_t)((u8_t *)mem - ram); diff --git a/src/core/tcp_out.c b/src/core/tcp_out.c index 7fa8a0ff..6d773303 100644 --- a/src/core/tcp_out.c +++ b/src/core/tcp_out.c @@ -1174,6 +1174,7 @@ tcp_output_segment(struct tcp_seg *seg, struct tcp_pcb *pcb, struct netif *netif /* Add any requested options. NB MSS option is only set on SYN packets, so ignore it here */ + /* cast through void* to get rid of alignment warnings */ opts = (u32_t *)(void *)(seg->tcphdr + 1); if (seg->flags & TF_SEG_OPTS_MSS) { u16_t mss;