Fix unit functions that are not invoked 20/278920/1
authorSuyeon Hwang <stom.hwang@samsung.com>
Wed, 13 Jul 2022 07:47:21 +0000 (16:47 +0900)
committerSuyeon Hwang <stom.hwang@samsung.com>
Thu, 28 Jul 2022 02:51:50 +0000 (11:51 +0900)
- Issue:
Some internal functions are not invoked from business logic.

- Solution:
Some functions are predefined for future needs, but they are note called
yet. So, these functions decrease the line coverage. To solve this issue,
this patch removes those dead functions.
And also, this patch invokes a dead function. This function has purpose
and code that needs to invoke this function, but current code does not
use it. Through this patch, this function is invoked and covered by test
case.

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

index 21a8f8bce2aa15e54552c2035447dbb40eb52862..ee974f973fecb131057be90e7e26eb8621888601 100644 (file)
@@ -318,58 +318,6 @@ int tts_client_get_use_callback(tts_client_s* client)
        return client->cb_ref_count;
 }
 
-//LCOV_EXCL_START
-int tts_client_get_connected_client_count()
-{
-       GList *iter = NULL;
-       tts_client_s *data = NULL;
-       int number = 0;
-
-       pthread_mutex_lock(&g_client_list_mutex);
-       if (g_list_length(g_client_list) > 0) {
-               /* Get a first item */
-               iter = g_list_first(g_client_list);
-
-               while (NULL != iter) {
-                       data = iter->data;
-                       if (0 < data->current_state) {
-                               number++;
-                       }
-
-                       /* Next item */
-                       iter = g_list_next(iter);
-               }
-       }
-       pthread_mutex_unlock(&g_client_list_mutex);
-       return number;
-}
-
-int tts_client_get_mode_client_count(tts_mode_e mode)
-{
-       GList *iter = NULL;
-       tts_client_s *data = NULL;
-       int number = 0;
-
-       pthread_mutex_lock(&g_client_list_mutex);
-       if (g_list_length(g_client_list) > 0) {
-               /* Get a first item */
-               iter = g_list_first(g_client_list);
-
-               while (NULL != iter) {
-                       data = iter->data;
-                       if (0 < data->current_state && data->mode == mode) {
-                               number++;
-                       }
-
-                       /* Next item */
-                       iter = g_list_next(iter);
-               }
-       }
-       pthread_mutex_unlock(&g_client_list_mutex);
-       return number;
-}
-//LCOV_EXCL_STOP
-
 GList* tts_client_get_client_list()
 {
        GList* copy_list = NULL;
index 32e05d5a402636ad090cf456169022bf9e12e348..59a74bb2b74443ccd05a4e0646271b8456c041e1 100644 (file)
@@ -103,10 +103,6 @@ int tts_client_not_use_callback(tts_client_s* client);
 
 int tts_client_get_use_callback(tts_client_s* client);
 
-int tts_client_get_connected_client_count();
-
-int tts_client_get_mode_client_count(tts_mode_e mode);
-
 GList* tts_client_get_client_list();
 
 unsigned int tts_client_get_uid(tts_client_s* client);
index 070d54093f9aa271ba83a9db5b5ce955628f841b..63f5c8ce6c8f87a18356ce61f94d371320d1b6eb 100644 (file)
@@ -1037,11 +1037,6 @@ int tts_core_receive_hello(unsigned int uid, int ret, int credential_needed)
        return TTS_ERROR_NONE;
 }
 
