From: Jihoon Kim Date: Fri, 30 Jun 2017 09:38:29 +0000 (+0900) Subject: Fix issues detected by static analysis tool X-Git-Tag: accepted/tizen/unified/20170713.153704~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F96%2F136596%2F5;p=platform%2Fcore%2Fuifw%2Fisf.git Fix issues detected by static analysis tool Change-Id: I3cd5c78be3f80b19385f165617596beca0e384f1 Signed-off-by: Jihoon Kim --- diff --git a/ism/extras/efl_panel/isf_panel_efl.cpp b/ism/extras/efl_panel/isf_panel_efl.cpp index eb8b39e..27c8c37 100644 --- a/ism/extras/efl_panel/isf_panel_efl.cpp +++ b/ism/extras/efl_panel/isf_panel_efl.cpp @@ -5581,7 +5581,7 @@ static void slot_show_helper_ise_list (void) if (ret == PMINFO_R_OK) { ret = pkgmgrinfo_appinfo_filter_add_string (handle, PMINFO_APPINFO_PROP_APP_CATEGORY, "http://tizen.org/category/ime-list"); if (ret == PMINFO_R_OK) { - ret = pkgmgrinfo_appinfo_filter_foreach_appinfo (handle, _find_appid_from_category, &app_id); + pkgmgrinfo_appinfo_filter_foreach_appinfo (handle, _find_appid_from_category, &app_id); } pkgmgrinfo_appinfo_filter_destroy (handle); @@ -5618,7 +5618,7 @@ static void slot_show_helper_ise_selector (void) if (ret == PMINFO_R_OK) { ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_CATEGORY, "http://tizen.org/category/ime-selector"); if (ret == PMINFO_R_OK) { - ret = pkgmgrinfo_appinfo_filter_foreach_appinfo(handle, _find_appid_from_category, &app_id); + pkgmgrinfo_appinfo_filter_foreach_appinfo(handle, _find_appid_from_category, &app_id); } pkgmgrinfo_appinfo_filter_destroy(handle); @@ -6616,7 +6616,7 @@ static void show_ime_selector_notification () if (ret == PMINFO_R_OK) { ret = pkgmgrinfo_appinfo_filter_add_string (handle, PMINFO_APPINFO_PROP_APP_CATEGORY, "http://tizen.org/category/ime-selector"); if (ret == PMINFO_R_OK) { - ret = pkgmgrinfo_appinfo_filter_foreach_appinfo (handle, _find_appid_from_category, &app_id); + pkgmgrinfo_appinfo_filter_foreach_appinfo (handle, _find_appid_from_category, &app_id); } pkgmgrinfo_appinfo_filter_destroy (handle); @@ -7409,6 +7409,8 @@ int main (int argc, char *argv []) update_ise_locale (); } catch (scim::Exception & e) { std::cerr << e.what () << "\n"; + } catch (std::logic_error & e) { + std::cerr << e.what () << "\n"; } #ifdef HAVE_ECOREX xclient_message_handler = ecore_event_handler_add (ECORE_X_EVENT_CLIENT_MESSAGE, x_event_client_message_cb, NULL); diff --git a/ism/extras/wayland_immodule/wayland_imcontext.c b/ism/extras/wayland_immodule/wayland_imcontext.c index d6604ad..a065a83 100644 --- a/ism/extras/wayland_immodule/wayland_imcontext.c +++ b/ism/extras/wayland_immodule/wayland_imcontext.c @@ -2258,7 +2258,7 @@ text_input_get_surrounding_text (void *data, maxlen_before = cursor_pos - maxlen_before; if (maxlen_after > wlen - cursor_pos) - maxlen_after = wlen; + maxlen_after = (uint32_t)wlen; else maxlen_after = cursor_pos + maxlen_after; diff --git a/ism/modules/config/scim_socket_config.cpp b/ism/modules/config/scim_socket_config.cpp index 8871d66..d628f02 100644 --- a/ism/modules/config/scim_socket_config.cpp +++ b/ism/modules/config/scim_socket_config.cpp @@ -203,7 +203,7 @@ SocketConfig::read (const String& key, double* val) const if (trans.get_command (cmd) && cmd == SCIM_TRANS_CMD_REPLY && trans.get_data (str) && trans.get_command (cmd) && cmd == SCIM_TRANS_CMD_OK) { - sscanf (str.c_str (), "%lE", val); + *val = strtod (str.c_str (), NULL); return true; } LOGW ("wrong format of transaction\n"); diff --git a/ism/modules/frontend/scim_socket_frontend.cpp b/ism/modules/frontend/scim_socket_frontend.cpp index 6edf02f..4de153c 100644 --- a/ism/modules/frontend/scim_socket_frontend.cpp +++ b/ism/modules/frontend/scim_socket_frontend.cpp @@ -2312,7 +2312,7 @@ SocketFrontEnd::socket_set_config_double (int /*client_id*/) if (m_receive_trans.get_data (key) && m_receive_trans.get_data (str)) { double value; - sscanf (str.c_str (), "%lE", &value); + value = strtod (str.c_str (), NULL); SCIM_DEBUG_FRONTEND (3) << " Key (" << key << ").\n"; SCIM_DEBUG_FRONTEND (3) << " Value (" << value << ").\n"; 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 2e42ed7..540d587 100644 --- a/ism/modules/panelagent/ecoresocket/ecore_socket_panel_agent_module.cpp +++ b/ism/modules/panelagent/ecoresocket/ecore_socket_panel_agent_module.cpp @@ -1756,6 +1756,8 @@ private: EcoreSocketPanelAgent* _agent = (EcoreSocketPanelAgent*)data; int fd = ecore_main_fd_handler_fd_get(fd_handler); + if (fd < 0) + return ECORE_CALLBACK_RENEW; for (unsigned int i = 0; i < _agent->_read_handler_list.size(); i++) { if (fd_handler == _agent->_read_handler_list [i]) { diff --git a/ism/modules/panelagent/wayland/wayland_panel_agent_module.cpp b/ism/modules/panelagent/wayland/wayland_panel_agent_module.cpp index 83acbe5..7f04b97 100644 --- a/ism/modules/panelagent/wayland/wayland_panel_agent_module.cpp +++ b/ism/modules/panelagent/wayland/wayland_panel_agent_module.cpp @@ -963,9 +963,9 @@ get_time (void) struct timeval tv; struct timezone tz; /* is not used since ages */ gettimeofday (&tv, &tz); - tint = tv.tv_sec * 1000; + tint = (unsigned int)(tv.tv_sec * 1000); tint = tint / 1000 * 1000; - tint = tint + tv.tv_usec / 1000; + tint = (unsigned int)(tint + tv.tv_usec / 1000); return tint; } @@ -3104,6 +3104,9 @@ public: 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); if (len == 0) { @@ -3239,6 +3242,9 @@ public: WSCContextISF* wsc_ctx = (WSCContextISF*)data; LOGD(""); 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); if (len == 0) { @@ -3305,7 +3311,9 @@ public: if (ic->selection_text_fd_read_handler) { int fd = ecore_main_fd_handler_fd_get (ic->selection_text_fd_read_handler); - close (fd); + if (fd >= 0) + close (fd); + ecore_main_fd_handler_del (ic->selection_text_fd_read_handler); ic->selection_text_fd_read_handler = NULL; } diff --git a/ism/src/scim_module.cpp b/ism/src/scim_module.cpp index 12b6b56..3183dc1 100644 --- a/ism/src/scim_module.cpp +++ b/ism/src/scim_module.cpp @@ -108,9 +108,10 @@ scim_get_module_list (std::vector & mod_list, const String& type) mod_list.push_back(mname[i]); struct stat sb; - stat("/usr/lib/scim-1.0/1.4.0/IMEngine/socket.so", &sb); - if (S_ISREG(sb.st_mode)) - mod_list.push_back("socket"); + if (stat ("/usr/lib/scim-1.0/1.4.0/IMEngine/socket.so", &sb) == 0) { + if (S_ISREG(sb.st_mode)) + mod_list.push_back("socket"); + } } else { _scim_get_module_paths (paths, type); diff --git a/ism/src/scim_socket.cpp b/ism/src/scim_socket.cpp index d93ce80..6c36948 100644 --- a/ism/src/scim_socket.cpp +++ b/ism/src/scim_socket.cpp @@ -645,11 +645,13 @@ public: // Set correct permission for the socket file #ifdef DISABLE_MULTIPLE_SOCKETS if (m_family == SCIM_SOCKET_LOCAL) { - ::chmod (data_un->sun_path, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); + if (::chmod (data_un->sun_path, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) == -1) + return false; } #else if (m_family == SCIM_SOCKET_LOCAL) { - ::chmod (data_un->sun_path, S_IRUSR | S_IWUSR); + if (::chmod (data_un->sun_path, S_IRUSR | S_IWUSR) == -1) + return false; } #endif diff --git a/ism/src/scim_utility.cpp b/ism/src/scim_utility.cpp index d754c79..a9b08c0 100644 --- a/ism/src/scim_utility.cpp +++ b/ism/src/scim_utility.cpp @@ -749,6 +749,16 @@ scim_load_file (const String &filename, char **bufptr) return 0; } + if (feof (fp) != 0) { + fclose (fp); + return 0; + } + + if (ferror (fp)) { + fclose (fp); + return 0; + } + try { *bufptr = new char [statbuf.st_size]; } catch (...) {