change the return value for solving corrupt issue 46/318146/2
authordyamy-lee <dyamy.lee@samsung.com>
Wed, 25 Sep 2024 05:46:38 +0000 (14:46 +0900)
committerdyamy-lee <dyamy.lee@samsung.com>
Wed, 25 Sep 2024 05:48:19 +0000 (14:48 +0900)
It can occur an corrupt error when there is no personal xml file but return 0.
So, this patch changed this as return error type no file and only that case makes as success and returns.

Change-Id: I1b06df9bb2d637dfdda851577232f837a0158bfe

common/tts_config_mgr.c
common/tts_config_parser.c

index a28f407..21bfdd5 100644 (file)
@@ -2221,7 +2221,12 @@ int __tts_config_mgr_print_personal_info(const char* engine_id)
        tts_personal_info_s* info = NULL;
        int ret = tts_parser_get_personal_info(filepath, &info);
        if (0 != ret) {
-               return -1;
+               if (ENOENT == ret) {
+                       SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] There is no personal xml file");
+                       return TTS_CONFIG_ERROR_NONE;
+               }
+               SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] Fail to get personal information");
+               return TTS_CONFIG_ERROR_OPERATION_FAILED;
        }
 
        GSList *iter_personal_voice = NULL;
@@ -2247,7 +2252,7 @@ int __tts_config_mgr_print_personal_info(const char* engine_id)
 
        tts_parser_free_personal_info(info);
 
-       return 0;
+       return TTS_CONFIG_ERROR_NONE;
 }
 
 int __tts_config_mgr_print_engine_info()
@@ -2483,6 +2488,10 @@ int tts_config_mgr_get_personal_voice_list(const char* engine_id, tts_config_sup
        tts_personal_info_s* info = NULL;
        ret = tts_parser_get_personal_info(filepath, &info);
        if (0 != ret) {
+               if (ENOENT == ret) {
+                       SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] There is no personal xml file");
+                       return TTS_CONFIG_ERROR_NONE;
+               }
                SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] Fail to get personal information");
                return TTS_CONFIG_ERROR_OPERATION_FAILED;
        }
@@ -2530,8 +2539,12 @@ int tts_config_mgr_check_duplicate_personal_voice(const char* engine_id, const c
        tts_personal_info_s* info = NULL;
        int ret = tts_parser_get_personal_info(filepath, &info);
        if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] There is no personal info file. It can be first time or fail.");
-               return 0;
+               if (ENOENT == ret) {
+                       SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] There is no personal xml file");
+                       return TTS_CONFIG_ERROR_NONE;
+               }
+               SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] Fail to get personal information");
+               return TTS_CONFIG_ERROR_OPERATION_FAILED;
        }
 
        GSList *iter_personal_voice = NULL;
@@ -2561,5 +2574,5 @@ int tts_config_mgr_check_duplicate_personal_voice(const char* engine_id, const c
        }
 
        tts_parser_free_personal_info(info);
-       return 0;
+       return TTS_CONFIG_ERROR_NONE;
 }
\ No newline at end of file
index f083708..b011225 100644 (file)
@@ -259,10 +259,14 @@ int tts_parser_get_personal_info(const char* path, tts_personal_info_s** persona
        xmlNodePtr cur = NULL;
 
        struct stat sb;
-       int ret = stat(path, &sb);
-       if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] There is no personal xml file");
-               return 0;
+       if (stat(path, &sb) == -1) {
+               if (errno == ENOENT) {
+                       SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] There is no personal xml file");
+                       return ENOENT;
+               } else {
+                       SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] stat error");
+                       return -1;
+               }
        }
 
        if (0 == access(path, F_OK)) {