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: I59b1cef85e4e0e5dd14b33a4e1bc15aaef2a8aac
diff --git a/ext_interface.cpp b/ext_interface.cpp
index 1e25b2d..538b6ef 100644
--- a/ext_interface.cpp
+++ b/ext_interface.cpp
@@ -39,8 +39,9 @@
auto mapperResponseMsg = bus.call(mapper);
- std::map<std::string, std::vector<std::string>> mapperResponse;
- mapperResponseMsg.read(mapperResponse);
+ auto mapperResponse =
+ mapperResponseMsg
+ .unpack<std::map<std::string, std::vector<std::string>>>();
if (mapperResponse.empty())
{
@@ -64,8 +65,7 @@
method.append(REBOOTCOUNTER_INTERFACE, "AttemptsLeft");
auto reply = bus.call(method);
- std::variant<uint32_t> rebootCount;
- reply.read(rebootCount);
+ auto rebootCount = reply.unpack<std::variant<uint32_t>>();
return std::get<uint32_t>(rebootCount);
}
diff --git a/extensions/phal/dump_utils.cpp b/extensions/phal/dump_utils.cpp
index 6d2a666..984e30b 100644
--- a/extensions/phal/dump_utils.cpp
+++ b/extensions/phal/dump_utils.cpp
@@ -136,8 +136,7 @@
auto response = bus.call(method);
// reply will be type dbus::ObjectPath
- sdbusplus::message::object_path reply;
- response.read(reply);
+ auto reply = response.unpack<sdbusplus::message::object_path>();
// monitor dump progress
monitorDump(reply, dumpParameters.timeout);
diff --git a/procedures/phal/start_host.cpp b/procedures/phal/start_host.cpp
index 51e46ab..af83d01 100644
--- a/procedures/phal/start_host.cpp
+++ b/procedures/phal/start_host.cpp
@@ -242,9 +242,7 @@
auto reply = bus.call(method);
- std::variant<bool> resp;
-
- reply.read(resp);
+ auto resp = reply.unpack<std::variant<bool>>();
if (const bool* enabledPropVal = std::get_if<bool>(&resp))
{
diff --git a/util.cpp b/util.cpp
index e106d26..f2205d2 100644
--- a/util.cpp
+++ b/util.cpp
@@ -104,8 +104,8 @@
properties.append("xyz.openbmc_project.State.Chassis");
properties.append("CurrentPowerState");
auto result = bus.call(properties);
- std::variant<std::string> val;
- result.read(val);
+ auto val = result.unpack<std::variant<std::string>>();
+
if (auto pVal = std::get_if<std::string>(&val))
{
powerState = *pVal;