From: Sangyoon Jang Date: Fri, 14 May 2021 07:44:27 +0000 (+0900) Subject: Use std::make_unique instead of new X-Git-Tag: accepted/tizen/unified/20210528.134635~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=500fd34261cbeb88e1ac852f5ac90412cf1de3cc;p=platform%2Fcore%2Fappfw%2Fpkgmgr-tool.git Use std::make_unique instead of new Change-Id: I3e12a3a6ae43640e826106de9261b00b18d6f7b8 Signed-off-by: Sangyoon Jang --- diff --git a/src/pkg_upgrade/src/pkg_upgrader_factory.cc b/src/pkg_upgrade/src/pkg_upgrader_factory.cc index 1712db7..b27c438 100644 --- a/src/pkg_upgrade/src/pkg_upgrader_factory.cc +++ b/src/pkg_upgrade/src/pkg_upgrader_factory.cc @@ -14,6 +14,8 @@ * limitations under the License. */ +#include + #include "logging.hh" #include "pkg_upgrader_factory.hh" #include "ro2rw_upgrader.hh" @@ -46,62 +48,43 @@ list> PkgUpgraderFactory::Merge( // UPDATE if (old_pkg->IsReadOnly() && new_pkg.IsReadOnly()) { // RO to RO - pkgs.emplace_back(new RoUpgrader( - unique_ptr(new SimpleUpgrader(*old_pkg, - PkgOperation::COMPLEX)), - unique_ptr(new SimpleUpgrader(new_pkg, - PkgOperation::UPDATE))) - ); + pkgs.emplace_back(std::make_unique( + std::make_unique(*old_pkg, PkgOperation::COMPLEX), + std::make_unique(new_pkg, PkgOperation::UPDATE))); } else if (!old_pkg->IsReadOnly() && !new_pkg.IsReadOnly()) { // RW to RW - pkgs.emplace_back(new RwUpgrader( - unique_ptr(new SimpleUpgrader(*old_pkg, - PkgOperation::COMPLEX)), - unique_ptr(new SimpleUpgrader(new_pkg, - PkgOperation::UPDATE)))); + pkgs.emplace_back(std::make_unique( + std::make_unique(*old_pkg, PkgOperation::COMPLEX), + std::make_unique(new_pkg, PkgOperation::UPDATE))); } else if (!old_pkg->IsReadOnly() && new_pkg.IsReadOnly()) { // RW to RO - pkgs.emplace_back(new Rw2RoUpgrader( - unique_ptr(new RwUpgrader( - nullptr, - std::unique_ptr(new SimpleUpgrader(*old_pkg, - PkgOperation::UNINSTALL_KEEP_RW_DATA)) - ) - ), - unique_ptr(new RoUpgrader( - nullptr, - std::unique_ptr(new SimpleUpgrader(new_pkg, - PkgOperation::INSTALL)) - ) - )) - ); + pkgs.emplace_back(std::make_unique( + std::make_unique(nullptr, + std::make_unique(*old_pkg, + PkgOperation::UNINSTALL_KEEP_RW_DATA)), + std::make_unique(nullptr, + std::make_unique(new_pkg, + PkgOperation::INSTALL)))); } else if (old_pkg->IsReadOnly() && !new_pkg.IsReadOnly()) { // RO to RW - pkgs.emplace_back(new Ro2RwUpgrader( - unique_ptr(new RoUpgrader( - nullptr, - std::unique_ptr(new SimpleUpgrader(*old_pkg, - PkgOperation::UNINSTALL_KEEP_RW_DATA)) - ) - ), - unique_ptr(new RwUpgrader( - nullptr, - std::unique_ptr(new SimpleUpgrader(new_pkg, - PkgOperation::INSTALL)) - ) - )) - ); + pkgs.emplace_back(std::make_unique( + std::make_unique(nullptr, + std::make_unique(*old_pkg, + PkgOperation::UNINSTALL_KEEP_RW_DATA)), + std::make_unique(nullptr, + std::make_unique(new_pkg, + PkgOperation::INSTALL)))); } } else { // INSTALL if (new_pkg.IsReadOnly()) { // RO - pkgs.emplace_back(new SimpleUpgrader(new_pkg, PkgOperation::INSTALL)); + pkgs.emplace_back(std::make_unique( + new_pkg, PkgOperation::INSTALL)); } else { // RW - pkgs.emplace_back(new RwUpgrader(nullptr, - unique_ptr(new SimpleUpgrader(new_pkg, - PkgOperation::INSTALL)))); + pkgs.emplace_back(std::make_unique(nullptr, + std::make_unique(new_pkg, PkgOperation::INSTALL))); } } } @@ -111,7 +94,7 @@ list> PkgUpgraderFactory::Merge( if (new_pkg == nullptr) { // UNINSTALL if (old_pkg.IsReadOnly()) { - pkgs.emplace_back(new SimpleUpgrader(old_pkg, + pkgs.emplace_back(std::make_unique(old_pkg, PkgOperation::UNINSTALL)); } }