diff options
author | Ed Tanous <edtanous@google.com> | 2021-12-14 01:39:53 +0300 |
---|---|---|
committer | Ed Tanous <ed@tanous.net> | 2021-12-28 00:42:41 +0300 |
commit | 168e20c1306e3e689907ba43e14ea679e2328611 (patch) | |
tree | 7c578ede3cf14ffaf06ad9fbc245a97b71b21cc9 /redfish-core/lib/processor.hpp | |
parent | b477fd4408bc0602cc86147121f03791d3f4824a (diff) | |
download | bmcweb-168e20c1306e3e689907ba43e14ea679e2328611.tar.xz |
Move to common variant
This saves approximately 34kB in the compressed binary size of bmcweb
due to reduced template instantiations. This amounts to a 2.5%
reduction in the overall size.
Note, there were a few places where we broke const-correctness in the
form of pulling a non-const reference out of a const variant. This
new variant now requires const correctness, so some consts are
added where required.
Tested: Code compiles.
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: I6a60c8881c1268627eedb4ffddf16689dc5f6ed2
Diffstat (limited to 'redfish-core/lib/processor.hpp')
-rw-r--r-- | redfish-core/lib/processor.hpp | 42 |
1 files changed, 17 insertions, 25 deletions
diff --git a/redfish-core/lib/processor.hpp b/redfish-core/lib/processor.hpp index e510768442..df0d0bb65f 100644 --- a/redfish-core/lib/processor.hpp +++ b/redfish-core/lib/processor.hpp @@ -19,6 +19,7 @@ #include <app.hpp> #include <boost/container/flat_map.hpp> +#include <dbus_utility.hpp> #include <registries/privilege_registry.hpp> #include <sdbusplus/message/native_types.hpp> #include <sdbusplus/utility/dedup_variant.hpp> @@ -59,9 +60,9 @@ inline void getProcessorUUID(std::shared_ptr<bmcweb::AsyncResp> aResp, { BMCWEB_LOG_DEBUG << "Get Processor UUID"; crow::connections::systemBus->async_method_call( - [objPath, - aResp{std::move(aResp)}](const boost::system::error_code ec, - const std::variant<std::string>& property) { + [objPath, aResp{std::move(aResp)}]( + const boost::system::error_code ec, + const dbus::utility::DbusVariantType& property) { if (ec) { BMCWEB_LOG_DEBUG << "DBUS response error"; @@ -303,8 +304,7 @@ inline void getCpuAssetData(std::shared_ptr<bmcweb::AsyncResp> aResp, [objPath, aResp{std::move(aResp)}]( const boost::system::error_code ec, const boost::container::flat_map< - std::string, std::variant<std::string, uint32_t, uint16_t, - bool>>& properties) { + std::string, dbus::utility::DbusVariantType>& properties) { if (ec) { BMCWEB_LOG_DEBUG << "DBUS response error"; @@ -395,8 +395,7 @@ inline void getCpuRevisionData(std::shared_ptr<bmcweb::AsyncResp> aResp, [objPath, aResp{std::move(aResp)}]( const boost::system::error_code ec, const boost::container::flat_map< - std::string, std::variant<std::string, uint32_t, uint16_t, - bool>>& properties) { + std::string, dbus::utility::DbusVariantType>& properties) { if (ec) { BMCWEB_LOG_DEBUG << "DBUS response error"; @@ -432,8 +431,7 @@ inline void getAcceleratorDataByService( [acclrtrId, aResp{std::move(aResp)}]( const boost::system::error_code ec, const boost::container::flat_map< - std::string, std::variant<std::string, uint32_t, uint16_t, - bool>>& properties) { + std::string, dbus::utility::DbusVariantType>& properties) { if (ec) { BMCWEB_LOG_DEBUG << "DBUS response error"; @@ -486,10 +484,8 @@ using BaseSpeedPrioritySettingsProperty = std::vector<std::tuple<uint32_t, std::vector<uint32_t>>>; // uint32_t and size_t may or may not be the same type, requiring a dedup'd // variant -using OperatingConfigProperties = std::vector<std::pair< - std::string, - sdbusplus::utility::dedup_variant_t<uint32_t, size_t, TurboProfileProperty, - BaseSpeedPrioritySettingsProperty>>>; +using OperatingConfigProperties = + std::vector<std::pair<std::string, dbus::utility::DbusVariantType>>; /** * Fill out the HighSpeedCoreIDs in a Processor resource from the given @@ -551,10 +547,8 @@ inline void getCpuConfigData(const std::shared_ptr<bmcweb::AsyncResp>& aResp, crow::connections::systemBus->async_method_call( [aResp, cpuId, service]( const boost::system::error_code ec, - const std::vector< - std::pair<std::string, - std::variant<sdbusplus::message::object_path, bool>>>& - properties) { + const std::vector<std::pair< + std::string, dbus::utility::DbusVariantType>>& properties) { if (ec) { BMCWEB_LOG_WARNING << "D-Bus error: " << ec << ", " @@ -604,8 +598,7 @@ inline void getCpuConfigData(const std::shared_ptr<bmcweb::AsyncResp>& aResp, crow::connections::systemBus->async_method_call( [aResp]( const boost::system::error_code ec, - const std::variant< - BaseSpeedPrioritySettingsProperty>& property) { + const dbus::utility::DbusVariantType& property) { if (ec) { BMCWEB_LOG_WARNING @@ -655,9 +648,9 @@ inline void getCpuLocationCode(std::shared_ptr<bmcweb::AsyncResp> aResp, { BMCWEB_LOG_DEBUG << "Get Cpu Location Data"; crow::connections::systemBus->async_method_call( - [objPath, - aResp{std::move(aResp)}](const boost::system::error_code ec, - const std::variant<std::string>& property) { + [objPath, aResp{std::move(aResp)}]( + const boost::system::error_code ec, + const dbus::utility::DbusVariantType& property) { if (ec) { BMCWEB_LOG_DEBUG << "DBUS response error"; @@ -697,7 +690,7 @@ inline void getCpuUniqueId(const std::shared_ptr<bmcweb::AsyncResp>& aResp, BMCWEB_LOG_DEBUG << "Get CPU UniqueIdentifier"; crow::connections::systemBus->async_method_call( [aResp](boost::system::error_code ec, - const std::variant<std::string>& property) { + const dbus::utility::DbusVariantType& property) { const std::string* id = std::get_if<std::string>(&property); if (ec || id == nullptr) { @@ -1090,8 +1083,7 @@ inline void patchAppliedOperatingConfig( }, *controlService, cpuObjectPath, "org.freedesktop.DBus.Properties", "Set", "xyz.openbmc_project.Control.Processor.CurrentOperatingConfig", - "AppliedConfig", - std::variant<sdbusplus::message::object_path>(std::move(configPath))); + "AppliedConfig", dbus::utility::DbusVariantType(std::move(configPath))); } inline void requestRoutesOperatingConfigCollection(App& app) |