Fix static analysis issues 36/324136/1
authorSangyoon Jang <jeremy.jang@samsung.com>
Tue, 13 May 2025 08:33:18 +0000 (17:33 +0900)
committerSangyoon Jang <jeremy.jang@samsung.com>
Tue, 13 May 2025 08:33:18 +0000 (17:33 +0900)
Change-Id: I14ded937a8d108ed2842a8a3cd63c423de28a0b6
Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>
src/action/plugin_executor.cc
src/api/api_stub.cc
src/api/connector.cc
src/pkgmgr_plugin_parser/json_action_schema_parser.cc
tool/action_tool/tools/list_actions.cc

index 45a3495d9517611c6999de19cb41e4815b5f58a5..01ca2d143404fb28edea58b52bb2932fad0250bf 100644 (file)
@@ -51,8 +51,12 @@ PluginExecutor::PluginExecutor(std::string id, int execution_id)
           "d::org.tizen.appfw.service.tizen_action_plugin_manager") {}
 
 PluginExecutor::~PluginExecutor() {
-  if (connected_)
-    plugin_manager_.Disconnect();
+  try {
+    if (connected_)
+      plugin_manager_.Disconnect();
+  } catch (const rpc_port::plugin_manager_proxy::proxy::InvalidIDException& e) {
+    LOG(ERROR) << "InvalidIDException on Disconnect()";
+  }
 }
 
 int PluginExecutor::Execute(const common::ActionModel& model) {
index ce250cda7e2a9bb68989a5293a4423fa8078ccf2..2f21423496ea90e92d391a9c43828a6dd0d545e1 100644 (file)
@@ -100,7 +100,7 @@ API int action_client_foreach_action(action_client_h client,
   auto proxy = con->GetProxy();
   auto actions = proxy->ListActions();
 
-  for (auto action : actions) {
+  for (const auto& action : actions) {
     common::ActionSchema schema(action.Getjson());
     if (!cb(static_cast<action_h>(&schema), user_data))
       break;
index 7089cece716569c198573a69b656c9a37354d4f7..ba02dc48aa53a3d3ea4fb3452b8d85d793bf16c3 100644 (file)
@@ -71,7 +71,11 @@ void Connector::Disconnect() {
   if (connected_) {
     user_callbacks_.clear();
     UnregisterInternalCallback();
-    proxy_->Disconnect();
+    try {
+      proxy_->Disconnect();
+    } catch (const rpc::proxy::InvalidIDException& e) {
+      LOG(ERROR) << "InvalidIDException on Disconnect()";
+    }
   }
 }
 
@@ -110,8 +114,16 @@ void Connector::UnregisterInternalCallback() {
   if (cb_id_ < 0)
     return;
 
-  proxy_->UnregisterActionReplyCb(cb_id_);
-  cb_id_ = -1;
+  try {
+    proxy_->UnregisterActionReplyCb(cb_id_);
+    cb_id_ = -1;
+  } catch (const rpc::proxy::NotConnectedSocketException& e) {
+    LOG(ERROR) << "NotConnectedSocketException on UnregisterActionReplyCb";
+  } catch (const rpc::proxy::InvalidIOException& e) {
+    LOG(ERROR) << "InvalidIOException on UnregisterActionReplyCb";
+  } catch (const rpc::proxy::RemoteException& e) {
+    LOG(ERROR) << "RemoteException on UnregisterActionReplyCb";
+  }
 }
 
 void Connector::RegisterUserCallback(int execution_id, action_result_cb cb,
index ecd9cce4915aa79206a55dab34ba2747a0a9afba..9acf1d5a36494b58c9ec8a5e0538eb731f5a4eb0 100644 (file)
@@ -53,7 +53,7 @@ ActionSchema JsonActionSchemaParser::Parse(const std::string& pkgid,
   LOG(DEBUG) << "Parased action for pkgid[ " << pkgid << " ] : " << name;
   LOG(DEBUG) << json;
 
-  return ActionSchema(std::move(pkgid), std::move(name), std::move(category),
+  return ActionSchema(pkgid, std::move(name), std::move(category),
                       std::move(privs), std::move(json));
 }
 
index 51d6503ae220ddec967430914ef65c89f0ce3978..60468a476fb4d88731c227e5642936155afe84f9 100644 (file)
@@ -62,7 +62,7 @@ class ListActions : public ActionTool,
     try {
       auto actions = proxy_.ListActions();
       _D("Actions cnt(%zu)", actions.size());
-      for (auto action : actions) {
+      for (const auto& action : actions) {
         _D("id: %s --------------------", action.Getaction_id().c_str());
         _D("type: %s", action.Gettype().c_str());
         _D("category: %s", action.Getcategory().c_str());