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: I01547e98d27910919e09ebf7907c86292a6c825d
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
diff --git a/dbus-sdr/sensorcommands.cpp b/dbus-sdr/sensorcommands.cpp
index 6517fdd..b3786c9 100644
--- a/dbus-sdr/sensorcommands.cpp
+++ b/dbus-sdr/sensorcommands.cpp
@@ -135,24 +135,24 @@
"type='signal',member='InterfacesAdded',arg0path='/xyz/openbmc_project/"
"sensors/'",
[](sdbusplus::message_t&) {
- getSensorTree().clear();
- getIpmiDecoratorPaths(/*ctx=*/std::nullopt).reset();
- sdrLastAdd = std::chrono::duration_cast<std::chrono::seconds>(
- std::chrono::system_clock::now().time_since_epoch())
- .count();
-});
+ getSensorTree().clear();
+ getIpmiDecoratorPaths(/*ctx=*/std::nullopt).reset();
+ sdrLastAdd = std::chrono::duration_cast<std::chrono::seconds>(
+ std::chrono::system_clock::now().time_since_epoch())
+ .count();
+ });
static sdbusplus::bus::match_t sensorRemoved(
*getSdBus(),
"type='signal',member='InterfacesRemoved',arg0path='/xyz/openbmc_project/"
"sensors/'",
[](sdbusplus::message_t&) {
- getSensorTree().clear();
- getIpmiDecoratorPaths(/*ctx=*/std::nullopt).reset();
- sdrLastRemove = std::chrono::duration_cast<std::chrono::seconds>(
- std::chrono::system_clock::now().time_since_epoch())
- .count();
-});
+ getSensorTree().clear();
+ getIpmiDecoratorPaths(/*ctx=*/std::nullopt).reset();
+ sdrLastRemove = std::chrono::duration_cast<std::chrono::seconds>(
+ std::chrono::system_clock::now().time_since_epoch())
+ .count();
+ });
ipmi_ret_t getSensorConnection(ipmi::Context::ptr ctx, uint8_t sensnum,
std::string& connection, std::string& path,
@@ -206,40 +206,43 @@
"type='signal',member='PropertiesChanged',interface='org.freedesktop.DBus."
"Properties',arg0namespace='xyz.openbmc_project.Sensor.Threshold'",
[](sdbusplus::message_t& m) {
- boost::container::flat_map<std::string, std::variant<bool, double>> values;
- m.read(std::string(), values);
+ boost::container::flat_map<std::string, std::variant<bool, double>>
+ values;
+ m.read(std::string(), values);
- auto findAssert = std::find_if(values.begin(), values.end(),
- [](const auto& pair) {
- return pair.first.find("Alarm") != std::string::npos;
- });
- if (findAssert != values.end())
- {
- auto ptr = std::get_if<bool>(&(findAssert->second));
- if (ptr == nullptr)
+ auto findAssert =
+ std::find_if(values.begin(), values.end(), [](const auto& pair) {
+ return pair.first.find("Alarm") != std::string::npos;
+ });
+ if (findAssert != values.end())
{
- lg2::error("thresholdChanged: Assert non bool");
- return;
- }
- if (*ptr)
- {
- lg2::info("thresholdChanged: Assert, sensor path: {SENSOR_PATH}",
- "SENSOR_PATH", m.get_path());
- thresholdDeassertMap[m.get_path()][findAssert->first] = *ptr;
- }
- else
- {
- auto& value = thresholdDeassertMap[m.get_path()][findAssert->first];
- if (value)
+ auto ptr = std::get_if<bool>(&(findAssert->second));
+ if (ptr == nullptr)
+ {
+ lg2::error("thresholdChanged: Assert non bool");
+ return;
+ }
+ if (*ptr)
{
lg2::info(
- "thresholdChanged: deassert, sensor path: {SENSOR_PATH}",
+ "thresholdChanged: Assert, sensor path: {SENSOR_PATH}",
"SENSOR_PATH", m.get_path());
- value = *ptr;
+ thresholdDeassertMap[m.get_path()][findAssert->first] = *ptr;
+ }
+ else
+ {
+ auto& value =
+ thresholdDeassertMap[m.get_path()][findAssert->first];
+ if (value)
+ {
+ lg2::info(
+ "thresholdChanged: deassert, sensor path: {SENSOR_PATH}",
+ "SENSOR_PATH", m.get_path());
+ value = *ptr;
+ }
}
}
- }
-});
+ });
namespace sensor
{
@@ -432,9 +435,8 @@
}
// Calculate VR Mode from input IPMI discrete event bytes
-static std::optional<std::string>
- calculateVRMode(uint15_t assertOffset,
- const ipmi::DbusInterfaceMap::mapped_type& VRObject)
+static std::optional<std::string> calculateVRMode(
+ uint15_t assertOffset, const ipmi::DbusInterfaceMap::mapped_type& VRObject)
{
// get VR mode profiles from Supported Interface
auto profiles = getSupportedVrProfiles(VRObject);
@@ -774,18 +776,16 @@
return ipmi::responseSuccess();
}
-ipmi::RspType<> ipmiSetSensorReading(ipmi::Context::ptr ctx,
- uint8_t sensorNumber, uint8_t,
- uint8_t reading, uint15_t assertOffset,
- bool, uint15_t, bool, uint8_t, uint8_t,
- uint8_t)
+ipmi::RspType<> ipmiSetSensorReading(
+ ipmi::Context::ptr ctx, uint8_t sensorNumber, uint8_t, uint8_t reading,
+ uint15_t assertOffset, bool, uint15_t, bool, uint8_t, uint8_t, uint8_t)
{
std::string connection;
std::string path;
std::vector<std::string> interfaces;
- ipmi::Cc status = getSensorConnection(ctx, sensorNumber, connection, path,
- &interfaces);
+ ipmi::Cc status =
+ getSensorConnection(ctx, sensorNumber, connection, path, &interfaces);
if (status)
{
return ipmi::response(status);
@@ -807,14 +807,14 @@
}
// Only allow external SetSensor if write permission granted
- if (!details::sdrWriteTable.getWritePermission((ctx->lun << 8) |
- sensorNumber))
+ if (!details::sdrWriteTable.getWritePermission(
+ (ctx->lun << 8) | sensorNumber))
{
return ipmi::responseResponseError();
}
- auto value = sensor::calculateValue(reading, sensorMap,
- sensorObject->second);
+ auto value =
+ sensor::calculateValue(reading, sensorMap, sensorObject->second);
if (!value)
{
return ipmi::responseResponseError();
@@ -863,8 +863,8 @@
// VR sensors are treated as a special case and we will not check the
// write permission for VR sensors, since they always deemed writable
// and permission table are not applied to VR sensors.
- auto vrMode = sensor::calculateVRMode(assertOffset,
- sensorObject->second);
+ auto vrMode =
+ sensor::calculateVRMode(assertOffset, sensorObject->second);
if (!vrMode)
{
return ipmi::responseResponseError();
@@ -982,8 +982,8 @@
return ipmi::responseResponseError();
}
- uint8_t value = scaleIPMIValueFromDouble(reading, mValue, rExp, bValue,
- bExp, bSigned);
+ uint8_t value =
+ scaleIPMIValueFromDouble(reading, mValue, rExp, bValue, bExp, bSigned);
uint8_t operation =
static_cast<uint8_t>(IPMISensorReadingByte2::sensorScanningEnable);
operation |=
@@ -1032,16 +1032,15 @@
{
// This is the first reading, show the coefficients
double step = (max - min) / 255.0;
- std::cerr << "IPMI sensor "
- << details::sdrStatsTable.getName((ctx->lun << 8) |
- sensnum)
- << ": Range min=" << min << " max=" << max
- << ", step=" << step
- << ", Coefficients mValue=" << static_cast<int>(mValue)
- << " rExp=" << static_cast<int>(rExp)
- << " bValue=" << static_cast<int>(bValue)
- << " bExp=" << static_cast<int>(bExp)
- << " bSigned=" << static_cast<int>(bSigned) << "\n";
+ std::cerr
+ << "IPMI sensor "
+ << details::sdrStatsTable.getName((ctx->lun << 8) | sensnum)
+ << ": Range min=" << min << " max=" << max << ", step=" << step
+ << ", Coefficients mValue=" << static_cast<int>(mValue)
+ << " rExp=" << static_cast<int>(rExp)
+ << " bValue=" << static_cast<int>(bValue)
+ << " bExp=" << static_cast<int>(bExp)
+ << " bSigned=" << static_cast<int>(bSigned) << "\n";
}
}
@@ -1296,8 +1295,8 @@
if (warningHigh != warningMap.end())
{
- double value = std::visit(VariantToDoubleVisitor(),
- warningHigh->second);
+ double value =
+ std::visit(VariantToDoubleVisitor(), warningHigh->second);
if (std::isfinite(value))
{
resp.warningHigh = scaleIPMIValueFromDouble(
@@ -1306,8 +1305,8 @@
}
if (warningLow != warningMap.end())
{
- double value = std::visit(VariantToDoubleVisitor(),
- warningLow->second);
+ double value =
+ std::visit(VariantToDoubleVisitor(), warningLow->second);
if (std::isfinite(value))
{
resp.warningLow = scaleIPMIValueFromDouble(
@@ -1324,8 +1323,8 @@
if (criticalHigh != criticalMap.end())
{
- double value = std::visit(VariantToDoubleVisitor(),
- criticalHigh->second);
+ double value =
+ std::visit(VariantToDoubleVisitor(), criticalHigh->second);
if (std::isfinite(value))
{
resp.criticalHigh = scaleIPMIValueFromDouble(
@@ -1334,8 +1333,8 @@
}
if (criticalLow != criticalMap.end())
{
- double value = std::visit(VariantToDoubleVisitor(),
- criticalLow->second);
+ double value =
+ std::visit(VariantToDoubleVisitor(), criticalLow->second);
if (std::isfinite(value))
{
resp.criticalLow = scaleIPMIValueFromDouble(
@@ -1511,8 +1510,8 @@
auto warningLow = warningMap.find("WarningLow");
if (warningHigh != warningMap.end())
{
- double value = std::visit(VariantToDoubleVisitor(),
- warningHigh->second);
+ double value =
+ std::visit(VariantToDoubleVisitor(), warningHigh->second);
if (std::isfinite(value))
{
assertionEnabledLsb |= static_cast<uint8_t>(
@@ -1525,8 +1524,8 @@
}
if (warningLow != warningMap.end())
{
- double value = std::visit(VariantToDoubleVisitor(),
- warningLow->second);
+ double value =
+ std::visit(VariantToDoubleVisitor(), warningLow->second);
if (std::isfinite(value))
{
assertionEnabledLsb |= static_cast<uint8_t>(
@@ -1547,8 +1546,8 @@
if (criticalHigh != criticalMap.end())
{
- double value = std::visit(VariantToDoubleVisitor(),
- criticalHigh->second);
+ double value =
+ std::visit(VariantToDoubleVisitor(), criticalHigh->second);
if (std::isfinite(value))
{
assertionEnabledMsb |= static_cast<uint8_t>(
@@ -1560,8 +1559,8 @@
}
if (criticalLow != criticalMap.end())
{
- double value = std::visit(VariantToDoubleVisitor(),
- criticalLow->second);
+ double value =
+ std::visit(VariantToDoubleVisitor(), criticalLow->second);
if (std::isfinite(value))
{
assertionEnabledLsb |= static_cast<uint8_t>(
@@ -1731,15 +1730,15 @@
}
if (warningHighAlarm)
{
- assertions.set(
- static_cast<size_t>(IPMIGetSensorEventEnableThresholds::
- upperNonCriticalGoingHigh));
+ assertions.set(static_cast<size_t>(
+ IPMIGetSensorEventEnableThresholds::
+ upperNonCriticalGoingHigh));
}
if (warningLowAlarm)
{
- assertions.set(
- static_cast<size_t>(IPMIGetSensorEventEnableThresholds::
- lowerNonCriticalGoingLow));
+ assertions.set(static_cast<size_t>(
+ IPMIGetSensorEventEnableThresholds::
+ lowerNonCriticalGoingLow));
}
}
if (criticalInterface != sensorMap.end())
@@ -1761,9 +1760,9 @@
}
if (criticalHighAlarm)
{
- assertions.set(
- static_cast<size_t>(IPMIGetSensorEventEnableThresholds::
- upperCriticalGoingHigh));
+ assertions.set(static_cast<size_t>(
+ IPMIGetSensorEventEnableThresholds::
+ upperCriticalGoingHigh));
}
if (criticalLowAlarm)
{
@@ -1898,8 +1897,8 @@
uint8_t bExpBits = bExp & 0x07;
// move rExp and bExp into place
- record.body.r_b_exponents = (rExpSign << 7) | (rExpBits << 4) |
- (bExpSign << 3) | bExpBits;
+ record.body.r_b_exponents =
+ (rExpSign << 7) | (rExpBits << 4) | (bExpSign << 3) | bExpBits;
// Set the analog reading byte interpretation accordingly
record.body.sensor_units_1 = (bSigned ? 1 : 0) << 7;
@@ -1923,8 +1922,8 @@
sensorMap.find("xyz.openbmc_project.Sensor.ValueMutability");
if (mutability != sensorMap.end())
{
- sensorSettable = mappedVariant<bool>(mutability->second, "Mutable",
- false);
+ sensorSettable =
+ mappedVariant<bool>(mutability->second, "Mutable", false);
}
get_sdr::body::init_settable_state(sensorSettable, &record.body);
@@ -2173,9 +2172,9 @@
ctx->lun = lun3;
}
- auto status = getSensorConnection(ctx,
- static_cast<uint8_t>(sensNumFromRecID),
- connection, path, &interfaces);
+ auto status =
+ getSensorConnection(ctx, static_cast<uint8_t>(sensNumFromRecID),
+ connection, path, &interfaces);
if (status)
{
lg2::error("getSensorDataRecord: getSensorConnection error");
@@ -2369,8 +2368,8 @@
// Return the number of sensors attached to the LUN
if ((ctx->lun == lun0) && (numSensors > 0))
{
- sdrCount = (numSensors > maxSensorsPerLUN) ? maxSensorsPerLUN
- : numSensors;
+ sdrCount =
+ (numSensors > maxSensorsPerLUN) ? maxSensorsPerLUN : numSensors;
}
else if ((ctx->lun == lun1) && (numSensors > maxSensorsPerLUN))
{
@@ -2435,8 +2434,8 @@
ipmiStorageGetSDRRepositoryInfo(ipmi::Context::ptr ctx)
{
constexpr const uint16_t unspecifiedFreeSpace = 0xFFFF;
- uint16_t recordCount = ipmi::getNumberOfSensors() +
- ipmi::sensor::getOtherSensorsCount(ctx);
+ uint16_t recordCount =
+ ipmi::getNumberOfSensors() + ipmi::sensor::getOtherSensorsCount(ctx);
uint8_t operationSupport = static_cast<uint8_t>(
SdrRepositoryInfoOps::overflow); // write not supported
@@ -2535,8 +2534,8 @@
return ipmi::responseSuccess(nextRecordId, record);
}
- size_t sdrLength = sizeof(get_sdr::SensorDataRecordHeader) +
- hdr->record_length;
+ size_t sdrLength =
+ sizeof(get_sdr::SensorDataRecordHeader) + hdr->record_length;
if (offset >= sdrLength)
{
lg2::error("ipmiStorageGetSDR: offset is outside the record");
@@ -2831,8 +2830,8 @@
for (const auto& sensor : sensorList)
{
- const auto& [readResult, tempVal,
- signBit] = readTemp(ctx, sensor.objectPath);
+ const auto& [readResult, tempVal, signBit] =
+ readTemp(ctx, sensor.objectPath);
if (readResult)
{
@@ -2931,14 +2930,14 @@
ipmi::storage::cmdGetSdr, ipmi::Privilege::User,
ipmiStorageGetSDR);
// <Get DCMI Sensor Info>
- ipmi::registerGroupHandler(ipmi::prioOpenBmcBase, ipmi::groupDCMI,
- ipmi::dcmi::cmdGetDcmiSensorInfo,
- ipmi::Privilege::Operator,
- ipmi::dcmi::getSensorInfo);
+ ipmi::registerGroupHandler(
+ ipmi::prioOpenBmcBase, ipmi::groupDCMI,
+ ipmi::dcmi::cmdGetDcmiSensorInfo, ipmi::Privilege::Operator,
+ ipmi::dcmi::getSensorInfo);
// <Get Temperature Readings>
- ipmi::registerGroupHandler(ipmi::prioOpenBmcBase, ipmi::groupDCMI,
- ipmi::dcmi::cmdGetTemperatureReadings,
- ipmi::Privilege::User,
- ipmi::dcmi::getTempReadings);
+ ipmi::registerGroupHandler(
+ ipmi::prioOpenBmcBase, ipmi::groupDCMI,
+ ipmi::dcmi::cmdGetTemperatureReadings, ipmi::Privilege::User,
+ ipmi::dcmi::getTempReadings);
}
} // namespace ipmi