47 lines
2.1 KiB
C
47 lines
2.1 KiB
C
/*
|
|
* Host stand-in for ESP-IDF's esp_check.h -- see compat/esp_err.h.
|
|
*/
|
|
#ifndef ESP_CHECK_H
|
|
#define ESP_CHECK_H
|
|
|
|
#include "esp_err.h"
|
|
#include "esp_log.h"
|
|
|
|
#define ESP_RETURN_ON_ERROR(x, tag, fmt, ...) \
|
|
do { \
|
|
const esp_err_t err_rc_ = (x); \
|
|
if (err_rc_ != ESP_OK) { \
|
|
ESP_LOGE(tag, fmt, ##__VA_ARGS__); \
|
|
return err_rc_; \
|
|
} \
|
|
} while (0)
|
|
|
|
#define ESP_RETURN_ON_FALSE(a, err_code, tag, fmt, ...) \
|
|
do { \
|
|
if (!(a)) { \
|
|
ESP_LOGE(tag, fmt, ##__VA_ARGS__); \
|
|
return (err_code); \
|
|
} \
|
|
} while (0)
|
|
|
|
#define ESP_GOTO_ON_ERROR(x, goto_tag, tag, fmt, ...) \
|
|
do { \
|
|
const esp_err_t err_rc_ = (x); \
|
|
if (err_rc_ != ESP_OK) { \
|
|
ret = err_rc_; \
|
|
ESP_LOGE(tag, fmt, ##__VA_ARGS__); \
|
|
goto goto_tag; \
|
|
} \
|
|
} while (0)
|
|
|
|
#define ESP_GOTO_ON_FALSE(a, err_code, goto_tag, tag, fmt, ...) \
|
|
do { \
|
|
if (!(a)) { \
|
|
ret = (err_code); \
|
|
ESP_LOGE(tag, fmt, ##__VA_ARGS__); \
|
|
goto goto_tag; \
|
|
} \
|
|
} while (0)
|
|
|
|
#endif
|