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: I2516cfa21eaf0fc51902f2b23d4a54241e9d4978
diff --git a/extensions/openpower-pels/data_interface.cpp b/extensions/openpower-pels/data_interface.cpp
index 50424af..b812e97 100644
--- a/extensions/openpower-pels/data_interface.cpp
+++ b/extensions/openpower-pels/data_interface.cpp
@@ -268,8 +268,7 @@
auto reply = _bus.call(method, dbusTimeout);
- DBusPathList paths;
- reply.read(paths);
+ auto paths = reply.unpack<DBusPathList>();
return paths;
}
@@ -285,8 +284,7 @@
auto reply = _bus.call(method, dbusTimeout);
- std::map<DBusService, DBusInterfaceList> response;
- reply.read(response);
+ auto response = reply.unpack<std::map<DBusService, DBusInterfaceList>>();
if (!response.empty())
{
@@ -494,8 +492,7 @@
auto reply = _bus.call(method, dbusTimeout);
- std::string expandedLocationCode;
- reply.read(expandedLocationCode);
+ auto expandedLocationCode = reply.unpack<std::string>();
if (!connectorLoc.empty())
{
@@ -532,8 +529,7 @@
auto reply = _bus.call(method, dbusTimeout);
- std::vector<sdbusplus::message::object_path> entries;
- reply.read(entries);
+ auto entries = reply.unpack<std::vector<sdbusplus::message::object_path>>();
std::vector<std::string> paths;
diff --git a/lib/elog.cpp b/lib/elog.cpp
index 70d1ced..f506e81 100644
--- a/lib/elog.cpp
+++ b/lib/elog.cpp
@@ -35,8 +35,8 @@
msg.append(id, name);
auto bus = sdbusplus::bus::new_default();
auto reply = bus.call(msg);
- uint32_t entryID;
- reply.read(entryID);
+ auto entryID = reply.unpack<uint32_t>();
+
return entryID;
}
@@ -47,8 +47,8 @@
msg.append(id, name, static_cast<uint32_t>(level));
auto bus = sdbusplus::bus::new_default();
auto reply = bus.call(msg);
- uint32_t entryID;
- reply.read(entryID);
+ auto entryID = reply.unpack<uint32_t>();
+
return entryID;
}
} // namespace details