Enforce const correctness
For all async calls, we should be consistently capturing non trivial
objects by const reference. This corrects bmcweb to be consistent and
capture errors by const value, and objects by const reference.
Tested: Code compiles. Trivial changes.
This saves about 300 bytes on our compressed binary size.
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: Ib3e0b6edef9803a1c480701556949488406305d4
diff --git a/redfish-core/lib/health.hpp b/redfish-core/lib/health.hpp
index 71da99e..9a4cd6c 100644
--- a/redfish-core/lib/health.hpp
+++ b/redfish-core/lib/health.hpp
@@ -184,13 +184,13 @@
std::shared_ptr<HealthPopulate> self = shared_from_this();
crow::connections::systemBus->async_method_call(
[self](const boost::system::error_code ec,
- std::vector<std::string>& resp) {
+ const std::vector<std::string>& resp) {
if (ec || resp.size() != 1)
{
// no global item, or too many
return;
}
- self->globalInventoryPath = std::move(resp[0]);
+ self->globalInventoryPath = resp[0];
},
"xyz.openbmc_project.ObjectMapper",
"/xyz/openbmc_project/object_mapper",
@@ -204,11 +204,12 @@
std::shared_ptr<HealthPopulate> self = shared_from_this();
crow::connections::systemBus->async_method_call(
[self](const boost::system::error_code ec,
- dbus::utility::ManagedObjectType& resp) {
+ const dbus::utility::ManagedObjectType& resp) {
if (ec)
{
return;
}
+ dbus::utility::ManagedObjectType copy = resp;
for (auto it = resp.begin(); it != resp.end();)
{
if (boost::ends_with(it->first.str, "critical") ||
@@ -217,9 +218,9 @@
it++;
continue;
}
- it = resp.erase(it);
+ it = copy.erase(it);
}
- self->statuses = std::move(resp);
+ self->statuses = std::move(copy);
},
"xyz.openbmc_project.ObjectMapper", "/",
"org.freedesktop.DBus.ObjectManager", "GetManagedObjects");