clang-format: copy latest and re-format
clang-format-16 has some backwards incompatible changes that require
additional settings for best compatibility and re-running the formatter.
Copy the latest .clang-format from the docs repository and reformat the
repository.
Change-Id: I44441096113929ce96eb1439e2932e6ff3c87f27
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
diff --git a/dbus-sdr/sdrutils.cpp b/dbus-sdr/sdrutils.cpp
index e818ef3..399b59a 100644
--- a/dbus-sdr/sdrutils.cpp
+++ b/dbus-sdr/sdrutils.cpp
@@ -61,8 +61,8 @@
static constexpr const int32_t depth = 2;
- auto lbdUpdateSensorTree = [&dbus](const char* path,
- const auto& interfaces) {
+ auto lbdUpdateSensorTree =
+ [&dbus](const char* path, const auto& interfaces) {
auto mapperCall = dbus->new_method_call(
"xyz.openbmc_project.ObjectMapper",
"/xyz/openbmc_project/object_mapper",
@@ -102,8 +102,8 @@
static constexpr const std::array vrInterfaces = {
"xyz.openbmc_project.Control.VoltageRegulatorMode"};
- bool sensorRez =
- lbdUpdateSensorTree("/xyz/openbmc_project/sensors", sensorInterfaces);
+ bool sensorRez = lbdUpdateSensorTree("/xyz/openbmc_project/sensors",
+ sensorInterfaces);
#ifdef FEATURE_HYBRID_SENSORS
@@ -218,7 +218,7 @@
return std::find_if(
ipmi::sensor::sensors.begin(), ipmi::sensor::sensors.end(),
[&path](const ipmi::sensor::IdInfoMap::value_type& findSensor) {
- return findSensor.second.sensorPath == path;
+ return findSensor.second.sensorPath == path;
});
}
#endif
@@ -394,8 +394,8 @@
return ipmiDecoratorPaths;
}
- ipmiDecoratorPaths =
- std::unordered_set<std::string>(paths.begin(), paths.end());
+ ipmiDecoratorPaths = std::unordered_set<std::string>(paths.begin(),
+ paths.end());
return ipmiDecoratorPaths;
}
diff --git a/dbus-sdr/sensorcommands.cpp b/dbus-sdr/sensorcommands.cpp
index ca6040f..16860dc 100644
--- a/dbus-sdr/sensorcommands.cpp
+++ b/dbus-sdr/sensorcommands.cpp
@@ -21,25 +21,26 @@
#include "dbus-sdr/storagecommands.hpp"
#include "entity_map_json.hpp"
-#include <algorithm>
-#include <array>
#include <boost/algorithm/string.hpp>
#include <boost/container/flat_map.hpp>
+#include <ipmid/api.hpp>
+#include <ipmid/types.hpp>
+#include <ipmid/utils.hpp>
+#include <phosphor-logging/log.hpp>
+#include <sdbusplus/bus.hpp>
+#include <user_channel/channel_layer.hpp>
+
+#include <algorithm>
+#include <array>
#include <chrono>
#include <cmath>
#include <cstring>
#include <iostream>
-#include <ipmid/api.hpp>
-#include <ipmid/types.hpp>
-#include <ipmid/utils.hpp>
#include <map>
#include <memory>
#include <optional>
-#include <phosphor-logging/log.hpp>
-#include <sdbusplus/bus.hpp>
#include <stdexcept>
#include <string>
-#include <user_channel/channel_layer.hpp>
#include <utility>
#include <variant>
@@ -131,11 +132,11 @@
"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(
@@ -143,11 +144,11 @@
"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();
});
// this keeps track of deassertions for sensor event status command. A
@@ -161,43 +162,41 @@
"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 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 ptr = std::get_if<bool>(&(findAssert->second));
- if (ptr == nullptr)
- {
- phosphor::logging::log<phosphor::logging::level::ERR>(
- "thresholdChanged: Assert non bool");
- return;
- }
- if (*ptr)
+ phosphor::logging::log<phosphor::logging::level::ERR>(
+ "thresholdChanged: Assert non bool");
+ return;
+ }
+ if (*ptr)
+ {
+ phosphor::logging::log<phosphor::logging::level::INFO>(
+ "thresholdChanged: Assert",
+ phosphor::logging::entry("SENSOR=%s", m.get_path()));
+ thresholdDeassertMap[m.get_path()][findAssert->first] = *ptr;
+ }
+ else
+ {
+ auto& value = thresholdDeassertMap[m.get_path()][findAssert->first];
+ if (value)
{
phosphor::logging::log<phosphor::logging::level::INFO>(
- "thresholdChanged: Assert",
+ "thresholdChanged: deassert",
phosphor::logging::entry("SENSOR=%s", m.get_path()));
- thresholdDeassertMap[m.get_path()][findAssert->first] = *ptr;
- }
- else
- {
- auto& value =
- thresholdDeassertMap[m.get_path()][findAssert->first];
- if (value)
- {
- phosphor::logging::log<phosphor::logging::level::INFO>(
- "thresholdChanged: deassert",
- phosphor::logging::entry("SENSOR=%s", m.get_path()));
- value = *ptr;
- }
+ value = *ptr;
}
}
+ }
});
namespace sensor
@@ -257,7 +256,6 @@
}
if (warning != sensorMap.end())
{
-
auto lower = warning->second.find("WarningLow");
auto upper = warning->second.find("WarningHigh");
if (lower != warning->second.end())
@@ -586,7 +584,6 @@
if (static_cast<ipmi::EChannelMediumType>(chInfo.mediumType) ==
ipmi::EChannelMediumType::systemInterface)
{
-
p.unpack(sysgeneratorID, evmRev, sensorType, sensorNum, eventType,
eventData1, eventData2, eventData3);
// Refer to IPMI Spec Table 32: SEL Event Records
@@ -597,7 +594,6 @@
}
else
{
-
p.unpack(evmRev, sensorType, sensorNum, eventType, eventData1,
eventData2, eventData3);
// Refer to IPMI Spec Table 32: SEL Event Records
@@ -635,8 +631,8 @@
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);
@@ -664,8 +660,8 @@
return ipmi::responseResponseError();
}
- auto value =
- sensor::calculateValue(reading, sensorMap, sensorObject->second);
+ auto value = sensor::calculateValue(reading, sensorMap,
+ sensorObject->second);
if (!value)
{
return ipmi::responseResponseError();
@@ -717,8 +713,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();
@@ -841,8 +837,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 |=
@@ -1155,9 +1151,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(
@@ -1166,8 +1161,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(
@@ -1184,8 +1179,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(
@@ -1194,8 +1189,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(
@@ -1735,8 +1730,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;
@@ -1760,8 +1755,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);
@@ -2058,9 +2053,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)
{
phosphor::logging::log<phosphor::logging::level::ERR>(
@@ -2256,8 +2251,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))
{
@@ -2269,8 +2264,8 @@
{
if (numSensors <= maxIPMISensors)
{
- sdrCount =
- (numSensors - (2 * maxSensorsPerLUN)) & maxSensorsPerLUN;
+ sdrCount = (numSensors - (2 * maxSensorsPerLUN)) &
+ maxSensorsPerLUN;
}
else
{
@@ -2335,8 +2330,8 @@
return ipmi::response(ret);
}
- uint16_t recordCount =
- getNumberOfSensors() + fruCount + ipmi::storage::type12Count;
+ uint16_t recordCount = getNumberOfSensors() + fruCount +
+ ipmi::storage::type12Count;
uint8_t operationSupport = static_cast<uint8_t>(
SdrRepositoryInfoOps::overflow); // write not supported
@@ -2454,8 +2449,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 (sdrLength < (offset + bytesToRead))
{
bytesToRead = sdrLength - offset;
diff --git a/dbus-sdr/sensorutils.cpp b/dbus-sdr/sensorutils.cpp
index d31dbed..e76a5f1 100644
--- a/dbus-sdr/sensorutils.cpp
+++ b/dbus-sdr/sensorutils.cpp
@@ -312,8 +312,8 @@
int8_t bExp = 0;
bool bSigned = false;
- bool result =
- getSensorAttributes(max, min, mValue, rExp, bValue, bExp, bSigned);
+ bool result = getSensorAttributes(max, min, mValue, rExp, bValue, bExp,
+ bSigned);
if (!result)
{
throw std::runtime_error("Illegal sensor attributes");
diff --git a/dbus-sdr/storagecommands.cpp b/dbus-sdr/storagecommands.cpp
index b50db1a..f123e99 100644
--- a/dbus-sdr/storagecommands.cpp
+++ b/dbus-sdr/storagecommands.cpp
@@ -22,16 +22,17 @@
#include <boost/algorithm/string.hpp>
#include <boost/container/flat_map.hpp>
#include <boost/process.hpp>
-#include <filesystem>
-#include <fstream>
-#include <functional>
-#include <iostream>
#include <ipmid/api.hpp>
#include <ipmid/message.hpp>
#include <ipmid/types.hpp>
#include <phosphor-logging/log.hpp>
#include <sdbusplus/message/types.hpp>
#include <sdbusplus/timer.hpp>
+
+#include <filesystem>
+#include <fstream>
+#include <functional>
+#include <iostream>
#include <stdexcept>
#include <string_view>
@@ -171,7 +172,6 @@
void recalculateHashes()
{
-
deviceHashes.clear();
// hash the object paths to create unique device id's. increment on
// collision
@@ -324,53 +324,51 @@
"type='signal',arg0path='/xyz/openbmc_project/"
"FruDevice/',member='InterfacesAdded'",
[](sdbusplus::message_t& message) {
- sdbusplus::message::object_path path;
- ObjectType object;
- try
- {
- message.read(path, object);
- }
- catch (const sdbusplus::exception_t&)
- {
- return;
- }
- auto findType = object.find(
- "xyz.openbmc_project.FruDevice");
- if (findType == object.end())
- {
- return;
- }
- writeFruIfRunning();
- frus[path] = object;
- recalculateHashes();
- lastDevId = 0xFF;
- });
+ sdbusplus::message::object_path path;
+ ObjectType object;
+ try
+ {
+ message.read(path, object);
+ }
+ catch (const sdbusplus::exception_t&)
+ {
+ return;
+ }
+ auto findType = object.find("xyz.openbmc_project.FruDevice");
+ if (findType == object.end())
+ {
+ return;
+ }
+ writeFruIfRunning();
+ frus[path] = object;
+ recalculateHashes();
+ lastDevId = 0xFF;
+ });
fruMatches.emplace_back(*bus,
"type='signal',arg0path='/xyz/openbmc_project/"
"FruDevice/',member='InterfacesRemoved'",
[](sdbusplus::message_t& message) {
- sdbusplus::message::object_path path;
- std::set<std::string> interfaces;
- try
- {
- message.read(path, interfaces);
- }
- catch (const sdbusplus::exception_t&)
- {
- return;
- }
- auto findType = interfaces.find(
- "xyz.openbmc_project.FruDevice");
- if (findType == interfaces.end())
- {
- return;
- }
- writeFruIfRunning();
- frus.erase(path);
- recalculateHashes();
- lastDevId = 0xFF;
- });
+ sdbusplus::message::object_path path;
+ std::set<std::string> interfaces;
+ try
+ {
+ message.read(path, interfaces);
+ }
+ catch (const sdbusplus::exception_t&)
+ {
+ return;
+ }
+ auto findType = interfaces.find("xyz.openbmc_project.FruDevice");
+ if (findType == interfaces.end())
+ {
+ return;
+ }
+ writeFruIfRunning();
+ frus.erase(path);
+ recalculateHashes();
+ lastDevId = 0xFF;
+ });
// call once to populate
boost::asio::spawn(*getIoContext(), [](boost::asio::yield_context yield) {
@@ -583,34 +581,31 @@
uint8_t& address = device->second.second;
boost::container::flat_map<std::string, Value>* fruData = nullptr;
- auto fru =
- std::find_if(frus.begin(), frus.end(),
- [bus, address, &fruData](ManagedEntry& entry) {
- auto findFruDevice =
- entry.second.find("xyz.openbmc_project.FruDevice");
- if (findFruDevice == entry.second.end())
- {
- return false;
- }
- fruData = &(findFruDevice->second);
- auto findBus = findFruDevice->second.find("BUS");
- auto findAddress =
- findFruDevice->second.find("ADDRESS");
- if (findBus == findFruDevice->second.end() ||
- findAddress == findFruDevice->second.end())
- {
- return false;
- }
- if (std::get<uint32_t>(findBus->second) != bus)
- {
- return false;
- }
- if (std::get<uint32_t>(findAddress->second) != address)
- {
- return false;
- }
- return true;
- });
+ auto fru = std::find_if(frus.begin(), frus.end(),
+ [bus, address, &fruData](ManagedEntry& entry) {
+ auto findFruDevice = entry.second.find("xyz.openbmc_project.FruDevice");
+ if (findFruDevice == entry.second.end())
+ {
+ return false;
+ }
+ fruData = &(findFruDevice->second);
+ auto findBus = findFruDevice->second.find("BUS");
+ auto findAddress = findFruDevice->second.find("ADDRESS");
+ if (findBus == findFruDevice->second.end() ||
+ findAddress == findFruDevice->second.end())
+ {
+ return false;
+ }
+ if (std::get<uint32_t>(findBus->second) != bus)
+ {
+ return false;
+ }
+ if (std::get<uint32_t>(findAddress->second) != address)
+ {
+ return false;
+ }
+ return true;
+ });
if (fru == frus.end())
{
return IPMI_CC_RESPONSE_ERROR;
@@ -638,48 +633,48 @@
return ipmi::ccResponseError;
}
- auto entity = std::find_if(
- entities.begin(), entities.end(),
- [bus, address, &entityData, &name](ManagedEntry& entry) {
- auto findFruDevice = entry.second.find(
- "xyz.openbmc_project.Inventory.Decorator.I2CDevice");
- if (findFruDevice == entry.second.end())
- {
- return false;
- }
+ auto entity =
+ std::find_if(entities.begin(), entities.end(),
+ [bus, address, &entityData, &name](ManagedEntry& entry) {
+ auto findFruDevice = entry.second.find(
+ "xyz.openbmc_project.Inventory.Decorator.I2CDevice");
+ if (findFruDevice == entry.second.end())
+ {
+ return false;
+ }
- // Integer fields added via Entity-Manager json are uint64_ts by
- // default.
- auto findBus = findFruDevice->second.find("Bus");
- auto findAddress = findFruDevice->second.find("Address");
+ // Integer fields added via Entity-Manager json are uint64_ts by
+ // default.
+ auto findBus = findFruDevice->second.find("Bus");
+ auto findAddress = findFruDevice->second.find("Address");
- if (findBus == findFruDevice->second.end() ||
- findAddress == findFruDevice->second.end())
- {
- return false;
- }
- if ((std::get<uint64_t>(findBus->second) != bus) ||
- (std::get<uint64_t>(findAddress->second) != address))
- {
- return false;
- }
+ if (findBus == findFruDevice->second.end() ||
+ findAddress == findFruDevice->second.end())
+ {
+ return false;
+ }
+ if ((std::get<uint64_t>(findBus->second) != bus) ||
+ (std::get<uint64_t>(findAddress->second) != address))
+ {
+ return false;
+ }
- auto fruName = findFruDevice->second.find("Name");
- if (fruName != findFruDevice->second.end())
- {
- name = std::get<std::string>(fruName->second);
- }
+ auto fruName = findFruDevice->second.find("Name");
+ if (fruName != findFruDevice->second.end())
+ {
+ name = std::get<std::string>(fruName->second);
+ }
- // At this point we found the device entry and should return
- // true.
- auto findIpmiDevice = entry.second.find(
- "xyz.openbmc_project.Inventory.Decorator.Ipmi");
- if (findIpmiDevice != entry.second.end())
- {
- entityData = &(findIpmiDevice->second);
- }
+ // At this point we found the device entry and should return
+ // true.
+ auto findIpmiDevice =
+ entry.second.find("xyz.openbmc_project.Inventory.Decorator.Ipmi");
+ if (findIpmiDevice != entry.second.end())
+ {
+ entityData = &(findIpmiDevice->second);
+ }
- return true;
+ return true;
});
if (entity == entities.end())
@@ -907,9 +902,9 @@
using oemEventType =
std::array<uint8_t, dynamic_sensors::ipmi::sel::oemEventSize>; // Event Data
-ipmi::RspType<uint16_t, // Next Record ID
- uint16_t, // Record ID
- uint8_t, // Record Type
+ipmi::RspType<uint16_t, // Next Record ID
+ uint16_t, // Record ID
+ uint8_t, // Record Type
std::variant<systemEventType, oemTsEventType,
oemEventType>> // Record Content
ipmiStorageGetSELEntry(uint16_t reservationID, uint16_t targetID,