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: Id49ad73c860533f4658c909e86d6dc8e1423efb4
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
diff --git a/.clang-format b/.clang-format
index d43e884..28e3328 100644
--- a/.clang-format
+++ b/.clang-format
@@ -87,7 +87,7 @@
IndentWrappedFunctionNames: true
InsertNewlineAtEOF: true
KeepEmptyLinesAtTheStartOfBlocks: false
-LambdaBodyIndentation: OuterScope
+LambdaBodyIndentation: Signature
LineEnding: LF
MacroBlockBegin: ''
MacroBlockEnd: ''
@@ -98,13 +98,14 @@
ObjCSpaceBeforeProtocolList: true
PackConstructorInitializers: BinPack
PenaltyBreakAssignment: 25
-PenaltyBreakBeforeFirstCallParameter: 19
+PenaltyBreakBeforeFirstCallParameter: 50
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
+PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
-PenaltyIndentedWhitespace: 0
+PenaltyIndentedWhitespace: 1
PointerAlignment: Left
QualifierAlignment: Left
ReferenceAlignment: Left
diff --git a/src/devices.hpp b/src/devices.hpp
index 23c4df7..28028bb 100644
--- a/src/devices.hpp
+++ b/src/devices.hpp
@@ -55,9 +55,8 @@
{
ExportTemplate(const char* params, const char* bus, const char* constructor,
const char* destructor, createsHWMon hasHWMonDir) :
- parameters(params),
- busPath(bus), add(constructor), remove(destructor),
- hasHWMonDir(hasHWMonDir){};
+ parameters(params), busPath(bus), add(constructor), remove(destructor),
+ hasHWMonDir(hasHWMonDir) {};
const char* parameters;
const char* busPath;
const char* add;
diff --git a/src/entity_manager.cpp b/src/entity_manager.cpp
index 0b519e0..fb72d83 100644
--- a/src/entity_manager.cpp
+++ b/src/entity_manager.cpp
@@ -202,20 +202,20 @@
jsonPointerString{std::string(jsonPointerString)}](
const std::vector<PropertyType>& newVal,
std::vector<PropertyType>& val) {
- val = newVal;
- if (!setJsonFromPointer(jsonPointerString, val,
- systemConfiguration))
- {
- std::cerr << "error setting json field\n";
- return -1;
- }
- if (!writeJsonFiles(systemConfiguration))
- {
- std::cerr << "error setting json file\n";
- return -1;
- }
- return 1;
- });
+ val = newVal;
+ if (!setJsonFromPointer(jsonPointerString, val,
+ systemConfiguration))
+ {
+ std::cerr << "error setting json field\n";
+ return -1;
+ }
+ if (!writeJsonFiles(systemConfiguration))
+ {
+ std::cerr << "error setting json file\n";
+ return -1;
+ }
+ return 1;
+ });
}
}
@@ -236,19 +236,20 @@
[&systemConfiguration,
jsonPointerString{std::string(jsonPointerString)}](
const PropertyType& newVal, PropertyType& val) {
- val = newVal;
- if (!setJsonFromPointer(jsonPointerString, val, systemConfiguration))
- {
- std::cerr << "error setting json field\n";
- return -1;
- }
- if (!writeJsonFiles(systemConfiguration))
- {
- std::cerr << "error setting json file\n";
- return -1;
- }
- return 1;
- });
+ val = newVal;
+ if (!setJsonFromPointer(jsonPointerString, val,
+ systemConfiguration))
+ {
+ std::cerr << "error setting json field\n";
+ return -1;
+ }
+ if (!writeJsonFiles(systemConfiguration))
+ {
+ std::cerr << "error setting json file\n";
+ return -1;
+ }
+ return 1;
+ });
}
void createDeleteObjectMethod(
@@ -258,32 +259,32 @@
nlohmann::json& systemConfiguration)
{
std::weak_ptr<sdbusplus::asio::dbus_interface> interface = iface;
- iface->register_method("Delete",
- [&objServer, &systemConfiguration, interface,
- jsonPointerPath{std::string(jsonPointerPath)}]() {
- std::shared_ptr<sdbusplus::asio::dbus_interface> dbusInterface =
- interface.lock();
- if (!dbusInterface)
- {
- // this technically can't happen as the pointer is pointing to
- // us
- throw DBusInternalError();
- }
- nlohmann::json::json_pointer ptr(jsonPointerPath);
- systemConfiguration[ptr] = nullptr;
+ iface->register_method(
+ "Delete", [&objServer, &systemConfiguration, interface,
+ jsonPointerPath{std::string(jsonPointerPath)}]() {
+ std::shared_ptr<sdbusplus::asio::dbus_interface> dbusInterface =
+ interface.lock();
+ if (!dbusInterface)
+ {
+ // this technically can't happen as the pointer is pointing to
+ // us
+ throw DBusInternalError();
+ }
+ nlohmann::json::json_pointer ptr(jsonPointerPath);
+ systemConfiguration[ptr] = nullptr;
- // todo(james): dig through sdbusplus to find out why we can't
- // delete it in a method call
- boost::asio::post(io, [&objServer, dbusInterface]() mutable {
- objServer.remove_interface(dbusInterface);
+ // todo(james): dig through sdbusplus to find out why we can't
+ // delete it in a method call
+ boost::asio::post(io, [&objServer, dbusInterface]() mutable {
+ objServer.remove_interface(dbusInterface);
+ });
+
+ if (!writeJsonFiles(systemConfiguration))
+ {
+ std::cerr << "error setting json file\n";
+ throw DBusInternalError();
+ }
});
-
- if (!writeJsonFiles(systemConfiguration))
- {
- std::cerr << "error setting json file\n";
- throw DBusInternalError();
- }
- });
}
// adds simple json types to interface's properties
@@ -451,11 +452,10 @@
: sdbusplus::asio::PropertyPermission::readOnly;
}
-void createAddObjectMethod(const std::string& jsonPointerPath,
- const std::string& path,
- nlohmann::json& systemConfiguration,
- sdbusplus::asio::object_server& objServer,
- const std::string& board)
+void createAddObjectMethod(
+ const std::string& jsonPointerPath, const std::string& path,
+ nlohmann::json& systemConfiguration,
+ sdbusplus::asio::object_server& objServer, const std::string& board)
{
std::shared_ptr<sdbusplus::asio::dbus_interface> iface = createInterface(
objServer, path, "xyz.openbmc_project.AddObject", board);
@@ -466,116 +466,116 @@
jsonPointerPath{std::string(jsonPointerPath)}, path{std::string(path)},
board](const boost::container::flat_map<std::string, JsonVariantType>&
data) {
- nlohmann::json::json_pointer ptr(jsonPointerPath);
- nlohmann::json& base = systemConfiguration[ptr];
- auto findExposes = base.find("Exposes");
+ nlohmann::json::json_pointer ptr(jsonPointerPath);
+ nlohmann::json& base = systemConfiguration[ptr];
+ auto findExposes = base.find("Exposes");
- if (findExposes == base.end())
- {
- throw std::invalid_argument("Entity must have children.");
- }
-
- // this will throw invalid-argument to sdbusplus if invalid json
- nlohmann::json newData{};
- for (const auto& item : data)
- {
- nlohmann::json& newJson = newData[item.first];
- std::visit(
- [&newJson](auto&& val) {
- newJson = std::forward<decltype(val)>(val);
- },
- item.second);
- }
-
- auto findName = newData.find("Name");
- auto findType = newData.find("Type");
- if (findName == newData.end() || findType == newData.end())
- {
- throw std::invalid_argument("AddObject missing Name or Type");
- }
- const std::string* type = findType->get_ptr<const std::string*>();
- const std::string* name = findName->get_ptr<const std::string*>();
- if (type == nullptr || name == nullptr)
- {
- throw std::invalid_argument("Type and Name must be a string.");
- }
-
- bool foundNull = false;
- size_t lastIndex = 0;
- // we add in the "exposes"
- for (const auto& expose : *findExposes)
- {
- if (expose.is_null())
+ if (findExposes == base.end())
{
- foundNull = true;
- continue;
+ throw std::invalid_argument("Entity must have children.");
}
- if (expose["Name"] == *name && expose["Type"] == *type)
+ // this will throw invalid-argument to sdbusplus if invalid json
+ nlohmann::json newData{};
+ for (const auto& item : data)
+ {
+ nlohmann::json& newJson = newData[item.first];
+ std::visit(
+ [&newJson](auto&& val) {
+ newJson = std::forward<decltype(val)>(val);
+ },
+ item.second);
+ }
+
+ auto findName = newData.find("Name");
+ auto findType = newData.find("Type");
+ if (findName == newData.end() || findType == newData.end())
+ {
+ throw std::invalid_argument("AddObject missing Name or Type");
+ }
+ const std::string* type = findType->get_ptr<const std::string*>();
+ const std::string* name = findName->get_ptr<const std::string*>();
+ if (type == nullptr || name == nullptr)
+ {
+ throw std::invalid_argument("Type and Name must be a string.");
+ }
+
+ bool foundNull = false;
+ size_t lastIndex = 0;
+ // we add in the "exposes"
+ for (const auto& expose : *findExposes)
+ {
+ if (expose.is_null())
+ {
+ foundNull = true;
+ continue;
+ }
+
+ if (expose["Name"] == *name && expose["Type"] == *type)
+ {
+ throw std::invalid_argument(
+ "Field already in JSON, not adding");
+ }
+
+ if (foundNull)
+ {
+ continue;
+ }
+
+ lastIndex++;
+ }
+
+ std::ifstream schemaFile(std::string(schemaDirectory) + "/" +
+ boost::to_lower_copy(*type) + ".json");
+ // todo(james) we might want to also make a list of 'can add'
+ // interfaces but for now I think the assumption if there is a
+ // schema avaliable that it is allowed to update is fine
+ if (!schemaFile.good())
{
throw std::invalid_argument(
- "Field already in JSON, not adding");
+ "No schema avaliable, cannot validate.");
}
-
+ nlohmann::json schema =
+ nlohmann::json::parse(schemaFile, nullptr, false, true);
+ if (schema.is_discarded())
+ {
+ std::cerr << "Schema not legal" << *type << ".json\n";
+ throw DBusInternalError();
+ }
+ if (!validateJson(schema, newData))
+ {
+ throw std::invalid_argument("Data does not match schema");
+ }
if (foundNull)
{
- continue;
+ findExposes->at(lastIndex) = newData;
}
+ else
+ {
+ findExposes->push_back(newData);
+ }
+ if (!writeJsonFiles(systemConfiguration))
+ {
+ std::cerr << "Error writing json files\n";
+ throw DBusInternalError();
+ }
+ std::string dbusName = *name;
- lastIndex++;
- }
+ std::regex_replace(dbusName.begin(), dbusName.begin(),
+ dbusName.end(), illegalDbusMemberRegex, "_");
- std::ifstream schemaFile(std::string(schemaDirectory) + "/" +
- boost::to_lower_copy(*type) + ".json");
- // todo(james) we might want to also make a list of 'can add'
- // interfaces but for now I think the assumption if there is a
- // schema avaliable that it is allowed to update is fine
- if (!schemaFile.good())
- {
- throw std::invalid_argument(
- "No schema avaliable, cannot validate.");
- }
- nlohmann::json schema = nlohmann::json::parse(schemaFile, nullptr,
- false, true);
- if (schema.is_discarded())
- {
- std::cerr << "Schema not legal" << *type << ".json\n";
- throw DBusInternalError();
- }
- if (!validateJson(schema, newData))
- {
- throw std::invalid_argument("Data does not match schema");
- }
- if (foundNull)
- {
- findExposes->at(lastIndex) = newData;
- }
- else
- {
- findExposes->push_back(newData);
- }
- if (!writeJsonFiles(systemConfiguration))
- {
- std::cerr << "Error writing json files\n";
- throw DBusInternalError();
- }
- std::string dbusName = *name;
-
- std::regex_replace(dbusName.begin(), dbusName.begin(), dbusName.end(),
- illegalDbusMemberRegex, "_");
-
- std::shared_ptr<sdbusplus::asio::dbus_interface> interface =
- createInterface(objServer, path + "/" + dbusName,
- "xyz.openbmc_project.Configuration." + *type, board,
- true);
- // permission is read-write, as since we just created it, must be
- // runtime modifiable
- populateInterfaceFromJson(
- systemConfiguration,
- jsonPointerPath + "/Exposes/" + std::to_string(lastIndex),
- interface, newData, objServer,
- sdbusplus::asio::PropertyPermission::readWrite);
- });
+ std::shared_ptr<sdbusplus::asio::dbus_interface> interface =
+ createInterface(objServer, path + "/" + dbusName,
+ "xyz.openbmc_project.Configuration." + *type,
+ board, true);
+ // permission is read-write, as since we just created it, must be
+ // runtime modifiable
+ populateInterfaceFromJson(
+ systemConfiguration,
+ jsonPointerPath + "/Exposes/" + std::to_string(lastIndex),
+ interface, newData, objServer,
+ sdbusplus::asio::PropertyPermission::readWrite);
+ });
tryIfaceInitialize(iface);
}
@@ -839,8 +839,8 @@
return false;
}
- std::ifstream schemaStream(std::string(schemaDirectory) + "/" +
- globalSchema);
+ std::ifstream schemaStream(
+ std::string(schemaDirectory) + "/" + globalSchema);
if (!schemaStream.good())
{
std::cerr
@@ -848,8 +848,8 @@
std::exit(EXIT_FAILURE);
return false;
}
- nlohmann::json schema = nlohmann::json::parse(schemaStream, nullptr, false,
- true);
+ nlohmann::json schema =
+ nlohmann::json::parse(schemaStream, nullptr, false, true);
if (schema.is_discarded())
{
std::cerr
@@ -954,24 +954,24 @@
timer.expires_after(std::chrono::seconds(10));
timer.async_wait(
[&systemConfiguration](const boost::system::error_code& ec) {
- if (ec == boost::asio::error::operation_aborted)
- {
- return;
- }
+ if (ec == boost::asio::error::operation_aborted)
+ {
+ return;
+ }
- bool powerOff = !isPowerOn();
- for (const auto& [name, device] : lastJson.items())
- {
- pruneDevice(systemConfiguration, powerOff, scannedPowerOff, name,
- device);
- }
+ bool powerOff = !isPowerOn();
+ for (const auto& [name, device] : lastJson.items())
+ {
+ pruneDevice(systemConfiguration, powerOff, scannedPowerOff,
+ name, device);
+ }
- scannedPowerOff = true;
- if (!powerOff)
- {
- scannedPowerOn = true;
- }
- });
+ scannedPowerOff = true;
+ if (!powerOff)
+ {
+ scannedPowerOn = true;
+ }
+ });
}
static std::vector<std::weak_ptr<sdbusplus::asio::dbus_interface>>&
@@ -1106,32 +1106,33 @@
objServer,
[&systemConfiguration, &objServer, count, oldConfiguration,
missingConfigurations]() {
- // this is something that since ac has been applied to the bmc
- // we saw, and we no longer see it
- bool powerOff = !isPowerOn();
- for (const auto& [name, device] : missingConfigurations->items())
- {
- pruneConfiguration(systemConfiguration, objServer, powerOff,
- name, device);
- }
+ // this is something that since ac has been applied to the bmc
+ // we saw, and we no longer see it
+ bool powerOff = !isPowerOn();
+ for (const auto& [name, device] :
+ missingConfigurations->items())
+ {
+ pruneConfiguration(systemConfiguration, objServer, powerOff,
+ name, device);
+ }
- nlohmann::json newConfiguration = systemConfiguration;
+ nlohmann::json newConfiguration = systemConfiguration;
- deriveNewConfiguration(oldConfiguration, newConfiguration);
+ deriveNewConfiguration(oldConfiguration, newConfiguration);
- for (const auto& [_, device] : newConfiguration.items())
- {
- logDeviceAdded(device);
- }
+ for (const auto& [_, device] : newConfiguration.items())
+ {
+ logDeviceAdded(device);
+ }
- inProgress = false;
+ inProgress = false;
- boost::asio::post(
- io, std::bind_front(publishNewConfiguration, std::ref(instance),
- count, std::ref(timer),
- std::ref(systemConfiguration),
- newConfiguration, std::ref(objServer)));
- });
+ boost::asio::post(
+ io, std::bind_front(
+ publishNewConfiguration, std::ref(instance), count,
+ std::ref(timer), std::ref(systemConfiguration),
+ newConfiguration, std::ref(objServer)));
+ });
perfScan->run();
});
}
@@ -1196,9 +1197,8 @@
}
// Check if InterfacesAdded payload contains an iface that needs probing.
-static bool
- iaContainsProbeInterface(sdbusplus::message_t& msg,
- const std::set<std::string>& probeInterfaces)
+static bool iaContainsProbeInterface(
+ sdbusplus::message_t& msg, const std::set<std::string>& probeInterfaces)
{
sdbusplus::message::object_path path;
DBusObject interfaces;
@@ -1209,8 +1209,8 @@
std::for_each(interfaces.begin(), interfaces.end(),
[&interfaceSet](const auto& iface) {
- interfaceSet.insert(iface.first);
- });
+ interfaceSet.insert(iface.first);
+ });
std::set_intersection(interfaceSet.begin(), interfaceSet.end(),
probeInterfaces.begin(), probeInterfaces.end(),
@@ -1219,9 +1219,8 @@
}
// Check if InterfacesRemoved payload contains an iface that needs probing.
-static bool
- irContainsProbeInterface(sdbusplus::message_t& msg,
- const std::set<std::string>& probeInterfaces)
+static bool irContainsProbeInterface(
+ sdbusplus::message_t& msg, const std::set<std::string>& probeInterfaces)
{
sdbusplus::message::object_path path;
std::set<std::string> interfaces;
@@ -1271,37 +1270,37 @@
static_cast<sdbusplus::bus_t&>(*systemBus),
sdbusplus::bus::match::rules::nameOwnerChanged(),
[&](sdbusplus::message_t& m) {
- auto [name, oldOwner,
- newOwner] = m.unpack<std::string, std::string, std::string>();
+ auto [name, oldOwner,
+ newOwner] = m.unpack<std::string, std::string, std::string>();
- if (name.starts_with(':'))
- {
- // We should do nothing with unique-name connections.
- return;
- }
+ if (name.starts_with(':'))
+ {
+ // We should do nothing with unique-name connections.
+ return;
+ }
- propertiesChangedCallback(systemConfiguration, objServer);
- });
+ propertiesChangedCallback(systemConfiguration, objServer);
+ });
// We also need a poke from DBus when new interfaces are created or
// destroyed.
sdbusplus::bus::match_t interfacesAddedMatch(
static_cast<sdbusplus::bus_t&>(*systemBus),
sdbusplus::bus::match::rules::interfacesAdded(),
[&](sdbusplus::message_t& msg) {
- if (iaContainsProbeInterface(msg, probeInterfaces))
- {
- propertiesChangedCallback(systemConfiguration, objServer);
- }
- });
+ if (iaContainsProbeInterface(msg, probeInterfaces))
+ {
+ propertiesChangedCallback(systemConfiguration, objServer);
+ }
+ });
sdbusplus::bus::match_t interfacesRemovedMatch(
static_cast<sdbusplus::bus_t&>(*systemBus),
sdbusplus::bus::match::rules::interfacesRemoved(),
[&](sdbusplus::message_t& msg) {
- if (irContainsProbeInterface(msg, probeInterfaces))
- {
- propertiesChangedCallback(systemConfiguration, objServer);
- }
- });
+ if (irContainsProbeInterface(msg, probeInterfaces))
+ {
+ propertiesChangedCallback(systemConfiguration, objServer);
+ }
+ });
boost::asio::post(io, [&]() {
propertiesChangedCallback(systemConfiguration, objServer);
@@ -1328,8 +1327,8 @@
auto data = nlohmann::json::parse(jsonStream, nullptr, false);
if (data.is_discarded())
{
- std::cerr << "syntax error in " << lastConfiguration
- << "\n";
+ std::cerr
+ << "syntax error in " << lastConfiguration << "\n";
}
else
{
diff --git a/src/entity_manager.hpp b/src/entity_manager.hpp
index 0fbef79..db7804e 100644
--- a/src/entity_manager.hpp
+++ b/src/entity_manager.hpp
@@ -57,9 +57,8 @@
MATCH_ONE
};
-using FoundProbeTypeT =
- std::optional<boost::container::flat_map<const char*, probe_type_codes,
- CmpStr>::const_iterator>;
+using FoundProbeTypeT = std::optional<boost::container::flat_map<
+ const char*, probe_type_codes, CmpStr>::const_iterator>;
FoundProbeTypeT findProbeType(const std::string& probe);
struct PerformScan : std::enable_shared_from_this<PerformScan>
diff --git a/src/fru_device.cpp b/src/fru_device.cpp
index 05f12bf..b265bf6 100644
--- a/src/fru_device.cpp
+++ b/src/fru_device.cpp
@@ -150,8 +150,8 @@
{
auto ec = std::error_code();
auto path = std::filesystem::read_symlink(
- std::filesystem::path("/sys/bus/i2c/devices/i2c-" +
- std::to_string(bus) + "/mux_device"),
+ std::filesystem::path(
+ "/sys/bus/i2c/devices/i2c-" + std::to_string(bus) + "/mux_device"),
ec);
if (ec)
{
@@ -235,10 +235,9 @@
// Issue an I2C transaction to first write to_target_buf_len bytes,then read
// from_target_buf_len bytes.
-static int i2cSmbusWriteThenRead(int file, uint16_t address,
- uint8_t* toTargetBuf, uint8_t toTargetBufLen,
- uint8_t* fromTargetBuf,
- uint8_t fromTargetBufLen)
+static int i2cSmbusWriteThenRead(
+ int file, uint16_t address, uint8_t* toTargetBuf, uint8_t toTargetBufLen,
+ uint8_t* fromTargetBuf, uint8_t fromTargetBufLen)
{
if (toTargetBuf == nullptr || toTargetBufLen == 0 ||
fromTargetBuf == nullptr || fromTargetBufLen == 0)
@@ -319,8 +318,8 @@
return readFromEeprom(file, offset, length, outbuf);
};
FRUReader reader(std::move(readFunc));
- std::pair<std::vector<uint8_t>, bool> pair = readFRUContents(reader,
- errorMessage);
+ std::pair<std::vector<uint8_t>, bool> pair =
+ readFRUContents(reader, errorMessage);
close(file);
return pair.first;
@@ -346,8 +345,8 @@
}
const std::string node = p.path().string();
std::smatch m;
- bool found = std::regex_match(node, m,
- std::regex(".+\\d+-([0-9abcdef]+$)"));
+ bool found =
+ std::regex_match(node, m, std::regex(".+\\d+-([0-9abcdef]+$)"));
if (!found)
{
@@ -514,14 +513,14 @@
}
bool is16BitBool{*is16Bit};
- auto readFunc = [is16BitBool, file, ii](off_t offset, size_t length,
- uint8_t* outbuf) {
+ auto readFunc = [is16BitBool, file,
+ ii](off_t offset, size_t length, uint8_t* outbuf) {
return readData(is16BitBool, false, file, ii, offset, length,
outbuf);
};
FRUReader reader(std::move(readFunc));
- std::string errorMessage = "bus " + std::to_string(bus) +
- " address " + std::to_string(ii);
+ std::string errorMessage =
+ "bus " + std::to_string(bus) + " address " + std::to_string(ii);
std::pair<std::vector<uint8_t>, bool> pair =
readFRUContents(reader, errorMessage);
const bool foundHeader = pair.second;
@@ -531,12 +530,12 @@
// certain FRU eeproms require bytewise reading.
// otherwise garbage is read. e.g. SuperMicro PWS 920P-SQ
- auto readFunc = [is16BitBool, file, ii](off_t offset,
- size_t length,
- uint8_t* outbuf) {
- return readData(is16BitBool, true, file, ii, offset, length,
- outbuf);
- };
+ auto readFunc =
+ [is16BitBool, file,
+ ii](off_t offset, size_t length, uint8_t* outbuf) {
+ return readData(is16BitBool, true, file, ii, offset,
+ length, outbuf);
+ };
FRUReader readerBytewise(std::move(readFunc));
pair = readFRUContents(readerBytewise, errorMessage);
}
@@ -578,8 +577,8 @@
return;
}
- nlohmann::json data = nlohmann::json::parse(blocklistStream, nullptr,
- false);
+ nlohmann::json data =
+ nlohmann::json::parse(blocklistStream, nullptr, false);
if (data.is_discarded())
{
std::cerr << "Illegal blocklist file detected, cannot validate JSON, "
@@ -732,9 +731,8 @@
BusMap& busmap, const bool& powerIsOn,
sdbusplus::asio::object_server& objServer,
std::function<void()>&& callback) :
- _i2cBuses(i2cBuses),
- _busMap(busmap), _powerIsOn(powerIsOn), _objServer(objServer),
- _callback(std::move(callback))
+ _i2cBuses(i2cBuses), _busMap(busmap), _powerIsOn(powerIsOn),
+ _objServer(objServer), _callback(std::move(callback))
{}
~FindDevicesWithCallback()
{
@@ -771,8 +769,8 @@
return;
}
- std::string productName = "/xyz/openbmc_project/FruDevice/" +
- optionalProductName.value();
+ std::string productName =
+ "/xyz/openbmc_project/FruDevice/" + optionalProductName.value();
std::optional<int> index = findIndexForFRU(dbusInterfaceMap, productName);
if (index.has_value())
@@ -793,8 +791,8 @@
{
continue;
}
- std::string key = std::regex_replace(property.first, nonAsciiRegex,
- "_");
+ std::string key =
+ std::regex_replace(property.first, nonAsciiRegex, "_");
if (property.first == "PRODUCT_ASSET_TAG")
{
@@ -804,24 +802,24 @@
[bus, address, propertyName, &dbusInterfaceMap,
&unknownBusObjectCount, &powerIsOn, &objServer,
&systemBus](const std::string& req, std::string& resp) {
- if (strcmp(req.c_str(), resp.c_str()) != 0)
- {
- // call the method which will update
- if (updateFRUProperty(req, bus, address, propertyName,
- dbusInterfaceMap,
- unknownBusObjectCount, powerIsOn,
- objServer, systemBus))
+ if (strcmp(req.c_str(), resp.c_str()) != 0)
{
- resp = req;
+ // call the method which will update
+ if (updateFRUProperty(req, bus, address, propertyName,
+ dbusInterfaceMap,
+ unknownBusObjectCount, powerIsOn,
+ objServer, systemBus))
+ {
+ resp = req;
+ }
+ else
+ {
+ throw std::invalid_argument(
+ "FRU property update failed.");
+ }
}
- else
- {
- throw std::invalid_argument(
- "FRU property update failed.");
- }
- }
- return 1;
- });
+ return 1;
+ });
}
else if (!iface->register_property(key, property.second + '\0'))
{
@@ -1015,32 +1013,32 @@
i2cBuses, busmap, powerIsOn, objServer,
[busNum, &busmap, &dbusInterfaceMap, &unknownBusObjectCount, &powerIsOn,
&objServer, &systemBus]() {
- for (auto busIface = dbusInterfaceMap.begin();
- busIface != dbusInterfaceMap.end();)
- {
- if (busIface->first.first == static_cast<size_t>(busNum))
+ for (auto busIface = dbusInterfaceMap.begin();
+ busIface != dbusInterfaceMap.end();)
{
- objServer.remove_interface(busIface->second);
- busIface = dbusInterfaceMap.erase(busIface);
+ if (busIface->first.first == static_cast<size_t>(busNum))
+ {
+ objServer.remove_interface(busIface->second);
+ busIface = dbusInterfaceMap.erase(busIface);
+ }
+ else
+ {
+ busIface++;
+ }
}
- else
+ auto found = busmap.find(busNum);
+ if (found == busmap.end() || found->second == nullptr)
{
- busIface++;
+ return;
}
- }
- auto found = busmap.find(busNum);
- if (found == busmap.end() || found->second == nullptr)
- {
- return;
- }
- for (auto& device : *(found->second))
- {
- addFruObjectToDbus(device.second, dbusInterfaceMap,
- static_cast<uint32_t>(busNum), device.first,
- unknownBusObjectCount, powerIsOn, objServer,
- systemBus);
- }
- });
+ for (auto& device : *(found->second))
+ {
+ addFruObjectToDbus(device.second, dbusInterfaceMap,
+ static_cast<uint32_t>(busNum), device.first,
+ unknownBusObjectCount, powerIsOn, objServer,
+ systemBus);
+ }
+ });
scan->run();
}
@@ -1093,34 +1091,34 @@
auto scan = std::make_shared<FindDevicesWithCallback>(
i2cBuses, busmap, powerIsOn, objServer, [&]() {
- for (auto& busIface : dbusInterfaceMap)
- {
- objServer.remove_interface(busIface.second);
- }
-
- dbusInterfaceMap.clear();
- unknownBusObjectCount = 0;
-
- // todo, get this from a more sensable place
- std::vector<uint8_t> baseboardFRU;
- if (readBaseboardFRU(baseboardFRU))
- {
- // If no device on i2c bus 0, the insertion will happen.
- auto bus0 = busmap.try_emplace(0,
- std::make_shared<DeviceMap>());
- bus0.first->second->emplace(0, baseboardFRU);
- }
- for (auto& devicemap : busmap)
- {
- for (auto& device : *devicemap.second)
+ for (auto& busIface : dbusInterfaceMap)
{
- addFruObjectToDbus(device.second, dbusInterfaceMap,
- devicemap.first, device.first,
- unknownBusObjectCount, powerIsOn,
- objServer, systemBus);
+ objServer.remove_interface(busIface.second);
}
- }
- });
+
+ dbusInterfaceMap.clear();
+ unknownBusObjectCount = 0;
+
+ // todo, get this from a more sensable place
+ std::vector<uint8_t> baseboardFRU;
+ if (readBaseboardFRU(baseboardFRU))
+ {
+ // If no device on i2c bus 0, the insertion will happen.
+ auto bus0 =
+ busmap.try_emplace(0, std::make_shared<DeviceMap>());
+ bus0.first->second->emplace(0, baseboardFRU);
+ }
+ for (auto& devicemap : busmap)
+ {
+ for (auto& device : *devicemap.second)
+ {
+ addFruObjectToDbus(device.second, dbusInterfaceMap,
+ devicemap.first, device.first,
+ unknownBusObjectCount, powerIsOn,
+ objServer, systemBus);
+ }
+ }
+ });
scan->run();
});
}
@@ -1212,10 +1210,10 @@
#ifdef ENABLE_FRU_AREA_RESIZE
size_t newFRUAreaSize = fruAreaDataSize + updatePropertyReqLen + 1;
// round size to 8-byte blocks
- newFRUAreaSize = ((newFRUAreaSize - 1) / fruBlockSize + 1) *
- fruBlockSize;
- size_t newFRUDataSize = fruData.size() + newFRUAreaSize -
- fruAreaParams.size;
+ newFRUAreaSize =
+ ((newFRUAreaSize - 1) / fruBlockSize + 1) * fruBlockSize;
+ size_t newFRUDataSize =
+ fruData.size() + newFRUAreaSize - fruAreaParams.size;
fruData.resize(newFRUDataSize);
fruAreaParams.size = newFRUAreaSize;
fruAreaParams.end = fruAreaParams.start + fruAreaParams.size;
@@ -1236,10 +1234,10 @@
fruData.begin() + fruAreaParams.updateFieldLoc);
// Copy remaining data to main fru area - post updated fru field vector
- fruAreaParams.restFieldsLoc = fruAreaParams.updateFieldLoc +
- updatePropertyReqLen;
- size_t fruAreaDataEnd = fruAreaParams.restFieldsLoc +
- restFRUAreaFieldsData.size();
+ fruAreaParams.restFieldsLoc =
+ fruAreaParams.updateFieldLoc + updatePropertyReqLen;
+ size_t fruAreaDataEnd =
+ fruAreaParams.restFieldsLoc + restFRUAreaFieldsData.size();
std::copy(restFRUAreaFieldsData.begin(), restFRUAreaFieldsData.end(),
fruData.begin() + fruAreaParams.restFieldsLoc);
@@ -1250,8 +1248,8 @@
#ifdef ENABLE_FRU_AREA_RESIZE
++nextFRUAreaNewLoc;
- ssize_t nextFRUAreaOffsetDiff = (nextFRUAreaNewLoc - nextFRUAreaLoc) /
- fruBlockSize;
+ ssize_t nextFRUAreaOffsetDiff =
+ (nextFRUAreaNewLoc - nextFRUAreaLoc) / fruBlockSize;
// Append rest FRU Areas if size changed and there were other sections after
// updated one
if (nextFRUAreaOffsetDiff && nextFRUAreaLoc)
@@ -1349,44 +1347,44 @@
iface->register_method("GetRawFru", getFRUInfo);
- iface->register_method("WriteFru",
- [&](const uint16_t bus, const uint8_t address,
- const std::vector<uint8_t>& data) {
- if (!writeFRU(bus, address, data))
- {
- throw std::invalid_argument("Invalid Arguments.");
- return;
- }
- // schedule rescan on success
- rescanBusses(busMap, dbusInterfaceMap, unknownBusObjectCount, powerIsOn,
- objServer, systemBus);
- });
+ iface->register_method(
+ "WriteFru", [&](const uint16_t bus, const uint8_t address,
+ const std::vector<uint8_t>& data) {
+ if (!writeFRU(bus, address, data))
+ {
+ throw std::invalid_argument("Invalid Arguments.");
+ return;
+ }
+ // schedule rescan on success
+ rescanBusses(busMap, dbusInterfaceMap, unknownBusObjectCount,
+ powerIsOn, objServer, systemBus);
+ });
iface->initialize();
std::function<void(sdbusplus::message_t & message)> eventHandler =
[&](sdbusplus::message_t& message) {
- std::string objectName;
- boost::container::flat_map<
- std::string,
- std::variant<std::string, bool, int64_t, uint64_t, double>>
- values;
- message.read(objectName, values);
- auto findState = values.find("CurrentHostState");
- if (findState != values.end())
- {
- if (std::get<std::string>(findState->second) ==
- "xyz.openbmc_project.State.Host.HostState.Running")
+ std::string objectName;
+ boost::container::flat_map<
+ std::string,
+ std::variant<std::string, bool, int64_t, uint64_t, double>>
+ values;
+ message.read(objectName, values);
+ auto findState = values.find("CurrentHostState");
+ if (findState != values.end())
{
- powerIsOn = true;
+ if (std::get<std::string>(findState->second) ==
+ "xyz.openbmc_project.State.Host.HostState.Running")
+ {
+ powerIsOn = true;
+ }
}
- }
- if (powerIsOn)
- {
- rescanBusses(busMap, dbusInterfaceMap, unknownBusObjectCount,
- powerIsOn, objServer, systemBus);
- }
- };
+ if (powerIsOn)
+ {
+ rescanBusses(busMap, dbusInterfaceMap, unknownBusObjectCount,
+ powerIsOn, objServer, systemBus);
+ }
+ };
sdbusplus::bus::match_t powerMatch = sdbusplus::bus::match_t(
static_cast<sdbusplus::bus_t&>(*systemBus),
@@ -1403,56 +1401,58 @@
std::function<void(const boost::system::error_code, std::size_t)>
watchI2cBusses = [&](const boost::system::error_code& ec,
std::size_t bytesTransferred) {
- if (ec)
- {
- std::cout << "Callback Error " << ec << "\n";
- return;
- }
- size_t index = 0;
- while ((index + sizeof(inotify_event)) <= bytesTransferred)
- {
- const char* p = &readBuffer[index];
- // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
- const auto* iEvent = reinterpret_cast<const inotify_event*>(p);
- switch (iEvent->mask)
+ if (ec)
{
- case IN_CREATE:
- case IN_MOVED_TO:
- case IN_DELETE:
+ std::cout << "Callback Error " << ec << "\n";
+ return;
+ }
+ size_t index = 0;
+ while ((index + sizeof(inotify_event)) <= bytesTransferred)
+ {
+ const char* p = &readBuffer[index];
+ // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
+ const auto* iEvent = reinterpret_cast<const inotify_event*>(p);
+ switch (iEvent->mask)
{
- std::string_view name(&iEvent->name[0], iEvent->len);
- if (boost::starts_with(name, "i2c"))
+ case IN_CREATE:
+ case IN_MOVED_TO:
+ case IN_DELETE:
{
- int bus = busStrToInt(name);
- if (bus < 0)
+ std::string_view name(&iEvent->name[0], iEvent->len);
+ if (boost::starts_with(name, "i2c"))
{
- std::cerr << "Could not parse bus " << name << "\n";
- continue;
- }
- int rootBus = getRootBus(bus);
- if (rootBus >= 0)
- {
- rescanOneBus(busMap, static_cast<uint16_t>(rootBus),
+ int bus = busStrToInt(name);
+ if (bus < 0)
+ {
+ std::cerr
+ << "Could not parse bus " << name << "\n";
+ continue;
+ }
+ int rootBus = getRootBus(bus);
+ if (rootBus >= 0)
+ {
+ rescanOneBus(busMap,
+ static_cast<uint16_t>(rootBus),
+ dbusInterfaceMap, false,
+ unknownBusObjectCount, powerIsOn,
+ objServer, systemBus);
+ }
+ rescanOneBus(busMap, static_cast<uint16_t>(bus),
dbusInterfaceMap, false,
unknownBusObjectCount, powerIsOn,
objServer, systemBus);
}
- rescanOneBus(busMap, static_cast<uint16_t>(bus),
- dbusInterfaceMap, false,
- unknownBusObjectCount, powerIsOn,
- objServer, systemBus);
}
- }
- break;
- default:
break;
+ default:
+ break;
+ }
+ index += sizeof(inotify_event) + iEvent->len;
}
- index += sizeof(inotify_event) + iEvent->len;
- }
- dirWatch.async_read_some(boost::asio::buffer(readBuffer),
- watchI2cBusses);
- };
+ dirWatch.async_read_some(boost::asio::buffer(readBuffer),
+ watchI2cBusses);
+ };
dirWatch.async_read_some(boost::asio::buffer(readBuffer), watchI2cBusses);
// run the initial scan
diff --git a/src/fru_reader.cpp b/src/fru_reader.cpp
index 5acfa65..61d4020 100644
--- a/src/fru_reader.cpp
+++ b/src/fru_reader.cpp
@@ -39,8 +39,8 @@
{
// miss, populate cache
uint8_t* newData = cache[blk].data();
- int64_t ret = readFunc(blk * cacheBlockSize, cacheBlockSize,
- newData);
+ int64_t ret =
+ readFunc(blk * cacheBlockSize, cacheBlockSize, newData);
// if we've reached the end of the eeprom, record its size
if (ret >= 0 && static_cast<size_t>(ret) < cacheBlockSize)
diff --git a/src/fru_utils.cpp b/src/fru_utils.cpp
index 768a84d..15d4234 100644
--- a/src/fru_utils.cpp
+++ b/src/fru_utils.cpp
@@ -98,10 +98,9 @@
* On fruDataErr, we have lost synchronisation with the length bytes, so the
* iterator is no longer usable.
*/
-std::pair<DecodeState, std::string>
- decodeFRUData(std::vector<uint8_t>::const_iterator& iter,
- const std::vector<uint8_t>::const_iterator& end,
- bool isLangEng)
+std::pair<DecodeState, std::string> decodeFRUData(
+ std::vector<uint8_t>::const_iterator& iter,
+ const std::vector<uint8_t>::const_iterator& end, bool isLangEng)
{
std::string value;
unsigned int i = 0;
@@ -313,8 +312,8 @@
}
areaOffset *= fruBlockSize;
- std::vector<uint8_t>::const_iterator fruBytesIter = device.begin() +
- areaOffset;
+ std::vector<uint8_t>::const_iterator fruBytesIter =
+ device.begin() + areaOffset;
/* Verify area offset */
if (!verifyOffset(device, fruAreas::fruAreaMultirecord, *fruBytesIter))
@@ -394,8 +393,8 @@
continue;
}
offset *= fruBlockSize;
- std::vector<uint8_t>::const_iterator fruBytesIter = fruBytes.begin() +
- offset;
+ std::vector<uint8_t>::const_iterator fruBytesIter =
+ fruBytes.begin() + offset;
if (fruBytesIter + fruBlockSize >= fruBytes.end())
{
std::cerr << "Not enough data to parse \n";
@@ -460,9 +459,9 @@
isLangEng = checkLangEng(lang);
fruBytesIter += 1;
- unsigned int minutes = *fruBytesIter |
- *(fruBytesIter + 1) << 8 |
- *(fruBytesIter + 2) << 16;
+ unsigned int minutes =
+ *fruBytesIter | *(fruBytesIter + 1) << 8 |
+ *(fruBytesIter + 2) << 16;
std::tm fruTime = intelEpoch();
std::time_t timeValue = timegm(&fruTime);
timeValue += static_cast<long>(minutes) * 60;
@@ -505,8 +504,8 @@
DecodeState state = DecodeState::ok;
do
{
- auto res = decodeFRUData(fruBytesIter, fruBytesIterEndArea,
- isLangEng);
+ auto res =
+ decodeFRUData(fruBytesIter, fruBytesIterEndArea, isLangEng);
state = res.first;
std::string value = res.second;
std::string name;
@@ -527,9 +526,8 @@
{
// Strip non null characters from the end
value.erase(std::find_if(value.rbegin(), value.rend(),
- [](char ch) {
- return ch != 0;
- }).base(),
+ [](char ch) { return ch != 0; })
+ .base(),
value.end());
result[name] = std::move(value);
@@ -551,9 +549,9 @@
{
if (fieldIndex < fruAreaFieldNames->size())
{
- std::cerr << "Mandatory fields absent in FRU area "
- << getFruAreaName(area) << " after " << name
- << "\n";
+ std::cerr
+ << "Mandatory fields absent in FRU area "
+ << getFruAreaName(area) << " after " << name << "\n";
ret = resCodes::resWarn;
}
}
@@ -594,10 +592,9 @@
// Update new fru area length &
// Update checksum at new checksum location
// Return the offset of the area checksum byte
-unsigned int updateFRUAreaLenAndChecksum(std::vector<uint8_t>& fruData,
- size_t fruAreaStart,
- size_t fruAreaEndOfFieldsOffset,
- size_t fruAreaEndOffset)
+unsigned int updateFRUAreaLenAndChecksum(
+ std::vector<uint8_t>& fruData, size_t fruAreaStart,
+ size_t fruAreaEndOfFieldsOffset, size_t fruAreaEndOffset)
{
size_t traverseFRUAreaIndex = fruAreaEndOfFieldsOffset - fruAreaStart;
diff --git a/src/fru_utils.hpp b/src/fru_utils.hpp
index 12e28b1..8a117a7 100644
--- a/src/fru_utils.hpp
+++ b/src/fru_utils.hpp
@@ -82,9 +82,9 @@
const std::vector<std::string> chassisFruAreas = {"PART_NUMBER",
"SERIAL_NUMBER"};
-const std::vector<std::string> boardFruAreas = {"MANUFACTURER", "PRODUCT_NAME",
- "SERIAL_NUMBER", "PART_NUMBER",
- "FRU_VERSION_ID"};
+const std::vector<std::string> boardFruAreas = {
+ "MANUFACTURER", "PRODUCT_NAME", "SERIAL_NUMBER", "PART_NUMBER",
+ "FRU_VERSION_ID"};
const std::vector<std::string> productFruAreas = {
"MANUFACTURER", "PRODUCT_NAME", "PART_NUMBER", "VERSION",
@@ -94,8 +94,8 @@
inline fruAreas operator++(fruAreas& x)
{
- return x = static_cast<fruAreas>(std::underlying_type<fruAreas>::type(x) +
- 1);
+ return x = static_cast<fruAreas>(
+ std::underlying_type<fruAreas>::type(x) + 1);
}
inline const std::string& getFruAreaName(fruAreas area)
@@ -117,10 +117,9 @@
bool verifyOffset(const std::vector<uint8_t>& fruBytes, fruAreas currentArea,
uint8_t len);
-std::pair<DecodeState, std::string>
- decodeFRUData(std::vector<uint8_t>::const_iterator& iter,
- const std::vector<uint8_t>::const_iterator& end,
- bool isLangEng);
+std::pair<DecodeState, std::string> decodeFRUData(
+ std::vector<uint8_t>::const_iterator& iter,
+ const std::vector<uint8_t>::const_iterator& end, bool isLangEng);
bool checkLangEng(uint8_t lang);
@@ -135,10 +134,9 @@
uint8_t calculateChecksum(std::vector<uint8_t>& fruAreaData);
-unsigned int updateFRUAreaLenAndChecksum(std::vector<uint8_t>& fruData,
- size_t fruAreaStart,
- size_t fruAreaEndOfFieldsOffset,
- size_t fruAreaEndOffset);
+unsigned int updateFRUAreaLenAndChecksum(
+ std::vector<uint8_t>& fruData, size_t fruAreaStart,
+ size_t fruAreaEndOfFieldsOffset, size_t fruAreaEndOffset);
ssize_t getFieldLength(uint8_t fruFieldTypeLenValue);
diff --git a/src/overlay.cpp b/src/overlay.cpp
index 8df8c8f..f6d2476 100644
--- a/src/overlay.cpp
+++ b/src/overlay.cpp
@@ -164,13 +164,12 @@
return std::filesystem::exists(dirPath, ec);
}
-static int buildDevice(const std::string& name, const std::string& busPath,
- const std::string& parameters, uint64_t bus,
- uint64_t address, const std::string& constructor,
- const std::string& destructor,
- const devices::createsHWMon hasHWMonDir,
- std::vector<std::string> channelNames,
- const size_t retries = 5)
+static int
+ buildDevice(const std::string& name, const std::string& busPath,
+ const std::string& parameters, uint64_t bus, uint64_t address,
+ const std::string& constructor, const std::string& destructor,
+ const devices::createsHWMon hasHWMonDir,
+ std::vector<std::string> channelNames, const size_t retries = 5)
{
if (retries == 0U)
{
@@ -196,15 +195,15 @@
constructor, destructor, hasHWMonDir,
channelNames(std::move(channelNames)),
retries](const boost::system::error_code& ec) mutable {
- if (ec)
- {
- std::cerr << "Timer error: " << ec << "\n";
- return -2;
- }
- return buildDevice(name, busPath, parameters, bus, address,
- constructor, destructor, hasHWMonDir,
- std::move(channelNames), retries - 1);
- });
+ if (ec)
+ {
+ std::cerr << "Timer error: " << ec << "\n";
+ return -2;
+ }
+ return buildDevice(name, busPath, parameters, bus, address,
+ constructor, destructor, hasHWMonDir,
+ std::move(channelNames), retries - 1);
+ });
return -1;
}
}
diff --git a/src/perform_probe.cpp b/src/perform_probe.cpp
index 102351e..c49ff7a 100644
--- a/src/perform_probe.cpp
+++ b/src/perform_probe.cpp
@@ -123,15 +123,15 @@
{
if (!std::regex_search(probe, match, command))
{
- std::cerr << "found probe syntax error " << probe
- << "\n";
+ std::cerr
+ << "found probe syntax error " << probe << "\n";
return false;
}
std::string commandStr = *(match.begin() + 1);
boost::replace_all(commandStr, "'", "");
cur = (std::find(scan->passedProbes.begin(),
- scan->passedProbes.end(),
- commandStr) != scan->passedProbes.end());
+ scan->passedProbes.end(), commandStr) !=
+ scan->passedProbes.end());
break;
}
default:
@@ -215,8 +215,8 @@
const std::vector<std::string>& probeCommand,
std::string probeName,
std::shared_ptr<PerformScan>& scanPtr) :
- recordRef(recordRef),
- _probeCommand(probeCommand), probeName(std::move(probeName)), scan(scanPtr)
+ recordRef(recordRef), _probeCommand(probeCommand),
+ probeName(std::move(probeName)), scan(scanPtr)
{}
PerformProbe::~PerformProbe()
{
diff --git a/src/perform_scan.cpp b/src/perform_scan.cpp
index c503d99..e787360 100644
--- a/src/perform_scan.cpp
+++ b/src/perform_scan.cpp
@@ -60,25 +60,26 @@
}
systemBus->async_method_call(
- [instance, scan, probeVector, retries](boost::system::error_code& errc,
- const DBusInterface& resp) {
- if (errc)
- {
- std::cerr << "error calling getall on " << instance.busName << " "
- << instance.path << " " << instance.interface << "\n";
+ [instance, scan, probeVector,
+ retries](boost::system::error_code& errc, const DBusInterface& resp) {
+ if (errc)
+ {
+ std::cerr << "error calling getall on " << instance.busName
+ << " " << instance.path << " "
+ << instance.interface << "\n";
- auto timer = std::make_shared<boost::asio::steady_timer>(io);
- timer->expires_after(std::chrono::seconds(2));
+ auto timer = std::make_shared<boost::asio::steady_timer>(io);
+ timer->expires_after(std::chrono::seconds(2));
- timer->async_wait([timer, instance, scan, probeVector,
- retries](const boost::system::error_code&) {
- getInterfaces(instance, probeVector, scan, retries - 1);
- });
- return;
- }
+ timer->async_wait([timer, instance, scan, probeVector,
+ retries](const boost::system::error_code&) {
+ getInterfaces(instance, probeVector, scan, retries - 1);
+ });
+ return;
+ }
- scan->dbusProbeObjects[instance.path][instance.interface] = resp;
- },
+ scan->dbusProbeObjects[instance.path][instance.interface] = resp;
+ },
instance.busName, instance.path, "org.freedesktop.DBus.Properties",
"GetAll", instance.interface);
@@ -103,8 +104,8 @@
std::function<void(sdbusplus::message_t & message)> eventHandler =
[&](sdbusplus::message_t&) {
- propertiesChangedCallback(systemConfiguration, objServer);
- };
+ propertiesChangedCallback(systemConfiguration, objServer);
+ };
sdbusplus::bus::match_t match(
static_cast<sdbusplus::bus_t&>(*systemBus),
@@ -165,35 +166,37 @@
[interfaces, probeVector{std::move(probeVector)}, scan,
retries](boost::system::error_code& ec,
const GetSubTreeType& interfaceSubtree) mutable {
- if (ec)
- {
- if (ec.value() == ENOENT)
+ if (ec)
{
- return; // wasn't found by mapper
- }
- std::cerr << "Error communicating to mapper.\n";
+ if (ec.value() == ENOENT)
+ {
+ return; // wasn't found by mapper
+ }
+ std::cerr << "Error communicating to mapper.\n";
- if (retries == 0U)
- {
- // if we can't communicate to the mapper something is very
- // wrong
- std::exit(EXIT_FAILURE);
+ if (retries == 0U)
+ {
+ // if we can't communicate to the mapper something is very
+ // wrong
+ std::exit(EXIT_FAILURE);
+ }
+
+ auto timer = std::make_shared<boost::asio::steady_timer>(io);
+ timer->expires_after(std::chrono::seconds(10));
+
+ timer->async_wait(
+ [timer, interfaces{std::move(interfaces)}, scan,
+ probeVector{std::move(probeVector)},
+ retries](const boost::system::error_code&) mutable {
+ findDbusObjects(std::move(probeVector),
+ std::move(interfaces), scan,
+ retries - 1);
+ });
+ return;
}
- auto timer = std::make_shared<boost::asio::steady_timer>(io);
- timer->expires_after(std::chrono::seconds(10));
-
- timer->async_wait([timer, interfaces{std::move(interfaces)}, scan,
- probeVector{std::move(probeVector)}, retries](
- const boost::system::error_code&) mutable {
- findDbusObjects(std::move(probeVector), std::move(interfaces),
- scan, retries - 1);
- });
- return;
- }
-
- processDbusObjects(probeVector, scan, interfaceSubtree);
- },
+ processDbusObjects(probeVector, scan, interfaceSubtree);
+ },
"xyz.openbmc_project.ObjectMapper",
"/xyz/openbmc_project/object_mapper",
"xyz.openbmc_project.ObjectMapper", "GetSubTree", "/", maxMapperDepth,
@@ -262,10 +265,9 @@
*findExposes = copy;
}
-static void recordDiscoveredIdentifiers(std::set<nlohmann::json>& usedNames,
- std::list<size_t>& indexes,
- const std::string& probeName,
- const nlohmann::json& record)
+static void recordDiscoveredIdentifiers(
+ std::set<nlohmann::json>& usedNames, std::list<size_t>& indexes,
+ const std::string& probeName, const nlohmann::json& record)
{
size_t indexIdx = probeName.find('$');
if (indexIdx == std::string::npos)
@@ -328,9 +330,8 @@
return false;
}
-static std::optional<std::vector<std::string>::iterator>
- findExposeActionRecord(std::vector<std::string>& matches,
- const nlohmann::json& record)
+static std::optional<std::vector<std::string>::iterator> findExposeActionRecord(
+ std::vector<std::string>& matches, const nlohmann::json& record)
{
const auto& name = (record)["Name"].get_ref<const std::string&>();
auto compare = [&name](const std::string& s) { return s == name; };
@@ -365,10 +366,9 @@
}
}
-static void applyConfigExposeActions(std::vector<std::string>& matches,
- nlohmann::json& expose,
- const std::string& propertyName,
- nlohmann::json& configExposes)
+static void applyConfigExposeActions(
+ std::vector<std::string>& matches, nlohmann::json& expose,
+ const std::string& propertyName, nlohmann::json& configExposes)
{
for (auto& exposedObject : configExposes)
{
@@ -382,10 +382,9 @@
}
}
-static void applyExposeActions(nlohmann::json& systemConfiguration,
- const std::string& recordName,
- nlohmann::json& expose,
- nlohmann::json::iterator& keyPair)
+static void applyExposeActions(
+ nlohmann::json& systemConfiguration, const std::string& recordName,
+ nlohmann::json& expose, nlohmann::json::iterator& keyPair)
{
bool isBind = boost::starts_with(keyPair.key(), "Bind");
bool isDisable = keyPair.key() == "DisableNode";
@@ -433,11 +432,10 @@
}
}
-static std::string generateDeviceName(const std::set<nlohmann::json>& usedNames,
- const DBusObject& dbusObject,
- size_t foundDeviceIdx,
- const std::string& nameTemplate,
- std::optional<std::string>& replaceStr)
+static std::string generateDeviceName(
+ const std::set<nlohmann::json>& usedNames, const DBusObject& dbusObject,
+ size_t foundDeviceIdx, const std::string& nameTemplate,
+ std::optional<std::string>& replaceStr)
{
nlohmann::json copyForName = {{"Name", nameTemplate}};
nlohmann::json::iterator copyIt = copyForName.begin();
diff --git a/src/topology.cpp b/src/topology.cpp
index 94389b9..168c160 100644
--- a/src/topology.cpp
+++ b/src/topology.cpp
@@ -101,8 +101,8 @@
for (auto it = upstreamPorts.begin(); it != upstreamPorts.end();)
{
- auto pathIt = std::find(it->second.begin(), it->second.end(),
- boardPath);
+ auto pathIt =
+ std::find(it->second.begin(), it->second.end(), boardPath);
if (pathIt != it->second.end())
{
it->second.erase(pathIt);
@@ -120,8 +120,8 @@
for (auto it = downstreamPorts.begin(); it != downstreamPorts.end();)
{
- auto pathIt = std::find(it->second.begin(), it->second.end(),
- boardPath);
+ auto pathIt =
+ std::find(it->second.begin(), it->second.end(), boardPath);
if (pathIt != it->second.end())
{
it->second.erase(pathIt);
diff --git a/src/utils.cpp b/src/utils.cpp
index 6ff7a2b..d95fb5e 100644
--- a/src/utils.cpp
+++ b/src/utils.cpp
@@ -158,28 +158,28 @@
"',path='" + std::string(power::path) + "',arg0='" +
std::string(power::interface) + "'",
[](sdbusplus::message_t& message) {
- std::string objectName;
- boost::container::flat_map<std::string, std::variant<std::string>>
- values;
- message.read(objectName, values);
- auto findState = values.find(power::property);
- if (findState != values.end())
- {
- powerStatusOn = boost::ends_with(
- std::get<std::string>(findState->second), "Running");
- }
- });
+ std::string objectName;
+ boost::container::flat_map<std::string, std::variant<std::string>>
+ values;
+ message.read(objectName, values);
+ auto findState = values.find(power::property);
+ if (findState != values.end())
+ {
+ powerStatusOn = boost::ends_with(
+ std::get<std::string>(findState->second), "Running");
+ }
+ });
conn->async_method_call(
[](boost::system::error_code ec,
const std::variant<std::string>& state) {
- if (ec)
- {
- return;
- }
- powerStatusOn = boost::ends_with(std::get<std::string>(state),
- "Running");
- },
+ if (ec)
+ {
+ return;
+ }
+ powerStatusOn =
+ boost::ends_with(std::get<std::string>(state), "Running");
+ },
power::busname, power::path, properties::interface, properties::get,
power::interface, power::property);
}
@@ -187,10 +187,9 @@
// Replaces the template character like the other version of this function,
// but checks all properties on all interfaces provided to do the substitution
// with.
-std::optional<std::string>
- templateCharReplace(nlohmann::json::iterator& keyPair,
- const DBusObject& object, const size_t index,
- const std::optional<std::string>& replaceStr)
+std::optional<std::string> templateCharReplace(
+ nlohmann::json::iterator& keyPair, const DBusObject& object,
+ const size_t index, const std::optional<std::string>& replaceStr)
{
for (const auto& [_, interface] : object)
{
@@ -206,10 +205,9 @@
// finds the template character (currently set to $) and replaces the value with
// the field found in a dbus object i.e. $ADDRESS would get populated with the
// ADDRESS field from a object on dbus
-std::optional<std::string>
- templateCharReplace(nlohmann::json::iterator& keyPair,
- const DBusInterface& interface, const size_t index,
- const std::optional<std::string>& replaceStr)
+std::optional<std::string> templateCharReplace(
+ nlohmann::json::iterator& keyPair, const DBusInterface& interface,
+ const size_t index, const std::optional<std::string>& replaceStr)
{
std::optional<std::string> ret = std::nullopt;
diff --git a/test/test_topology.cpp b/test/test_topology.cpp
index e23c802..b3e4d0c 100644
--- a/test/test_topology.cpp
+++ b/test/test_topology.cpp
@@ -12,8 +12,8 @@
const Association subchassisAssoc =
std::make_tuple("contained_by", "containing", superchassisPath);
-const Association powerAssoc = std::make_tuple("powered_by", "powering",
- subchassisPath);
+const Association powerAssoc =
+ std::make_tuple("powered_by", "powering", subchassisPath);
const nlohmann::json subchassisExposesItem = nlohmann::json::parse(R"(
{