From cde6d0deed1b1e27ed13cc419500a31f1a498961 Mon Sep 17 00:00:00 2001 From: goldsimon Date: Mon, 30 Apr 2007 11:56:48 +0000 Subject: [PATCH] pbuf_alloc() / pbuf_realloc(): added LWIP_DEBUG_ASSERT() and cast operator when assigning s32_t to u16_t to get rid of compiler warnings --- src/core/pbuf.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/core/pbuf.c b/src/core/pbuf.c index fcc7383b..e476450c 100644 --- a/src/core/pbuf.c +++ b/src/core/pbuf.c @@ -290,9 +290,10 @@ pbuf_alloc(pbuf_layer l, u16_t length, pbuf_flag flag) /* make previous pbuf point to this pbuf */ r->next = q; /* set total length of this pbuf and next in chain */ - q->tot_len = rem_len; + LWIP_DEBUG_ASSERT("rem_len < max_u16_t",rem_len < 0xffff); + q->tot_len = (u16_t)rem_len; /* this pbuf length is pool size, unless smaller sized tail */ - q->len = rem_len > PBUF_POOL_BUFSIZE? PBUF_POOL_BUFSIZE: rem_len; + q->len = rem_len > PBUF_POOL_BUFSIZE? PBUF_POOL_BUFSIZE: (u16_t)rem_len; q->payload = (void *)((u8_t *)q + sizeof(struct pbuf)); LWIP_ASSERT("pbuf_alloc: pbuf q->payload properly aligned", ((mem_ptr_t)q->payload % MEM_ALIGNMENT) == 0); @@ -420,7 +421,8 @@ pbuf_realloc(struct pbuf *p, u16_t new_len) /* decrease remaining length by pbuf length */ rem_len -= q->len; /* decrease total length indicator */ - q->tot_len += grow; + LWIP_DEBUG_ASSERT("grow < max_u16_t",grow < 0xffff); + q->tot_len += (u16_t)grow; /* proceed to next pbuf in chain */ q = q->next; }