Remove unused or unreachable code 59/295159/2
authorSuyeon Hwang <stom.hwang@samsung.com>
Mon, 3 Jul 2023 08:42:49 +0000 (17:42 +0900)
committerSuyeon Hwang <stom.hwang@samsung.com>
Thu, 13 Jul 2023 04:20:46 +0000 (13:20 +0900)
- Contents:
This patch removes some unused or unrechable code. Through this patch,
unvaluable code is removed and also test cases covers more code and
logics.

Change-Id: I7822086a9160fafd6014e6759508a6cf3cfaa2cb
Signed-off-by: Suyeon Hwang <stom.hwang@samsung.com>
client/tts.c
client/tts_client.c
client/tts_core.c
client/tts_core.h

index 191d2d46d39bd3dbac42a197df14854f9c840df7..c47ef85c0596812f2d9dcbbb7b77fec55847a8f2 100644 (file)
@@ -108,36 +108,7 @@ static void __tts_config_voice_changed_cb(const char* before_lang, int before_vo
 
        return;
 }
-/*
-static Eina_Bool __reconnect_by_engine_changed(void* data)
-{
-       tts_h tts = (tts_h)data;
-
-       tts_client_s* client = tts_client_get(tts);
-       if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid. tts(%p)", tts);
-               return EINA_FALSE;
-       }
-
-       tts_state_e current_state = tts_client_get_current_state(client);
-       if (TTS_STATE_READY != current_state) {
-               usleep(10000);
-               return EINA_TRUE;
-       }
 
-       // TODO: change to tts_core function
-       int ret = tts_unprepare(tts);
-       if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to prepare for setting a new engine... (%d)", ret);
-       }
-       ret = tts_prepare(tts);
-       if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to prepare for setting a new engine... (%d)", ret);
-       }
-
-       return EINA_FALSE;
-}
-*/
 static void __tts_config_engine_changed_cb(const char* engine_id, const char* setting, const char* language, int voice_type, bool auto_voice, bool need_credential, void* user_data)
 {
        tts_h tts = (tts_h)user_data;
@@ -499,10 +470,8 @@ int tts_set_server_tts(tts_h tts, const char* credential)
        int ret = app_manager_get_app_id(pid, &appid);
        if (0 != ret || NULL == appid) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to get appid, ret(%d), pid(%d), appid(%s)", ret, pid, appid);;
-               if (NULL != appid) {
-                       free(appid);
-                       appid = NULL;
-               }
+               free(appid);
+               appid = NULL;
                return TTS_ERROR_OPERATION_FAILED;
        }
 
index ba8789a65b664f6665d76794834caab65c9ca63f..c5bfa27be3028b2fe12d918db8b9dd3c662e1e2a 100644 (file)
@@ -589,10 +589,8 @@ void tts_client_set_error_message(tts_client_s* client, const char* error_messag
                return;
        }
 
-       if (NULL != client->err_msg) {
-               free(client->err_msg);
-               client->err_msg = NULL;
-       }
+       free(client->err_msg);
+       client->err_msg = NULL;
 
        if (NULL != error_message) {
                client->err_msg = strdup(error_message);
@@ -871,6 +869,7 @@ void* tts_client_get_service_state_changed_user_data(tts_client_s* client)
        return client->service_state_changed_user_data;
 }
 
+//LCOV_EXCL_START
 tts_synthesized_pcm_cb tts_client_get_synthesized_pcm_cb(tts_client_s* client)
 {
        if (false == tts_client_is_valid_client(client)) {
@@ -886,6 +885,7 @@ void* tts_client_get_synthesized_pcm_user_data(tts_client_s* client)
        }
        return client->synthesized_pcm_user_data;
 }
+//LCOV_EXCL_STOP
 
 int tts_client_get_registered_event_mask(tts_client_s* client)
 {
index 17e881bcbda012e99bafbb7b63aae99ca1124474..b0e5382cabd52170ed6040d423c972b9cbd437d2 100644 (file)
@@ -260,30 +260,26 @@ static void __create_pkgmgr_thread(void* data, Ecore_Thread* thread)
                if (NULL == g_pkgmgr) {
                        if (0 == cnt % 5) {
                                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to create pkgmgr handle");
-                               time_delay *= 2;
                        }
                } else {
                        int ret = pkgmgr_client_set_status_type(g_pkgmgr, PKGMGR_CLIENT_STATUS_INSTALL | PKGMGR_CLIENT_STATUS_UNINSTALL | PKGMGR_CLIENT_STATUS_UPGRADE);
                        if (0 == ret) {
                                if (pkgmgr_client_listen_status(g_pkgmgr, __pkgmgr_status_cb, NULL) < 0) {
                                        SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to listen pkgmgr status. remove and recreate client");
-                                       pkgmgr_client_free(g_pkgmgr);
-                                       g_pkgmgr = NULL;
-                                       if (0 == cnt % 5)
-                                               time_delay *= 2;
                                } else {
                                        SLOG(LOG_ERROR, TAG_TTSC, "[INFO] Succeed to register pkgmgr cb");
                                        break;
                                }
                        } else {
                                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to set status type on pkgmgr, ret(%d)", ret);
-                               pkgmgr_client_free(g_pkgmgr);
-                               g_pkgmgr = NULL;
-                               if (0 == cnt % 5)
-                                       time_delay *= 2;
                        }
+
+                       pkgmgr_client_free(g_pkgmgr);
+                       g_pkgmgr = NULL;
                }
 
+               if (0 == cnt % 5) time_delay *= 2;
+
                usleep(time_delay);
                cnt++;
        }
