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: Ia968a74764d3bda33160a8a9890629ed3cc94d0e
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
diff --git a/src/erase/pattern.cpp b/src/erase/pattern.cpp
index 7d7990b..7855fc9 100644
--- a/src/erase/pattern.cpp
+++ b/src/erase/pattern.cpp
@@ -76,7 +76,6 @@
void Pattern::verifyPattern(const uint64_t driveSize, Fd& fd)
{
-
uint64_t currentIndex = 0;
// random number generator seeded with a constant value will
// generate a predictable sequence of values NOLINTNEXTLINE
diff --git a/src/erase/sanitize.cpp b/src/erase/sanitize.cpp
index ac1770d..dbf92f5 100644
--- a/src/erase/sanitize.cpp
+++ b/src/erase/sanitize.cpp
@@ -73,7 +73,6 @@
void Sanitize::emmcErase(uint64_t driveSize)
{
-
uint64_t sectorSize = 0x200; // default value see eMMC spec 6.6.34.
// NOTE: 0x200 is only valid for eMMC greater
// then 2 GB
@@ -105,7 +104,6 @@
void Sanitize::emmcSanitize()
{
-
struct mmc_ioc_cmd idata = {};
idata.write_flag = 1;
idata.opcode = mmcSwitch;
diff --git a/src/estoraged.cpp b/src/estoraged.cpp
index 341440a..3a6a8bb 100644
--- a/src/estoraged.cpp
+++ b/src/estoraged.cpp
@@ -48,8 +48,8 @@
/* Get the filename of the device (without "/dev/"). */
std::string deviceName = std::filesystem::path(devPath).filename().string();
/* DBus object path */
- std::string objectPath =
- "/xyz/openbmc_project/inventory/storage/" + deviceName;
+ std::string objectPath = "/xyz/openbmc_project/inventory/storage/" +
+ deviceName;
/* Add Volume interface. */
volumeInterface = objectServer.add_interface(
@@ -59,13 +59,15 @@
Volume::FilesystemType type) {
this->formatLuks(password, type);
});
- volumeInterface->register_method(
- "Erase",
- [this](Volume::EraseMethod eraseType) { this->erase(eraseType); });
+ volumeInterface->register_method("Erase",
+ [this](Volume::EraseMethod eraseType) {
+ this->erase(eraseType);
+ });
volumeInterface->register_method("Lock", [this]() { this->lock(); });
- volumeInterface->register_method(
- "Unlock",
- [this](std::vector<uint8_t>& password) { this->unlock(password); });
+ volumeInterface->register_method("Unlock",
+ [this](std::vector<uint8_t>& password) {
+ this->unlock(password);
+ });
volumeInterface->register_method(
"ChangePassword", [this](const std::vector<uint8_t>& oldPassword,
const std::vector<uint8_t>& newPassword) {
@@ -74,8 +76,8 @@
volumeInterface->register_property_r(
"Locked", lockedProperty, sdbusplus::vtable::property_::emits_change,
[this](bool& value) {
- value = this->isLocked();
- return value;
+ value = this->isLocked();
+ return value;
});
/* Add Drive interface. */
@@ -89,16 +91,16 @@
driveInterface->register_property_r(
"Locked", lockedProperty, sdbusplus::vtable::property_::emits_change,
[this](bool& value) {
- value = this->isLocked();
- return value;
+ value = this->isLocked();
+ return value;
});
driveInterface->register_property_r(
"EncryptionStatus", encryptionStatus,
sdbusplus::vtable::property_::emits_change,
[this](Drive::DriveEncryptionState& value) {
- value = this->findEncryptionStatus();
- return value;
+ value = this->findEncryptionStatus();
+ return value;
});
embeddedLocationInterface = objectServer.add_interface(
@@ -335,7 +337,6 @@
CryptHandle EStoraged::loadLuksHeader()
{
-
CryptHandle cryptHandle(devPath);
int retval = cryptIface->cryptLoad(cryptHandle.get(), CRYPT_LUKS2, nullptr);
diff --git a/src/getConfig.cpp b/src/getConfig.cpp
index 1046416..79579b1 100644
--- a/src/getConfig.cpp
+++ b/src/getConfig.cpp
@@ -34,15 +34,15 @@
[self, path, owner](
const boost::system::error_code ec,
boost::container::flat_map<std::string, BasicVariantType>& data) {
- if (ec)
- {
- lg2::error("Error getting properties for {PATH}", "PATH", path,
- "REDFISH_MESSAGE_ID",
- std::string("OpenBMC.0.1.GetStorageInfoFail"));
- return;
- }
+ if (ec)
+ {
+ lg2::error("Error getting properties for {PATH}", "PATH", path,
+ "REDFISH_MESSAGE_ID",
+ std::string("OpenBMC.0.1.GetStorageInfoFail"));
+ return;
+ }
- self->respData[path] = std::move(data);
+ self->respData[path] = std::move(data);
},
owner, path, "org.freedesktop.DBus.Properties", "GetAll",
emmcConfigInterface);
@@ -53,28 +53,28 @@
std::shared_ptr<GetStorageConfiguration> self = shared_from_this();
dbusConnection->async_method_call(
[self](const boost::system::error_code ec, const GetSubTreeType& ret) {
- if (ec)
+ if (ec)
+ {
+ lg2::error("Error calling mapper");
+ return;
+ }
+ for (const auto& [objPath, objDict] : ret)
+ {
+ if (objDict.empty())
{
- lg2::error("Error calling mapper");
return;
}
- for (const auto& [objPath, objDict] : ret)
+ const std::string& objOwner = objDict.begin()->first;
+ /* Look for the config interface exposed by this object. */
+ for (const std::string& interface : objDict.begin()->second)
{
- if (objDict.empty())
+ if (interface.compare(emmcConfigInterface) == 0)
{
- return;
- }
- const std::string& objOwner = objDict.begin()->first;
- /* Look for the config interface exposed by this object. */
- for (const std::string& interface : objDict.begin()->second)
- {
- if (interface.compare(emmcConfigInterface) == 0)
- {
- /* Get the properties exposed by this interface. */
- self->getStorageInfo(objPath, objOwner);
- }
+ /* Get the properties exposed by this interface. */
+ self->getStorageInfo(objPath, objOwner);
}
}
+ }
},
mapper::busName, mapper::path, mapper::interface, mapper::subtree, "/",
0, std::vector<const char*>(1, emmcConfigInterface));
diff --git a/src/main.cpp b/src/main.cpp
index 578d505..db3173a 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -40,72 +40,67 @@
dbusConnection,
[&objectServer, &storageObjects](
const estoraged::ManagedStorageType& storageConfigurations) {
- size_t numConfigObj = storageConfigurations.size();
- if (numConfigObj > 1)
+ size_t numConfigObj = storageConfigurations.size();
+ if (numConfigObj > 1)
+ {
+ lg2::error("eStoraged can only manage 1 eMMC device; found {NUM}",
+ "NUM", numConfigObj, "REDFISH_MESSAGE_ID",
+ std::string("OpenBMC.0.1.CreateStorageObjectsFail"));
+ return;
+ }
+
+ for (const std::pair<sdbusplus::message::object_path,
+ estoraged::StorageData>& storage :
+ storageConfigurations)
+ {
+ const std::string& path = storage.first.str;
+
+ if (storageObjects.find(path) != storageObjects.end())
{
- lg2::error(
- "eStoraged can only manage 1 eMMC device; found {NUM}",
- "NUM", numConfigObj, "REDFISH_MESSAGE_ID",
- std::string("OpenBMC.0.1.CreateStorageObjectsFail"));
- return;
+ /*
+ * We've already created this object, or at least
+ * attempted to.
+ */
+ continue;
}
- for (const std::pair<sdbusplus::message::object_path,
- estoraged::StorageData>& storage :
- storageConfigurations)
+ /* Get the properties from the config object. */
+ const estoraged::StorageData& data = storage.second;
+
+ /* Look for the device file. */
+ const std::filesystem::path blockDevDir{"/sys/block"};
+ std::filesystem::path deviceFile, sysfsDir;
+ std::string luksName;
+ bool found = estoraged::util::findDevice(
+ data, blockDevDir, deviceFile, sysfsDir, luksName);
+ if (!found)
{
- const std::string& path = storage.first.str;
-
- if (storageObjects.find(path) != storageObjects.end())
- {
- /*
- * We've already created this object, or at least
- * attempted to.
- */
- continue;
- }
-
- /* Get the properties from the config object. */
- const estoraged::StorageData& data = storage.second;
-
- /* Look for the device file. */
- const std::filesystem::path blockDevDir{"/sys/block"};
- std::filesystem::path deviceFile, sysfsDir;
- std::string luksName;
- bool found = estoraged::util::findDevice(
- data, blockDevDir, deviceFile, sysfsDir, luksName);
- if (!found)
- {
- lg2::error(
- "Device not found for path {PATH}", "PATH", path,
- "REDFISH_MESSAGE_ID",
- std::string("OpenBMC.0.1.CreateStorageObjectsFail"));
- /*
- * Set a NULL pointer as a placeholder, so that we don't
- * try and fail again later.
- */
- storageObjects[path] = nullptr;
- continue;
- }
-
- uint64_t size =
- estoraged::util::findSizeOfBlockDevice(deviceFile);
-
- uint8_t lifeleft =
- estoraged::util::findPredictedMediaLifeLeftPercent(
- sysfsDir);
- std::string partNumber =
- estoraged::util::getPartNumber(sysfsDir);
- std::string serialNumber =
- estoraged::util::getSerialNumber(sysfsDir);
- /* Create the storage object. */
- storageObjects[path] = std::make_unique<estoraged::EStoraged>(
- objectServer, path, deviceFile, luksName, size, lifeleft,
- partNumber, serialNumber);
- lg2::info("Created eStoraged object for path {PATH}", "PATH",
- path, "REDFISH_MESSAGE_ID",
- std::string("OpenBMC.0.1.CreateStorageObjects"));
+ lg2::error("Device not found for path {PATH}", "PATH", path,
+ "REDFISH_MESSAGE_ID",
+ std::string("OpenBMC.0.1.CreateStorageObjectsFail"));
+ /*
+ * Set a NULL pointer as a placeholder, so that we don't
+ * try and fail again later.
+ */
+ storageObjects[path] = nullptr;
+ continue;
}
+
+ uint64_t size = estoraged::util::findSizeOfBlockDevice(deviceFile);
+
+ uint8_t lifeleft =
+ estoraged::util::findPredictedMediaLifeLeftPercent(sysfsDir);
+ std::string partNumber = estoraged::util::getPartNumber(sysfsDir);
+ std::string serialNumber =
+ estoraged::util::getSerialNumber(sysfsDir);
+ /* Create the storage object. */
+ storageObjects[path] = std::make_unique<estoraged::EStoraged>(
+ objectServer, path, deviceFile, luksName, size, lifeleft,
+ partNumber, serialNumber);
+ lg2::info("Created eStoraged object for path {PATH}", "PATH", path,
+ "REDFISH_MESSAGE_ID",
+ std::string("OpenBMC.0.1.CreateStorageObjects"));
+ }
});
getter->getConfiguration();
}
@@ -134,34 +129,33 @@
boost::asio::deadline_timer filterTimer(io);
std::function<void(sdbusplus::message_t&)> eventHandler =
[&](sdbusplus::message_t& message) {
- if (message.is_method_error())
+ if (message.is_method_error())
+ {
+ lg2::error("eventHandler callback method error");
+ return;
+ }
+ /*
+ * This implicitly cancels the timer, if it's already pending.
+ * If there's a burst of events within a short period, we want
+ * to handle them all at once. So, we will wait this long for no
+ * more events to occur, before processing them.
+ */
+ filterTimer.expires_from_now(boost::posix_time::seconds(1));
+
+ filterTimer.async_wait([&](const boost::system::error_code& ec) {
+ if (ec == boost::asio::error::operation_aborted)
{
- lg2::error("eventHandler callback method error");
+ /* we were canceled */
return;
}
- /*
- * This implicitly cancels the timer, if it's already pending.
- * If there's a burst of events within a short period, we want
- * to handle them all at once. So, we will wait this long for no
- * more events to occur, before processing them.
- */
- filterTimer.expires_from_now(boost::posix_time::seconds(1));
-
- filterTimer.async_wait(
- [&](const boost::system::error_code& ec) {
- if (ec == boost::asio::error::operation_aborted)
- {
- /* we were canceled */
- return;
- }
- if (ec)
- {
- lg2::error("timer error");
- return;
- }
- createStorageObjects(server, storageObjects, conn);
- });
- };
+ if (ec)
+ {
+ lg2::error("timer error");
+ return;
+ }
+ createStorageObjects(server, storageObjects, conn);
+ });
+ };
auto match = std::make_unique<sdbusplus::bus::match_t>(
static_cast<sdbusplus::bus_t&>(*conn),
diff --git a/src/test/erase/crypto_test.cpp b/src/test/erase/crypto_test.cpp
index 9eefa9d..dd3954e 100644
--- a/src/test/erase/crypto_test.cpp
+++ b/src/test/erase/crypto_test.cpp
@@ -63,8 +63,8 @@
EXPECT_CALL(*mockCryptIface, cryptKeyslotDestroy(_, 0)).Times(1);
- CryptErase myCryptErase =
- CryptErase(testFileName.c_str(), std::move(mockCryptIface));
+ CryptErase myCryptErase = CryptErase(testFileName.c_str(),
+ std::move(mockCryptIface));
EXPECT_NO_THROW(myCryptErase.doErase());
}
@@ -79,8 +79,8 @@
EXPECT_CALL(*mockCryptIface, cryptKeySlotMax(StrEq(CRYPT_LUKS2)))
.WillOnce(Return(-1));
- CryptErase myCryptErase =
- CryptErase(testFileName.c_str(), std::move(mockCryptIface));
+ CryptErase myCryptErase = CryptErase(testFileName.c_str(),
+ std::move(mockCryptIface));
EXPECT_THROW(myCryptErase.doErase(), ResourceNotFound);
}
@@ -95,8 +95,8 @@
EXPECT_CALL(*mockCryptIface, cryptKeySlotMax(StrEq(CRYPT_LUKS2)))
.WillOnce(Return(0));
- CryptErase myCryptErase =
- CryptErase(testFileName.c_str(), std::move(mockCryptIface));
+ CryptErase myCryptErase = CryptErase(testFileName.c_str(),
+ std::move(mockCryptIface));
EXPECT_THROW(myCryptErase.doErase(), ResourceNotFound);
}
@@ -114,8 +114,8 @@
EXPECT_CALL(*mockCryptIface, cryptKeySlotStatus(_, _))
.WillRepeatedly(Return(CRYPT_SLOT_INVALID));
- CryptErase myCryptErase =
- CryptErase(testFileName.c_str(), std::move(mockCryptIface));
+ CryptErase myCryptErase = CryptErase(testFileName.c_str(),
+ std::move(mockCryptIface));
EXPECT_NO_THROW(myCryptErase.doErase());
}
@@ -136,8 +136,8 @@
EXPECT_CALL(*mockCryptIface, cryptKeyslotDestroy(_, 0))
.WillOnce(Return(-1));
- CryptErase myCryptErase =
- CryptErase(testFileName.c_str(), std::move(mockCryptIface));
+ CryptErase myCryptErase = CryptErase(testFileName.c_str(),
+ std::move(mockCryptIface));
EXPECT_THROW(myCryptErase.doErase(), InternalFailure);
}
diff --git a/src/test/erase/pattern_test.cpp b/src/test/erase/pattern_test.cpp
index 0693163..e8ea6ce 100644
--- a/src/test/erase/pattern_test.cpp
+++ b/src/test/erase/pattern_test.cpp
@@ -166,8 +166,8 @@
size_t shortSize = 128;
Pattern tryPattern(testFileName);
auto shortData = std::vector<std::byte>(shortSize, std::byte{0});
- auto restOfData =
- std::vector<std::byte>(size - shortSize * 3, std::byte{0});
+ auto restOfData = std::vector<std::byte>(size - shortSize * 3,
+ std::byte{0});
std::span shortDataSpan{shortData};
std::span restOfDataSpan{restOfData};
// open the file and write none to it
diff --git a/src/test/erase/zero_test.cpp b/src/test/erase/zero_test.cpp
index 8570154..f57cd62 100644
--- a/src/test/erase/zero_test.cpp
+++ b/src/test/erase/zero_test.cpp
@@ -126,8 +126,8 @@
size_t shortSize = 128;
Zero pass(testFileName);
auto shortData = std::vector<std::byte>(shortSize, std::byte{0});
- auto restOfData =
- std::vector<std::byte>(size - shortSize * 3, std::byte{0});
+ auto restOfData = std::vector<std::byte>(size - shortSize * 3,
+ std::byte{0});
std::span shortDataSpan{shortData};
std::span restOfDataSpan{restOfData};
stdplus::fd::FdMock mock;
@@ -159,8 +159,8 @@
size_t shortSize = 128;
Zero tryZero(testFileName);
auto shortData = std::vector<std::byte>(shortSize, std::byte{0});
- auto restOfData =
- std::vector<std::byte>(size - shortSize * 3, std::byte{0});
+ auto restOfData = std::vector<std::byte>(size - shortSize * 3,
+ std::byte{0});
std::span shortDataSpan{shortData};
std::span restOfDataSpan{restOfData};
// open the file and write none zero to it
diff --git a/src/test/util_test.cpp b/src/test/util_test.cpp
index 5f16068..b85fca0 100644
--- a/src/test/util_test.cpp
+++ b/src/test/util_test.cpp
@@ -31,7 +31,6 @@
TEST(utilTest, estimatesSame)
{
-
std::string prefixName = ".";
std::string testFileName = prefixName + "/life_time";
std::ofstream testFile;
@@ -46,7 +45,6 @@
TEST(utilTest, estimatesNotAvailable)
{
-
std::string prefixName = ".";
std::string testFileName = prefixName + "/life_time";
std::ofstream testFile;
diff --git a/src/util.cpp b/src/util.cpp
index b971646..8aad066 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -174,7 +174,7 @@
}
/* Look for the eMMC in the specified searchDir directory. */
- for (auto const& dirEntry : std::filesystem::directory_iterator{searchDir})
+ for (const auto& dirEntry : std::filesystem::directory_iterator{searchDir})
{
/*
* We will look at the 'type' file to determine if this is an MMC