Remove duplicated check code 12/260512/1
authorSuyeon Hwang <stom.hwang@samsung.com>
Mon, 28 Jun 2021 05:27:12 +0000 (14:27 +0900)
committerSuyeon Hwang <stom.hwang@samsung.com>
Mon, 28 Jun 2021 05:27:12 +0000 (14:27 +0900)
Change-Id: I2641de9f183dfa758a8bfe18fcc27c86f2801b04
Signed-off-by: Suyeon Hwang <stom.hwang@samsung.com>
client/tts_ipc.c

index 3cf3bad..c102982 100644 (file)
@@ -50,16 +50,9 @@ int(*ttsc_tidl_vtable[])() = { &tts_tidl_open_connection, &tts_tidl_close_connec
 static int (**g_vtable)();
 static tts_ipc_method_e g_ipc_method = TTS_IPC_METHOD_UNDEFINED;
 
-int tts_ipc_set_method(tts_ipc_method_e method) {
-       if (TTS_IPC_METHOD_UNDEFINED > method || TTS_IPC_METHOD_TIDL < method) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] method is not valid");
-               return TTS_ERROR_INVALID_PARAMETER;
-       }
-
-       g_ipc_method = method;
-
-       /* choose ipc */
-       switch (g_ipc_method) {
+int tts_ipc_set_method(tts_ipc_method_e method)
+{
+       switch (method) {
        case TTS_IPC_METHOD_DBUS:
                g_vtable = ttsc_dbus_vtable;
                break;
@@ -69,12 +62,15 @@ int tts_ipc_set_method(tts_ipc_method_e method) {
        default:
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] IPC method is not valid");
                g_vtable = NULL;
+               return TTS_ERROR_INVALID_PARAMETER;
        }
 
+       g_ipc_method = method;
        return TTS_ERROR_NONE;
 }
 
-int tts_ipc_get_method(tts_ipc_method_e* method) {
+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;
@@ -84,7 +80,8 @@ int tts_ipc_get_method(tts_ipc_method_e* method) {
        return TTS_ERROR_NONE;
 }
 
-bool tts_ipc_is_method_set() {
+bool tts_ipc_is_method_set()
+{
        SLOG(LOG_INFO, TAG_TTSC, "Set method (TIDL or DBUS) for ipc");
        return (g_ipc_method != TTS_IPC_METHOD_UNDEFINED);
 }
@@ -99,15 +96,7 @@ int tts_ipc_open_connection(int uid)
                return TTS_ERROR_INVALID_STATE;
        }
 
-       /* choose ipc */
-       switch (g_ipc_method) {
-       case TTS_IPC_METHOD_DBUS:
-               g_vtable = ttsc_dbus_vtable;
-               break;
-       case TTS_IPC_METHOD_TIDL:
-               g_vtable = ttsc_tidl_vtable;
-               break;
-       default:
+       if (NULL == g_vtable) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] IPC method is not set");
                return TTS_ERROR_OPERATION_FAILED;
        }