clang-format: re-format for clang-18
clang-format-18 isn't compatible with the clang-format-17 output, so we
need to reformat the code with the latest version. The way clang-18
handles lambda formatting also changed, so we have made changes to the
organization default style format to better handle lambda formatting.
See I5e08687e696dd240402a2780158664b7113def0e for updated style.
See Iea0776aaa7edd483fa395e23de25ebf5a6288f71 for clang-18 enablement.
Change-Id: Ib7af6345a7b9e858700bd81645fe87d9d7e9d0fb
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
diff --git a/src/PwmSensor.cpp b/src/PwmSensor.cpp
index 2a431eb..a06d7c4 100644
--- a/src/PwmSensor.cpp
+++ b/src/PwmSensor.cpp
@@ -41,8 +41,8 @@
sdbusplus::asio::object_server& objectServer,
const std::string& sensorConfiguration,
const std::string& sensorType, bool isValueMutable) :
- sysPath(sysPath),
- objectServer(objectServer), name(sensor_paths::escapePathForDbus(pwmname))
+ sysPath(sysPath), objectServer(objectServer),
+ name(sensor_paths::escapePathForDbus(pwmname))
{
// add interface under sensor and Control.FanPwm as Control is used
// in obmc project, also add sensor so it can be viewed as a sensor
@@ -69,49 +69,50 @@
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;
+ 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;
- });
+
+ 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;
+ });
// pwm sensor interface is in percent
sensorInterface->register_property("MaxValue", static_cast<double>(100));
sensorInterface->register_property("MinValue", static_cast<double>(0));
@@ -123,37 +124,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;
+ 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;
- });
+
+ 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;
+ });
sensorInterface->initialize();
controlInterface->initialize();