tbm_surface_internal: check the memory validation at macro 37/259937/1
authorSooChan Lim <sc1.lim@samsung.com>
Thu, 17 Jun 2021 00:48:11 +0000 (09:48 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Thu, 17 Jun 2021 00:48:11 +0000 (09:48 +0900)
checkt the validataion of the error pointer at TBM_SURFACE_RETURN_VAL_SET_ERR_IF_FAIL

Change-Id: Idd6815577e1e03d0bfc0ad1e234e348e18b7055f

src/tbm_surface_internal.c

index 823f061..5b899b9 100644 (file)
@@ -98,7 +98,8 @@ void _tbm_surface_mutex_unlock(void);
 #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;\
+               if (error)\
+                       *error = error_type;\
                _tbm_set_last_result(error_type);\
                _tbm_surface_mutex_unlock();\
                return val;\
@@ -886,7 +887,7 @@ _tbm_surface_internal_hal_tbm_import_surface(tbm_bufmgr bufmgr, int width, int h
        }
 
        // import surface
-       hal_surface = hal_tbm_bufmgr_import_surface(bufmgr->hal_bufmgr, 
+       hal_surface = hal_tbm_bufmgr_import_surface(bufmgr->hal_bufmgr,
                                                                                        (uint32_t)width,
                                                                                        (uint32_t)height,
                                                                                        (hal_tbm_format)format,
@@ -945,8 +946,6 @@ _tbm_surface_internal_hal_tbm_import_surface(tbm_bufmgr bufmgr, int width, int h
                _tbm_bo_set_surface(surf->bos[i], surf);
        }
 
-       *error = TBM_ERROR_NONE;
-
        return surf;
 
 get_bo_fail:
@@ -2955,13 +2954,13 @@ tbm_surface_internal_export(tbm_surface_h surface, tbm_error_e *error)
        _tbm_surface_mutex_lock();
 
        surf = (struct _tbm_surface *)surface;
-       TBM_SURFACE_RETURN_VAL_SET_ERR_IF_FAIL(_tbm_surface_internal_is_valid(surface), NULL, *error, TBM_ERROR_INVALID_PARAMETER);
+       TBM_SURFACE_RETURN_VAL_SET_ERR_IF_FAIL(_tbm_surface_internal_is_valid(surface), NULL, error, TBM_ERROR_INVALID_PARAMETER);
 
        bufmgr = surf->bufmgr;
-       TBM_SURFACE_RETURN_VAL_SET_ERR_IF_FAIL(bufmgr != NULL, NULL, *error, TBM_ERROR_INVALID_PARAMETER);
+       TBM_SURFACE_RETURN_VAL_SET_ERR_IF_FAIL(bufmgr != NULL, NULL, error, TBM_ERROR_INVALID_PARAMETER);
 
        // this function supports when it comes to be use_hal.
-       TBM_SURFACE_RETURN_VAL_SET_ERR_IF_FAIL(bufmgr->use_hal_tbm, NULL, *error, TBM_ERROR_NOT_SUPPORTED);
+       TBM_SURFACE_RETURN_VAL_SET_ERR_IF_FAIL(bufmgr->use_hal_tbm, NULL, error, TBM_ERROR_NOT_SUPPORTED);
 
        // export a surface
        buffer_data = (tbm_surface_buffer_data *)hal_tbm_surface_export((hal_tbm_surface *)surf->hal_surface,
@@ -2988,15 +2987,15 @@ tbm_surface_internal_import(tbm_surface_info_s *surface_info, tbm_surface_buffer
        _tbm_surface_mutex_lock();
 
        bufmgr = g_surface_bufmgr;
-       TBM_SURFACE_RETURN_VAL_SET_ERR_IF_FAIL(bufmgr != NULL, NULL, *error, TBM_ERROR_INVALID_PARAMETER);
+       TBM_SURFACE_RETURN_VAL_SET_ERR_IF_FAIL(bufmgr != NULL, NULL, error, TBM_ERROR_INVALID_PARAMETER);
 
        // this function supports when it comes to be use_hal.
-       TBM_SURFACE_RETURN_VAL_SET_ERR_IF_FAIL(bufmgr->use_hal_tbm, NULL, *error, TBM_ERROR_NOT_SUPPORTED);
+       TBM_SURFACE_RETURN_VAL_SET_ERR_IF_FAIL(bufmgr->use_hal_tbm, NULL, error, TBM_ERROR_NOT_SUPPORTED);
 
-       TBM_SURFACE_RETURN_VAL_SET_ERR_IF_FAIL(surface_info != NULL, NULL, *error, TBM_ERROR_INVALID_PARAMETER);
-       TBM_SURFACE_RETURN_VAL_SET_ERR_IF_FAIL(surface_info->width > 0, NULL, *error, TBM_ERROR_INVALID_PARAMETER);
-       TBM_SURFACE_RETURN_VAL_SET_ERR_IF_FAIL(surface_info->height > 0, NULL, *error, TBM_ERROR_INVALID_PARAMETER);
-       TBM_SURFACE_RETURN_VAL_SET_ERR_IF_FAIL(buffer_data != NULL, NULL, *error, TBM_ERROR_INVALID_PARAMETER);
+       TBM_SURFACE_RETURN_VAL_SET_ERR_IF_FAIL(surface_info != NULL, NULL, error, TBM_ERROR_INVALID_PARAMETER);
+       TBM_SURFACE_RETURN_VAL_SET_ERR_IF_FAIL(surface_info->width > 0, NULL, error, TBM_ERROR_INVALID_PARAMETER);
+       TBM_SURFACE_RETURN_VAL_SET_ERR_IF_FAIL(surface_info->height > 0, NULL, error, TBM_ERROR_INVALID_PARAMETER);
+       TBM_SURFACE_RETURN_VAL_SET_ERR_IF_FAIL(buffer_data != NULL, NULL, error, TBM_ERROR_INVALID_PARAMETER);
 
        // import a surface
        surf = _tbm_surface_internal_hal_tbm_import_surface(bufmgr,
@@ -3015,9 +3014,6 @@ tbm_surface_internal_import(tbm_surface_info_s *surface_info, tbm_surface_buffer
 
        TBM_TRACE_SURFACE_INTERNAL("tbm_surface(%p)", surf);
 
-       if (error)
-               *error = TBM_ERROR_NONE;
-
        _tbm_set_last_result(TBM_ERROR_NONE);
        _tbm_surface_mutex_unlock();