Make routing capture by const reference
Where possible, we should avoid doing async_method_calls that capture by
mutable value.
Tested: Ran redfish/v1 and webui. Both appear to function.
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: I3065a230568ac13f63ce030b6f19eabba1ece5fe
diff --git a/http/routing.hpp b/http/routing.hpp
index 0a0dc74..eca1b3a 100644
--- a/http/routing.hpp
+++ b/http/routing.hpp
@@ -1308,8 +1308,9 @@
crow::connections::systemBus->async_method_call(
[&req, asyncResp, &rules, ruleIndex, found](
const boost::system::error_code ec,
- std::map<std::string, std::variant<bool, std::string,
- std::vector<std::string>>>
+ const std::map<
+ std::string,
+ std::variant<bool, std::string, std::vector<std::string>>>&
userInfo) {
if (ec)
{
@@ -1335,7 +1336,7 @@
<< " userRole = " << *userRolePtr;
}
- bool* remoteUserPtr = nullptr;
+ const bool* remoteUserPtr = nullptr;
auto remoteUserIter = userInfo.find("RemoteUser");
if (remoteUserIter != userInfo.end())
{
@@ -1354,7 +1355,7 @@
bool passwordExpired = false; // default for remote user
if (!remoteUser)
{
- bool* passwordExpiredPtr = nullptr;
+ const bool* passwordExpiredPtr = nullptr;
auto passwordExpiredIter =
userInfo.find("UserPasswordExpired");
if (passwordExpiredIter != userInfo.end())