From: dyamy-lee Date: Wed, 25 Sep 2024 05:46:38 +0000 (+0900) Subject: change the return value for solving corrupt issue X-Git-Tag: accepted/tizen/unified/20240930.043752~7 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ea995cf3ceeeaf1c137ee1a285b5551cfeba6ad3;p=platform%2Fcore%2Fuifw%2Ftts.git change the return value for solving corrupt issue 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 --- diff --git a/common/tts_config_mgr.c b/common/tts_config_mgr.c index a28f407e..21bfdd5f 100644 --- a/common/tts_config_mgr.c +++ b/common/tts_config_mgr.c @@ -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 diff --git a/common/tts_config_parser.c b/common/tts_config_parser.c index f0837088..b0112251 100644 --- a/common/tts_config_parser.c +++ b/common/tts_config_parser.c @@ -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)) {