Fix const correctness issues
cppcheck correctly notes that a lot of variables in the new code can be
const. Make most of them const.
Tested: WIP
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: I8f37b6353fd707923f533e1d61c5b5419282bf23
diff --git a/include/authentication.hpp b/include/authentication.hpp
index 3c1ca48..8d59be4 100644
--- a/include/authentication.hpp
+++ b/include/authentication.hpp
@@ -21,7 +21,7 @@
namespace authentication
{
-static void cleanupTempSession(Request& req)
+static void cleanupTempSession(const Request& req)
{
// TODO(ed) THis should really be handled by the persistent data
// middleware, but because it is upstream, it doesn't have access to the
@@ -260,7 +260,7 @@
[[maybe_unused]] static std::shared_ptr<persistent_data::UserSession>
authenticate(
- boost::asio::ip::address& ipAddress [[maybe_unused]],
+ const boost::asio::ip::address& ipAddress [[maybe_unused]],
Response& res [[maybe_unused]], boost::beast::http::verb method,
const boost::beast::http::header<true>& reqHeader,
[[maybe_unused]] const std::shared_ptr<persistent_data::UserSession>&
diff --git a/include/ibm/management_console_rest.hpp b/include/ibm/management_console_rest.hpp
index 2bede28..8d50c9f 100644
--- a/include/ibm/management_console_rest.hpp
+++ b/include/ibm/management_console_rest.hpp
@@ -520,7 +520,7 @@
returnJson["LockType"] = std::get<2>(var.second);
returnJson["ResourceID"] = std::get<3>(var.second);
- for (auto& i : std::get<4>(var.second))
+ for (const auto& i : std::get<4>(var.second))
{
segments["LockFlag"] = i.first;
segments["SegmentLength"] = i.second;
@@ -588,7 +588,7 @@
returnJson["LockType"] = std::get<2>(var.second);
returnJson["ResourceID"] = std::get<3>(var.second);
- for (auto& i : std::get<4>(var.second))
+ for (const auto& i : std::get<4>(var.second))
{
segments["LockFlag"] = i.first;
segments["SegmentLength"] = i.second;
diff --git a/include/openbmc_dbus_rest.hpp b/include/openbmc_dbus_rest.hpp
index 0e2af70..d0bc29c 100644
--- a/include/openbmc_dbus_rest.hpp
+++ b/include/openbmc_dbus_rest.hpp
@@ -2340,7 +2340,7 @@
nlohmann::json& propertyItem = propertiesObj[name];
crow::connections::systemBus->async_send(
m, [&propertyItem,
- asyncResp](boost::system::error_code& e,
+ asyncResp](const boost::system::error_code& e,
sdbusplus::message::message& msg) {
if (e)
{
@@ -2420,7 +2420,7 @@
std::sort(names.begin(), names.end());
asyncResp->res.jsonValue["status"] = "ok";
auto& objectsSub = asyncResp->res.jsonValue["objects"];
- for (auto& name : names)
+ for (const auto& name : names)
{
nlohmann::json::object_t object;
object["name"] = name;