Change variable scopes
cppcheck correctly notes that a lot of our variables can be declared at
more specific scopes, and in every case, it seems to be correct.
Tested: Redfish service validator passes. Unit test coverage on others.
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: Ia4414410d0e8f74a3bd40fdc0e0232450d1a6416
diff --git a/redfish-core/lib/sensors.hpp b/redfish-core/lib/sensors.hpp
index 3cd4379..627ba7e 100644
--- a/redfish-core/lib/sensors.hpp
+++ b/redfish-core/lib/sensors.hpp
@@ -531,11 +531,10 @@
return;
}
const std::string* chassisPath = nullptr;
- std::string chassisName;
for (const std::string& chassis : chassisPaths)
{
sdbusplus::message::object_path path(chassis);
- chassisName = path.filename();
+ std::string chassisName = path.filename();
if (chassisName.empty())
{
BMCWEB_LOG_ERROR << "Failed to find '/' in " << chassis;