Skip to content

Commit 4603d72

Browse files
committed
net: Fully disable LWIP_ASSERTs
I was doing some debugging that had me looking at the disassembly of lpc_rx_queue() from within the debugger. I was looking for the call to pbuf_alloc() that we see in the following code snippet: p = pbuf_alloc(PBUF_RAW, (u16_t) EMAC_ETH_MAX_FLEN, PBUF_RAM); if (p == NULL) { LWIP_DEBUGF(UDP_LPC_EMAC | LWIP_DBG_TRACE, ("lpc_rx_queue: could not allocate RX pbuf (free desc=%d)\n", lpc_enetif->rx_free_descs)); return queued; } /* pbufs allocated from the RAM pool should be non-chained. */ LWIP_ASSERT("lpc_rx_queue: pbuf is not contiguous (chained)", pbuf_clen(p) <= 1); When I was looking through the disassembly for this code I noticed a call to pbuf_clen() in the actual machine code. => 0x0000bab0 <+24>: bl 0x44c0 <pbuf_clen> 0x0000bab4 <+28>: ldr r3, [r4, ARMmbed#112] ; 0x70 0x0000bab6 <+30>: ldrh.w r12, [r5, ARMmbed#10] 0x0000baba <+34>: add.w r2, r3, ARMmbed#9 0x0000babe <+38>: add.w r0, r12, #4294967295 ; 0xffffffff The only call to pbuf_clean made from this function is made from within the LWIP_ASSERT. When I looked more closely at how this macro was defined, I saw that the mbed version of the stack had disabled the LWIP_PLATFORM_ASSERT macro when LWIP_DEBUG was false which means that no action will be taken if the assert is false but it still allows the LWIP_ASSERT macro to potentially evaluate the assert expression. Defining the LWIP_NOASSERT macro will fully disable the LWIP_ASSERT macro. I saw one of my TCP/IP samples shrink about 0.5K when I made this change.
1 parent 2cdd41d commit 4603d72

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

libraries/net/lwip/lwip/lwipopts.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@
9999
#define MEMP_OVERFLOW_CHECK 1
100100
#define MEMP_SANITY_CHECK 1
101101
#else
102+
#define LWIP_NOASSERT 1
102103
#define LWIP_STATS 0
103104
#endif
104105

0 commit comments

Comments
 (0)