Fix format string and data types 39/286239/1
authorSuyeon Hwang <stom.hwang@samsung.com>
Mon, 2 Jan 2023 05:51:55 +0000 (14:51 +0900)
committerTizen AI <ai.tzn.sec@samsung.com>
Mon, 2 Jan 2023 10:31:20 +0000 (19:31 +0900)
- Issue:
Some format string and data types are not matched to the size of those
values.

- Solution:
This patch fixes the format string and data types for handling the size
of the value. And also this patch removes data copy in iterating
vector lists using reference type.

Change-Id: I3076c3ff9899b44469267a78bd7a8562aa4ee104
Signed-off-by: Suyeon Hwang <stom.hwang@samsung.com>
client/vc_setting_tidl.c
client/vc_tidl.c
common/VoiceControlEngineInfo.cpp
common/VoiceControlEngines.cpp
server/vcd_tidl.c

index 162cd50514ebb8d65d8d71f185ca99ab901e6ff7..686652f53bec3396988de68840b4604132b2cf42 100644 (file)
@@ -80,7 +80,7 @@ static char* __get_engine_appid(void)
 
 static void __on_connected(rpc_port_proxy_vc_setting_proxy_vc_setting_h h, void* user_data)
 {
-       unsigned int pid = (uintptr_t)user_data;
+       unsigned int pid = (intptr_t)user_data;
 
        vc_setting_tidl_info_s* info = __get_tidl_info_s(pid);
        RETM_IF(NULL == info, TAG_VCC, "[ERROR] Fail to get tidl info");
@@ -94,7 +94,7 @@ static void __on_connected(rpc_port_proxy_vc_setting_proxy_vc_setting_h h, void*
 
 static void __on_disconnected(rpc_port_proxy_vc_setting_proxy_vc_setting_h h, void* user_data)
 {
-       unsigned int pid = (uintptr_t)user_data;
+       unsigned int pid = (intptr_t)user_data;
 
        vc_setting_tidl_info_s* info = __get_tidl_info_s(pid);
        RETM_IF(NULL == info, TAG_VCC, "[ERROR] Fail to get tidl info");
@@ -109,7 +109,7 @@ static void __on_disconnected(rpc_port_proxy_vc_setting_proxy_vc_setting_h h, vo
 
 static void __on_rejected(rpc_port_proxy_vc_setting_proxy_vc_setting_h h, void* user_data)
 {
-       unsigned int pid = (uintptr_t)user_data;
+       unsigned int pid = (intptr_t)user_data;
 
        vc_setting_tidl_info_s* info = __get_tidl_info_s(pid);
        RETM_IF(NULL == info, TAG_VCC, "[ERROR] Fail to get tidl info");
@@ -132,7 +132,7 @@ static rpc_port_proxy_vc_setting_proxy_vc_setting_h __create_rpc_port(int pid, c
        };
 
        rpc_port_proxy_vc_setting_proxy_vc_setting_h handle = NULL;
-       uintptr_t ptr_pid = pid;
+       intptr_t ptr_pid = pid;
        if (0 != rpc_port_proxy_vc_setting_proxy_vc_setting_create(engine_app_id, &rpc_callback, (void*)ptr_pid, &handle)) {
                SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail rpc_port_proxy_vc_setting_proxy_vc_setting_create");
                return NULL;
index d1b39ec288a50413b34b46b4a1a62966bb8e1bf7..aad0435cdd3ec397aa49fbde2ca505d5ef6ee1be 100644 (file)
@@ -89,7 +89,7 @@ static char* __get_engine_appid(void)
 
 static void __on_connected(rpc_port_proxy_vc_proxy_vc_h h, void* user_data)
 {
-       unsigned int pid = (uintptr_t)user_data;
+       unsigned int pid = (intptr_t)user_data;
 
        vc_tidl_info_s* info = __get_tidl_info_s(pid);
        RETM_IF(NULL == info, TAG_VCC, "[ERROR] Fail to get tidl info");
@@ -103,7 +103,7 @@ static void __on_connected(rpc_port_proxy_vc_proxy_vc_h h, void* user_data)
 
 static void __on_disconnected(rpc_port_proxy_vc_proxy_vc_h h, void* user_data)
 {
-       unsigned int pid = (uintptr_t)user_data;
+       unsigned int pid = (intptr_t)user_data;
 
        vc_tidl_info_s* info = __get_tidl_info_s(pid);
        RETM_IF(NULL == info, TAG_VCC, "[ERROR] Fail to get tidl info");
@@ -122,7 +122,7 @@ static void __on_disconnected(rpc_port_proxy_vc_proxy_vc_h h, void* user_data)
 //LCOV_EXCL_START
 static void __on_rejected(rpc_port_proxy_vc_proxy_vc_h h, void* user_data)
 {
-       unsigned int pid = (uintptr_t)user_data;
+       unsigned int pid = (intptr_t)user_data;
 
        vc_tidl_info_s* info = __get_tidl_info_s(pid);
        RETM_IF(NULL == info, TAG_VCC, "[ERROR] Fail to get tidl info");
@@ -146,7 +146,7 @@ static rpc_port_proxy_vc_proxy_vc_h __create_rpc_port(int pid, const char* engin
        };
 
        rpc_port_proxy_vc_proxy_vc_h handle = NULL;
-       uintptr_t ptr_pid = pid;
+       intptr_t ptr_pid = pid;
        if (0 != rpc_port_proxy_vc_proxy_vc_create(engine_app_id, &rpc_callback, (void*)ptr_pid, &handle)) {
                return NULL;
        }
index 2968704a38c9c35db1799d5f8a2257b8124259cb..475bee14c71a2465eedd50374f172c00e52f66a2 100644 (file)
@@ -76,7 +76,7 @@ void VoiceControlEngineInfo::printOutEngine()
                SLOG(LOG_DEBUG, TAG_VCCONFIG, "    language is NONE");
        } else {
                unsigned int index = 1;
-               for (auto language : __supportedLanguages) {
+               for (auto &language : __supportedLanguages) {
                        SLOG(LOG_DEBUG, TAG_VCCONFIG, "    [%uth] %s", index, language.c_str());
                        index++;
                }
@@ -85,7 +85,7 @@ void VoiceControlEngineInfo::printOutEngine()
 
 bool VoiceControlEngineInfo::isLanguageValid(const std::string language)
 {
-       for (auto supportedLanguage : __supportedLanguages) {
+       for (auto &supportedLanguage : __supportedLanguages) {
                SLOG(LOG_DEBUG, TAG_VCCONFIG, "Compare language(%s), Target(%s)", supportedLanguage.c_str(), language.c_str());
                if (0 == supportedLanguage.compare(language)) {
                        SLOG(LOG_INFO, TAG_VCCONFIG, "Language(%s) is valid", language.c_str());
index 3143d0ca0b8987cf36f84d1af66a7a5ac4ad71c0..47a32513096d2abd6642cecacccfb65fd09ec4a9 100644 (file)
@@ -37,7 +37,7 @@ void VoiceControlEngines::printOutEngineInfo()
                SLOG(LOG_DEBUG, TAG_VCCONFIG, "  No Engine in engine directory");
        } else {
                unsigned int index = 0;
-               for (auto engineInfo : __engines) {
+               for (auto &engineInfo : __engines) {
                        SLOG(LOG_DEBUG, TAG_VCCONFIG, "[%uth]", index);
                        engineInfo.printOutEngine();
                }
@@ -98,7 +98,7 @@ std::shared_ptr<VoiceControlEngineInfo> VoiceControlEngines::getFirstEngineInfo(
                return nullptr;
        }
 
-       SLOG(LOG_INFO, TAG_VCCONFIG, "Get first engine info. size(%u)", __engines.size());
+       SLOG(LOG_INFO, TAG_VCCONFIG, "Get first engine info. size(%zu)", __engines.size());
        return make_shared<VoiceControlEngineInfo>(__engines[0]);
 }
 
@@ -124,14 +124,14 @@ VoiceControlEngineInfo *VoiceControlEngines::findEngine(const std::string engine
 std::vector<VoiceControlEngineInfo> VoiceControlEngines::getEngines()
 {
        unique_lock<mutex> lock(__enginesMutex);
-       SLOG(LOG_INFO, TAG_VCCONFIG, "Get engines. size(%u)", __engines.size());
+       SLOG(LOG_INFO, TAG_VCCONFIG, "Get engines. size(%zu)", __engines.size());
        return __engines;
 }
 
 bool VoiceControlEngines::isEngineEmpty()
 {
        unique_lock<mutex> lock(__enginesMutex);
-       SLOG(LOG_INFO, TAG_VCCONFIG, "Length of engines (%u)", __engines.size());
+       SLOG(LOG_INFO, TAG_VCCONFIG, "Length of engines (%zu)", __engines.size());
        return __engines.empty();
 }
 
index 7d8abfe29cdd02694e898c8286588252271e6b4d..0940cd0e52fcd545f8f502b708a37a9d188b0c4e 100644 (file)
@@ -330,7 +330,7 @@ static void __vc_terminate_cb(rpc_port_stub_vcd_stub_vc_context_h context, void
        rpc_port_stub_vcd_stub_vc_context_get_tag(context, &tag);
 
        if (NULL != tag) {
-               int pid = (uintptr_t)tag;
+               int pid = (intptr_t)tag;
                SLOG(LOG_DEBUG, TAG_VCD, "@@@ VC FINALIZE. pid(%u)", pid);
 
                pthread_mutex_lock(&g_client_tidl_info_mutex);
@@ -400,7 +400,7 @@ static int __vc_register_notify_cb_sync_cb(rpc_port_stub_vcd_stub_vc_context_h c
                SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to add tidl info.");
                return ret;
        }
-       
+
        ret = vcd_client_set_tidl_notify_cb(pid, callback, user_data);
        if (0 != ret) {
                SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to set notify callback.");
@@ -450,7 +450,7 @@ static int __vc_register_feedback_cb_sync_cb(rpc_port_stub_vcd_stub_vc_context_h
                SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to add tidl info.");
                return ret;
        }
-       
+
        ret = vcd_client_set_tidl_feedback_cb(pid, callback, user_data);
        if (0 != ret) {
                SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to set feedback callback.");
@@ -467,7 +467,7 @@ static int __vc_initialize_cb(rpc_port_stub_vcd_stub_vc_context_h context, int p
 
        int ret = VCD_ERROR_OPERATION_FAILED;
 
-       uintptr_t ptr_pid = pid;
+       intptr_t ptr_pid = pid;
        rpc_port_stub_vcd_stub_vc_context_set_tag(context, (void*)ptr_pid);
 
        ret = vcd_server_initialize(pid);
@@ -528,7 +528,7 @@ static int __vc_unset_command_cb(rpc_port_stub_vcd_stub_vc_context_h context, in
        } else {
                SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to vcd unset command : pid(%d), cmd_type(%d) ret(%d)", pid, cmd_type, ret);
        }
-       
+
        return ret;
 }
 
@@ -544,7 +544,7 @@ static int __vc_set_foreground_cb(rpc_port_stub_vcd_stub_vc_context_h context, i
                SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to vcd set foreground : pid(%d) ret(%d)", pid, ret);
                return ret;
        }
-       
+
        SLOG(LOG_INFO, TAG_VCD, "[IN] vcd set foreground : pid(%d)", pid);
        vcdc_send_request_set_foreground(pid, value);
 
@@ -563,7 +563,7 @@ static int __vc_set_server_dialog_cb(rpc_port_stub_vcd_stub_vc_context_h context
        } else {
                SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to vcd set server dialog : pid(%d), app_id(%s) ret(%d)", pid, app_id, ret);
        }
-       
+
        return ret;
 }
 
@@ -579,7 +579,7 @@ static int __vc_request_dialog_cb(rpc_port_stub_vcd_stub_vc_context_h context, i
        } else {
                SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to vcd request dialog : pid(%d), disp_text(%s), utt_text(%s), continuous(%d), ret(%d)", pid, disp_text, utt_text, continuous, ret);
        }
-       
+
        return VCD_ERROR_NONE;
 }
 
@@ -595,7 +595,7 @@ static int __vc_is_system_command_valid_cb(rpc_port_stub_vcd_stub_vc_context_h c
        } else {
                SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to vcd check system command is valid : pid(%d), ret(%d)", pid, ret);
        }
-       
+
        return ret;
 }
 
@@ -686,7 +686,7 @@ static int __vc_request_tts_cb(rpc_port_stub_vcd_stub_vc_context_h context, int
        } else {
                SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to vcd request tts : pid(%d), text(%s), language(%s), to_vcm(%d), ret(%d)", pid, text, lang, to_vcm, ret);
        }
-       
+
        return ret;
 }
 
@@ -702,7 +702,7 @@ static int __vc_cancel_tts_cb(rpc_port_stub_vcd_stub_vc_context_h context, int p
        } else {
                SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to vcd cancel tts : pid(%d), utt_id(%d), ret(%d)", pid, utt_id, ret);
        }
-       
+
        return ret;
 }
 
@@ -718,7 +718,7 @@ static int __vc_get_tts_audio_format_cb(rpc_port_stub_vcd_stub_vc_context_h cont
        } else {
                SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to vcd get tts audio format : pid(%d) ret(%d)", pid, ret);
        }
-       
+
        return ret;
 }
 
@@ -1535,7 +1535,7 @@ static int  __vc_widget_initialize_cb(rpc_port_stub_vcd_widget_stub_vc_widget_co
 {
        SLOG(LOG_INFO, TAG_VCD, "@@@ VCD Widget Initialize");
 
-       uintptr_t ptr_pid = pid;
+       intptr_t ptr_pid = pid;
        int ret = -1;
 
        rpc_port_stub_vcd_widget_stub_vc_widget_context_set_tag(context, (void*)ptr_pid);
@@ -1804,7 +1804,7 @@ static int __vc_setting_register_notify_cb_sync_cb(rpc_port_stub_vcd_setting_stu
                SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to add tidl info.");
                return ret;
        }
-       
+
        ret = vcd_client_setting_set_tidl_notify_cb(pid, callback, user_data);
        if (0 != ret) {
                SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to set notify callback.");
@@ -2274,7 +2274,7 @@ int vcdc_send_service_state(vcd_state_e state)
 
        bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_METHOD_SET_SERVICE_STATE);
        bundle_add_str(msg, VC_BUNDLE_SERVICE_STATE, tmp_state);
-       
+
        __send_signal(msg, VCD_CLIENT_TYPE_MANAGER);
        __send_signal(msg, VCD_CLIENT_TYPE_NORMAL);
        __send_signal(msg, VCD_CLIENT_TYPE_WIDGET);