tbm_surface_internal: add some error log macros 72/258172/1
authorSooChan Lim <sc1.lim@samsung.com>
Tue, 11 May 2021 23:37:40 +0000 (08:37 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Tue, 11 May 2021 23:37:40 +0000 (08:37 +0900)
this macros deals with the tbm_error types when a condition is failed.

Change-Id: Ie458e7b84b3d39565a5b535dac7beac111330e51

src/tbm_surface_internal.c

index 50d108c..18a922c 100644 (file)
@@ -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)