Skip to content

Instantly share code, notes, and snippets.

@Carbon225
Created August 10, 2020 00:16
Show Gist options
  • Save Carbon225/f777f7cd56c8ed46b86e280935852ce4 to your computer and use it in GitHub Desktop.
Save Carbon225/f777f7cd56c8ed46b86e280935852ce4 to your computer and use it in GitHub Desktop.
The most useful ESP-IDF macro. Check for errors and return if not ESP_OK.
#ifndef COMPONENTS_ERROR_CHECK_RETURN_INCLUDE_ERROR_CHECK_RETURN_H_
#define COMPONENTS_ERROR_CHECK_RETURN_INCLUDE_ERROR_CHECK_RETURN_H_
#define ESP_ERROR_CHECK_RETURN(fn) ({ \
esp_err_t __ret = ESP_ERROR_CHECK_WITHOUT_ABORT((fn)); \
if (__ret != ESP_OK) { \
return __ret; \
} \
__ret; \
})
#endif /* COMPONENTS_ERROR_CHECK_RETURN_INCLUDE_ERROR_CHECK_RETURN_H_ */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment