From 502251b809ba693329292717d32627ab61017d8d Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Tue, 27 Sep 2022 03:04:17 +0000 Subject: [PATCH] Fix static analysis issues The following issues are fixed: - INEFFECTIVE_MOVE - HFA - AUTO_CAUSES_COPY - UNINIT_CTOR Change-Id: I3372b6578b80f91331d0da3b3a6dc8df8aea5a6f Signed-off-by: Hwankyu Jhun --- parser/src/pkgmgr_parser.c | 1 - parser/src/pkgmgr_parser_db.c | 1 - src/manager/pkginfo_manager.cc | 4 ++-- src/pkgmgrinfo_certinfo.c | 1 - src/pkgmgrinfo_db.c | 1 - src/pkgmgrinfo_pkginfo.c | 1 - src/server/certinfo_internal.c | 1 - src/server/database/abstract_db_handler.cc | 2 +- src/server/pkginfo_internal.c | 1 - src/server/request_handler/abstract_request_handler.hh | 4 ++-- test/unit_tests/test_parcel.cc | 2 +- 11 files changed, 6 insertions(+), 13 deletions(-) diff --git a/parser/src/pkgmgr_parser.c b/parser/src/pkgmgr_parser.c index 3d87fe2..5c78b18 100644 --- a/parser/src/pkgmgr_parser.c +++ b/parser/src/pkgmgr_parser.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include diff --git a/parser/src/pkgmgr_parser_db.c b/parser/src/pkgmgr_parser_db.c index 5034849..16faf6d 100644 --- a/parser/src/pkgmgr_parser_db.c +++ b/parser/src/pkgmgr_parser_db.c @@ -36,7 +36,6 @@ #include "pkgmgr-info.h" #include "pkgmgrinfo_basic.h" #include "pkgmgr_parser.h" -#include "pkgmgr_parser_db_queries.h" #include "pkgmgr_parser_debug.h" #include "pkgmgr_parser_internal.h" #include "manager/pkginfo_manager.h" diff --git a/src/manager/pkginfo_manager.cc b/src/manager/pkginfo_manager.cc index 2b72d05..0515e47 100644 --- a/src/manager/pkginfo_manager.cc +++ b/src/manager/pkginfo_manager.cc @@ -566,7 +566,7 @@ extern "C" EXPORT_API int _get_pkg_updateinfo(const char* pkgid, } std::shared_ptr parcelable( - new pcp::QueryParcelable(uid, std::move(info), + new pcp::QueryParcelable(uid, info, pkgmgr_common::DBType::DB_TYPE_FILE_PKGDB, pkgmgr_common::DBOperationType::OPERATION_TYPE_READ)); @@ -790,7 +790,7 @@ extern "C" EXPORT_API int _parser_execute_write_queries( } std::shared_ptr parcelable( - new pcp::QueryParcelable(uid, std::move(queries), + new pcp::QueryParcelable(uid, queries, pkgmgr_common::DBType::DB_TYPE_FILE_PKGDB, pkgmgr_common::DBOperationType::OPERATION_TYPE_WRITE)); diff --git a/src/pkgmgrinfo_certinfo.c b/src/pkgmgrinfo_certinfo.c index 7ba0be5..8024fc2 100644 --- a/src/pkgmgrinfo_certinfo.c +++ b/src/pkgmgrinfo_certinfo.c @@ -11,7 +11,6 @@ #include "pkgmgr-info.h" #include "pkgmgrinfo_debug.h" #include "pkgmgrinfo_private.h" -#include "pkgmgr_parser.h" API int pkgmgrinfo_pkginfo_create_certinfo(pkgmgrinfo_certinfo_h *handle) { diff --git a/src/pkgmgrinfo_db.c b/src/pkgmgrinfo_db.c index 3f30408..f175cde 100644 --- a/src/pkgmgrinfo_db.c +++ b/src/pkgmgrinfo_db.c @@ -17,7 +17,6 @@ #include "pkgmgrinfo_debug.h" #include "pkgmgrinfo_private.h" #include "pkgmgr_parser.h" -#include "pkgmgr_parser_db.h" #include "manager/pkginfo_manager.h" typedef int (*sqlite_query_callback)(void *data, int ncols, diff --git a/src/pkgmgrinfo_pkginfo.c b/src/pkgmgrinfo_pkginfo.c index 247ee17..ea5a3a4 100644 --- a/src/pkgmgrinfo_pkginfo.c +++ b/src/pkgmgrinfo_pkginfo.c @@ -29,7 +29,6 @@ #include #include #include -#include #include #include diff --git a/src/server/certinfo_internal.c b/src/server/certinfo_internal.c index 2d2cd8d..549f39b 100644 --- a/src/server/certinfo_internal.c +++ b/src/server/certinfo_internal.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include diff --git a/src/server/database/abstract_db_handler.cc b/src/server/database/abstract_db_handler.cc index 1e57815..05500cd 100644 --- a/src/server/database/abstract_db_handler.cc +++ b/src/server/database/abstract_db_handler.cc @@ -215,7 +215,7 @@ bool AbstractDBHandler::Connect() { } void AbstractDBHandler::ClearDBHandle() { - for (auto db_handle : db_handle_list_) + for (const auto& db_handle : db_handle_list_) sqlite3_close_v2(db_handle.first); db_handle_list_.clear(); diff --git a/src/server/pkginfo_internal.c b/src/server/pkginfo_internal.c index 3873f4c..cb46059 100644 --- a/src/server/pkginfo_internal.c +++ b/src/server/pkginfo_internal.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include diff --git a/src/server/request_handler/abstract_request_handler.hh b/src/server/request_handler/abstract_request_handler.hh index 5c093e7..1a54cd6 100644 --- a/src/server/request_handler/abstract_request_handler.hh +++ b/src/server/request_handler/abstract_request_handler.hh @@ -39,8 +39,8 @@ class EXPORT_API AbstractRequestHandler { uid_t GetUID(); private: - pid_t pid_; - uid_t uid_; + pid_t pid_ = -1; + uid_t uid_ = 0; }; } // namespace request_handler diff --git a/test/unit_tests/test_parcel.cc b/test/unit_tests/test_parcel.cc index 093f72f..8dd603f 100644 --- a/test/unit_tests/test_parcel.cc +++ b/test/unit_tests/test_parcel.cc @@ -201,7 +201,7 @@ TEST_F(ParcelTest, QueryParcelable) { { 2, { nullptr, "arg2" } } }; - pp::QueryParcelable origin_parcelable(0, std::move(query_args), + pp::QueryParcelable origin_parcelable(0, query_args, pkgmgr_common::DBType::DB_TYPE_FILE_PKGDB, pkgmgr_common::DBOperationType::OPERATION_TYPE_READ); pp::QueryParcelable new_parcelable; -- 2.7.4