From 8a70e0854cc728e4f7a9ad9cc635b518a2d6348d Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Wed, 12 May 2021 08:37:40 +0900 Subject: [PATCH] tbm_surface_internal: add some error log macros this macros deals with the tbm_error types when a condition is failed. Change-Id: Ie458e7b84b3d39565a5b535dac7beac111330e51 --- src/tbm_surface_internal.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/tbm_surface_internal.c b/src/tbm_surface_internal.c index 50d108c..18a922c 100644 --- a/src/tbm_surface_internal.c +++ b/src/tbm_surface_internal.c @@ -57,6 +57,25 @@ void _tbm_surface_mutex_unlock(void); } \ } +#define TBM_SURFACE_RETURN_ERR_IF_FAIL(cond, error_type) {\ + if (!(cond)) {\ + TBM_ERR("'%s' failed.\n", #cond);\ + _tbm_set_last_result(error_type);\ + _tbm_surface_mutex_unlock();\ + return;\ + } \ +} + +#define TBM_SURFACE_RETURN_SET_ERR_IF_FAIL(cond, error, error_type) {\ + if (!(cond)) {\ + TBM_ERR("'%s' failed.\n", #cond);\ + error = error_type;\ + _tbm_set_last_result(error_type);\ + _tbm_surface_mutex_unlock();\ + return;\ + } \ +} + #define TBM_SURFACE_RETURN_VAL_IF_FAIL(cond, val) {\ if (!(cond)) {\ TBM_ERR("'%s' failed.\n", #cond);\ @@ -66,6 +85,26 @@ void _tbm_surface_mutex_unlock(void); } \ } + +#define TBM_SURFACE_RETURN_VAL_ERR_IF_FAIL(cond, val, error_type) {\ + if (!(cond)) {\ + TBM_ERR("'%s' failed.\n", #cond);\ + _tbm_set_last_result(error_type);\ + _tbm_surface_mutex_unlock();\ + return val;\ + } \ +} + +#define TBM_SURFACE_RETURN_VAL_SET_ERR_IF_FAIL(cond, val, error, error_type) {\ + if (!(cond)) {\ + TBM_ERR("'%s' failed.\n", #cond);\ + error = error_type;\ + _tbm_set_last_result(error_type);\ + _tbm_surface_mutex_unlock();\ + return val;\ + } \ +} + /* LCOV_EXCL_START */ static double _tbm_surface_internal_get_time(void) -- 2.7.4