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: Id36cca2ca362f505ed9f70d30f6665a8c1a62722
diff --git a/occ_manager.cpp b/occ_manager.cpp
index 6b735f7..ed6453c 100644
--- a/occ_manager.cpp
+++ b/occ_manager.cpp
@@ -326,8 +326,8 @@
{
namespace fs = std::filesystem;
- sdbusplus::message::object_path o;
- msg.read(o);
+ auto o = msg.unpack<sdbusplus::message::object_path>();
+
fs::path cpuPath(std::string(std::move(o)));
auto name = cpuPath.filename().string();
diff --git a/powermode.cpp b/powermode.cpp
index 6d2424a..0202a90 100644
--- a/powermode.cpp
+++ b/powermode.cpp
@@ -309,8 +309,8 @@
method.append(HYPE_INTERFACE, HYPE_PROP);
auto reply = bus.call(method);
- std::variant<std::string> hyperEntryValue;
- reply.read(hyperEntryValue);
+ auto hyperEntryValue = reply.unpack<std::variant<std::string>>();
+
auto propVal = std::get<std::string>(hyperEntryValue);
if (Hyper::Target::convertHypervisorFromString(propVal) ==
Hyper::Target::Hypervisor::PowerVM)
@@ -915,8 +915,8 @@
method.append(PMODE_DEFAULT_INTERFACE, "PowerMode");
auto reply = bus.call(method);
- std::variant<std::string> stateEntryValue;
- reply.read(stateEntryValue);
+ auto stateEntryValue = reply.unpack<std::variant<std::string>>();
+
auto propVal = std::get<std::string>(stateEntryValue);
const std::string fullModeString =
diff --git a/utils.cpp b/utils.cpp
index 4025f94..bc299cb 100644
--- a/utils.cpp
+++ b/utils.cpp
@@ -192,9 +192,7 @@
auto reply = bus.call(method);
- std::variant<std::string> propertyVal;
-
- reply.read(propertyVal);
+ auto propertyVal = reply.unpack<std::variant<std::string>>();
stateVal = std::get<std::string>(propertyVal);
}