From: Minje Ahn Date: Fri, 23 Apr 2021 06:16:48 +0000 (+0900) Subject: Fix minor issue X-Git-Tag: accepted/tizen/6.0/unified/20210428.125006^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fheads%2Ftizen_6.0;p=platform%2Fcore%2Fmultimedia%2Flibmedia-service.git Fix minor issue Fix comparison of integer expressions of different signedness Change-Id: I75d7130924bc7021bfad9e850ad846b9f9291a24 Signed-off-by: Minje Ahn --- diff --git a/src/common/media-svc-db-utils.c b/src/common/media-svc-db-utils.c index d9c5e44..fac20e4 100755 --- a/src/common/media-svc-db-utils.c +++ b/src/common/media-svc-db-utils.c @@ -838,8 +838,8 @@ int _media_svc_sql_query_list(GList **query_list, uid_t uid) int length = g_list_length(*query_list); char *sql = NULL; char query_bundle[MEDIA_SVC_QUERY_LEN_MAX] = {0, }; - int query_len = 0; - int total_len = 0; + unsigned int query_len = 0; + unsigned int total_len = 0; media_svc_debug("query list length : [%d]", length); @@ -851,7 +851,7 @@ int _media_svc_sql_query_list(GList **query_list, uid_t uid) query_len = strlen(sql); if (query_len >= (sizeof(query_bundle) - 1)) { - media_svc_error("NEED TO CHECK FILE : A single query size exceeds 8k [%d]", query_len); + media_svc_error("NEED TO CHECK FILE : A single query size exceeds 8k [%u]", query_len); SQLITE3_SAFE_FREE(sql); continue; } diff --git a/src/common/media-svc-util.c b/src/common/media-svc-util.c index 4e44550..1d1283f 100644 --- a/src/common/media-svc-util.c +++ b/src/common/media-svc-util.c @@ -567,51 +567,28 @@ static int __media_svc_safe_atoi(char *buffer, int *si) static int __media_svc_save_image(unsigned char *image, unsigned int size, char *image_path, uid_t uid) { int ret = MS_MEDIA_ERR_NONE; + struct statfs fs; + char *thumb_path = NULL; + long bsize_kbytes = 0; + GError *error = NULL; + media_svc_retvm_if(!image || size == 0, MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid image"); media_svc_sec_debug("start save image, path [%s] image size [%d]", image_path, size); - if (!image) { - media_svc_error("invalid image.."); - return MS_MEDIA_ERR_INVALID_PARAMETER; - } - - struct statfs fs; - char *thumb_path = NULL; ret = ms_user_get_root_thumb_store_path(uid, &thumb_path); - media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "ms_user_get_root_thumb_store_path fail"); - - if (-1 == statfs(thumb_path, &fs)) { - media_svc_error("error in statfs"); - g_free(thumb_path); - return MS_MEDIA_ERR_INTERNAL; - } + media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "ms_user_get_root_thumb_store_path error"); + ret = statfs(thumb_path, &fs); g_free(thumb_path); + media_svc_retvm_if(ret == -1, MS_MEDIA_ERR_INTERNAL, "statfs failed"); - long bsize_kbytes = fs.f_bsize >> 10; + bsize_kbytes = fs.f_bsize >> 10; + media_svc_retvm_if((bsize_kbytes * fs.f_bavail) < 1024, MS_MEDIA_ERR_NOT_ENOUGH_SPACE, "Not enough space"); - if ((bsize_kbytes * fs.f_bavail) < 1024) { - media_svc_error("not enought space..."); - return MS_MEDIA_ERR_NOT_ENOUGH_SPACE; - } - - FILE *fp = NULL; - int nwrite = -1; - if (image != NULL && size > 0) { - fp = fopen(image_path, "w"); - - if (fp == NULL) { - media_svc_error("failed to open file"); - return MS_MEDIA_ERR_INTERNAL; - } - - nwrite = fwrite(image, 1, size, fp); - if (nwrite != size) { - media_svc_error("failed to write thumbnail"); - fclose(fp); - return MS_MEDIA_ERR_INTERNAL; - } - fclose(fp); + if (!g_file_set_contents(image_path, (const gchar *)image, (gssize)size, &error)) { + media_svc_error("g_file_set_contents faild:%s", error->message); + g_error_free(error); + return MS_MEDIA_ERR_INTERNAL; } return MS_MEDIA_ERR_NONE; diff --git a/src/common/media-svc.c b/src/common/media-svc.c index 0ca6a5e..136234d 100755 --- a/src/common/media-svc.c +++ b/src/common/media-svc.c @@ -561,7 +561,7 @@ static void __media_svc_noti_all_storage(sqlite3 *handle, uid_t uid) int ret = MS_MEDIA_ERR_NONE; char *root_path = NULL; GPtrArray *path_list = NULL; - int i = 0; + guint i = 0; ret = ms_user_get_internal_root_path(uid, &root_path); media_svc_retm_if(ret != MS_MEDIA_ERR_NONE, "Fail to get root path");