Removed redundant string parsing
Newer sdbusplus builds support the converting of enumerations
to read directly as an std::string which eliminates the need
to unnecessarily parse them as strings.
Signed-off-by: Corey Hardesty <corey.hardesty@icloud.com>
Change-Id: Ic58b0ebac9c4769cc6aff291e9a1a48dcb16ed18
diff --git a/host_reset_recovery.cpp b/host_reset_recovery.cpp
index aa26916..7898622 100644
--- a/host_reset_recovery.cpp
+++ b/host_reset_recovery.cpp
@@ -8,6 +8,7 @@
#include <sdbusplus/exception.hpp>
#include <xyz/openbmc_project/Logging/Create/server.hpp>
#include <xyz/openbmc_project/Logging/Entry/server.hpp>
+#include <xyz/openbmc_project/State/Boot/Progress/server.hpp>
#include <cstdlib>
#include <fstream>
@@ -41,25 +42,27 @@
{
try
{
+ using ProgressStages = sdbusplus::xyz::openbmc_project::State::Boot::
+ server::Progress::ProgressStages;
+
auto method = bus.new_method_call(HOST_STATE_SVC, HOST_STATE_PATH,
PROPERTY_INTERFACE, "Get");
method.append(BOOT_STATE_INTF, BOOT_PROGRESS_PROP);
auto response = bus.call(method);
- std::variant<std::string> bootProgress;
- response.read(bootProgress);
+ std::variant<ProgressStages> bootProgressV;
+ response.read(bootProgressV);
+ auto bootProgress = std::get<ProgressStages>(bootProgressV);
- if (std::get<std::string>(bootProgress) ==
- "xyz.openbmc_project.State.Boot.Progress.ProgressStages."
- "Unspecified")
+ if (bootProgress == ProgressStages::Unspecified)
{
info("Host was not booting before BMC reboot");
return false;
}
info("Host was booting before BMC reboot: {BOOTPROGRESS}",
- "BOOTPROGRESS", std::get<std::string>(bootProgress));
+ "BOOTPROGRESS", bootProgress);
}
catch (const sdbusplus::exception::exception& e)
{