diff options
Diffstat (limited to 'src/media-thumbnail.c')
-rwxr-xr-x | src/media-thumbnail.c | 50 |
1 files changed, 13 insertions, 37 deletions
diff --git a/src/media-thumbnail.c b/src/media-thumbnail.c index be1b09a..474325b 100755 --- a/src/media-thumbnail.c +++ b/src/media-thumbnail.c @@ -30,20 +30,12 @@ int thumbnail_request_from_db_async(unsigned int request_id, const char *origin_path, ThumbFunc func, void *user_data, uid_t uid) { int err = MS_MEDIA_ERR_NONE; + ms_user_storage_type_e store_type = MS_USER_STORAGE_INTERNAL; - if (origin_path == NULL) { - thumb_err("Invalid parameter"); - return MS_MEDIA_ERR_INVALID_PARAMETER; - } - - if (!g_file_test(origin_path, G_FILE_TEST_IS_REGULAR)) { - thumb_err("Original path(%s) doesn't exist.", origin_path); - return MS_MEDIA_ERR_INVALID_PARAMETER; - } + thumb_retvm_if(!origin_path, MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid parameter"); + thumb_retvm_if(!g_file_test(origin_path, G_FILE_TEST_IS_REGULAR), MS_MEDIA_ERR_INVALID_PARAMETER, "No file [%s]", origin_path); - ms_user_storage_type_e store_type = -1; err = ms_user_get_storage_type(uid, origin_path, &store_type); - if ((err != MS_MEDIA_ERR_NONE) || ((store_type != MS_USER_STORAGE_INTERNAL) && (store_type != MS_USER_STORAGE_EXTERNAL))) { thumb_err_slog("origin path(%s) is invalid. err : [%d] store_type [%d]", origin_path, err, store_type); return MS_MEDIA_ERR_INVALID_PARAMETER; @@ -52,10 +44,8 @@ int thumbnail_request_from_db_async(unsigned int request_id, const char *origin_ thumb_dbg_slog("Path : %s", origin_path); thumbUserData *userData = (thumbUserData*)malloc(sizeof(thumbUserData)); - if (userData == NULL) { - thumb_err("memory allocation failed"); - return MS_MEDIA_ERR_OUT_OF_MEMORY; - } + thumb_retvm_if(!userData, MS_MEDIA_ERR_OUT_OF_MEMORY, "Allocation failed"); + userData->func = (ThumbFunc)func; userData->user_data = user_data; @@ -75,10 +65,7 @@ int thumbnail_request_extract_raw_data_async(int request_id, const char *origin_ int err = MS_MEDIA_ERR_NONE; int exist = 0; - if (origin_path == NULL || request_id == 0) { - thumb_err("original path is NULL. Or there is an error in request_id."); - return MS_MEDIA_ERR_INVALID_PARAMETER; - } + thumb_retvm_if(!origin_path || request_id == 0, MS_MEDIA_ERR_INVALID_PARAMETER, "original path is NULL. Or there is an error in request_id."); /* check the file exits actually */ exist = open(origin_path, O_RDONLY); @@ -96,10 +83,8 @@ int thumbnail_request_extract_raw_data_async(int request_id, const char *origin_ thumb_dbg_slog("Path : %s", origin_path); thumbRawUserData *userData = (thumbRawUserData*)malloc(sizeof(thumbRawUserData)); - if (userData == NULL) { - thumb_err("userData malloc failed : %d", err); - return MS_MEDIA_ERR_OUT_OF_MEMORY; - } + thumb_retvm_if(!userData, MS_MEDIA_ERR_OUT_OF_MEMORY, "Allocation failed"); + userData->func = func; userData->user_data = user_data; @@ -118,28 +103,19 @@ int thumbnail_request_cancel_media(unsigned int request_id) int err = MS_MEDIA_ERR_NONE; err = _media_thumb_request_async(THUMB_REQUEST_CANCEL_MEDIA, request_id, NULL, NULL, 0); - if (err != MS_MEDIA_ERR_NONE) { - thumb_err("_media_thumb_request failed : %d", err); - return err; - } + thumb_retvm_if(err != MS_MEDIA_ERR_NONE, err, "_media_thumb_request_async failed : %d", err); - return MS_MEDIA_ERR_NONE; + return err; } int thumbnail_request_cancel_raw_data(int request_id) { int err = MS_MEDIA_ERR_NONE; - if (request_id == 0) { - thumb_err("Invalid parameter"); - return MS_MEDIA_ERR_INVALID_PARAMETER; - } + thumb_retvm_if(request_id == 0, MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid parameter"); err = _media_thumb_request_raw_data_async(THUMB_REQUEST_CANCEL_RAW_DATA, request_id, NULL, 0, 0, NULL, 0); - if (err != MS_MEDIA_ERR_NONE) { - thumb_err("_media_thumb_request failed : %d", err); - return err; - } + thumb_retvm_if(err != MS_MEDIA_ERR_NONE, err, "_media_thumb_request_raw_data_async failed : %d", err); - return MS_MEDIA_ERR_NONE; + return err; } |