Fix minor issue 68/257368/5 accepted/tizen/unified/20210428.040435 submit/tizen/20210427.230809 submit/tizen/20210427.230831 submit/tizen/20210428.231245
authorMinje Ahn <minje.ahn@samsung.com>
Fri, 23 Apr 2021 06:16:48 +0000 (15:16 +0900)
committerMinje Ahn <minje.ahn@samsung.com>
Mon, 26 Apr 2021 06:45:06 +0000 (15:45 +0900)
Fix comparison of integer expressions of different signedness

Change-Id: I75d7130924bc7021bfad9e850ad846b9f9291a24
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
src/common/media-svc-db-utils.c
src/common/media-svc-util.c
src/common/media-svc.c

index d9c5e446adabde8869971ee037a9ba3edf6fd3c1..fac20e44cff2a163e99ac2de0b603165dc0d1fcd 100755 (executable)
@@ -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;
                        }
index e5bf9198cd3ab3a515bdde7f2d508fb09f5201b9..2e71b309dd5ca84ec51d68c25d3632e4f8bfa84f 100644 (file)
@@ -500,51 +500,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;
index 4a2327bb1cef732a4322565db6c291aaeb7b4bfb..d69874c4808285291f9dfa4b24c09d7c07279e34 100755 (executable)
@@ -562,7 +562,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");