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: I311c0a4a3aa8b68ea2814c00eaff11e2e8803fb1
diff --git a/dump/create_pel.cpp b/dump/create_pel.cpp
index 07cd07a..f1b6b4b 100644
--- a/dump/create_pel.cpp
+++ b/dump/create_pel.cpp
@@ -179,8 +179,8 @@
method.append(opEntryInterface);
method.append("PlatformLogID");
auto response = bus.call(method);
- std::variant<uint32_t, std::string> v;
- response.read(v);
+ auto v = response.unpack<std::variant<uint32_t, std::string>>();
+
pelId = std::get<uint32_t>(v);
method =
bus.new_method_call(service.c_str(), loggingEntryObjectPath.c_str(),
diff --git a/dump/dump_utils.cpp b/dump/dump_utils.cpp
index 74ec563..fa776a6 100644
--- a/dump/dump_utils.cpp
+++ b/dump/dump_utils.cpp
@@ -87,8 +87,7 @@
uint64_t(failingUnit)}};
method.append(createParams);
- sdbusplus::message::object_path reply;
- bus.call(method).read(reply);
+ auto reply = bus.call(method).unpack<sdbusplus::message::object_path>();
monitorDumpCreation(reply.str, SBE_DUMP_TIMEOUT);
}
@@ -131,8 +130,9 @@
mapper.append(path, std::vector<std::string>({intf}));
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())
{
diff --git a/watchdog/watchdog_dbus.cpp b/watchdog/watchdog_dbus.cpp
index 204aecd..7564e40 100644
--- a/watchdog/watchdog_dbus.cpp
+++ b/watchdog/watchdog_dbus.cpp
@@ -39,8 +39,8 @@
auto reply = bus.call(newMethod);
// dbus call results
- std::map<std::string, std::vector<std::string>> responseFindService;
- reply.read(responseFindService);
+ auto responseFindService =
+ reply.unpack<std::map<std::string, std::vector<std::string>>>();
// If we successfully found the service associated with the dbus object
// path and interface then create a method for the specified interface
@@ -145,9 +145,8 @@
method.append(interface, "CurrentHostState");
auto bus = sdbusplus::bus::new_system();
auto response = bus.call(method);
- std::variant<std::string> reply;
+ auto reply = response.unpack<std::variant<std::string>>();
- response.read(reply);
std::string currentHostState(std::get<std::string>(reply));
if (currentHostState ==
diff --git a/watchdog/watchdog_handler.cpp b/watchdog/watchdog_handler.cpp
index 5f48ac5..169be42 100644
--- a/watchdog/watchdog_handler.cpp
+++ b/watchdog/watchdog_handler.cpp
@@ -157,8 +157,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);