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);
}