Utils: simplify control flow in getSensorConfiguration()
The bool flag variables were only used for control flow that can be
expressed much more directly; let's do that instead. (Also removing a
redundant log message in the GetManagedObjects failure case.)
Signed-off-by: Zev Weiss <zev@bewilderbeest.net>
Change-Id: Idb05b37dc7c7fe937f787507392554253d6b625c
diff --git a/src/Utils.cpp b/src/Utils.cpp
index 7dc40c4..cf9ff75 100644
--- a/src/Utils.cpp
+++ b/src/Utils.cpp
@@ -150,7 +150,6 @@
dbusConnection->new_method_call(
entityManagerName, "/", "org.freedesktop.DBus.ObjectManager",
"GetManagedObjects");
- bool err = false;
try
{
sdbusplus::message_t reply =
@@ -163,30 +162,19 @@
<< entityManagerName << " exception name:" << e.name()
<< "and description:" << e.description()
<< " was thrown\n";
- err = true;
- }
-
- if (err)
- {
- std::cerr << "Error communicating to entity manager\n";
return false;
}
}
for (const auto& pathPair : managedObj)
{
- bool correctType = false;
for (const auto& [intf, cfg] : pathPair.second)
{
if (intf.starts_with(type))
{
- correctType = true;
+ resp.emplace(pathPair);
break;
}
}
- if (correctType)
- {
- resp.emplace(pathPair);
- }
}
return true;
}