From 9ff7d2969682ddfc9fbb7c1a31338916878ae665 Mon Sep 17 00:00:00 2001 From: goldsimon Date: Tue, 2 Feb 2010 20:14:05 +0000 Subject: [PATCH] Fixed compiler warnings when MEM_SIZE < 64000 --- src/core/dns.c | 4 ++-- src/core/mem.c | 12 ++++++------ src/core/pbuf.c | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/core/dns.c b/src/core/dns.c index 871a8233..d672bae1 100644 --- a/src/core/dns.c +++ b/src/core/dns.c @@ -342,7 +342,7 @@ dns_init_local() struct local_hostlist_entry *init_entry = &local_hostlist_init[i]; LWIP_ASSERT("invalid host name (NULL)", init_entry->name != NULL); namelen = strlen(init_entry->name); - entry = mem_malloc(sizeof(struct local_hostlist_entry) + namelen + 1); + entry = mem_malloc((mem_size_t)(sizeof(struct local_hostlist_entry) + namelen + 1)); LWIP_ASSERT("mem-error in dns_init_local", entry != NULL); if (entry != NULL) { entry->name = (char*)entry + sizeof(struct local_hostlist_entry); @@ -436,7 +436,7 @@ dns_local_addhost(const char *hostname, const struct ip_addr *addr) size_t namelen; LWIP_ASSERT("invalid host name (NULL)", hostname != NULL); namelen = strlen(hostname); - entry = mem_malloc(sizeof(struct local_hostlist_entry) + namelen + 1); + entry = mem_malloc((mem_size_t)(sizeof(struct local_hostlist_entry) + namelen + 1)); if (entry == NULL) { return ERR_MEM; } diff --git a/src/core/mem.c b/src/core/mem.c index 2ab94745..a0f5d26e 100644 --- a/src/core/mem.c +++ b/src/core/mem.c @@ -248,7 +248,7 @@ plug_holes(struct mem *mem) lfree = mem; } mem->next = nmem->next; - ((struct mem *)&ram[nmem->next])->prev = (u8_t *)mem - ram; + ((struct mem *)&ram[nmem->next])->prev = (mem_size_t)((u8_t *)mem - ram); } /* plug hole backward */ @@ -259,7 +259,7 @@ plug_holes(struct mem *mem) lfree = pmem; } pmem->next = mem->next; - ((struct mem *)&ram[mem->next])->prev = (u8_t *)pmem - ram; + ((struct mem *)&ram[mem->next])->prev = (mem_size_t)((u8_t *)pmem - ram); } } @@ -339,7 +339,7 @@ mem_free(void *rmem) lfree = mem; } - MEM_STATS_DEC_USED(used, mem->next - ((u8_t *)mem - ram)); + MEM_STATS_DEC_USED(used, mem->next - (mem_size_t)(((u8_t *)mem - ram))); /* finally, see if prev or next are free also */ plug_holes(mem); @@ -398,7 +398,7 @@ mem_realloc(void *rmem, mem_size_t newsize) /* Get the corresponding struct mem ... */ mem = (struct mem *)((u8_t *)rmem - SIZEOF_STRUCT_MEM); /* ... and its offset pointer */ - ptr = (u8_t *)mem - ram; + ptr = (mem_size_t)((u8_t *)mem - ram); size = mem->next - ptr - SIZEOF_STRUCT_MEM; LWIP_ASSERT("mem_realloc can only shrink memory", newsize <= size); @@ -525,7 +525,7 @@ mem_malloc(mem_size_t size) /* Scan through the heap searching for a free block that is big enough, * beginning with the lowest free block. */ - for (ptr = (u8_t *)lfree - ram; ptr < MEM_SIZE_ALIGNED - size; + for (ptr = (mem_size_t)((u8_t *)lfree - ram); ptr < MEM_SIZE_ALIGNED - size; ptr = ((struct mem *)&ram[ptr])->next) { mem = (struct mem *)&ram[ptr]; #if LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT @@ -578,7 +578,7 @@ mem_malloc(mem_size_t size) * will always be used at this point! */ mem->used = 1; - MEM_STATS_INC_USED(used, mem->next - ((u8_t *)mem - ram)); + MEM_STATS_INC_USED(used, mem->next - (mem_size_t)((u8_t *)mem - ram)); } if (mem == lfree) { diff --git a/src/core/pbuf.c b/src/core/pbuf.c index 2557eb37..8f415d54 100644 --- a/src/core/pbuf.c +++ b/src/core/pbuf.c @@ -383,7 +383,7 @@ pbuf_realloc(struct pbuf *p, u16_t new_len) /* (other types merely adjust their length fields */ if ((q->type == PBUF_RAM) && (rem_len != q->len)) { /* reallocate and adjust the length of the pbuf that will be split */ - q = (struct pbuf *)mem_realloc(q, (u8_t *)q->payload - (u8_t *)q + rem_len); + q = (struct pbuf *)mem_realloc(q, (u16_t)((u8_t *)q->payload - (u8_t *)q) + rem_len); LWIP_ASSERT("mem_realloc give q == NULL", q != NULL); } /* adjust length fields for new last pbuf */