]> granicus.if.org Git - esp-idf/commitdiff
fix warnings generated by ESP_ERROR_CHECK(variable) in release builds
authorIvan Grokhotkov <ivan@espressif.com>
Fri, 7 Apr 2017 07:24:58 +0000 (15:24 +0800)
committerIvan Grokhotkov <ivan@espressif.com>
Fri, 7 Apr 2017 07:24:58 +0000 (15:24 +0800)
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

index c7beafd37563b08c7291ede1dd85d0bac1e0a9d7..2990c8938e3fb3bc26f92a750fa4771e980758f6 100644 (file)
@@ -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);                                             \