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: Iaaf3bb529ac369640779de56abfde5ebd1352ab4
diff --git a/src/oemcommands.cpp b/src/oemcommands.cpp
index eddc19c..f8b1cf4 100644
--- a/src/oemcommands.cpp
+++ b/src/oemcommands.cpp
@@ -1697,11 +1697,9 @@
using PropertyValue = std::variant<std::string, uint32_t, int32_t, bool>;
- std::map<sdbusplus::message::object_path,
- std::map<std::string, std::map<std::string, PropertyValue>>>
- objects;
-
- reply.read(objects);
+ auto objects = reply.unpack<std::map<
+ sdbusplus::message::object_path,
+ std::map<std::string, std::map<std::string, PropertyValue>>>>();
int index = 0;
bool found = false;
diff --git a/src/usb-dbg.cpp b/src/usb-dbg.cpp
index f02469e..36982ff 100644
--- a/src/usb-dbg.cpp
+++ b/src/usb-dbg.cpp
@@ -560,8 +560,7 @@
{
auto reply = bus->call(method);
- IpmbMethodType resp;
- reply.read(resp);
+ auto resp = reply.unpack<IpmbMethodType>();
respData = std::move(
std::get<std::remove_reference_t<decltype(respData)>>(resp));
@@ -601,8 +600,7 @@
{
auto reply = bus->call(method);
- IpmbMethodType resp;
- reply.read(resp);
+ auto resp = reply.unpack<IpmbMethodType>();
respData = std::move(
std::get<std::remove_reference_t<decltype(respData)>>(resp));
@@ -828,9 +826,8 @@
auto reply = bus.call(method); // Send synchronous method call
// Read postcode value
- std::vector<std::tuple<std::vector<uint8_t>, std::vector<uint8_t>>>
- postcodes;
- reply.read(postcodes);
+ auto postcodes = reply.unpack<std::vector<
+ std::tuple<std::vector<uint8_t>, std::vector<uint8_t>>>>();
// retrieve the latest postcodes
size_t numEntries = std::min(maxPostcodes, postcodes.size());