Fix some warnings by cppcheck
Warning message:
redfish-core/include/redfish_aggregator.hpp:800:21: style: The scope
of the variable 'collectionItem' can be reduced. [variableScope]
std::string collectionItem;
^
redfish-core/lib/power.hpp:279:33: style: The scope of the variable
'value' can be reduced. [variableScope]
nlohmann::json& value =
^
Tested: Verify that there are no such warnings in local CI.
Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: Ie379dcb04a22a00b495f9ab3948d97e2e537f395
diff --git a/redfish-core/lib/power.hpp b/redfish-core/lib/power.hpp
index 4d94e57..116ea25 100644
--- a/redfish-core/lib/power.hpp
+++ b/redfish-core/lib/power.hpp
@@ -276,9 +276,6 @@
}
}
- nlohmann::json& value =
- sensorJson["PowerLimit"]["LimitInWatts"];
-
// LimitException is Mandatory attribute as per OCP
// Baseline Profile – v1.0.0, so currently making it
// "NoAction" as default value to make it OCP Compliant.
@@ -288,7 +285,8 @@
{
// Redfish specification indicates PowerLimit should
// be null if the limit is not enabled.
- value = powerCap * std::pow(10, scale);
+ sensorJson["PowerLimit"]["LimitInWatts"] =
+ powerCap * std::pow(10, scale);
}
};