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/oem/ibm/libpldmresponder/platform_oem_ibm.cpp b/oem/ibm/libpldmresponder/platform_oem_ibm.cpp
index 5d9eea5..7ac8ada 100644
--- a/oem/ibm/libpldmresponder/platform_oem_ibm.cpp
+++ b/oem/ibm/libpldmresponder/platform_oem_ibm.cpp
@@ -34,16 +34,15 @@
{
auto propVal = pldm::utils::DBusHandler().getDbusPropertyVariant(
hostStatePath, hostStateProperty, 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)
{
return PLDM_SUCCESS;
}