Fix cosmetic issues
authorJunghyun Yeon <jungh.yeon@samsung.com>
Wed, 17 Mar 2021 05:32:57 +0000 (14:32 +0900)
committer연정현/Tizen Platform Lab(SR)/Staff Engineer/삼성전자 <jungh.yeon@samsung.com>
Wed, 17 Mar 2021 07:58:49 +0000 (16:58 +0900)
- Supress build warnings.
- Fix coding rule.
- Adjust log level.

Signed-off-by: Junghyun Yeon <jungh.yeon@samsung.com>
17 files changed:
parser/src/pkgmgr_parser.c
parser/src/pkgmgr_parser_db.c
src/client/pkginfo_client.cc
src/client/pkginfo_client.hh
src/common/database/abstract_db_handler.cc
src/common/database/appinfo_db_handler.cc
src/common/database/cert_get_db_handler.cc
src/common/database/pkg_set_db_handler.cc
src/common/parcel/depinfo_parcelable.cc
src/logging.cc
src/manager/pkginfo_manager.cc
src/pkgmgrinfo_plugininfo.c
src/pkgmgrinfo_private.c
src/server/main.cc
src/server/pkg_request.cc
src/server/worker_thread.cc
src/server/worker_thread.hh

index a71f6b1..3d87fe2 100644 (file)
@@ -46,13 +46,14 @@ static int __ps_remove_appsvc_db(manifest_x *mfx, uid_t uid)
        GList *tmp;
        application_x *application;
 
