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/log_services.hpp b/redfish-core/lib/log_services.hpp
index 0bfd15e..ddd124b 100644
--- a/redfish-core/lib/log_services.hpp
+++ b/redfish-core/lib/log_services.hpp
@@ -1363,7 +1363,7 @@
// Make call to Logging Service to find all log entry objects
crow::connections::systemBus->async_method_call(
[asyncResp](const boost::system::error_code ec,
- dbus::utility::ManagedObjectType& resp) {
+ const dbus::utility::ManagedObjectType& resp) {
if (ec)
{
// TODO Handle for specific error code
@@ -1378,12 +1378,12 @@
entriesArray = nlohmann::json::array();
for (auto& objectPath : resp)
{
- uint32_t* id = nullptr;
+ const uint32_t* id = nullptr;
std::time_t timestamp{};
std::time_t updateTimestamp{};
- std::string* severity = nullptr;
- std::string* message = nullptr;
- std::string* filePath = nullptr;
+ const std::string* severity = nullptr;
+ const std::string* message = nullptr;
+ const std::string* filePath = nullptr;
bool resolved = false;
for (auto& interfaceMap : objectPath.second)
{
@@ -1434,8 +1434,9 @@
}
else if (propertyMap.first == "Resolved")
{
- bool* resolveptr = std::get_if<bool>(
- &propertyMap.second);
+ const bool* resolveptr =
+ std::get_if<bool>(
+ &propertyMap.second);
if (resolveptr == nullptr)
{
messages::internalError(
@@ -1528,7 +1529,7 @@
// Make call to Logging Service to find all log entry objects
crow::connections::systemBus->async_method_call(
[asyncResp, entryID](const boost::system::error_code ec,
- GetManagedPropertyType& resp) {
+ const GetManagedPropertyType& resp) {
if (ec.value() == EBADR)
{
messages::resourceNotFound(
@@ -1543,12 +1544,12 @@
messages::internalError(asyncResp->res);
return;
}
- uint32_t* id = nullptr;
+ const uint32_t* id = nullptr;
std::time_t timestamp{};
std::time_t updateTimestamp{};
- std::string* severity = nullptr;
- std::string* message = nullptr;
- std::string* filePath = nullptr;
+ const std::string* severity = nullptr;
+ const std::string* message = nullptr;
+ const std::string* filePath = nullptr;
bool resolved = false;
for (auto& propertyMap : resp)
@@ -1590,7 +1591,7 @@
}
else if (propertyMap.first == "Resolved")
{
- bool* resolveptr =
+ const bool* resolveptr =
std::get_if<bool>(&propertyMap.second);
if (resolveptr == nullptr)
{