From 47a2c7013cf6a78d30c11a08eb76b8995021fb34 Mon Sep 17 00:00:00 2001 From: Piotr Ganicz Date: Thu, 22 Jun 2017 11:03:39 +0200 Subject: [PATCH] Binary size reduction This commit reduces binary size by removing usage of boost str and boost format functions (about 20kB less). Change-Id: I62be9b8fa6dd3db8ad3abe128e2cff8f42cefd0d --- src/common/certificate_validation.cc | 6 +++--- src/common/security_registration.cc | 38 ++++++++++++++++++------------------ 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/common/certificate_validation.cc b/src/common/certificate_validation.cc index 279f9d0..ace451d 100644 --- a/src/common/certificate_validation.cc +++ b/src/common/certificate_validation.cc @@ -148,7 +148,7 @@ bool ValidateSignatureFile( result = validator.checkList(true, ValidationCore::UriList(), data); } - std::string errnum = boost::str(boost::format("%d") % result); + std::string errnum = std::to_string(result); *error_message = validator.errorToString(result); *error_message += ":<" + errnum + ">"; @@ -267,7 +267,7 @@ bool ValidatePrivilegeLevel(common_installer::PrivilegeLevel level, pair.first, PrivilegeLevelToVisibility(level), &error); } if (status != PRVMGR_ERR_NONE) { - std::string errnum = boost::str(boost::format("%d") % status); + std::string errnum = std::to_string(status); LOG(ERROR) << "Error while verifing privilege level: " << (error ? error : "") << " <" << errnum << ">"; *error_message = error; @@ -299,7 +299,7 @@ bool ValidateMetadataPrivilege(common_installer::PrivilegeLevel level, g_list_free(metadata_keylist); if (status != PRVMGR_ERR_NONE) { - std::string errnum = boost::str(boost::format("%d") % status); + std::string errnum = std::to_string(status); LOG(ERROR) << "Error while verifing metadata privilege: " << (error ? error : "") << " <" << errnum << ">"; *error_message = error; diff --git a/src/common/security_registration.cc b/src/common/security_registration.cc index bd52d97..b49397f 100644 --- a/src/common/security_registration.cc +++ b/src/common/security_registration.cc @@ -73,7 +73,7 @@ bool PrepareRequest(const std::string& app_id, const std::string& pkg_id, int error = security_manager_app_inst_req_set_app_id(req, app_id.c_str()); if (error != SECURITY_MANAGER_SUCCESS) { - std::string errnum = boost::str(boost::format("%d") % error); + std::string errnum = std::to_string(error); *error_message = security_manager_strerror(static_cast(error)); *error_message += ":<" + errnum + ">"; return false; @@ -82,7 +82,7 @@ bool PrepareRequest(const std::string& app_id, const std::string& pkg_id, error = security_manager_app_inst_req_set_pkg_id(req, pkg_id.c_str()); if (error != SECURITY_MANAGER_SUCCESS) { - std::string errnum = boost::str(boost::format("%d") % error); + std::string errnum = std::to_string(error); *error_message = security_manager_strerror(static_cast(error)); *error_message += ":<" + errnum + ">"; return false; @@ -90,7 +90,7 @@ bool PrepareRequest(const std::string& app_id, const std::string& pkg_id, error = security_manager_app_inst_req_set_uid(req, uid); if (error != SECURITY_MANAGER_SUCCESS) { - std::string errnum = boost::str(boost::format("%d") % error); + std::string errnum = std::to_string(error); *error_message = security_manager_strerror(static_cast(error)); *error_message += ":<" + errnum + ">"; return false; @@ -99,7 +99,7 @@ bool PrepareRequest(const std::string& app_id, const std::string& pkg_id, if (cross_app_rules) { error = security_manager_app_inst_req_set_hybrid(req); if (error != SECURITY_MANAGER_SUCCESS) { - std::string errnum = boost::str(boost::format("%d") % error); + std::string errnum = std::to_string(error); *error_message = security_manager_strerror(static_cast(error)); *error_message += ":<" + errnum + ">"; @@ -111,7 +111,7 @@ bool PrepareRequest(const std::string& app_id, const std::string& pkg_id, error = security_manager_app_inst_req_set_target_version(req, api_version.c_str()); if (error != SECURITY_MANAGER_SUCCESS) { - std::string errnum = boost::str(boost::format("%d") % error); + std::string errnum = std::to_string(error); *error_message = security_manager_strerror(static_cast(error)); *error_message += ":<" + errnum + ">"; @@ -122,7 +122,7 @@ bool PrepareRequest(const std::string& app_id, const std::string& pkg_id, if (!author_id.empty()) { error = security_manager_app_inst_req_set_author_id(req, author_id.c_str()); if (error != SECURITY_MANAGER_SUCCESS) { - std::string errnum = boost::str(boost::format("%d") % error); + std::string errnum = std::to_string(error); *error_message = security_manager_strerror(static_cast(error)); *error_message += ":<" + errnum + ">"; @@ -147,7 +147,7 @@ bool PrepareRequest(const std::string& app_id, const std::string& pkg_id, LOG(INFO) << "install_type(" << type << ")"; error = security_manager_app_inst_req_set_install_type(req, type); if (error != SECURITY_MANAGER_SUCCESS) { - std::string errnum = boost::str(boost::format("%d") % error); + std::string errnum = std::to_string(error); *error_message = security_manager_strerror(static_cast(error)); *error_message += ":<" + errnum + ">"; @@ -173,7 +173,7 @@ bool PreparePathRequest(path_req* req, const std::string& pkg_id, int error = security_manager_path_req_set_pkg_id(req, pkg_id.c_str()); if (error != SECURITY_MANAGER_SUCCESS) { - std::string errnum = boost::str(boost::format("%d") % error); + std::string errnum = std::to_string(error); *error_message = security_manager_strerror(static_cast(error)); *error_message += ":<" + errnum + ">"; return false; @@ -181,7 +181,7 @@ bool PreparePathRequest(path_req* req, const std::string& pkg_id, error = security_manager_path_req_set_uid(req, uid); if (error != SECURITY_MANAGER_SUCCESS) { - std::string errnum = boost::str(boost::format("%d") % error); + std::string errnum = std::to_string(error); *error_message = security_manager_strerror(static_cast(error)); *error_message += ":<" + errnum + ">"; return false; @@ -205,7 +205,7 @@ bool PreparePathRequest(path_req* req, const std::string& pkg_id, error = security_manager_path_req_set_install_type(req, type); if (error != SECURITY_MANAGER_SUCCESS) { - std::string errnum = boost::str(boost::format("%d") % error); + std::string errnum = std::to_string(error); *error_message = security_manager_strerror(static_cast(error)); *error_message += ":<" + errnum + ">"; @@ -238,7 +238,7 @@ bool PreparePathRequest(path_req* req, const std::string& pkg_id, error = security_manager_path_req_add_path(req, subpath.c_str(), policy.second); if (error != SECURITY_MANAGER_SUCCESS) { - std::string errnum = boost::str(boost::format("%d") % error); + std::string errnum = std::to_string(error); *error_message = security_manager_strerror(static_cast(error)); *error_message += ":<" + errnum + ">"; @@ -265,7 +265,7 @@ bool RegisterSecurityContext(const std::string& app_id, LOG(ERROR) << "Failed while calling security_manager_app_inst_req_new failed " << "(error code: " << error << ")"; - std::string errnum = boost::str(boost::format("%d") % error); + std::string errnum = std::to_string(error); *error_message = security_manager_strerror(static_cast(error)); *error_message += ":<" + errnum + ">"; return false; @@ -282,7 +282,7 @@ bool RegisterSecurityContext(const std::string& app_id, if (error != SECURITY_MANAGER_SUCCESS) { LOG(ERROR) << "Failed while calling security_manager_app_install failed " << "(error code: " << error << ")"; - std::string errnum = boost::str(boost::format("%d") % error); + std::string errnum = std::to_string(error); *error_message = security_manager_strerror(static_cast(error)); *error_message += ":<" + errnum + ">"; security_manager_app_inst_req_free(req); @@ -301,7 +301,7 @@ bool UnregisterSecurityContext(const std::string& app_id, if (error != SECURITY_MANAGER_SUCCESS) { LOG(ERROR) << "Failed while calling security_manager_app_inst_req_new " << "(error code: " << error << ")"; - std::string errnum = boost::str(boost::format("%d") % error); + std::string errnum = std::to_string(error); *error_message = security_manager_strerror(static_cast(error)); *error_message += ":<" + errnum + ">"; return false; @@ -318,7 +318,7 @@ bool UnregisterSecurityContext(const std::string& app_id, if (error != SECURITY_MANAGER_SUCCESS) { LOG(ERROR) << "Failed while calling security_manager_app_uninstall failed " << "(error code: " << error << ")"; - std::string errnum = boost::str(boost::format("%d") % error); + std::string errnum = std::to_string(error); *error_message = security_manager_strerror(static_cast(error)); *error_message += ":<" + errnum + ">"; security_manager_app_inst_req_free(req); @@ -396,7 +396,7 @@ bool RegisterSecurityContextForPath(const std::string &pkg_id, LOG(ERROR) << "Failed while calling security_manager_path_req_new failed " << "(error code: " << error << ")"; - std::string errnum = boost::str(boost::format("%d") % error); + std::string errnum = std::to_string(error); *error_message = security_manager_strerror(static_cast(error)); *error_message += ":<" + errnum + ">"; return false; @@ -413,7 +413,7 @@ bool RegisterSecurityContextForPath(const std::string &pkg_id, if (error != SECURITY_MANAGER_SUCCESS) { LOG(ERROR) << "Failed while calling security_manager_paths_register failed " << "(error code: " << error << ")"; - std::string errnum = boost::str(boost::format("%d") % error); + std::string errnum = std::to_string(error); *error_message = security_manager_strerror(static_cast(error)); *error_message += ":<" + errnum + ">"; security_manager_path_req_free(req); @@ -434,7 +434,7 @@ bool RegisterSecurityContextForPathExternalOnly(const std::string &pkg_id, LOG(ERROR) << "Failed while calling security_manager_path_req_new failed " << "(error code: " << error << ")"; - std::string errnum = boost::str(boost::format("%d") % error); + std::string errnum = std::to_string(error); *error_message = security_manager_strerror(static_cast(error)); *error_message += ":<" + errnum + ">"; return false; @@ -451,7 +451,7 @@ bool RegisterSecurityContextForPathExternalOnly(const std::string &pkg_id, if (error != SECURITY_MANAGER_SUCCESS) { LOG(ERROR) << "Failed while calling security_manager_paths_register failed " << "(error code: " << error << ")"; - std::string errnum = boost::str(boost::format("%d") % error); + std::string errnum = std::to_string(error); *error_message = security_manager_strerror(static_cast(error)); *error_message += ":<" + errnum + ">"; security_manager_path_req_free(req); -- 2.7.4