diff options
author | Ed Tanous <edtanous@google.com> | 2022-01-07 22:38:34 +0300 |
---|---|---|
committer | Ed Tanous <ed@tanous.net> | 2022-01-10 20:36:54 +0300 |
commit | 914e2d5d5dbeddca9f48504256f7089efe86fc65 (patch) | |
tree | b9e60be35e5a15989b5d2d70038e9085dbd6e2bb /redfish-core/lib/log_services.hpp | |
parent | 711ac7a931dd3f151fc4064063b5ea90404b9054 (diff) | |
download | bmcweb-914e2d5d5dbeddca9f48504256f7089efe86fc65.tar.xz |
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
Diffstat (limited to 'redfish-core/lib/log_services.hpp')
-rw-r--r-- | redfish-core/lib/log_services.hpp | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp index 0bfd15e8e6..ddd124bb49 100644 --- a/redfish-core/lib/log_services.hpp +++ b/redfish-core/lib/log_services.hpp @@ -1363,7 +1363,7 @@ inline void requestRoutesDBusEventLogEntryCollection(App& app) // 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 @@ inline void requestRoutesDBusEventLogEntryCollection(App& app) 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 @@ inline void requestRoutesDBusEventLogEntryCollection(App& app) } 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 @@ inline void requestRoutesDBusEventLogEntry(App& app) // 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 @@ inline void requestRoutesDBusEventLogEntry(App& app) 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 @@ inline void requestRoutesDBusEventLogEntry(App& app) } else if (propertyMap.first == "Resolved") { - bool* resolveptr = + const bool* resolveptr = std::get_if<bool>(&propertyMap.second); if (resolveptr == nullptr) { |