Apply LambdaBodyIndentation to dbus-sensors
Per the transform being done in bmcweb, do the same for dbus-sensors.
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: If21489607759f3cdf20fad17eede50fb4e228e5e
diff --git a/src/PwmSensor.cpp b/src/PwmSensor.cpp
index c1f0674..2ed24a6 100644
--- a/src/PwmSensor.cpp
+++ b/src/PwmSensor.cpp
@@ -60,50 +60,49 @@
sensorInterface->register_property(
"Value", fValue,
[this](const double& req, double& resp) {
- if (!std::isfinite(req))
- {
- // Reject attempted change, if to NaN or other non-numeric
- return -1;
- }
- if (req > 100.0 || req < 0.0)
- {
- // TODO(): It does not seem desirable to halt daemon here,
- // probably should just reject the change, continue running?
- throw std::runtime_error("Value out of range");
- return -1;
- }
+ if (!std::isfinite(req))
+ {
+ // Reject attempted change, if to NaN or other non-numeric
+ return -1;
+ }
+ if (req > 100.0 || req < 0.0)
+ {
+ // TODO(): It does not seem desirable to halt daemon here,
+ // probably should just reject the change, continue running?
+ throw std::runtime_error("Value out of range");
+ return -1;
+ }
- double reqValue = (req / 100.0) * pwmMax;
- double respValue = (resp / 100.0) * pwmMax;
- auto reqInt = static_cast<uint32_t>(std::round(reqValue));
- auto respInt = static_cast<uint32_t>(std::round(respValue));
- // Avoid floating-point equality, compare as integers
- if (reqInt == respInt)
- {
- return 1;
- }
- setValue(reqInt);
- resp = req;
-
- controlInterface->signal_property("Target");
-
+ double reqValue = (req / 100.0) * pwmMax;
+ double respValue = (resp / 100.0) * pwmMax;
+ auto reqInt = static_cast<uint32_t>(std::round(reqValue));
+ auto respInt = static_cast<uint32_t>(std::round(respValue));
+ // Avoid floating-point equality, compare as integers
+ if (reqInt == respInt)
+ {
return 1;
+ }
+ setValue(reqInt);
+ resp = req;
+
+ controlInterface->signal_property("Target");
+
+ return 1;
},
[this](double& curVal) {
- double currScaled = (curVal / 100.0) * pwmMax;
- auto currInt = static_cast<uint32_t>(std::round(currScaled));
- auto getInt = getValue();
- // Avoid floating-point equality, compare as integers
- if (currInt != getInt)
- {
- double getScaled =
- 100.0 * (static_cast<double>(getInt) / pwmMax);
- curVal = getScaled;
- controlInterface->signal_property("Target");
- sensorInterface->signal_property("Value");
- }
- return curVal;
- });
+ double currScaled = (curVal / 100.0) * pwmMax;
+ auto currInt = static_cast<uint32_t>(std::round(currScaled));
+ auto getInt = getValue();
+ // Avoid floating-point equality, compare as integers
+ if (currInt != getInt)
+ {
+ double getScaled = 100.0 * (static_cast<double>(getInt) / pwmMax);
+ curVal = getScaled;
+ controlInterface->signal_property("Target");
+ sensorInterface->signal_property("Value");
+ }
+ return curVal;
+ });
// pwm sensor interface is in percent
sensorInterface->register_property("MaxValue", static_cast<int64_t>(100));
sensorInterface->register_property("MinValue", static_cast<int64_t>(0));
@@ -115,37 +114,37 @@
controlInterface->register_property(
"Target", static_cast<uint64_t>(pwmValue),
[this](const uint64_t& req, uint64_t& resp) {
- if (req > static_cast<uint64_t>(targetIfaceMax))
- {
- throw std::runtime_error("Value out of range");
- return -1;
- }
- if (req == resp)
- {
- return 1;
- }
- auto scaledValue = static_cast<double>(req) / targetIfaceMax;
- auto roundValue = std::round(scaledValue * pwmMax);
- setValue(static_cast<uint32_t>(roundValue));
- resp = req;
-
- sensorInterface->signal_property("Value");
-
+ if (req > static_cast<uint64_t>(targetIfaceMax))
+ {
+ throw std::runtime_error("Value out of range");
+ return -1;
+ }
+ if (req == resp)
+ {
return 1;
+ }
+ auto scaledValue = static_cast<double>(req) / targetIfaceMax;
+ auto roundValue = std::round(scaledValue * pwmMax);
+ setValue(static_cast<uint32_t>(roundValue));
+ resp = req;
+
+ sensorInterface->signal_property("Value");
+
+ return 1;
},
[this](uint64_t& curVal) {
- auto getInt = getValue();
- auto scaledValue = static_cast<double>(getInt) / pwmMax;
- auto roundValue = std::round(scaledValue * targetIfaceMax);
- auto value = static_cast<uint64_t>(roundValue);
- if (curVal != value)
- {
- curVal = value;
- controlInterface->signal_property("Target");
- sensorInterface->signal_property("Value");
- }
- return curVal;
- });
+ auto getInt = getValue();
+ auto scaledValue = static_cast<double>(getInt) / pwmMax;
+ auto roundValue = std::round(scaledValue * targetIfaceMax);
+ auto value = static_cast<uint64_t>(roundValue);
+ if (curVal != value)
+ {
+ curVal = value;
+ controlInterface->signal_property("Target");
+ sensorInterface->signal_property("Value");
+ }
+ return curVal;
+ });
sensorInterface->initialize();
controlInterface->initialize();