-       if ((lib_handle = dlopen(LIBAPPSVC_PATH, RTLD_LAZY)) == NULL) {
+       lib_handle = dlopen(LIBAPPSVC_PATH, RTLD_LAZY);
+       if (lib_handle == NULL) {
                _LOGE("dlopen is failed LIBAPPSVC_PATH[%s]\n", LIBAPPSVC_PATH);
                goto END;
        }
 
-       if ((appsvc_operation =
-                dlsym(lib_handle, "appsvc_unset_defapp")) == NULL || dlerror() != NULL) {
+       appsvc_operation = dlsym(lib_handle, "appsvc_unset_defapp");
+       if (appsvc_operation == NULL || dlerror() != NULL) {
                _LOGE("can not find symbol \n");
                goto END;
        }
@@ -88,7 +89,7 @@ API int pkgmgr_parser_update_tep(const char *pkgid, const char *tep_path)
        return pkgmgr_parser_update_tep_info_in_db(pkgid, tep_path);
 }
 
-API int pkgmgr_parser_process_manifest_x_for_installation(manifest_xmfx)
+API int pkgmgr_parser_process_manifest_x_for_installation(manifest_x *mfx)
 {
        retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
        int ret = -1;
@@ -100,7 +101,7 @@ API int pkgmgr_parser_process_manifest_x_for_installation(manifest_x* mfx)
        return PMINFO_R_OK;
 }
 
-API int pkgmgr_parser_process_usr_manifest_x_for_installation(manifest_xmfx, uid_t uid)
+API int pkgmgr_parser_process_usr_manifest_x_for_installation(manifest_x *mfx, uid_t uid)
 {
        retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
        int ret = -1;
@@ -112,7 +113,7 @@ API int pkgmgr_parser_process_usr_manifest_x_for_installation(manifest_x* mfx, u
        return PMINFO_R_OK;
 }
 
-API int pkgmgr_parser_process_manifest_x_for_upgrade(manifest_xmfx)
+API int pkgmgr_parser_process_manifest_x_for_upgrade(manifest_x *mfx)
 {
        retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
        int ret = -1;
@@ -124,7 +125,7 @@ API int pkgmgr_parser_process_manifest_x_for_upgrade(manifest_x* mfx)
        return PMINFO_R_OK;
 }
 
-API int pkgmgr_parser_process_usr_manifest_x_for_upgrade(manifest_xmfx, uid_t uid)
+API int pkgmgr_parser_process_usr_manifest_x_for_upgrade(manifest_x *mfx, uid_t uid)
 {
        retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
        int ret = -1;
@@ -136,7 +137,7 @@ API int pkgmgr_parser_process_usr_manifest_x_for_upgrade(manifest_x* mfx, uid_t
        return PMINFO_R_OK;
 }
 
-API int pkgmgr_parser_process_manifest_x_for_uninstallation(manifest_xmfx)
+API int pkgmgr_parser_process_manifest_x_for_uninstallation(manifest_x *mfx)
 {
        retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
        int ret = -1;
@@ -150,7 +151,7 @@ API int pkgmgr_parser_process_manifest_x_for_uninstallation(manifest_x* mfx)
        return PMINFO_R_OK;
 }
 
-API int pkgmgr_parser_process_usr_manifest_x_for_uninstallation(manifest_xmfx, uid_t uid)
+API int pkgmgr_parser_process_usr_manifest_x_for_uninstallation(manifest_x *mfx, uid_t uid)
 {
        retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
        int ret = -1;
index 7a85d9a..4d684d5 100644 (file)
@@ -1133,7 +1133,7 @@ API int pkgmgr_parser_clear_cache_usr_memory_db(uid_t uid)
        return _parser_clear_cache_memory_db(uid);
 }
 
-API int pkgmgr_parser_clear_cache_memory_db()
+API int pkgmgr_parser_clear_cache_memory_db(void)
 {
        return pkgmgr_parser_clear_cache_usr_memory_db(__getuid());
 }
index 8f4d65a..e20f362 100644 (file)
@@ -81,7 +81,8 @@ bool PkgInfoClient::SendRequest() {
 
 std::shared_ptr<pkgmgr_common::parcel::AbstractParcelable>
 PkgInfoClient::GetResultParcel() {
-  if (is_offline_) return result_parcel_;
+  if (is_offline_)
+    return result_parcel_;
 
   if (socket_ == nullptr) {
     LOGE("Socket is not ready");
@@ -167,11 +168,12 @@ bool PkgInfoClient::RequestHandlerDirectAccess() {
 
   handler->HandleRequest(&raw[0], raw.size(), locale.get());
   auto result = handler->ExtractResult();
-  if (result.size() == 0) return true;
+  if (result.size() == 0)
+    return true;
 
   result_parcel_.reset(pkgmgr_common::parcel::ParcelableFactory::GetInst()
-                           .CreateParcel(&result[0], result.size())
-                           .release());
+      .CreateParcel(&result[0], result.size())
+      .release());
 
   return true;
 }
index 12430ad..eecef50 100644 (file)
@@ -15,7 +15,8 @@ namespace pkgmgr_client {
 
 class PkgInfoClient {
  public:
-  PkgInfoClient(std::shared_ptr<pkgmgr_common::parcel::AbstractParcelable> parcel,
+  PkgInfoClient(
+      std::shared_ptr<pkgmgr_common::parcel::AbstractParcelable> parcel,
       uid_t uid, pkgmgr_common::ReqType req_type);
   ~PkgInfoClient();
   bool SendRequest();
index 967022c..103257d 100644 (file)
 #include "abstract_db_handler.hh"
 
 #include <gio/gio.h>
+#include <stdlib.h>
 #include <sys/stat.h>
-#include <sys/types.h>
 #include <sys/sysmacros.h>
-#include <stdlib.h>
+#include <sys/types.h>
 #include <tzplatform_config.h>
 
 #include <string>
index d57da52..6f19f34 100644 (file)
@@ -57,7 +57,8 @@ void AppInfoDBHandler::SetFilter(pkgmgrinfo_filter_x* filter) {
 int AppInfoDBHandler::Execute() {
   SetOpType(OPERATION_TYPE_READ);
   SetDBType(DB_TYPE_FILE_PKGDB);
-  if (!Connect()) return PMINFO_R_ERROR;
+  if (!Connect())
+    return PMINFO_R_ERROR;
 
   GHashTable* list = g_hash_table_new_full(g_str_hash, g_str_equal,
       NULL, __free_applications);
@@ -65,9 +66,9 @@ int AppInfoDBHandler::Execute() {
   int ret = PMINFO_R_OK;
   for (auto conn : conn_list) {
     ret = appinfo_internal_filter_get_list(conn.first, filter_, conn.second,
-                                             GetLocale().c_str(), list);
+        GetLocale().c_str(), list);
     if (ret == PMINFO_R_ERROR) {
-      _LOGE("Failed to appinfo_internal_filter_get_list (%d)", ret);
+      _LOGD("Failed to appinfo_internal_filter_get_list (%d)", ret);
       break;
     }
   }
index b15d604..426e4c2 100644 (file)
@@ -29,7 +29,9 @@ CertGetDBHandler::CertGetDBHandler(uid_t uid, int pid)
 
 CertGetDBHandler::~CertGetDBHandler() {}
 
-pkgmgr_certinfo_x* CertGetDBHandler::GetCertHandle() { return handle_; }
+pkgmgr_certinfo_x* CertGetDBHandler::GetCertHandle() {
+  return handle_;
+}
 
 void CertGetDBHandler::SetPkgID(std::string pkgid) {
   pkgid_ = std::move(pkgid);
index 51667d4..a0c6080 100644 (file)
@@ -54,11 +54,10 @@ int PkgSetDBHandler::Execute() {
   if (!Connect())
     return PMINFO_R_ERROR;
 
-  int ret = 0;
-
   DBHandleProvider::GetInst(uid_).SetMemoryMode(GetPID(), true);
   std::vector<std::pair<sqlite3*, uid_t>> conn_list = GetConnection();
   sqlite3* conn = conn_list.front().first;
+  int ret = 0;
   if (write_type_ == Insert)
     ret = pkgmgr_parser_insert_pkg_info(conn, package_, uid_);
   else if (write_type_ == Update)
index 28947e8..491b33f 100644 (file)
@@ -27,7 +27,7 @@ DepInfoParcelable::DepInfoParcelable()
         pkgid_(""), auto_release_(true) {}
 
 DepInfoParcelable::DepInfoParcelable(int ret,
-    std::vector<dependency_x *>&& dependency_list, bool auto_release)
+    std::vector<dependency_x*>&& dependency_list, bool auto_release)
     : AbstractParcelable(0, ParcelableType::DepInfo, ret),
         pkgid_(""),
         dependency_list_(std::move(dependency_list)),
@@ -41,17 +41,16 @@ DepInfoParcelable::~DepInfoParcelable() {
   if (!auto_release_)
     return;
 
-  for (auto dep : dependency_list_) {
+  for (auto dep : dependency_list_)
     pkgmgrinfo_basic_free_dependency(dep);
-  }
 }
 
 
-const std::vector<dependency_x *>& DepInfoParcelable::GetDependencyInfo() {
+const std::vector<dependency_x*>& DepInfoParcelable::GetDependencyInfo() {
   return dependency_list_;
 }
 
-std::vector<dependency_x *> DepInfoParcelable::ExtractDependencyInfo() {
+std::vector<dependency_x*> DepInfoParcelable::ExtractDependencyInfo() {
   return std::move(dependency_list_);
 }
 
@@ -64,21 +63,18 @@ void DepInfoParcelable::WriteToParcel(tizen_base::Parcel* parcel) const {
   parcel->WriteString(pkgid_);
   WriteInt(parcel, dependency_list_.size());
 
-  for (auto dependency : dependency_list_) {
+  for (auto dependency : dependency_list_)
     WriteDependency(parcel, dependency);
-  }
 }
 
 void DepInfoParcelable::ReadFromParcel(tizen_base::Parcel* parcel) {
   int len = 0;
-  char *pkgid;
   AbstractParcelable::ReadFromParcel(parcel);
   pkgid_ = parcel->ReadString();
   ReadInt(parcel, &len);
 
-  for (int i = 0; i < len ; ++i) {
+  for (int i = 0; i < len ; ++i)
     dependency_list_.emplace_back(ReadDependency(parcel));
-  }
 }
 
 void DepInfoParcelable::WriteDependency(tizen_base::Parcel* parcel,
@@ -91,7 +87,7 @@ void DepInfoParcelable::WriteDependency(tizen_base::Parcel* parcel,
 
 dependency_x *DepInfoParcelable::ReadDependency(tizen_base::Parcel* parcel) {
   dependency_x* dep =
-        reinterpret_cast<dependency_x*>(calloc(1, sizeof(dependency_x)));
+      reinterpret_cast<dependency_x*>(calloc(1, sizeof(dependency_x)));
   ReadString(parcel, &dep->pkgid);
   ReadString(parcel, &dep->depends_on);
   ReadString(parcel, &dep->type);
index cf641e5..5e2a5d6 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+// Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
 // Use of this source code is governed by a apache 2.0 license that can be
 // found in the LICENSE file.
 
index b3f38d0..c6472ee 100644 (file)
@@ -75,7 +75,8 @@ extern "C" EXPORT_API int _pkginfo_get_packages(uid_t uid,
   }
 
   if (ptr->GetRequestResult() != PMINFO_R_OK) {
-    LOG(ERROR) << "Request fail";
+    if (ptr->GetRequestResult() == PMINFO_R_ERROR)
+      LOG(ERROR) << "Request fail";
     return ptr->GetRequestResult();
   }
 
@@ -283,7 +284,6 @@ extern "C" EXPORT_API int _appinfo_get_datacontrol_info(
   std::shared_ptr<pcp::ResultParcelable> return_parcel(
       std::static_pointer_cast<pcp::ResultParcelable>(ptr));
 
-  // result_list is vector of string vector
   auto result_list = return_parcel->GetResult();
   if (result_list.size() == 0)
     return PMINFO_R_ENOENT;
index 3367a87..822f2a6 100644 (file)
@@ -3,7 +3,8 @@
  *
  * Copyright (c) 2000 - 2019 Samsung Electronics Co., Ltd. All rights reserved.
  *
- * Contact: Junghyun Yeon <jungh.yeon@samsung.com>, Sangyoon Jang <jeremy.jang@samsung.com>
+ * Contact: Junghyun Yeon <jungh.yeon@samsung.com>,
+ * Sangyoon Jang <jeremy.jang@samsung.com>
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -44,18 +45,20 @@ API int pkgmgrinfo_plugininfo_foreach_plugininfo(const char *pkgid,
                return PMINFO_R_EINVAL;
        }
 
-       ret = _plugininfo_get_appids(pkgid, plugin_type, plugin_name, &appid_list);
+       ret = _plugininfo_get_appids(pkgid, plugin_type, plugin_name,
+                       &appid_list);
        if (ret != PMINFO_R_OK) {
                _LOGE("Fail to get plugininfo");
                return ret;
        }
 
-       for (tmp_list = appid_list; tmp_list != NULL; tmp_list = tmp_list->next) {
+       for (tmp_list = appid_list; tmp_list != NULL;
+                       tmp_list = tmp_list->next) {
                appid = (char *)tmp_list->data;
                if (!appid)
                        continue;
                ret = plugin_list_cb(pkgid, appid, plugin_type,
-                                                        plugin_name, user_data);
+                               plugin_name, user_data);
                if (ret != 0)
                        break;
        }
@@ -64,4 +67,4 @@ API int pkgmgrinfo_plugininfo_foreach_plugininfo(const char *pkgid,
 
        return ret;
 
-}
\ No newline at end of file
+}
index 2d51515..9291cf1 100644 (file)
@@ -560,7 +560,7 @@ struct type_map {
        const char *type;
 };
 
-struct type_map type_map[] = {
+const struct type_map type_map[] = {
        { "res/wgt/config.xml", "wgt" },
        { "config.xml", "wgt" },
        { "tizen-manifest.xml", "tpk" },
@@ -638,13 +638,14 @@ API pkg_plugin_set *__load_library(const char *pkg_type)
                return plugin_set;
        }
 
-       if ((library_handle = dlopen(library_path, RTLD_LAZY)) == NULL) {
+       library_handle = dlopen(library_path, RTLD_LAZY);
+       if (library_handle == NULL) {
                _LOGE("dlopen is failed library_path[%s]", library_path);
                return NULL;
        }
 
-       if ((on_load = dlsym(library_handle, "pkg_plugin_on_load")) == NULL ||
-                       dlerror() != NULL) {
+       on_load = dlsym(library_handle, "pkg_plugin_on_load");
+       if (on_load == NULL || dlerror() != NULL) {
                _LOGE("cannot find symbol");
                dlclose(library_handle);
                return NULL;
index d792936..8e013a7 100644 (file)
@@ -105,18 +105,22 @@ static int __init_signal_handler(void) {
 }
 
 static void __finish(void) {
-  if (sig_source > 0) g_source_remove(sig_source);
+  if (sig_source > 0)
+    g_source_remove(sig_source);
 
-  if (channel) g_io_channel_unref(channel);
+  if (channel)
+    g_io_channel_unref(channel);
 
-  if (runner) delete runner;
+  if (runner)
+    delete runner;
 }
 
 static void __pkgmgr_init() { runner = new pkgmgr_server::Runner(5); }
 
 int main() {
   main_loop = g_main_loop_new(NULL, FALSE);
-  if (!main_loop) return -1;
+  if (!main_loop)
+    return -1;
 
 #if (GLIB_MAJOR_VERSION <= 2 && GLIB_MINOR_VERSION < 36)
   g_type_init();
@@ -125,7 +129,8 @@ int main() {
   sd_notify(0, "READY=1");
   __pkgmgr_init();
 
-  if (__init_signal_handler() < 0) _LOGE("Failed to init signal handler");
+  if (__init_signal_handler() < 0)
+    _LOGE("Failed to init signal handler");
 
   g_main_loop_run(main_loop);
 
index e86b4b2..45fbc5d 100644 (file)
@@ -23,22 +23,30 @@ PkgRequest::PkgRequest(int fd)
     : fd_(fd), request_type_(pkgmgr_common::REQ_TYPE_NONE), data_size_(-1) {
   socket_ = std::unique_ptr<pkgmgr_common::socket::DataSocket>(
       new (std::nothrow) pkgmgr_common::socket::DataSocket(fd_));
-  if (socket_ == nullptr) LOGE("Out of memory");
+  if (socket_ == nullptr)
+    LOGE("Out of memory");
 }
 
 PkgRequest::~PkgRequest() {
-  if (data_ != nullptr) delete[] data_;
+  if (data_ != nullptr)
+    delete[] data_;
 }
 
-unsigned char* PkgRequest::GetData() { return data_; }
+unsigned char* PkgRequest::GetData() {
+  return data_;
+}
 
-int PkgRequest::GetSize() { return data_size_; }
+int PkgRequest::GetSize() {
+  return data_size_;
+}
 
 pid_t PkgRequest::GetSenderPID() {
   return socket_->GetPID();
 }
 
-pkgmgr_common::ReqType PkgRequest::GetRequestType() { return request_type_; }
+pkgmgr_common::ReqType PkgRequest::GetRequestType() {
+  return request_type_;
+}
 
 bool PkgRequest::ReceiveData() {
   int ret = socket_->ReceiveData(&request_type_, sizeof(request_type_));
index dc15821..c150088 100644 (file)
@@ -52,7 +52,8 @@ WorkerThread::~WorkerThread() {
   stop_all_ = true;
   cv_.notify_all();
 
-  for (auto& t : threads_) t.join();
+  for (auto& t : threads_)
+    t.join();
 }
 
 bool WorkerThread::PushQueue(std::shared_ptr<PkgRequest> req) {
@@ -90,7 +91,8 @@ void WorkerThread::Run() {
     {
       std::unique_lock<std::mutex> u(lock_);
       cv_.wait(u, [this] { return !this->queue_.empty() || stop_all_; });
-      if (stop_all_ && queue_.empty()) return;
+      if (stop_all_ && queue_.empty())
+        return;
       req = PopQueue();
     }
 
@@ -172,7 +174,7 @@ std::shared_ptr<PkgRequest> WorkerThread::PopQueue() {
 
 void WorkerThread::SetLocale(std::string locale) {
   LOGD("Change locale (%s) -> (%s)", locale_.GetObject().c_str(),
-       locale.c_str());
+      locale.c_str());
   locale_.SetObject(std::move(locale));
 }
 
index 2720d6d..813fdbb 100644 (file)
@@ -42,6 +42,7 @@ class EXPORT_API WorkerThread {
   ~WorkerThread();
   bool PushQueue(std::shared_ptr<PkgRequest> req);
   void SetLocale(std::string locale);
+
  private:
   void Run();
   static void SetMemoryTrimTimer();