Remove __ms_check_ini_status() function 86/231986/4
authorSangchul Lee <sc11.lee@samsung.com>
Mon, 27 Apr 2020 06:33:25 +0000 (15:33 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Tue, 28 Apr 2020 01:16:44 +0000 (10:16 +0900)
Since the ini file is located in read-only partition,
removal or modification of this file is meaningless.
Also, ini file size can not be a reasonable method
to check if this file is tainted or not.

Missing const qualifier is added.

Unnecessary null check for g_strdup() is removed.

[Version] 0.1.36
[Issue Type] Improvement

Change-Id: I935729f3ab5578feac628845b823e0fe8564eb56
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
include/media_streamer_util.h
packaging/capi-media-streamer.spec
src/media_streamer_util.c

index 47664d4..04fb494 100644 (file)
@@ -266,7 +266,7 @@ void __ms_load_ini_settings(media_streamer_ini_t *ini);
  *
  * @since_tizen 3.0
  */
-gchar *__ms_ini_get_string(const char *ini_path, char *default_str);
+gchar *__ms_ini_get_string(const char *ini_path, const char *default_str);
 
 /**
  * @brief Reads comma-separated string list from ini file.
index 949754d..0d8b88e 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-streamer
 Summary:    A Media Streamer API
-Version:    0.1.35
+Version:    0.1.36
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index 1ece08c..fa590f3 100644 (file)
@@ -85,41 +85,14 @@ static const format_s format_table[] = {
        {MEDIA_FORMAT_MAX, NULL}
 };
 
-static void __ms_check_ini_status(void)
-{
-       FILE *fp = fopen(MEDIA_STREAMER_INI_PATH, "r");
-       int file_size = 0;
-       int status = 0;
-
-       ms_debug_fenter();
-
-       if (fp == NULL) {
-               ms_debug("Failed to get media streamer ini file.");
-       } else {
-               fseek(fp, 0, SEEK_END);
-               file_size = ftell(fp);
-               fclose(fp);
-               if (file_size < 5) {
-                       ms_debug("media_streamer.ini file size=%d, Corrupted! Removed", file_size);
-                       status = g_remove(MEDIA_STREAMER_INI_PATH);
-                       if (status == -1)
-                               ms_error("failed to delete corrupted ini");
-               }
-       }
-
-       ms_debug_fleave();
-}
-
 static dictionary *__ms_get_ini_instance(void)
 {
        static dictionary *instance = NULL;
+       dictionary *ms_dict = NULL;
 
        ms_debug_fenter();
 
-       if (NULL == instance) {
-               dictionary *ms_dict = NULL;
-               __ms_check_ini_status();
-
+       if (!instance) {
                /* loading existing ini file */
                ms_dict = iniparser_load(MEDIA_STREAMER_INI_PATH);
 
@@ -135,7 +108,7 @@ static dictionary *__ms_get_ini_instance(void)
        return instance;
 }
 
-gchar *__ms_ini_get_string(const char *ini_path, char *default_str)
+gchar *__ms_ini_get_string(const char *ini_path, const char *default_str)
 {
        const char *result_str = default_str;
 
@@ -151,7 +124,7 @@ gchar *__ms_ini_get_string(const char *ini_path, char *default_str)
 
        ms_debug_fleave();
 
-       return result_str ? g_strdup(result_str) : NULL;
+       return g_strdup(result_str);
 }
 
 void __ms_ini_read_list(const char *key, gchar ***list)