- Add empty lines for readability.
- Move initialization to initialization list for consistency.
- Fix minor coding rule.
Signed-off-by: Junghyun Yeon <jungh.yeon@samsung.com>
#include <shared_mutex>
#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_internal.h"
#include "pkgmgrinfo_debug.h"
+#include "pkgmgrinfo_internal.h"
namespace {
std::vector<application_x*>* app_list =
static_cast<std::vector<application_x*>*>(user_data);
app_list->emplace_back(appinfo);
+
return true;
}
namespace database {
AppInfoDBHandler::AppInfoDBHandler(uid_t uid, int pid)
- : AbstractDBHandler(uid, pid), uid_(uid) {}
+ : AbstractDBHandler(uid, pid), filter_(nullptr), uid_(uid) {}
AppInfoDBHandler::~AppInfoDBHandler() {}
std::shared_lock<std::shared_timed_mutex> s(lock_);
SetOpType(pkgmgr_common::DBOperationType::OPERATION_TYPE_READ);
SetDBType(pkgmgr_common::DBType::DB_TYPE_FILE_PKGDB);
+
if (!Connect())
return PMINFO_R_ERROR;
int Execute() override;
private:
- pkgmgrinfo_filter_x* filter_ = nullptr;
+ pkgmgrinfo_filter_x* filter_;
std::vector<application_x*> handle_list_;
uid_t uid_;
};
namespace database {
CertGetDBHandler::CertGetDBHandler(uid_t uid, int pid)
- : AbstractDBHandler(uid, pid), uid_(uid) {}
+ : AbstractDBHandler(uid, pid), uid_(uid), handle_(nullptr) {}
CertGetDBHandler::~CertGetDBHandler() {}
int CertGetDBHandler::Execute() {
std::shared_lock<std::shared_timed_mutex> s(lock_);
+
SetOpType(pkgmgr_common::DBOperationType::OPERATION_TYPE_READ);
SetDBType(pkgmgr_common::DBType::DB_TYPE_FILE_CERTDB);
+
if (!Connect()) {
_LOGE("Failed to connect database");
return PMINFO_R_ERROR;
if (ret != PMINFO_R_OK)
return ret;
- handle_ = static_cast<pkgmgr_certinfo_x*>(handle);
+ handle_ = reinterpret_cast<pkgmgr_certinfo_x*>(handle);
sqlite3* conn = GetConnection().front().first;
- ret = certinfo_internal_get(conn, pkgid_.c_str(), uid_, handle_);
- return ret;
+ return certinfo_internal_get(conn, pkgid_.c_str(), uid_, handle_);
}
} // namespace database
private:
uid_t uid_;
std::string pkgid_;
- pkgmgr_certinfo_x* handle_ = nullptr;
+ pkgmgr_certinfo_x* handle_;
};
} // namespace database
namespace database {
CertSetDBHandler::CertSetDBHandler(uid_t uid, int pid)
- : AbstractDBHandler(uid, pid), uid_(uid) {}
+ : AbstractDBHandler(uid, pid), uid_(uid), handle_(nullptr) {}
CertSetDBHandler::~CertSetDBHandler() {}
int CertSetDBHandler::Execute() {
std::unique_lock<std::shared_timed_mutex> u(lock_);
+
SetOpType(pkgmgr_common::DBOperationType::OPERATION_TYPE_WRITE);
SetDBType(pkgmgr_common::DBType::DB_TYPE_FILE_CERTDB);
+
if (!Connect())
return PMINFO_R_ERROR;
DBHandleProvider::GetInst(uid_).SetMemoryMode(GetPID(), true);
- sqlite3 *conn = GetConnection().front().first;
- int ret = certinfo_internal_set(conn, handle_->pkgid, handle_, uid_);
+ sqlite3* conn = GetConnection().front().first;
- return ret;
+ return certinfo_internal_set(conn, handle_->pkgid, handle_, uid_);
}
} // namespace database
private:
uid_t uid_;
- pkgmgr_certinfo_x* handle_ = nullptr;
+ pkgmgr_certinfo_x* handle_;
};
} // namespace database
* limitations under the License.
*/
+#include "db_handle_provider.hh"
+
#include <fcntl.h>
#include <sys/types.h>
#include <string>
#include <vector>
-#include "db_handle_provider.hh"
#include "pkgmgrinfo_debug.h"
#include "pkgmgr-info.h"
-
#ifdef LOG_TAG
#undef LOG_TAG
#endif
~DBHandleProvider() = default;
static DBHandleProvider& GetInst(uid_t uid);
static bool IsCrashedWriteRequest();
- std::vector<std::pair<std::string, uid_t>> GetParserDBPath(int pid, bool write);
+ std::vector<std::pair<std::string, uid_t>> GetParserDBPath(
+ int pid, bool write);
std::string GetCertDBPath(int pid, bool write);
void SetMemoryMode(pid_t pid, bool flag);
const std::string& memorydb_path);
private:
- static std::unordered_map<uid_t, std::unique_ptr<DBHandleProvider>> provider_;
+ static std::unordered_map<uid_t,
+ std::unique_ptr<DBHandleProvider>> provider_;
static bool is_memory_global_;
static std::unique_ptr<sqlite3, decltype(sqlite3_close_v2)*>
global_parser_memory_db_handle_;
uid_t uid_;
bool is_memory_;
- std::unique_ptr<sqlite3, decltype(sqlite3_close_v2)*> parser_memory_db_handle_;
+ std::unique_ptr<sqlite3,
+ decltype(sqlite3_close_v2)*> parser_memory_db_handle_;
std::string parser_memory_db_path_;
std::string parser_file_db_path_;
};