use sdbusplus unpack syntax
Rather than defining a variable and then reading it from a message,
sdbusplus also supports directly unpack-ing from the message. Use
this syntax instead as it is more efficient and succinct.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I37b8d2921b175f4050623935c0f4bffc0e448c70
diff --git a/src/host_then_chassis_poweroff.cpp b/src/host_then_chassis_poweroff.cpp
index 4489364..54431c4 100644
--- a/src/host_then_chassis_poweroff.cpp
+++ b/src/host_then_chassis_poweroff.cpp
@@ -193,8 +193,7 @@
method.append(interface::chassisState, "CurrentPowerState");
auto result = bus.call(method);
- std::variant<std::string> state;
- result.read(state);
+ auto state = result.unpack<std::variant<std::string>>();
chassisState =
Chassis::convertPowerStateFromString(std::get<std::string>(state));
@@ -220,8 +219,7 @@
method.append(interface::bmcState, "CurrentBMCState");
auto result = bus.call(method);
- std::variant<std::string> state;
- result.read(state);
+ auto state = result.unpack<std::variant<std::string>>();
bmcState = BMC::convertBMCStateFromString(std::get<std::string>(state));
}