From 636fecdc2f08ad2b760a6d2d5500f252df260f94 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Fri, 11 Jun 2021 17:06:15 +0900 Subject: [PATCH] tbm_log: add the condition check macro with error Change-Id: I064a9d7588a4d8ec0f02fa5da770b5c12c3bbcb6 --- include/tbm_log.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/include/tbm_log.h b/include/tbm_log.h index 9f724cc..d37c351 100644 --- a/include/tbm_log.h +++ b/include/tbm_log.h @@ -133,6 +133,22 @@ void tbm_log_print_stdout(int level, const char *fmt, ...); } \ } +#define TBM_RETURN_SET_ERR_IF_FAIL(cond, error, error_type) {\ + if (!(cond)) {\ + TBM_ERR("'%s' failed.\n", #cond);\ + error = error_type;\ + return;\ + } \ +} + +#define TBM_RETURN_VAL_SET_ERR_IF_FAIL(cond, val, error, error_type) {\ + if (!(cond)) {\ + TBM_ERR("'%s' failed.\n", #cond);\ + error = error_type;\ + return val;\ + } \ +} + #ifdef __cplusplus } #endif -- 2.7.4