cleanup: reduced scope of variables
Cppcheck CI tool identified many variables whose scope could be reduced.
Change-Id: I1478b5680adc560d08bc74ffc91929b1d19e24fa
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/sensor.cpp b/sensor.cpp
index e68f7a7..21f3d87 100644
--- a/sensor.cpp
+++ b/sensor.cpp
@@ -170,8 +170,6 @@
namespace fs = std::experimental::filesystem;
std::shared_ptr<StatusObject> iface = nullptr;
- static constexpr bool deferSignals = true;
- auto& bus = *std::get<sdbusplus::bus::bus*>(info);
auto& objPath = std::get<std::string>(info);
auto& obj = std::get<Object>(info);
@@ -185,11 +183,10 @@
if (fs::exists(sysfsFullPath))
{
bool functional = true;
- uint32_t fault = 0;
try
{
- fault = ioAccess.read(faultName, faultID, entry, hwmonio::retries,
- hwmonio::delay);
+ uint32_t fault = ioAccess.read(faultName, faultID, entry,
+ hwmonio::retries, hwmonio::delay);
if (fault != 0)
{
functional = false;
@@ -209,6 +206,9 @@
phosphor::logging::entry("FILE=%s", sysfsFullPath.c_str()));
}
+ static constexpr bool deferSignals = true;
+ auto& bus = *std::get<sdbusplus::bus::bus*>(info);
+
iface =
std::make_shared<StatusObject>(bus, objPath.c_str(), deferSignals);
// Set functional property