From 73d40cb813ddf18135e254bc5502aec435425ef1 Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Thu, 18 Feb 2021 10:06:36 +1100 Subject: [PATCH] lwip: Support silent assertion configuration If silent assert configuration is enabled, LWIP asserts are now 'silent' also. Also updates KConfig to note that LWIP asserts are also disabled when asserts are disabled globally (this was already the behaviour, but the config item suggested otherwise.) Progress towards https://github.com/espressif/esp-idf/issues/5873 --- components/lwip/Kconfig | 8 ++++++-- components/lwip/port/esp32/include/arch/cc.h | 13 ++++++++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/components/lwip/Kconfig b/components/lwip/Kconfig index d9324f83a03..b9e71131e74 100644 --- a/components/lwip/Kconfig +++ b/components/lwip/Kconfig @@ -757,9 +757,13 @@ menu "LWIP" config LWIP_ESP_LWIP_ASSERT bool "Enable LWIP ASSERT checks" default y + depends on !COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE help - Enable this option allows lwip to check assert. - It is recommended to keep it open, do not close it. + Enable this option keeps LWIP assertion checks enabled. + It is recommended to keep this option enabled. + + If asserts are disabled for the entire project, they are also disabled + for LWIP and this option is ignored. menu "Hooks" diff --git a/components/lwip/port/esp32/include/arch/cc.h b/components/lwip/port/esp32/include/arch/cc.h index e74efa967f9..78935f3b5f4 100644 --- a/components/lwip/port/esp32/include/arch/cc.h +++ b/components/lwip/port/esp32/include/arch/cc.h @@ -75,13 +75,20 @@ typedef int sys_prot_t; #include #define LWIP_PLATFORM_DIAG(x) do {printf x;} while(0) -// __assert_func is the assertion failure handler from newlib, defined in assert.h -#define LWIP_PLATFORM_ASSERT(message) __assert_func(__FILE__, __LINE__, __ASSERT_FUNC, message) #ifdef NDEBUG -#define LWIP_NOASSERT + +#define LWIP_NOASSERT 1 + #else // Assertions enabled +#if CONFIG_OPTIMIZATION_ASSERTIONS_SILENT +#define LWIP_PLATFORM_ASSERT(message) abort() +#else +// __assert_func is the assertion failure handler from newlib, defined in assert.h +#define LWIP_PLATFORM_ASSERT(message) __assert_func(__FILE__, __LINE__, __ASSERT_FUNC, message) +#endif + // 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).