Use g_snprintf() instead of ms_strappend() 58/240958/3
authorMinje Ahn <minje.ahn@samsung.com>
Thu, 13 Aug 2020 06:41:47 +0000 (15:41 +0900)
committerMinje Ahn <minje.ahn@samsung.com>
Thu, 13 Aug 2020 06:48:15 +0000 (15:48 +0900)
Changed ms_strappend() to g_snprintf().
And removed ms_strappend().

Change-Id: If9dac5bed4a670abafaedcfa259feca871e30ffd
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
src/common/include/media-common-utils.h
src/common/media-common-utils.c
src/scanner-v2/media-scanner-scan-v2.c

index cf99aa1aa1bbc64163c9186b9d8ee47684a47365..9b888f6554fd9cf28e6a9b77cae0024917e3f532 100755 (executable)
@@ -26,7 +26,6 @@
 #include "media-util.h"
 #include "media-common-types.h"
 
-int ms_strappend(char *res, const int size, const char *pattern, const char *str1, const char *str2);
 bool ms_config_get_int(const char *key, int *value);
 bool ms_config_set_int(const char *key, int value);
 bool ms_config_get_str(const char *key, char **value);
index 0ea1a487ca1eccb9ca1b7065abbb82a363755945..cb699539322c18202890b2b84aa4df223e72ad70 100644 (file)
 #include "media-common-system.h"
 #include "media-common-utils.h"
 
-int ms_strappend(char *res, const int size, const char *pattern, const char *str1, const char *str2)
-{
-       int len = 0;
-       int real_size = size - 1;
-
-       if (!res || !pattern || !str1 || !str2)
-               return MS_MEDIA_ERR_INVALID_PARAMETER;
-
-       if (real_size < (int)(strlen(str1) + strlen(str2)))
-               return MS_MEDIA_ERR_INVALID_PARAMETER;
-
-       len = snprintf(res, real_size, pattern, str1, str2);
-       if (len < 0)
-               return MS_MEDIA_ERR_INVALID_PARAMETER;
-
-       res[len] = '\0';
-
-       return MS_MEDIA_ERR_NONE;
-}
-
 bool ms_config_get_int(const char *key, int *value)
 {
        int err;
index bea751f8c0cc7bfde00fe707689670e917f173b5..605bff4d54fe10ceb952c9d3567d3218e85ea5eb 100644 (file)
@@ -297,8 +297,8 @@ static int __msc_dir_scan_for_folder(sqlite3 *handle, const char *storage_id, ch
                        if (strcmp(name, RECYCLE_DIR_NAME) == 0)
                                continue;
 
-                       if (ms_strappend(path, sizeof(path), "%s/%s", current_path, name) != MS_MEDIA_ERR_NONE) {
-                               MS_DBG_ERR("ms_strappend failed");
+                       if (g_snprintf(path, MS_FILE_PATH_LEN_MAX, "%s/%s", current_path, name) >= MS_FILE_PATH_LEN_MAX) {
+                               MS_DBG_ERR("g_snprintf failed");
                                continue;
                        }
 
@@ -504,15 +504,14 @@ static int __msc_dir_scan_for_storage(sqlite3 *handle, const char *storage_id, c
                        if (strcmp(name, RECYCLE_DIR_NAME) == 0)
                                continue;
 
-                       if (ms_strappend(path, sizeof(path), "%s/%s", current_path, name) != MS_MEDIA_ERR_NONE) {
-                               MS_DBG_ERR("ms_strappend failed");
+                       if (g_snprintf(path, MS_FILE_PATH_LEN_MAX, "%s/%s", current_path, name) >= MS_FILE_PATH_LEN_MAX) {
+                               MS_DBG_ERR("g_snprintf failed");
                                continue;
                        }
 
                        if (g_file_test(path, G_FILE_TEST_IS_REGULAR)) {
-                               if (!ms_check_support_media_type(path)) {
+                               if (!ms_check_support_media_type(path))
                                        continue;
-                               }
 
                                ret = scan_function(handle, storage_id, path, uid);
                                if (ret != MS_MEDIA_ERR_NONE) {