simplify convert_from_string calls
There were a few sdbusplus convert_from_string calls added with
commit 7b4d59aa8f6020b919d41415bece7f0651304b00. Simplify these
to reduce the duplicate string-conversion calls and to improve
readability.
Change-Id: Iec688fb88dc2513d42583af110abd4c04aeb9fa0
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
diff --git a/host-bmc/dbus_to_host_effecters.cpp b/host-bmc/dbus_to_host_effecters.cpp
index b16c750..d83b4d9 100644
--- a/host-bmc/dbus_to_host_effecters.cpp
+++ b/host-bmc/dbus_to_host_effecters.cpp
@@ -164,19 +164,18 @@
{
auto propVal = dbusHandler->getDbusPropertyVariant(
hostStatePath, "BootProgress", BootProgress::interface);
- const auto& currHostState = std::get<std::string>(propVal);
- if ((sdbusplus::message::convert_from_string<
- BootProgress::ProgressStages>(currHostState) !=
- BootProgress::ProgressStages::SystemInitComplete) &&
- (sdbusplus::message::convert_from_string<
- BootProgress::ProgressStages>(currHostState) !=
- BootProgress::ProgressStages::OSRunning) &&
- (sdbusplus::message::convert_from_string<
- BootProgress::ProgressStages>(currHostState) !=
- BootProgress::ProgressStages::SystemSetup))
+
+ using Stages = BootProgress::ProgressStages;
+ auto currHostState = sdbusplus::message::convert_from_string<Stages>(
+ std::get<std::string>(propVal))
+ .value();
+
+ if (currHostState != Stages::SystemInitComplete &&
+ currHostState != Stages::OSRunning &&
+ currHostState != Stages::SystemSetup)
{
info("Host is not up. Current host state: {CUR_HOST_STATE}",
- "CUR_HOST_STATE", currHostState.c_str());
+ "CUR_HOST_STATE", currHostState);
return;
}
}