From ccdc43c22ff01032ffcfc91cabf55cd5098c0ef0 Mon Sep 17 00:00:00 2001 From: InHong Han Date: Mon, 2 Apr 2018 20:43:51 +0900 Subject: [PATCH] Fix defect detected by static anlaysis tool Change-Id: I9ce40294ac796696821016ae459ba59a117aa2a4 --- ism/extras/efl_panel/isf_panel_efl.cpp | 2 +- ism/extras/wayland_immodule/wayland_imcontext.c | 3 --- .../ecoresocket/ecore_socket_panel_agent_module.cpp | 18 +++++------------- .../panelagent/wayland/wayland_panel_agent_module.cpp | 17 ++++++++++++----- ism/src/isf_imcontrol_client.cpp | 6 +----- ism/src/isf_query_utility.cpp | 3 ++- ism/src/scim_helper_launcher.cpp | 2 +- ism/src/scim_utility.cpp | 7 ++++++- 8 files changed, 28 insertions(+), 30 deletions(-) diff --git a/ism/extras/efl_panel/isf_panel_efl.cpp b/ism/extras/efl_panel/isf_panel_efl.cpp index 01798dd..4958248 100644 --- a/ism/extras/efl_panel/isf_panel_efl.cpp +++ b/ism/extras/efl_panel/isf_panel_efl.cpp @@ -7697,7 +7697,7 @@ int main (int argc, char *argv []) ret = -1; goto cleanup; } - DebugOutput::set_output (argv [i]); + DebugOutput::set_output (String (argv [i])); continue; } diff --git a/ism/extras/wayland_immodule/wayland_imcontext.c b/ism/extras/wayland_immodule/wayland_imcontext.c index edfe6b0..ac6df2d 100644 --- a/ism/extras/wayland_immodule/wayland_imcontext.c +++ b/ism/extras/wayland_immodule/wayland_imcontext.c @@ -823,9 +823,6 @@ key_down_filter_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *event) LOGD("no focus"); SECURE_LOGD ("%s key is pressed. ret : %d", ev->keyname, filter_ret); - if (filter_ret) { - return EINA_FALSE; /* the event is removed from the queue */ - } return EINA_FALSE; /* the event is removed from the queue */ } return EINA_TRUE; /* the event is kept */ diff --git a/ism/modules/panelagent/ecoresocket/ecore_socket_panel_agent_module.cpp b/ism/modules/panelagent/ecoresocket/ecore_socket_panel_agent_module.cpp index c4e856d..61a3b0f 100644 --- a/ism/modules/panelagent/ecoresocket/ecore_socket_panel_agent_module.cpp +++ b/ism/modules/panelagent/ecoresocket/ecore_socket_panel_agent_module.cpp @@ -922,8 +922,8 @@ private: if (trans.write_to_socket(client_socket) && trans.read_from_socket(client_socket) - && trans.get_command(cmd) && cmd == SCIM_TRANS_CMD_REPLY) { - trans.get_data(imdata, len); + && trans.get_command(cmd) && cmd == SCIM_TRANS_CMD_REPLY + && trans.get_data(imdata, len)) { LOGD ("length of imdata is %d", len); } else { LOGW ("read imdata failed"); @@ -3168,22 +3168,14 @@ private: if (m_info_manager->check_privilege_by_sockfd(client_id, IMEMANAGER_PRIVILEGE)) { String strAppid; uint32 nEnabled = 0; - bool ret = true; - //FIXME - //ret need be checked + m_info_manager->is_helper_ise_enabled(client_id, strAppid, nEnabled); Transaction trans; Socket client_socket(client_id); trans.clear(); trans.put_command(SCIM_TRANS_CMD_REPLY); - - if (ret) { - trans.put_command(SCIM_TRANS_CMD_OK); - trans.put_data(static_cast(nEnabled)); - } else { - trans.put_command(SCIM_TRANS_CMD_FAIL); - } - + trans.put_command(SCIM_TRANS_CMD_OK); + trans.put_data(static_cast(nEnabled)); trans.write_to_socket(client_socket); } else { diff --git a/ism/modules/panelagent/wayland/wayland_panel_agent_module.cpp b/ism/modules/panelagent/wayland/wayland_panel_agent_module.cpp index 229a86e..9d88744 100644 --- a/ism/modules/panelagent/wayland/wayland_panel_agent_module.cpp +++ b/ism/modules/panelagent/wayland/wayland_panel_agent_module.cpp @@ -1281,7 +1281,8 @@ isf_wsc_context_del (WSCContextISF *wsc_ctx) if (context_scim->selection_text_fd_read_handler) { int fd = ecore_main_fd_handler_fd_get (context_scim->selection_text_fd_read_handler); - close (fd); + if (fd >= 0) + close (fd); ecore_main_fd_handler_del (context_scim->selection_text_fd_read_handler); context_scim->selection_text_fd_read_handler = NULL; } @@ -1293,14 +1294,16 @@ isf_wsc_context_del (WSCContextISF *wsc_ctx) if (context_scim->surrounding_text_fd_read_handler) { int fd = ecore_main_fd_handler_fd_get (context_scim->surrounding_text_fd_read_handler); - close (fd); + if (fd >= 0) + close (fd); ecore_main_fd_handler_del (context_scim->surrounding_text_fd_read_handler); context_scim->surrounding_text_fd_read_handler = NULL; } if (context_scim->remote_surrounding_text_fd_read_handler) { int fd = ecore_main_fd_handler_fd_get (context_scim->remote_surrounding_text_fd_read_handler); - close (fd); + if (fd >= 0) + close (fd); ecore_main_fd_handler_del (context_scim->remote_surrounding_text_fd_read_handler); context_scim->remote_surrounding_text_fd_read_handler = NULL; } @@ -1338,7 +1341,7 @@ isf_wsc_context_del (WSCContextISF *wsc_ctx) // we need set the focused_ic to this context temporary. WSCContextISF* old_focused = _focused_ic; _focused_ic = context_scim; - _focused_ic = old_focused; + context_scim = old_focused; if (context_scim == _focused_ic) { g_info_manager->socket_turn_off (); @@ -2012,6 +2015,9 @@ remote_surrounding_text_fd_read_func (void* data, Ecore_Fd_Handler* fd_handler) WSCContextISF* wsc_ctx = (WSCContextISF*)data; int fd = ecore_main_fd_handler_fd_get (fd_handler); + if (fd < 0) + return ECORE_CALLBACK_RENEW; + char buff[512]; int len = read (fd, buff, sizeof (buff) - 1); @@ -3266,7 +3272,8 @@ public: if (ic->surrounding_text_fd_read_handler) { int fd = ecore_main_fd_handler_fd_get (ic->surrounding_text_fd_read_handler); - close (fd); + if (fd >= 0) + close (fd); ecore_main_fd_handler_del (ic->surrounding_text_fd_read_handler); ic->surrounding_text_fd_read_handler = NULL; } diff --git a/ism/src/isf_imcontrol_client.cpp b/ism/src/isf_imcontrol_client.cpp index 155fff5..edbf6f1 100644 --- a/ism/src/isf_imcontrol_client.cpp +++ b/ism/src/isf_imcontrol_client.cpp @@ -425,11 +425,7 @@ public: return false; } - if (appid.size () > 0) { - m_trans.get_data (label); - m_trans.get_data (is_enabled); - m_trans.get_data (is_preinstalled); - m_trans.get_data (has_option); + if (appid.size () > 0 && m_trans.get_data (label) && m_trans.get_data (is_enabled) && m_trans.get_data (is_preinstalled) && m_trans.get_data (has_option)) { if (appid.size () == label.size () && appid.size () == is_enabled.size () && appid.size () == is_preinstalled.size () && appid.size () == has_option.size ()) { info.appid = appid; info.label = label; diff --git a/ism/src/isf_query_utility.cpp b/ism/src/isf_query_utility.cpp index d65a81b..fe78fb4 100644 --- a/ism/src/isf_query_utility.cpp +++ b/ism/src/isf_query_utility.cpp @@ -299,7 +299,8 @@ static inline int _db_connect(void) _db_disconnect(); LOGD("need_reset, removing db"); databaseInfo.need_reset = false; - remove(databaseInfo.pPath); + if (remove(databaseInfo.pPath) != 0) + LOGW ("Error deleting path"); ret = _db_init(); } diff --git a/ism/src/scim_helper_launcher.cpp b/ism/src/scim_helper_launcher.cpp index fdc902b..5e16524 100644 --- a/ism/src/scim_helper_launcher.cpp +++ b/ism/src/scim_helper_launcher.cpp @@ -145,7 +145,7 @@ int main (int argc, char *argv []) } } - String exec = String (argv[0]); + String exec = argv[0]; if (exec != String (SCIM_HELPER_LAUNCHER_PROGRAM)) { /* 3rd party shared object type IME */ diff --git a/ism/src/scim_utility.cpp b/ism/src/scim_utility.cpp index ea076c0..fdab609 100644 --- a/ism/src/scim_utility.cpp +++ b/ism/src/scim_utility.cpp @@ -681,9 +681,14 @@ scim_get_user_name () char buf [2048] = {0,}; setpwent (); - getpwuid_r (getuid (), &pw, buf, sizeof (buf), &result); + int ret = getpwuid_r (getuid (), &pw, buf, sizeof (buf), &result); endpwent (); + if (ret != 0 || !result) { + LOGE ("Fail to getpwuid_r"); + return String (""); + } + if (result && pw.pw_name) { return String (pw.pw_name); } else if ((user_name = getenv ("USER")) != NULL) { -- 2.7.4