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
diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp
index 074c927..d632552 100644
--- a/redfish-core/lib/log_services.hpp
+++ b/redfish-core/lib/log_services.hpp
@@ -32,6 +32,7 @@
#include <boost/beast/http.hpp>
#include <boost/container/flat_map.hpp>
#include <boost/system/linux_error.hpp>
+#include <dbus_utility.hpp>
#include <error_messages.hpp>
#include <registries/privilege_registry.hpp>
@@ -102,9 +103,8 @@
namespace fs = std::filesystem;
-using GetManagedPropertyType = boost::container::flat_map<
- std::string, std::variant<std::string, bool, uint8_t, int16_t, uint16_t,
- int32_t, uint32_t, int64_t, uint64_t, double>>;
+using GetManagedPropertyType =
+ boost::container::flat_map<std::string, dbus::utility::DbusVariantType>;
using GetManagedObjectsType = boost::container::flat_map<
sdbusplus::message::object_path,
@@ -736,8 +736,8 @@
return task::completed;
}
std::vector<std::pair<
- std::string,
- std::vector<std::pair<std::string, std::variant<std::string>>>>>
+ std::string, std::vector<std::pair<
+ std::string, dbus::utility::DbusVariantType>>>>
interfacesList;
sdbusplus::message::object_path objPath;
@@ -900,7 +900,8 @@
}
inline static void parseCrashdumpParameters(
- const std::vector<std::pair<std::string, VariantType>>& params,
+ const std::vector<std::pair<std::string, dbus::utility::DbusVariantType>>&
+ params,
std::string& filename, std::string& timestamp, std::string& logfile)
{
for (auto property : params)
@@ -1670,7 +1671,7 @@
"/xyz/openbmc_project/logging/entry/" + entryId,
"org.freedesktop.DBus.Properties", "Set",
"xyz.openbmc_project.Logging.Entry", "Resolved",
- std::variant<bool>(*resolved));
+ dbus::utility::DbusVariantType(*resolved));
});
BMCWEB_ROUTE(
@@ -2638,7 +2639,9 @@
auto getStoredLogCallback =
[asyncResp, logID, &logEntryJson](
const boost::system::error_code ec,
- const std::vector<std::pair<std::string, VariantType>>& params) {
+ const std::vector<
+ std::pair<std::string, dbus::utility::DbusVariantType>>&
+ params) {
if (ec)
{
BMCWEB_LOG_DEBUG << "failed to get log ec: " << ec.message();
@@ -2799,7 +2802,8 @@
auto getStoredLogCallback =
[asyncResp, logID, fileName](
const boost::system::error_code ec,
- const std::vector<std::pair<std::string, VariantType>>&
+ const std::vector<std::pair<
+ std::string, dbus::utility::DbusVariantType>>&
resp) {
if (ec)
{
@@ -3318,7 +3322,7 @@
crow::connections::systemBus->async_method_call(
[aResp, entryCount, skip,
top](const boost::system::error_code ec,
- const std::variant<uint16_t>& bootCount) {
+ const dbus::utility::DbusVariantType& bootCount) {
if (ec)
{
BMCWEB_LOG_DEBUG << "DBUS response error " << ec;