Enable readability-avoid-const-params-in-decls
This check involves explicitly declaring variables const when they're
declared auto, which helps in readability, and makes it more clear that
the variables are const.
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: I71198ea03850384a389a56ad26f2c4a48c75b148
diff --git a/redfish-core/lib/sensors.hpp b/redfish-core/lib/sensors.hpp
index 121223e..f3fa52c 100644
--- a/redfish-core/lib/sensors.hpp
+++ b/redfish-core/lib/sensors.hpp
@@ -761,11 +761,11 @@
// Check if sensor has critical threshold alarm
- for (auto& [interface, values] : interfacesDict)
+ for (const auto& [interface, values] : interfacesDict)
{
if (interface == "xyz.openbmc_project.Sensor.Threshold.Critical")
{
- for (auto& [valueName, value] : values)
+ for (const auto& [valueName, value] : values)
{
if (valueName == "CriticalAlarmHigh" ||
valueName == "CriticalAlarmLow")
@@ -798,11 +798,11 @@
}
// Check if sensor has warning threshold alarm
- for (auto& [interface, values] : interfacesDict)
+ for (const auto& [interface, values] : interfacesDict)
{
if (interface == "xyz.openbmc_project.Sensor.Threshold.Warning")
{
- for (auto& [valueName, value] : values)
+ for (const auto& [valueName, value] : values)
{
if (valueName == "WarningAlarmHigh" ||
valueName == "WarningAlarmLow")
@@ -866,11 +866,11 @@
{
// Assume values exist as is (10^0 == 1) if no scale exists
int64_t scaleMultiplier = 0;
- for (auto& [interface, values] : interfacesDict)
+ for (const auto& [interface, values] : interfacesDict)
{
if (interface == "xyz.openbmc_project.Sensor.Value")
{
- for (auto& [valueName, value] : values)
+ for (const auto& [valueName, value] : values)
{
if (valueName == "Scale")
{
@@ -1194,13 +1194,15 @@
return;
}
- auto allowedFailures = std::get_if<uint8_t>(
- &(findFailures->second));
- auto collection =
+ const uint8_t* allowedFailures =
+ std::get_if<uint8_t>(
+ &(findFailures->second));
+ const std::vector<std::string>* collection =
std::get_if<std::vector<std::string>>(
&(findCollection->second));
- auto status = std::get_if<std::string>(
- &(findStatus->second));
+ const std::string* status =
+ std::get_if<std::string>(
+ &(findStatus->second));
if (allowedFailures == nullptr ||
collection == nullptr || status == nullptr)
@@ -1467,11 +1469,11 @@
{
// Get properties from Inventory.Item interface
- for (auto& [interface, values] : interfacesDict)
+ for (const auto& [interface, values] : interfacesDict)
{
if (interface == "xyz.openbmc_project.Inventory.Item")
{
- for (auto& [name, dbusValue] : values)
+ for (const auto& [name, dbusValue] : values)
{
if (name == "Present")
{
@@ -1493,7 +1495,7 @@
// Get properties from Inventory.Decorator.Asset interface
if (interface == "xyz.openbmc_project.Inventory.Decorator.Asset")
{
- for (auto& [name, dbusValue] : values)
+ for (const auto& [name, dbusValue] : values)
{
if (name == "Manufacturer")
{
@@ -1537,7 +1539,7 @@
if (interface ==
"xyz.openbmc_project.State.Decorator.OperationalStatus")
{
- for (auto& [name, dbusValue] : values)
+ for (const auto& [name, dbusValue] : values)
{
if (name == "Functional")
{