@@ -361,7 +357,6 @@ static void __start_reprepare_thread(void* data, Ecore_Thread* thread)
 
        return;
 }
-//LCOV_EXCL_STOP
 
 static void __end_reprepare_thread(void* data, Ecore_Thread* thread)
 {
@@ -394,14 +389,12 @@ static void __end_reprepare_thread(void* data, Ecore_Thread* thread)
        g_reprepare_thread = NULL;
 }
 
-//LCOV_EXCL_START
 static void __cancel_reprepare_thread(void* data, Ecore_Thread* thread)
 {
        SLOG(LOG_INFO, TAG_TTSC, "[INFO] cancel reprepare thread");
        g_is_engine_name_changed = false;
        g_reprepare_thread = NULL;
 }
-//LCOV_EXCL_STOP
 
 static inline void __run_client_reprepare_thread()
 {
@@ -412,6 +405,7 @@ static inline void __run_client_reprepare_thread()
                SLOG(LOG_INFO, TAG_TTSC, "[INFO] Reprepare thread is already running");
        }
 }
+//LCOV_EXCL_STOP
 
 static int __send_hello_msg(tts_client_s* client)
 {
@@ -438,10 +432,12 @@ static int __send_hello_msg(tts_client_s* client)
        if (false == is_launched) {
                /* If engine is NOT launched, check whether engine is updating or not */
                if (g_engine_update_status) {
+                       //LCOV_EXCL_START
                        /* suyeon wait engine update */
                        SLOG(LOG_INFO, TAG_TTSC, "[INFO] cannot prepare due to engine update");
                        __run_client_reprepare_thread();
                        return TTS_ERROR_INVALID_STATE;
+                       //LCOV_EXCL_STOP
                }
        }
 
@@ -513,10 +509,12 @@ static int __prepare_sync_cb(tts_client_s* client, tts_service_state_e* service_
        if (false == is_launched) {
                /* check whether engine is updating or not */
                if (g_engine_update_status) {
+                       //LCOV_EXCL_START
                        SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Cannot prepare due to engine update.");
                        SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Client automatically tries to reprepare asynchrnously.");
                        __run_client_reprepare_thread();
                        return TTS_ERROR_OPERATION_FAILED;
+                       //LCOV_EXCL_STOP
                }
        }
 
@@ -735,10 +733,9 @@ int tts_core_deinitialize()
                g_pkgmgr = NULL;
        }
 
-       if (NULL != g_pkgmgr_status) {
-               free(g_pkgmgr_status);
-               g_pkgmgr_status = NULL;
-       }
+       free(g_pkgmgr_status);
+       g_pkgmgr_status = NULL;
+
        pthread_mutex_unlock(&g_pkgmgr_mutex);
 
        /* Unregister vconfkey callback */
@@ -918,6 +915,7 @@ int tts_core_notify_service_state_changed(tts_client_s* client, tts_service_stat
        return TTS_ERROR_NONE;
 }
 
+//LCOV_EXCL_START
 int tts_core_notify_synthesized_pcm(tts_client_s* client, int utt_id, tts_synthesized_pcm_event_e event, const char* pcm_data, int pcm_data_size, tts_audio_type_e audio_type, int sample_rate)
 {
        RETVM_IF(false == tts_client_is_valid_client(client), TTS_ERROR_INVALID_PARAMETER, "[ERROR] Client is invalid.");
@@ -939,6 +937,7 @@ int tts_core_notify_synthesized_pcm(tts_client_s* client, int utt_id, tts_synthe
 
        return TTS_ERROR_NONE;
 }
+//LCOV_EXCL_STOP
 
 bool tts_core_is_valid_text(const char* text)
 {
@@ -1184,31 +1183,6 @@ int tts_core_unprepare(tts_client_s* client)
        return TTS_ERROR_NONE;
 }
 
-int tts_core_reprepare()
-{
-       GList* clients = tts_client_get_client_list();
-       RETVM_IF(NULL == clients, TTS_ERROR_OPERATION_FAILED, "[ERROR] Fail to get client list");
-
-       GList *iter = NULL;
-       if (g_list_length(clients) > 0) {
-               iter = g_list_first(clients);
-
-               while (NULL != iter) {
-                       tts_client_s* client = iter->data;
-                       if (true == tts_client_is_valid_client(client)) {
-                               tts_client_set_current_state(client, TTS_STATE_CREATED);
-                       }
-
-                       iter = g_list_next(iter);
-               }
-       }
-
-       g_list_free(clients);
-       __run_client_reprepare_thread();
-
-       return TTS_ERROR_NONE;
-}
-
 int tts_core_foreach_supported_voices(tts_client_s* client, const char* engine_id, tts_supported_voice_cb callback, void* user_data)
 {
        RETVM_IF(false == tts_client_is_valid_client(client), TTS_ERROR_INVALID_PARAMETER, "[ERROR] Client is invalid.");
index 2b843dc5d19c962c4f6ae79c5215cf4b1a94f98e..0dfa313a55cc36622d62d7391f5940a7a03656a9 100644 (file)
@@ -46,7 +46,6 @@ int tts_core_deinitialize();
 int tts_core_prepare(tts_client_s* client);
 int tts_core_prepare_sync(tts_client_s* client);
 int tts_core_unprepare(tts_client_s* client);
-int tts_core_reprepare();
 
 int tts_core_foreach_supported_voices(tts_client_s* client, const char* engine_id, tts_supported_voice_cb callback, void* user_data);