From 275b574ace7f02f2ca127bab19f19af1dbace236 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Fri, 7 Apr 2017 15:24:58 +0800 Subject: [PATCH] fix warnings generated by ESP_ERROR_CHECK(variable) in release builds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This uses the same pattern as “assert” in release builds to silence the warning. At the same time, we make sure that if a statement is wrapped into ESP_ERROR_CHECK, it is executed in release build as well. --- components/esp32/include/esp_err.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/components/esp32/include/esp_err.h b/components/esp32/include/esp_err.h index c7beafd375..2990c8938e 100644 --- a/components/esp32/include/esp_err.h +++ b/components/esp32/include/esp_err.h @@ -61,7 +61,10 @@ void _esp_error_check_failed(esp_err_t rc, const char *file, int line, const cha * Disabled if assertions are disabled. */ #ifdef NDEBUG -#define ESP_ERROR_CHECK(x) do { (x); } while (0) +#define ESP_ERROR_CHECK(x) do { \ + esp_err_t rc = (x); \ + (void) sizeof(rc); \ + } while(0); #else #define ESP_ERROR_CHECK(x) do { \ esp_err_t rc = (x); \