From: Angus Gratton Date: Tue, 27 Jun 2017 08:36:54 +0000 (+1000) Subject: lwip: Make LWIP_ERROR behave as if assertions were off, even if they are on X-Git-Tag: v3.1-dev~506^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=857a7f186e277914038a15ae7b8724580d54cf79;p=esp-idf lwip: Make LWIP_ERROR behave as if assertions were off, even if they are on --- diff --git a/components/lwip/include/lwip/port/arch/cc.h b/components/lwip/include/lwip/port/arch/cc.h index 2b182d6410..cba0b365ea 100644 --- a/components/lwip/include/lwip/port/arch/cc.h +++ b/components/lwip/include/lwip/port/arch/cc.h @@ -37,6 +37,7 @@ #include #include #include +#include #include "arch/sys_arch.h" @@ -73,7 +74,21 @@ typedef int sys_prot_t; #ifdef NDEBUG #define LWIP_NOASSERT -#endif -//#define LWIP_ERROR +#else // Assertions enabled + +// If assertions are on, the default LWIP_ERROR handler behaviour is to +// abort w/ an assertion failure. Don't do this, instead just print the error (if LWIP_DEBUG is set) +// and run the handler (same as the LWIP_ERROR behaviour if LWIP_NOASSERT is set). +#ifdef LWIP_DEBUG +#define LWIP_ERROR(message, expression, handler) do { if (!(expression)) { \ + puts(message); handler;}} while(0) +#else +// If LWIP_DEBUG is not set, return the error silently (default LWIP behaviour, also.) +#define LWIP_ERROR(message, expression, handler) do { if (!(expression)) { \ + handler;}} while(0) +#endif // LWIP_DEBUG + +#endif /* NDEBUG */ + #endif /* __ARCH_CC_H__ */