From: Changgyu Choi Date: Tue, 21 Mar 2023 09:11:42 +0000 (+0900) Subject: Fix static analysis issues X-Git-Tag: accepted/tizen/unified/20230601.162954~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=35d191c76efe9d96752e9e64403baa6ece301c07;p=platform%2Fcore%2Fappfw%2Frpc-port.git Fix static analysis issues Change-Id: I4e2de4075c4822edc168495db2cd4edadf9072a0 Signed-off-by: Changgyu Choi --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 33f92a3..9e9387d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,7 @@ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden") SET(CMAKE_C_FLAGS_DEBUG "-O0 -g") SET(CMAKE_C_FLAGS_RELEASE "-O2") -SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_C_FLAGS} -std=c++14") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_C_FLAGS} -std=c++17") SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g") SET(CMAKE_CXX_FLAGS_RELEASE "-O2") diff --git a/src/ac-internal.cc b/src/ac-internal.cc index 8dbac48..70821d6 100644 --- a/src/ac-internal.cc +++ b/src/ac-internal.cc @@ -99,15 +99,17 @@ void AccessController::CheckAsync(int fd, std::string sender_appid, Job job([=]() -> Job::Type { int res = Check(fd, sender_appid); auto* cbdata = new std::pair(callback, res); - if (callback != nullptr) { - g_idle_add( - [](gpointer data) -> gboolean { - auto* cbdata = static_cast*>(data); - auto [callback, res] = *cbdata; - callback(res); - delete (cbdata); - return G_SOURCE_REMOVE; - }, cbdata); + guint sid = g_idle_add( + [](gpointer data) -> gboolean { + auto* cbdata = static_cast*>(data); + auto [callback, res] = *cbdata; + callback(res); + delete cbdata; + return G_SOURCE_REMOVE; + }, cbdata); + if (sid == 0) { + _E("Failed to call g_idle_add"); + delete cbdata; } return Job::Type::Continue; diff --git a/src/cynara_thread.cc b/src/cynara_thread.cc index a8f7fd0..7e5b84b 100644 --- a/src/cynara_thread.cc +++ b/src/cynara_thread.cc @@ -23,9 +23,10 @@ namespace internal { Job::Job(Job::JobHandlerCallback cb) : cb_(std::move(cb)) {} -Job::Job() : cb_([]() { return Job::Type::Finish; }) {} - Job::Type Job::Do() { + if (cb_ == nullptr) + return Job::Type::Finish; + return cb_(); } diff --git a/src/cynara_thread.hh b/src/cynara_thread.hh index 8067f7a..3babdd3 100644 --- a/src/cynara_thread.hh +++ b/src/cynara_thread.hh @@ -33,8 +33,7 @@ class Job { using JobHandlerCallback = std::function; - explicit Job(JobHandlerCallback cb); - Job(); + explicit Job(JobHandlerCallback cb = nullptr); ~Job() = default; diff --git a/src/proxy-internal.cc b/src/proxy-internal.cc index 4a63e3a..67fd462 100644 --- a/src/proxy-internal.cc +++ b/src/proxy-internal.cc @@ -275,7 +275,7 @@ int Proxy::ConnectSync(std::string appid, std::string port_name, main_port_.reset(new ProxyPort(this, fds_[0], target_appid_, false)); delegate_port_.reset(new ProxyPort(this, fds_[1], target_appid_)); - DebugPort::AddSession(port_name, target_appid_, fds_[0], fds_[1]); + DebugPort::AddSession(port_name_, target_appid_, fds_[0], fds_[1]); listener_->OnConnected(target_appid_, main_port_.get()); return RPC_PORT_ERROR_NONE; }