mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-11-06 20:29:04 +00:00
Done some work on task #6933: converted some LWIP_ASSERTs to LWIP_ERROR to give back an error return value for LWIP_NOASSERT=1
This commit is contained in:
parent
ced2543be0
commit
6784fd64f3
@ -1356,7 +1356,9 @@ static void dhcp_delete_request(struct netif *netif)
|
||||
LWIP_ERROR("dhcp_create_request: dhcp == NULL", (dhcp == NULL), return;);
|
||||
LWIP_ASSERT("dhcp_free_msg: dhcp->p_out != NULL", dhcp->p_out != NULL);
|
||||
LWIP_ASSERT("dhcp_free_msg: dhcp->msg_out != NULL", dhcp->msg_out != NULL);
|
||||
pbuf_free(dhcp->p_out);
|
||||
if (dhcp->p_out != NULL) {
|
||||
pbuf_free(dhcp->p_out);
|
||||
}
|
||||
dhcp->p_out = NULL;
|
||||
dhcp->msg_out = NULL;
|
||||
}
|
||||
|
@ -194,7 +194,7 @@ 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 */
|
||||
LWIP_ASSERT("rem_len < max_u16_t",rem_len < 0xffff);
|
||||
LWIP_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_ALIGNED) ? PBUF_POOL_BUFSIZE_ALIGNED : (u16_t)rem_len;
|
||||
@ -302,7 +302,7 @@ pbuf_realloc(struct pbuf *p, u16_t new_len)
|
||||
/* decrease remaining length by pbuf length */
|
||||
rem_len -= q->len;
|
||||
/* decrease total length indicator */
|
||||
LWIP_ASSERT("grow < max_u16_t",grow < 0xffff);
|
||||
LWIP_ASSERT("grow < max_u16_t", grow < 0xffff);
|
||||
q->tot_len += (u16_t)grow;
|
||||
/* proceed to next pbuf in chain */
|
||||
q = q->next;
|
||||
@ -357,15 +357,17 @@ pbuf_header(struct pbuf *p, s16_t header_size_increment)
|
||||
u16_t increment_magnitude;
|
||||
|
||||
LWIP_ASSERT("p != NULL", p != NULL);
|
||||
if ((header_size_increment == 0) || (p == NULL)) return 0;
|
||||
if ((header_size_increment == 0) || (p == NULL))
|
||||
return 0;
|
||||
|
||||
if (header_size_increment < 0){
|
||||
increment_magnitude = -header_size_increment;
|
||||
increment_magnitude = header_size_increment;
|
||||
if (increment_magnitude < 0){
|
||||
increment_magnitude = -increment_magnitude;
|
||||
/* Check that we aren't going to move off the end of the pbuf */
|
||||
LWIP_ASSERT("increment_magnitude <= p->len", increment_magnitude <= p->len);
|
||||
LWIP_ERROR("increment_magnitude > p->len", (increment_magnitude > p->len), return 1;);
|
||||
} else {
|
||||
increment_magnitude = header_size_increment;
|
||||
#if 0 /* Can't assert these as some callers speculatively call
|
||||
#if 0
|
||||
/* Can't assert these as some callers speculatively call
|
||||
pbuf_header() to see if it's OK. Will return 1 below instead. */
|
||||
/* Check that we've got the correct type of pbuf to work with */
|
||||
LWIP_ASSERT("p->flags == PBUF_FLAG_RAM || p->flags == PBUF_FLAG_POOL",
|
||||
@ -415,7 +417,7 @@ pbuf_header(struct pbuf *p, s16_t header_size_increment)
|
||||
p->len += header_size_increment;
|
||||
p->tot_len += header_size_increment;
|
||||
|
||||
LWIP_DEBUGF( PBUF_DEBUG, ("pbuf_header: old %p new %p (%"S16_F")\n",
|
||||
LWIP_DEBUGF(PBUF_DEBUG, ("pbuf_header: old %p new %p (%"S16_F")\n",
|
||||
(void *)payload, (void *)p->payload, header_size_increment));
|
||||
|
||||
return 0;
|
||||
@ -461,9 +463,9 @@ pbuf_free(struct pbuf *p)
|
||||
struct pbuf *q;
|
||||
u8_t count;
|
||||
|
||||
LWIP_ASSERT("p != NULL", p != NULL);
|
||||
/* if assertions are disabled, proceed with debug output */
|
||||
if (p == NULL) {
|
||||
LWIP_ASSERT("p != NULL", p != NULL);
|
||||
/* if assertions are disabled, proceed with debug output */
|
||||
LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE | 2, ("pbuf_free(p == NULL) was called.\n"));
|
||||
return 0;
|
||||
}
|
||||
@ -575,9 +577,8 @@ pbuf_cat(struct pbuf *h, struct pbuf *t)
|
||||
{
|
||||
struct pbuf *p;
|
||||
|
||||
LWIP_ASSERT("h != NULL (programmer violates API)", h != NULL);
|
||||
LWIP_ASSERT("t != NULL (programmer violates API)", t != NULL);
|
||||
if ((h == NULL) || (t == NULL)) return;
|
||||
LWIP_ERROR("(h == NULL) || (t == NULL) (programmer violates API)",
|
||||
((h == NULL) || (t == NULL)), return;);
|
||||
|
||||
/* proceed to last pbuf of chain */
|
||||
for (p = h; p->next != NULL; p = p->next) {
|
||||
@ -688,12 +689,8 @@ pbuf_copy(struct pbuf *p_to, struct pbuf *p_from)
|
||||
LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE | 3, ("pbuf_copy(%p, %p)\n", p_to, p_from));
|
||||
|
||||
/* is the target big enough to hold the source? */
|
||||
if ((p_to == NULL) || (p_from == NULL) || (p_to->tot_len < p_from->tot_len)) {
|
||||
LWIP_ASSERT("pbuf_copy: p_to != NULL\n", p_to != NULL);
|
||||
LWIP_ASSERT("pbuf_copy: p_from != NULL\n", p_from != NULL);
|
||||
LWIP_ASSERT("pbuf_copy: p_to->tot_len >= p_from->tot_len\n", p_to->tot_len >= p_from->tot_len);
|
||||
return ERR_ARG;
|
||||
}
|
||||
LWIP_ERROR("pbuf_copy: target not big enough to hold source", ((p_to == NULL) ||
|
||||
(p_from == NULL) || (p_to->tot_len < p_from->tot_len)), return ERR_ARG;);
|
||||
#ifdef LWIP_DEBUG
|
||||
shouldbe = p_from->tot_len;
|
||||
#endif
|
||||
@ -731,19 +728,13 @@ pbuf_copy(struct pbuf *p_to, struct pbuf *p_from)
|
||||
|
||||
if((p_from != NULL) && (p_from->len == p_from->tot_len)) {
|
||||
/* don't copy more than one packet! */
|
||||
if (p_from->next != NULL) {
|
||||
LWIP_ASSERT("pbuf_copy() does not allow packet queues!\n",
|
||||
p_from->next == NULL);
|
||||
return ERR_VAL;
|
||||
}
|
||||
LWIP_ERROR("pbuf_copy() does not allow packet queues!\n",
|
||||
(p_from->next != NULL), return ERR_VAL;);
|
||||
}
|
||||
if((p_to != NULL) && (p_to->len == p_to->tot_len)) {
|
||||
/* don't copy more than one packet! */
|
||||
if (p_to->next != NULL) {
|
||||
LWIP_ASSERT("pbuf_copy() does not allow packet queues!\n",
|
||||
p_to->next == NULL);
|
||||
return ERR_VAL;
|
||||
}
|
||||
LWIP_ERROR("pbuf_copy() does not allow packet queues!\n",
|
||||
(p_to->next != NULL), return ERR_VAL;);
|
||||
}
|
||||
} while (p_from);
|
||||
LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE | 1, ("pbuf_copy: end of chain reached.\n"));
|
||||
|
@ -198,9 +198,10 @@ sys_timeout(u32_t msecs, sys_timeout_handler h, void *arg)
|
||||
LWIP_DEBUGF(SYS_DEBUG, ("sys_timeout: %p msecs=%"U32_F" h=%p arg=%p\n",
|
||||
(void *)timeout, msecs, (void *)h, (void *)arg));
|
||||
|
||||
LWIP_ASSERT("sys_timeout: timeouts != NULL", timeouts != NULL);
|
||||
if (timeouts == NULL)
|
||||
if (timeouts == NULL) {
|
||||
LWIP_ASSERT("sys_timeout: timeouts != NULL", timeouts != NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
if (timeouts->next == NULL) {
|
||||
timeouts->next = timeout;
|
||||
@ -244,11 +245,13 @@ sys_untimeout(sys_timeout_handler h, void *arg)
|
||||
|
||||
timeouts = sys_arch_timeouts();
|
||||
|
||||
LWIP_ASSERT("sys_untimeout: timeouts != NULL", timeouts != NULL);
|
||||
if (timeouts == NULL)
|
||||
if (timeouts == NULL) {
|
||||
LWIP_ASSERT("sys_untimeout: timeouts != NULL", timeouts != NULL);
|
||||
return;
|
||||
if (timeouts->next == NULL)
|
||||
}
|
||||
if (timeouts->next == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (t = timeouts->next, prev_t = NULL; t != NULL; prev_t = t, t = t->next) {
|
||||
if ((t->h == h) && (t->arg == arg)) {
|
||||
|
@ -654,7 +654,7 @@ tcp_slowtmr(void)
|
||||
tcp_pcb_purge(pcb);
|
||||
/* Remove PCB from tcp_active_pcbs list. */
|
||||
if (prev != NULL) {
|
||||
LWIP_ASSERT("tcp_slowtmr: middle tcp != tcp_active_pcbs", pcb != tcp_active_pcbs);
|
||||
LWIP_ASSERT("tcp_slowtmr: middle tcp != tcp_active_pcbs", pcb != tcp_active_pcbs);
|
||||
prev->next = pcb->next;
|
||||
} else {
|
||||
/* This PCB was the first. */
|
||||
@ -705,7 +705,7 @@ tcp_slowtmr(void)
|
||||
tcp_pcb_purge(pcb);
|
||||
/* Remove PCB from tcp_tw_pcbs list. */
|
||||
if (prev != NULL) {
|
||||
LWIP_ASSERT("tcp_slowtmr: middle tcp != tcp_tw_pcbs", pcb != tcp_tw_pcbs);
|
||||
LWIP_ASSERT("tcp_slowtmr: middle tcp != tcp_tw_pcbs", pcb != tcp_tw_pcbs);
|
||||
prev->next = pcb->next;
|
||||
} else {
|
||||
/* This PCB was the first. */
|
||||
|
@ -137,10 +137,10 @@ tcp_enqueue(struct tcp_pcb *pcb, void *arg, u16_t len,
|
||||
|
||||
LWIP_DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_enqueue(pcb=%p, arg=%p, len=%"U16_F", flags=%"X16_F", copy=%"U16_F")\n",
|
||||
(void *)pcb, arg, len, (u16_t)flags, (u16_t)copy));
|
||||
LWIP_ASSERT("tcp_enqueue: len == 0 || optlen == 0 (programmer violates API)",
|
||||
len == 0 || optlen == 0);
|
||||
LWIP_ASSERT("tcp_enqueue: arg == NULL || optdata == NULL (programmer violates API)",
|
||||
arg == NULL || optdata == NULL);
|
||||
LWIP_ERROR("tcp_enqueue: len != 0 && optlen != 0 (programmer violates API)",
|
||||
(len != 0 && optlen != 0), return ERR_ARG;);
|
||||
LWIP_ERROR("tcp_enqueue: arg != NULL && optdata != NULL (programmer violates API)",
|
||||
(arg != NULL && optdata != NULL), return ERR_ARG;);
|
||||
/* fail on too much data */
|
||||
if (len > pcb->snd_buf) {
|
||||
LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 3, ("tcp_enqueue: too much data (len=%"U16_F" > snd_buf=%"U16_F")\n", len, pcb->snd_buf));
|
||||
|
@ -403,7 +403,7 @@ update_arp_entry(struct netif *netif, struct ip_addr *ipaddr, struct eth_addr *e
|
||||
s8_t i;
|
||||
u8_t k;
|
||||
LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE | 3, ("update_arp_entry()\n"));
|
||||
LWIP_ASSERT("netif->hwaddr_len != 0", netif->hwaddr_len != 0);
|
||||
LWIP_ASSERT("netif->hwaddr_len == 6", netif->hwaddr_len == 6);
|
||||
LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("update_arp_entry: %"U16_F".%"U16_F".%"U16_F".%"U16_F" - %02"X16_F":%02"X16_F":%02"X16_F":%02"X16_F":%02"X16_F":%02"X16_F"\n",
|
||||
ip4_addr1(ipaddr), ip4_addr2(ipaddr), ip4_addr3(ipaddr), ip4_addr4(ipaddr),
|
||||
ethaddr->addr[0], ethaddr->addr[1], ethaddr->addr[2],
|
||||
@ -516,7 +516,7 @@ void
|
||||
etharp_ip_input(struct netif *netif, struct pbuf *p)
|
||||
{
|
||||
struct ethip_hdr *hdr;
|
||||
LWIP_ASSERT("netif != NULL", netif != NULL);
|
||||
LWIP_ERROR("netif == NULL", (netif == NULL), return;);
|
||||
/* Only insert an entry if the source IP address of the
|
||||
incoming IP packet comes from a host on the local network. */
|
||||
hdr = p->payload;
|
||||
@ -558,7 +558,7 @@ etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr, struct pbuf *p)
|
||||
u8_t i;
|
||||
u8_t for_us;
|
||||
|
||||
LWIP_ASSERT("netif != NULL", netif != NULL);
|
||||
LWIP_ERROR("netif == NULL", (netif == NULL), return;);
|
||||
|
||||
/* drop short ARP packets */
|
||||
if (p->tot_len < sizeof(struct etharp_hdr)) {
|
||||
@ -858,8 +858,8 @@ etharp_query(struct netif *netif, struct ip_addr *ipaddr, struct pbuf *q)
|
||||
* PBUF_ROMs can be left as they are, since ROM must not get changed. */
|
||||
p = q;
|
||||
while(p) {
|
||||
LWIP_ASSERT("no packet queues allowed!", (p->len == p->tot_len) || (p->next == 0));
|
||||
if(p->len == p->tot_len) {
|
||||
LWIP_ASSERT("no packet queues allowed!", p->next == 0);
|
||||
}
|
||||
if(p->flags != PBUF_FLAG_ROM) {
|
||||
copy_needed = 1;
|
||||
|
@ -64,10 +64,7 @@ loopif_poll(struct netif *netif)
|
||||
struct pbuf *in = NULL;
|
||||
struct loopif_private *priv = (struct loopif_private*)netif->state;
|
||||
|
||||
LWIP_ASSERT("priv != NULL", priv != NULL);
|
||||
if(priv == NULL) {
|
||||
return;
|
||||
}
|
||||
LWIP_ERROR("priv == NULL", (priv == NULL), return;);
|
||||
|
||||
do {
|
||||
/* Get a packet from the list. With SYS_LIGHTWEIGHT_PROT=1, this is protected */
|
||||
@ -161,7 +158,7 @@ loopif_output(struct netif *netif, struct pbuf *p,
|
||||
|
||||
SYS_ARCH_PROTECT(lev);
|
||||
if(priv->first != NULL) {
|
||||
LWIP_ASSERT("if first!=NULL, last must also be != NULL", priv->last != NULL);
|
||||
LWIP_ASSERT("if first != NULL, last must also be != NULL", priv->last != NULL);
|
||||
priv->last->next = r;
|
||||
priv->last = r;
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user