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: I07b444d4ae00b0fce52a846f2bff2e6b99fb971c
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
diff --git a/.clang-format b/.clang-format
index ef6f54e..d92a3f1 100644
--- a/.clang-format
+++ b/.clang-format
@@ -6,12 +6,14 @@
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Right
-AlignOperands: true
-AlignTrailingComments: true
+AlignOperands: Align
+AlignTrailingComments:
+ Kind: Always
+ OverEmptyLines: 1
AllowAllParametersOfDeclarationOnNextLine: true
-AllowShortBlocksOnASingleLine: false
+AllowShortBlocksOnASingleLine: Empty
AllowShortCaseLabelsOnASingleLine: false
-AllowShortFunctionsOnASingleLine: None
+AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None
@@ -36,12 +38,13 @@
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: false
+BreakAfterAttributes: Never
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: AfterColon
BreakInheritanceList: AfterColon
-BreakStringLiterals: true
+BreakStringLiterals: false
ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
@@ -49,6 +52,7 @@
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
+DeriveLineEnding: false
DerivePointerAlignment: false
PointerAlignment: Left
DisableFormat: false
@@ -74,9 +78,13 @@
- Regex: '.*'
Priority: 6
IndentCaseLabels: true
+IndentRequiresClause: true
IndentWidth: 4
IndentWrappedFunctionNames: true
-KeepEmptyLinesAtTheStartOfBlocks: true
+InsertNewlineAtEOF: true
+KeepEmptyLinesAtTheStartOfBlocks: false
+LambdaBodyIndentation: OuterScope
+LineEnding: LF
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
@@ -84,13 +92,19 @@
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
+PenaltyBreakAssignment: 25
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
+PenaltyIndentedWhitespace: 0
+QualifierAlignment: Left
+ReferenceAlignment: Left
ReflowComments: true
+RequiresClausePosition: OwnLine
+RequiresExpressionIndentation: Keyword
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
@@ -108,7 +122,7 @@
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
-Standard: Cpp11
+Standard: Latest
TabWidth: 4
UseTab: Never
...
diff --git a/src/entity_manager.cpp b/src/entity_manager.cpp
index c28e50f..428d63e 100644
--- a/src/entity_manager.cpp
+++ b/src/entity_manager.cpp
@@ -184,19 +184,19 @@
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;
});
}
}
@@ -218,19 +218,18 @@
[&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;
});
}
@@ -241,32 +240,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);
- });
-
- if (!writeJsonFiles(systemConfiguration))
- {
- std::cerr << "error setting json file\n";
- throw DBusInternalError();
- }
+ // 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();
+ }
+ });
}
// adds simple json types to interface's properties
@@ -449,115 +448,115 @@
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())
+ 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())
{
- throw std::invalid_argument("Entity must have children.");
+ foundNull = true;
+ continue;
}
- // 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())
+ if (expose["Name"] == *name && expose["Type"] == *type)
{
throw std::invalid_argument(
- "No schema avaliable, cannot validate.");
+ "Field already in JSON, not adding");
}
- nlohmann::json schema =
- nlohmann::json::parse(schemaFile, nullptr, false);
- 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;
+ continue;
}
- 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, "_");
+ lastIndex++;
+ }
- 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::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);
+ 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);
});
iface->initialize();
}
@@ -916,24 +915,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>>&
@@ -1067,32 +1066,31 @@
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();
});
@@ -1171,8 +1169,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(),
@@ -1233,16 +1231,16 @@
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.
@@ -1250,19 +1248,19 @@
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, [&]() {
diff --git a/src/entity_manager.hpp b/src/entity_manager.hpp
index 3eae773..a4c7511 100644
--- a/src/entity_manager.hpp
+++ b/src/entity_manager.hpp
@@ -64,7 +64,6 @@
struct PerformScan : std::enable_shared_from_this<PerformScan>
{
-
PerformScan(nlohmann::json& systemConfiguration,
nlohmann::json& missingConfigurations,
std::list<nlohmann::json>& configurations,
@@ -101,7 +100,6 @@
inline void logDeviceAdded(const nlohmann::json& record)
{
-
if (!deviceHasLogging(record))
{
return;
diff --git a/src/fru_device.cpp b/src/fru_device.cpp
index c67bfc5..ad6f016 100644
--- a/src/fru_device.cpp
+++ b/src/fru_device.cpp
@@ -312,8 +312,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)
{
@@ -364,7 +364,6 @@
std::shared_ptr<DeviceMap> devices, const bool& powerIsOn,
sdbusplus::asio::object_server& objServer)
{
-
std::future<int> future = std::async(std::launch::async, [&]() {
// NOTE: When reading the devices raw on the bus, it can interfere with
// the driver's ability to operate, therefore read eeproms first before
@@ -463,8 +462,8 @@
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::vector<uint8_t> device = readFRUContents(reader, errorMessage);
if (device.empty())
{
@@ -503,8 +502,8 @@
return;
}
- nlohmann::json data =
- nlohmann::json::parse(blacklistStream, nullptr, false);
+ nlohmann::json data = nlohmann::json::parse(blacklistStream, nullptr,
+ false);
if (data.is_discarded())
{
std::cerr << "Illegal blacklist file detected, cannot validate JSON, "
@@ -666,8 +665,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())
@@ -682,15 +681,14 @@
for (auto& property : formattedFRU)
{
-
std::regex_replace(property.second.begin(), property.second.begin(),
property.second.end(), nonAsciiRegex, "_");
if (property.second.empty() && property.first != "PRODUCT_ASSET_TAG")
{
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")
{
@@ -700,23 +698,23 @@
[bus, address, propertyName, &dbusInterfaceMap,
&unknownBusObjectCount, &powerIsOn, &objServer,
&systemBus](const std::string& req, std::string& resp) {
- if (strcmp(req.c_str(), resp.c_str()) != 0)
+ 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))
{
- // 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.");
- }
+ resp = req;
}
- return 1;
+ else
+ {
+ throw std::invalid_argument(
+ "FRU property update failed.");
+ }
+ }
+ return 1;
});
}
else if (!iface->register_property(key, property.second + '\0'))
@@ -907,25 +905,25 @@
i2cBuses, busmap, powerIsOn, objServer,
[busNum, &busmap, &dbusInterfaceMap, &unknownBusObjectCount, &powerIsOn,
&objServer, &systemBus]() {
- for (auto& busIface : dbusInterfaceMap)
+ for (auto& busIface : dbusInterfaceMap)
+ {
+ if (busIface.first.first == static_cast<size_t>(busNum))
{
- if (busIface.first.first == static_cast<size_t>(busNum))
- {
- objServer.remove_interface(busIface.second);
- }
+ objServer.remove_interface(busIface.second);
}
- 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);
- }
+ }
+ 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);
+ }
});
scan->run();
}
@@ -1095,14 +1093,13 @@
size_t fruAreaAvailableSize = fruAreaParams.size - fruAreaDataSize;
if ((updatePropertyReqLen + 1) > fruAreaAvailableSize)
{
-
#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;
@@ -1123,10 +1120,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);
@@ -1137,8 +1134,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)
@@ -1236,9 +1233,9 @@
iface->register_method("GetRawFru", getFRUInfo);
- iface->register_method("WriteFru", [&](const uint16_t bus,
- const uint8_t address,
- const std::vector<uint8_t>& data) {
+ 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.");
@@ -1252,28 +1249,28 @@
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())
+ 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")
{
- if (std::get<std::string>(findState->second) ==
- "xyz.openbmc_project.State.Host.HostState.Running")
- {
- powerIsOn = true;
- }
+ 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),
@@ -1288,55 +1285,54 @@
// monitor for new i2c devices
boost::asio::posix::stream_descriptor dirWatch(io, fd);
std::function<void(const boost::system::error_code, std::size_t)>
- watchI2cBusses = [&](const boost::system::error_code& ec,
- std::size_t bytesTransferred) {
- if (ec)
+ 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)
{
- 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)
- {
- case IN_CREATE:
- case IN_MOVED_TO:
- case IN_DELETE:
- 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:
+ std::string_view name(&iEvent->name[0], iEvent->len);
+ if (boost::starts_with(name, "i2c"))
+ {
+ int bus = busStrToInt(name);
+ if (bus < 0)
{
- 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),
+ 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);
}
- }
- index += sizeof(inotify_event) + iEvent->len;
+ rescanOneBus(busMap, static_cast<uint16_t>(bus),
+ dbusInterfaceMap, false,
+ unknownBusObjectCount, powerIsOn,
+ objServer, systemBus);
+ }
}
+ 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 61d4020..5acfa65 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 b168705..808179f 100644
--- a/src/fru_utils.cpp
+++ b/src/fru_utils.cpp
@@ -194,7 +194,6 @@
bool verifyOffset(const std::vector<uint8_t>& fruBytes, fruAreas currentArea,
uint8_t len)
{
-
unsigned int fruBytesSize = fruBytes.size();
// check if Fru data has at least 8 byte header
@@ -276,15 +275,14 @@
for (fruAreas area = fruAreas::fruAreaChassis;
area <= fruAreas::fruAreaProduct; ++area)
{
-
size_t offset = *(fruBytes.begin() + getHeaderAreaFieldOffset(area));
if (offset == 0)
{
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";
@@ -394,8 +392,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;
@@ -951,16 +949,14 @@
std::shared_ptr<sdbusplus::asio::dbus_interface>>& dbusInterfaceMap,
std::string& productName)
{
-
int highest = -1;
bool found = false;
- for (auto const& busIface : dbusInterfaceMap)
+ for (const auto& busIface : dbusInterfaceMap)
{
std::string path = busIface.second->get_object_path();
if (std::regex_match(path, std::regex(productName + "(_\\d+|)$")))
{
-
// Check if the match named has extra information.
found = true;
std::smatch baseMatch;
diff --git a/src/overlay.cpp b/src/overlay.cpp
index 6352cba..4568699 100644
--- a/src/overlay.cpp
+++ b/src/overlay.cpp
@@ -231,7 +231,6 @@
const devices::ExportTemplate& exportTemplate,
const nlohmann::json& configuration)
{
-
std::string parameters = exportTemplate.parameters;
std::string busPath = exportTemplate.busPath;
std::string constructor = exportTemplate.add;
diff --git a/src/overlay.hpp b/src/overlay.hpp
index e11f1b8..8e818c2 100644
--- a/src/overlay.hpp
+++ b/src/overlay.hpp
@@ -19,4 +19,4 @@
#include <nlohmann/json.hpp>
void unloadAllOverlays(void);
-bool loadOverlays(const nlohmann::json& systemConfiguration);
\ No newline at end of file
+bool loadOverlays(const nlohmann::json& systemConfiguration);
diff --git a/src/perform_probe.cpp b/src/perform_probe.cpp
index 04ba87d..1ef8bb2 100644
--- a/src/perform_probe.cpp
+++ b/src/perform_probe.cpp
@@ -51,8 +51,8 @@
auto deviceValue = interface.find(matchProp);
if (deviceValue != interface.end())
{
- deviceMatches =
- deviceMatches && matchProbe(matchJSON, deviceValue->second);
+ deviceMatches = deviceMatches &&
+ matchProbe(matchJSON, deviceValue->second);
}
else
{
@@ -193,8 +193,8 @@
ret = cur;
first = false;
}
- lastCommand =
- probeType ? (*probeType)->second : probe_type_codes::FALSE_T;
+ lastCommand = probeType ? (*probeType)->second
+ : probe_type_codes::FALSE_T;
}
// probe passed, but empty device
diff --git a/src/perform_scan.cpp b/src/perform_scan.cpp
index 0ad6509..2be6477 100644
--- a/src/perform_scan.cpp
+++ b/src/perform_scan.cpp
@@ -60,23 +60,22 @@
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";
+ 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);
@@ -102,8 +101,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),
@@ -164,36 +163,34 @@
[interfaces, probeVector{std::move(probeVector)}, scan,
retries](boost::system::error_code& ec,
const GetSubTreeType& interfaceSubtree) mutable {
- if (ec)
+ if (ec)
+ {
+ if (ec.value() == ENOENT)
{
- if (ec.value() == ENOENT)
- {
- return; // wasn't found by mapper
- }
- std::cerr << "Error communicating to mapper.\n";
+ 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);
- }
-
- 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;
+ if (retries == 0U)
+ {
+ // if we can't communicate to the mapper something is very
+ // wrong
+ std::exit(EXIT_FAILURE);
}
- processDbusObjects(probeVector, scan, interfaceSubtree);
+ 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);
},
"xyz.openbmc_project.ObjectMapper",
"/xyz/openbmc_project/object_mapper",
@@ -567,7 +564,6 @@
for (auto keyPair = expose.begin(); keyPair != expose.end();
keyPair++)
{
-
templateCharReplace(keyPair, dbusObject, foundDeviceIdx,
replaceStr);
diff --git a/src/utils.cpp b/src/utils.cpp
index 2b77755..8fbbcd1 100644
--- a/src/utils.cpp
+++ b/src/utils.cpp
@@ -156,27 +156,27 @@
"',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);
diff --git a/src/utils.hpp b/src/utils.hpp
index 99e2f85..746bc25 100644
--- a/src/utils.hpp
+++ b/src/utils.hpp
@@ -115,7 +115,6 @@
std::ifstream hashFile(versionHashFile);
if (hashFile.good())
{
-
std::string hashString;
hashFile >> hashString;