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/thresholds.hpp b/thresholds.hpp
index c483665..8b5329c 100644
--- a/thresholds.hpp
+++ b/thresholds.hpp
@@ -82,9 +82,6 @@
auto addThreshold(const std::string& sensorType, const std::string& sensorID,
int64_t value, ObjectInfo& info)
{
- 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);
std::shared_ptr<T> iface;
@@ -93,6 +90,9 @@
auto tHi = env::getEnv(Thresholds<T>::envHi, sensorType, sensorID);
if (!tLo.empty() && !tHi.empty())
{
+ static constexpr bool deferSignals = true;
+ auto& bus = *std::get<sdbusplus::bus::bus*>(info);
+
iface = std::make_shared<T>(bus, objPath.c_str(), deferSignals);
auto lo = stoll(tLo);
auto hi = stoll(tHi);