]> granicus.if.org Git - esp-idf/commit
Update esp_err.h
authorjeanleflambeur <catalin.vasile@gmail.com>
Thu, 12 Oct 2017 07:53:09 +0000 (09:53 +0200)
committerIvan Grokhotkov <ivan@espressif.com>
Fri, 3 Nov 2017 08:45:28 +0000 (16:45 +0800)
commit8712fd3ccfd6edde17305b1c8ff51b8d3ecc11d0
tree5db323f27ec2257ccc452f984b6bfd3f1eef26c7
parenta0cedb1f442f79e1c87a37c2653226abdd293756
Update esp_err.h

Renamed the internal rc to __err_rc to avoid clashes with local variables.
This code would not do the expected thing with the original ESP_ERROR_CHECK macro:

esp_err_t my_func(esp_err_t x)
{
  assert(x == 23);
}

esp_err_t rc = 23; //some value that is important fo the user
ESP_ERROR_CHECK(my_func(rc));

The macro will expand to:
esp_err_t rc = (my_func(rc));

And the code will assert, as my_func will receive a random value - whatever is in the internal macro rc temp variable. This is due to the C weirdness of allowing this code:

int x = x; //x has a random value.
components/esp32/include/esp_err.h