-const char* tts_core_get_engine_name()
-{
-       return g_engine_name;
-}
-
 int tts_core_prepare(tts_client_s* client)
 {
        if (false == tts_client_is_valid_client(client)) {
index 41a7616ae59650d1e5bb0d596c092a6eea3dabc4..538d44fbcc4cdc3325d1bbc209d696a6e8a722e1 100644 (file)
@@ -39,7 +39,6 @@ const char* tts_core_covert_error_code(tts_error_e err);
 // called by tts.c
 int tts_core_initialize();
 int tts_core_deinitialize();
-const char* tts_core_get_engine_name();
 
 int tts_core_prepare(tts_client_s* client);
 int tts_core_prepare_sync(tts_client_s* client);
index ff9b2aac81cdda1569c1762fb0faa0eda11b3c4f..d69ef303a5c565bd6214f1eee27bf1588913ef93 100644 (file)
@@ -70,17 +70,6 @@ int tts_ipc_set_method(tts_ipc_method_e method)
        return TTS_ERROR_NONE;
 }
 
-int tts_ipc_get_method(tts_ipc_method_e* method)
-{
-       if (NULL == method) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] method is NULL");
-               return TTS_ERROR_INVALID_PARAMETER;
-       }
-
-       *method = g_ipc_method;
-       return TTS_ERROR_NONE;
-}
-
 bool tts_ipc_is_method_set()
 {
        SLOG(LOG_INFO, TAG_TTSC, "Set method (TIDL or DBUS) for ipc");
@@ -91,10 +80,9 @@ int tts_ipc_open_connection(unsigned int uid)
 {
        SLOG(LOG_INFO, TAG_TTSC, "[IPC] tts_ipc_open_connection");
 
-       tts_client_s* client = tts_client_get_by_uid(uid);
-       if (!client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "Fail to get tts_client with uid");
-               return TTS_ERROR_INVALID_STATE;
+       if (false == tts_client_is_valid_uid(uid)) {
+               SLOG(LOG_ERROR, TAG_TTSC, "Fail to get tts_client with uid(%d)", uid);
+               return TTS_ERROR_INVALID_PARAMETER;
        }
 
        if (NULL == g_vtable) {
@@ -109,10 +97,9 @@ int tts_ipc_close_connection(unsigned int uid)
 {
        SLOG(LOG_INFO, TAG_TTSC, "[IPC] tts_ipc_close_connection");
 
-       tts_client_s* client = tts_client_get_by_uid(uid);
-       if (!client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "Fail to get tts_client with uid");
-               return TTS_ERROR_OPERATION_FAILED;
+       if (false == tts_client_is_valid_uid(uid)) {
+               SLOG(LOG_ERROR, TAG_TTSC, "Fail to get tts_client with uid(%d)", uid);
+               return TTS_ERROR_INVALID_PARAMETER;
        }
 
        if (NULL == g_vtable) {
@@ -128,7 +115,7 @@ int tts_ipc_stop_listening(unsigned int uid)
        SLOG(LOG_INFO, TAG_TTSC, "[IPC] tts_ipc_stop_listening");
 
        if (false == tts_client_is_valid_uid(uid)) {
-               SLOG(LOG_ERROR, TAG_TTSC, "Fail to get tts_client with uid");
+               SLOG(LOG_ERROR, TAG_TTSC, "Fail to get tts_client with uid(%d)", uid);
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
@@ -144,10 +131,9 @@ int tts_ipc_request_hello(unsigned int uid)
 {
        SLOG(LOG_INFO, TAG_TTSC, "[IPC] tts_ipc_request_hello");
 
-       tts_client_s* client = tts_client_get_by_uid(uid);
-       if (!client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "Fail to get tts_client with uid");
-               return TTS_ERROR_OPERATION_FAILED;
+       if (false == tts_client_is_valid_uid(uid)) {
+               SLOG(LOG_ERROR, TAG_TTSC, "Fail to get tts_client with uid(%d)", uid);
+               return TTS_ERROR_INVALID_PARAMETER;
        }
 
        if (NULL == g_vtable) {
@@ -162,10 +148,9 @@ int tts_ipc_request_hello_sync(unsigned int uid)
 {
        SLOG(LOG_INFO, TAG_TTSC, "[IPC] tts_ipc_request_hello_sync");
 
-       tts_client_s* client = tts_client_get_by_uid(uid);
-       if (!client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "Fail to get tts_client with uid");
-               return TTS_ERROR_OPERATION_FAILED;
+       if (false == tts_client_is_valid_uid(uid)) {
+               SLOG(LOG_ERROR, TAG_TTSC, "Fail to get tts_client with uid(%d)", uid);
+               return TTS_ERROR_INVALID_PARAMETER;
        }
 
        if (NULL == g_vtable) {
@@ -180,10 +165,9 @@ int tts_ipc_request_initialize(unsigned int uid, bool* credential_needed)
 {
        SLOG(LOG_INFO, TAG_TTSC, "[IPC] tts_ipc_request_initialize");
 
-       tts_client_s* client = tts_client_get_by_uid(uid);
-       if (!client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "Fail to get tts_client with uid");
-               return TTS_ERROR_OPERATION_FAILED;
+       if (false == tts_client_is_valid_uid(uid)) {
+               SLOG(LOG_ERROR, TAG_TTSC, "Fail to get tts_client with uid(%d)", uid);
+               return TTS_ERROR_INVALID_PARAMETER;
        }
 
        if (NULL == g_vtable) {
@@ -198,10 +182,9 @@ int tts_ipc_request_finalize(unsigned int uid)
 {
        SLOG(LOG_INFO, TAG_TTSC, "[IPC] tts_ipc_request_finalize");
 
-       tts_client_s* client = tts_client_get_by_uid(uid);
-       if (!client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "Fail to get tts_client with uid");
-               return TTS_ERROR_OPERATION_FAILED;
+       if (false == tts_client_is_valid_uid(uid)) {
+               SLOG(LOG_ERROR, TAG_TTSC, "Fail to get tts_client with uid(%d)", uid);
+               return TTS_ERROR_INVALID_PARAMETER;
        }
 
        if (NULL == g_vtable) {
@@ -216,10 +199,9 @@ int tts_ipc_request_add_text(unsigned int uid, const char* text, const char* lan
 {
        SLOG(LOG_INFO, TAG_TTSC, "[IPC] tts_ipc_request_add_text");
 
-       tts_client_s* client = tts_client_get_by_uid(uid);
-       if (!client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "Fail to get tts_client with uid");
-               return TTS_ERROR_OPERATION_FAILED;
+       if (false == tts_client_is_valid_uid(uid)) {
+               SLOG(LOG_ERROR, TAG_TTSC, "Fail to get tts_client with uid(%d)", uid);
+               return TTS_ERROR_INVALID_PARAMETER;
        }
 
        if (NULL == g_vtable) {
@@ -234,10 +216,9 @@ int tts_ipc_request_set_private_data(unsigned int uid, const char* key, const ch
 {
        SLOG(LOG_INFO, TAG_TTSC, "[IPC] tts_ipc_request_set_private_data");
 
-       tts_client_s* client = tts_client_get_by_uid(uid);
-       if (!client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "Fail to get tts_client with uid");
-               return TTS_ERROR_OPERATION_FAILED;
+       if (false == tts_client_is_valid_uid(uid)) {
+               SLOG(LOG_ERROR, TAG_TTSC, "Fail to get tts_client with uid(%d)", uid);
+               return TTS_ERROR_INVALID_PARAMETER;
        }
 
        if (NULL == g_vtable) {
@@ -252,11 +233,11 @@ int tts_ipc_request_get_private_data(unsigned int uid, const char* key, char** d
 {
        SLOG(LOG_INFO, TAG_TTSC, "[IPC] tts_ipc_request_get_private_data");
 
-       tts_client_s* client = tts_client_get_by_uid(uid);
-       if (!client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "Fail to get tts_client with uid");
-               return TTS_ERROR_OPERATION_FAILED;
+       if (false == tts_client_is_valid_uid(uid)) {
+               SLOG(LOG_ERROR, TAG_TTSC, "Fail to get tts_client with uid(%d)", uid);
+               return TTS_ERROR_INVALID_PARAMETER;
        }
+
        if (NULL == g_vtable) {
                SLOG(LOG_ERROR, TAG_TTSC, "g_vtable is NULL");
                return TTS_ERROR_OPERATION_FAILED;
@@ -269,10 +250,9 @@ int tts_ipc_request_play(unsigned int uid, const char* credential)
 {
        SLOG(LOG_INFO, TAG_TTSC, "[IPC] tts_ipc_request_play");
 
-       tts_client_s* client = tts_client_get_by_uid(uid);
-       if (!client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "Fail to get tts_client with uid");
-               return TTS_ERROR_OPERATION_FAILED;
+       if (false == tts_client_is_valid_uid(uid)) {
+               SLOG(LOG_ERROR, TAG_TTSC, "Fail to get tts_client with uid(%d)", uid);
+               return TTS_ERROR_INVALID_PARAMETER;
        }
 
        if (NULL == g_vtable) {
@@ -287,10 +267,9 @@ int tts_ipc_request_stop(unsigned int uid)
 {
        SLOG(LOG_INFO, TAG_TTSC, "[IPC] tts_ipc_request_stop");
 
-       tts_client_s* client = tts_client_get_by_uid(uid);
-       if (!client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "Fail to get tts_client with uid");
-               return TTS_ERROR_OPERATION_FAILED;
+       if (false == tts_client_is_valid_uid(uid)) {
+               SLOG(LOG_ERROR, TAG_TTSC, "Fail to get tts_client with uid(%d)", uid);
+               return TTS_ERROR_INVALID_PARAMETER;
        }
 
        if (NULL == g_vtable) {
@@ -305,10 +284,9 @@ int tts_ipc_request_pause(unsigned int uid)
 {
        SLOG(LOG_INFO, TAG_TTSC, "[IPC] tts_ipc_request_pause");
 
-       tts_client_s* client = tts_client_get_by_uid(uid);
-       if (!client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "Fail to get tts_client with uid");
-               return TTS_ERROR_OPERATION_FAILED;
+       if (false == tts_client_is_valid_uid(uid)) {
+               SLOG(LOG_ERROR, TAG_TTSC, "Fail to get tts_client with uid(%d)", uid);
+               return TTS_ERROR_INVALID_PARAMETER;
        }
 
        if (NULL == g_vtable) {
@@ -323,10 +301,9 @@ int tts_ipc_request_play_pcm(unsigned int uid)
 {
        SLOG(LOG_INFO, TAG_TTSC, "[IPC] tts_ipc_request_play_pcm");
 
-       tts_client_s* client = tts_client_get_by_uid(uid);
-       if (!client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "Fail to get tts_client with uid");
-               return TTS_ERROR_OPERATION_FAILED;
+       if (false == tts_client_is_valid_uid(uid)) {
+               SLOG(LOG_ERROR, TAG_TTSC, "Fail to get tts_client with uid(%d)", uid);
+               return TTS_ERROR_INVALID_PARAMETER;
        }
 
        if (NULL == g_vtable) {
@@ -341,10 +318,9 @@ int tts_ipc_request_stop_pcm(unsigned int uid)
 {
        SLOG(LOG_INFO, TAG_TTSC, "[IPC] tts_ipc_request_stop_pcm");
 
-       tts_client_s* client = tts_client_get_by_uid(uid);
-       if (!client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "Fail to get tts_client with uid");
-               return TTS_ERROR_OPERATION_FAILED;
+       if (false == tts_client_is_valid_uid(uid)) {
+               SLOG(LOG_ERROR, TAG_TTSC, "Fail to get tts_client with uid(%d)", uid);
+               return TTS_ERROR_INVALID_PARAMETER;
        }
 
        if (NULL == g_vtable) {
@@ -359,10 +335,9 @@ int tts_ipc_request_add_pcm(unsigned int uid, int event, const char* data, int d
 {
        SLOG(LOG_INFO, TAG_TTSC, "[IPC] tts_ipc_request_add_pcm");
 
-       tts_client_s* client = tts_client_get_by_uid(uid);
-       if (!client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "Fail to get tts_client with uid");
-               return TTS_ERROR_OPERATION_FAILED;
+       if (false == tts_client_is_valid_uid(uid)) {
+               SLOG(LOG_ERROR, TAG_TTSC, "Fail to get tts_client with uid(%d)", uid);
+               return TTS_ERROR_INVALID_PARAMETER;
        }
 
        if (NULL == g_vtable) {
@@ -377,10 +352,9 @@ int tts_ipc_request_set_mode(unsigned int uid, tts_mode_e mode)
 {
        SLOG(LOG_INFO, TAG_TTSC, "[IPC] tts_ipc_request_set_mode");
 
-       tts_client_s* client = tts_client_get_by_uid(uid);
-       if (!client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "Fail to get tts_client with uid");
-               return TTS_ERROR_OPERATION_FAILED;
+       if (false == tts_client_is_valid_uid(uid)) {
+               SLOG(LOG_ERROR, TAG_TTSC, "Fail to get tts_client with uid(%d)", uid);
+               return TTS_ERROR_INVALID_PARAMETER;
        }
 
        if (NULL == g_vtable) {
index ac74325c42809f8797e7523ee0cf8322e87ef314..df61feadf6897bc48d7746720f760cd20774ba5d 100644 (file)
@@ -22,8 +22,6 @@ extern "C" {
 
 int tts_ipc_set_method(tts_ipc_method_e method);
 
-int tts_ipc_get_method(tts_ipc_method_e* method);
-
 bool tts_ipc_is_method_set();
 
 int tts_ipc_open_connection(unsigned int uid);