From ea995cf3ceeeaf1c137ee1a285b5551cfeba6ad3 Mon Sep 17 00:00:00 2001 From: dyamy-lee Date: Wed, 25 Sep 2024 14:46:38 +0900 Subject: [PATCH] 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 --- common/tts_config_mgr.c | 23 ++++++++++++++++++----- common/tts_config_parser.c | 12 ++++++++---- 2 files changed, 26 insertions(+), 9 deletions(-) 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)) { -- 2.34.1