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: I07372e75f12f406bd0555dd27e249bc7dd0958d4
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/include/cryptsetupInterface.hpp b/include/cryptsetupInterface.hpp
index fb03a8b..4f824cd 100644
--- a/include/cryptsetupInterface.hpp
+++ b/include/cryptsetupInterface.hpp
@@ -63,12 +63,10 @@
*
* @returns allocated key slot number or negative errno otherwise.
*/
- virtual int cryptKeyslotChangeByPassphrase(struct crypt_device* cd,
- int keyslotOld, int keyslotNew,
- const char* passphrase,
- size_t passphraseSize,
- const char* newPassphrase,
- size_t newPassphraseSize) = 0;
+ virtual int cryptKeyslotChangeByPassphrase(
+ struct crypt_device* cd, int keyslotOld, int keyslotNew,
+ const char* passphrase, size_t passphraseSize,
+ const char* newPassphrase, size_t newPassphraseSize) = 0;
/** @brief Wrapper around crypt_keyslot_add_by_volume_key.
* @details Used for mocking purposes.
@@ -83,11 +81,10 @@
*
* @returns allocated key slot number or negative errno otherwise.
*/
- virtual int cryptKeyslotAddByVolumeKey(struct crypt_device* cd, int keyslot,
- const char* volumeKey,
- size_t volumeKeySize,
- const char* passphrase,
- size_t passphraseSize) = 0;
+ virtual int cryptKeyslotAddByVolumeKey(
+ struct crypt_device* cd, int keyslot, const char* volumeKey,
+ size_t volumeKeySize, const char* passphrase,
+ size_t passphraseSize) = 0;
/** @brief Wrapper around crypt_load.
* @details Used for mocking purposes.
@@ -114,11 +111,9 @@
*
* @returns unlocked key slot number or negative errno otherwise.
*/
- virtual int cryptActivateByPassphrase(struct crypt_device* cd,
- const char* name, int keyslot,
- const char* passphrase,
- size_t passphraseSize,
- uint32_t flags) = 0;
+ virtual int cryptActivateByPassphrase(
+ struct crypt_device* cd, const char* name, int keyslot,
+ const char* passphrase, size_t passphraseSize, uint32_t flags) = 0;
/** @brief Wrapper around crypt_deactivate.
* @details Used for mocking purposes.
@@ -159,8 +154,8 @@
*
* @return value defined by crypt_keyslot_info
*/
- virtual crypt_keyslot_info cryptKeySlotStatus(struct crypt_device* cd,
- int keyslot) = 0;
+ virtual crypt_keyslot_info
+ cryptKeySlotStatus(struct crypt_device* cd, int keyslot) = 0;
/** @brief Wrapper around crypt_get_dir.
* @details Used for mocking purposes.
@@ -193,11 +188,10 @@
volumeKeySize, params);
}
- int cryptKeyslotChangeByPassphrase(struct crypt_device* cd, int keyslotOld,
- int keyslotNew, const char* passphrase,
- size_t passphraseSize,
- const char* newPassphrase,
- size_t newPassphraseSize) override
+ int cryptKeyslotChangeByPassphrase(
+ struct crypt_device* cd, int keyslotOld, int keyslotNew,
+ const char* passphrase, size_t passphraseSize,
+ const char* newPassphrase, size_t newPassphraseSize) override
{
return crypt_keyslot_change_by_passphrase(
cd, keyslotOld, keyslotNew, passphrase, passphraseSize,
@@ -219,10 +213,9 @@
return crypt_load(cd, requestedType, params);
}
- int cryptActivateByPassphrase(struct crypt_device* cd, const char* name,
- int keyslot, const char* passphrase,
- size_t passphraseSize,
- uint32_t flags) override
+ int cryptActivateByPassphrase(
+ struct crypt_device* cd, const char* name, int keyslot,
+ const char* passphrase, size_t passphraseSize, uint32_t flags) override
{
return crypt_activate_by_passphrase(cd, name, keyslot, passphrase,
passphraseSize, flags);
diff --git a/include/getConfig.hpp b/include/getConfig.hpp
index 077cdb6..bcb7950 100644
--- a/include/getConfig.hpp
+++ b/include/getConfig.hpp
@@ -39,8 +39,7 @@
GetStorageConfiguration(
std::shared_ptr<sdbusplus::asio::connection> connection,
std::function<void(ManagedStorageType& resp)>&& callbackFunc) :
- dbusConnection(std::move(connection)),
- callback(std::move(callbackFunc))
+ dbusConnection(std::move(connection)), callback(std::move(callbackFunc))
{}
GetStorageConfiguration& operator=(const GetStorageConfiguration&) = delete;
diff --git a/include/sanitize.hpp b/include/sanitize.hpp
index a9ba8e8..48b49aa 100644
--- a/include/sanitize.hpp
+++ b/include/sanitize.hpp
@@ -79,8 +79,7 @@
Sanitize(std::string_view inDevPath,
std::unique_ptr<IOCTLWrapperInterface> inIOCTL =
std::make_unique<IOCTLWrapperImpl>()) :
- Erase(inDevPath),
- ioctlWrapper(std::move(inIOCTL))
+ Erase(inDevPath), ioctlWrapper(std::move(inIOCTL))
{}
/** @brief sanitize the drive, using eMMC specified erase commands
diff --git a/include/util.hpp b/include/util.hpp
index 5f96c0d..a719720 100644
--- a/include/util.hpp
+++ b/include/util.hpp
@@ -26,10 +26,10 @@
std::string& locationCode, uint64_t eraseMaxGeometry,
uint64_t eraseMinGeometry, std::string& driveType,
std::string& driveProtocol) :
- deviceFile(deviceFile),
- sysfsDir(sysfsDir), luksName(luksName), locationCode(locationCode),
- eraseMaxGeometry(eraseMaxGeometry), eraseMinGeometry(eraseMinGeometry),
- driveType(driveType), driveProtocol(driveProtocol)
+ deviceFile(deviceFile), sysfsDir(sysfsDir), luksName(luksName),
+ locationCode(locationCode), eraseMaxGeometry(eraseMaxGeometry),
+ eraseMinGeometry(eraseMinGeometry), driveType(driveType),
+ driveProtocol(driveProtocol)
{}
};
diff --git a/src/erase/cryptoErase.cpp b/src/erase/cryptoErase.cpp
index 08553f7..579370e 100644
--- a/src/erase/cryptoErase.cpp
+++ b/src/erase/cryptoErase.cpp
@@ -19,8 +19,7 @@
CryptErase::CryptErase(
std::string_view devPathIn,
std::unique_ptr<estoraged::CryptsetupInterface> inCryptIface) :
- Erase(devPathIn),
- cryptIface(std::move(inCryptIface))
+ Erase(devPathIn), cryptIface(std::move(inCryptIface))
{}
void CryptErase::doErase()
diff --git a/src/erase/verifyDriveGeometry.cpp b/src/erase/verifyDriveGeometry.cpp
index 359135e..6706a36 100644
--- a/src/erase/verifyDriveGeometry.cpp
+++ b/src/erase/verifyDriveGeometry.cpp
@@ -9,9 +9,8 @@
{
using sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
-void VerifyDriveGeometry::geometryOkay(uint64_t eraseMaxGeometry,
- uint64_t eraseMinGeometry,
- uint64_t bytes)
+void VerifyDriveGeometry::geometryOkay(
+ uint64_t eraseMaxGeometry, uint64_t eraseMinGeometry, uint64_t bytes)
{
if (bytes > eraseMaxGeometry)
{
diff --git a/src/estoraged.cpp b/src/estoraged.cpp
index 6c26e5a..e03fc4d 100644
--- a/src/estoraged.cpp
+++ b/src/estoraged.cpp
@@ -32,28 +32,27 @@
using sdbusplus::xyz::openbmc_project::Inventory::Item::server::Drive;
using sdbusplus::xyz::openbmc_project::Inventory::Item::server::Volume;
-EStoraged::EStoraged(sdbusplus::asio::object_server& server,
- const std::string& configPath, const std::string& devPath,
- const std::string& luksName, uint64_t size,
- uint8_t lifeTime, const std::string& partNumber,
- const std::string& serialNumber,
- const std::string& locationCode, uint64_t eraseMaxGeometry,
- uint64_t eraseMinGeometry, const std::string& driveType,
- const std::string& driveProtocol,
- std::unique_ptr<CryptsetupInterface> cryptInterface,
- std::unique_ptr<FilesystemInterface> fsInterface) :
- devPath(devPath),
- containerName(luksName), mountPoint("/mnt/" + luksName + "_fs"),
- eraseMaxGeometry(eraseMaxGeometry), eraseMinGeometry(eraseMinGeometry),
- cryptIface(std::move(cryptInterface)), fsIface(std::move(fsInterface)),
+EStoraged::EStoraged(
+ sdbusplus::asio::object_server& server, const std::string& configPath,
+ const std::string& devPath, const std::string& luksName, uint64_t size,
+ uint8_t lifeTime, const std::string& partNumber,
+ const std::string& serialNumber, const std::string& locationCode,
+ uint64_t eraseMaxGeometry, uint64_t eraseMinGeometry,
+ const std::string& driveType, const std::string& driveProtocol,
+ std::unique_ptr<CryptsetupInterface> cryptInterface,
+ std::unique_ptr<FilesystemInterface> fsInterface) :
+ devPath(devPath), containerName(luksName),
+ mountPoint("/mnt/" + luksName + "_fs"), eraseMaxGeometry(eraseMaxGeometry),
+ eraseMinGeometry(eraseMinGeometry), cryptIface(std::move(cryptInterface)),
+ fsIface(std::move(fsInterface)),
cryptDevicePath(cryptIface->cryptGetDir() + "/" + luksName),
objectServer(server)
{
/* 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(
@@ -61,8 +60,8 @@
volumeInterface->register_method(
"FormatLuks", [this](const std::vector<uint8_t>& password,
Volume::FilesystemType type) {
- this->formatLuks(password, type);
- });
+ this->formatLuks(password, type);
+ });
volumeInterface->register_method(
"Erase",
[this](Volume::EraseMethod eraseType) { this->erase(eraseType); });
@@ -73,14 +72,14 @@
volumeInterface->register_method(
"ChangePassword", [this](const std::vector<uint8_t>& oldPassword,
const std::vector<uint8_t>& newPassword) {
- this->changePassword(oldPassword, newPassword);
- });
+ this->changePassword(oldPassword, newPassword);
+ });
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. */
driveInterface = objectServer.add_interface(
@@ -99,17 +98,17 @@
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(
objectPath, "xyz.openbmc_project.Inventory.Connector.Embedded");
diff --git a/src/getConfig.cpp b/src/getConfig.cpp
index 563a057..3d2cc5a 100644
--- a/src/getConfig.cpp
+++ b/src/getConfig.cpp
@@ -28,44 +28,43 @@
std::pair<std::string,
std::vector<std::pair<std::string, std::vector<std::string>>>>>;
-void GetStorageConfiguration::getStorageInfo(const std::string& path,
- const std::string& owner,
- size_t retries)
+void GetStorageConfiguration::getStorageInfo(
+ const std::string& path, const std::string& owner, size_t retries)
{
std::shared_ptr<GetStorageConfiguration> self = shared_from_this();
self->dbusConnection->async_method_call(
[self, path, owner, retries](
const boost::system::error_code ec,
boost::container::flat_map<std::string, BasicVariantType>& data) {
- if (ec)
- {
- lg2::error(
- "Error getting properties for {PATH}: {RETRIES} retries left",
- "PATH", path, "RETRIES", retries - 1, "REDFISH_MESSAGE_ID",
- std::string("OpenBMC.0.1.GetStorageInfoFail"));
- if (retries == 0U)
+ if (ec)
{
+ lg2::error(
+ "Error getting properties for {PATH}: {RETRIES} retries left",
+ "PATH", path, "RETRIES", retries - 1, "REDFISH_MESSAGE_ID",
+ std::string("OpenBMC.0.1.GetStorageInfoFail"));
+ if (retries == 0U)
+ {
+ return;
+ }
+
+ auto timer = std::make_shared<boost::asio::steady_timer>(
+ self->dbusConnection->get_io_context());
+ timer->expires_after(std::chrono::seconds(10));
+ timer->async_wait([self, timer, path, owner,
+ retries](boost::system::error_code ec) {
+ if (ec)
+ {
+ lg2::error("Timer error!");
+ return;
+ }
+ self->getStorageInfo(path, owner, retries - 1);
+ });
+
return;
}
- auto timer = std::make_shared<boost::asio::steady_timer>(
- self->dbusConnection->get_io_context());
- timer->expires_after(std::chrono::seconds(10));
- timer->async_wait([self, timer, path, owner,
- retries](boost::system::error_code ec) {
- if (ec)
- {
- lg2::error("Timer error!");
- return;
- }
- self->getStorageInfo(path, owner, retries - 1);
- });
-
- return;
- }
-
- self->respData[path] = std::move(data);
- },
+ self->respData[path] = std::move(data);
+ },
owner, path, "org.freedesktop.DBus.Properties", "GetAll",
emmcConfigInterface);
}
@@ -75,29 +74,29 @@
std::shared_ptr<GetStorageConfiguration> self = shared_from_this();
dbusConnection->async_method_call(
[self](const boost::system::error_code ec, const GetSubTreeType& ret) {
- if (ec)
- {
- lg2::error("Error calling mapper");
- return;
- }
- for (const auto& [objPath, objDict] : ret)
- {
- if (objDict.empty())
+ if (ec)
{
+ lg2::error("Error calling mapper");
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)
+ for (const auto& [objPath, objDict] : ret)
{
- if (interface.compare(emmcConfigInterface) == 0)
+ if (objDict.empty())
{
- /* Get the properties exposed by this interface. */
- self->getStorageInfo(objPath, objOwner);
+ 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);
+ }
}
}
- }
- },
+ },
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 6d92ecf..5f4be19 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -41,76 +41,83 @@
dbusConnection,
[&objectServer, &storageObjects](
const estoraged::ManagedStorageType& storageConfigurations) {
- 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())
+ size_t numConfigObj = storageConfigurations.size();
+ if (numConfigObj > 1)
{
- /*
- * We've already created this object, or at least
- * attempted to.
- */
- continue;
+ lg2::error(
+ "eStoraged can only manage 1 eMMC device; found {NUM}",
+ "NUM", numConfigObj, "REDFISH_MESSAGE_ID",
+ std::string("OpenBMC.0.1.CreateStorageObjectsFail"));
+ return;
}
- /* 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"};
- auto deviceInfo = estoraged::util::findDevice(data, blockDevDir);
- if (!deviceInfo)
+ for (const std::pair<sdbusplus::message::object_path,
+ estoraged::StorageData>& storage :
+ storageConfigurations)
{
- 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;
+ 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"};
+ auto deviceInfo =
+ estoraged::util::findDevice(data, blockDevDir);
+ if (!deviceInfo)
+ {
+ 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;
+ }
+
+ std::filesystem::path deviceFile =
+ std::move(deviceInfo->deviceFile);
+ std::filesystem::path sysfsDir =
+ std::move(deviceInfo->sysfsDir);
+ std::string luksName = std::move(deviceInfo->luksName);
+ std::string locationCode = std::move(deviceInfo->locationCode);
+ uint64_t eraseMaxGeometry = deviceInfo->eraseMaxGeometry;
+ uint64_t eraseMinGeometry = deviceInfo->eraseMinGeometry;
+
+ 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);
+ const std::string& driveType = deviceInfo->driveType;
+ const std::string& driveProtocol = deviceInfo->driveProtocol;
+ /* Create the storage object. */
+ storageObjects[path] = std::make_unique<estoraged::EStoraged>(
+ objectServer, path, deviceFile, luksName, size, lifeleft,
+ partNumber, serialNumber, locationCode, eraseMaxGeometry,
+ eraseMinGeometry, driveType, driveProtocol);
+ lg2::info("Created eStoraged object for path {PATH}", "PATH",
+ path, "REDFISH_MESSAGE_ID",
+ std::string("OpenBMC.0.1.CreateStorageObjects"));
}
-
- std::filesystem::path deviceFile =
- std::move(deviceInfo->deviceFile);
- std::filesystem::path sysfsDir = std::move(deviceInfo->sysfsDir);
- std::string luksName = std::move(deviceInfo->luksName);
- std::string locationCode = std::move(deviceInfo->locationCode);
- uint64_t eraseMaxGeometry = deviceInfo->eraseMaxGeometry;
- uint64_t eraseMinGeometry = deviceInfo->eraseMinGeometry;
-
- 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);
- const std::string& driveType = deviceInfo->driveType;
- const std::string& driveProtocol = deviceInfo->driveProtocol;
- /* Create the storage object. */
- storageObjects[path] = std::make_unique<estoraged::EStoraged>(
- objectServer, path, deviceFile, luksName, size, lifeleft,
- partNumber, serialNumber, locationCode, eraseMaxGeometry,
- eraseMinGeometry, driveType, driveProtocol);
- lg2::info("Created eStoraged object for path {PATH}", "PATH", path,
- "REDFISH_MESSAGE_ID",
- std::string("OpenBMC.0.1.CreateStorageObjects"));
- }
- });
+ });
getter->getConfiguration();
}
@@ -128,8 +135,9 @@
std::unique_ptr<estoraged::EStoraged>>
storageObjects;
- boost::asio::post(
- io, [&]() { createStorageObjects(server, storageObjects, conn); });
+ boost::asio::post(io, [&]() {
+ createStorageObjects(server, storageObjects, conn);
+ });
/*
* Set up an event handler to process any new configuration objects
@@ -138,33 +146,34 @@
boost::asio::deadline_timer filterTimer(io);
std::function<void(sdbusplus::message_t&)> eventHandler =
[&](sdbusplus::message_t& message) {
- 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));
+ 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)
- {
- /* we were canceled */
- return;
- }
- if (ec)
- {
- lg2::error("timer error");
- return;
- }
- createStorageObjects(server, storageObjects, conn);
- });
- };
+ 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);
+ });
+ };
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 030f6bb..909e54d 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,
- std::move(mockCryptIface));
+ CryptErase myCryptErase =
+ CryptErase(testFileName, 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,
- std::move(mockCryptIface));
+ CryptErase myCryptErase =
+ CryptErase(testFileName, 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,
- std::move(mockCryptIface));
+ CryptErase myCryptErase =
+ CryptErase(testFileName, 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,
- std::move(mockCryptIface));
+ CryptErase myCryptErase =
+ CryptErase(testFileName, std::move(mockCryptIface));
EXPECT_NO_THROW(myCryptErase.doErase());
}
@@ -136,8 +136,8 @@
EXPECT_CALL(*mockCryptIface, cryptKeyslotDestroy(_, 0))
.WillOnce(Return(-1));
- CryptErase myCryptErase = CryptErase(testFileName,
- std::move(mockCryptIface));
+ CryptErase myCryptErase =
+ CryptErase(testFileName, 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 bccbd37..6a475d5 100644
--- a/src/test/erase/pattern_test.cpp
+++ b/src/test/erase/pattern_test.cpp
@@ -112,41 +112,47 @@
// test write pattern with short blocks
EXPECT_CALL(mock, write(_))
.WillOnce(Invoke([](std::span<const std::byte> x) {
- std::copy_n(x.begin(), shortData1.size(), shortData1.begin());
- return shortData1;
- })).RetiresOnSaturation();
+ std::copy_n(x.begin(), shortData1.size(), shortData1.begin());
+ return shortData1;
+ }))
+ .RetiresOnSaturation();
EXPECT_CALL(mock, write(_))
.WillOnce(Invoke([](std::span<const std::byte> x) {
- std::copy_n(x.begin(), restOfData.size(), restOfData.begin());
- return restOfData;
- })).RetiresOnSaturation();
+ std::copy_n(x.begin(), restOfData.size(), restOfData.begin());
+ return restOfData;
+ }))
+ .RetiresOnSaturation();
EXPECT_CALL(mock, write(_))
.WillOnce(Invoke([](std::span<const std::byte> x) {
- std::copy_n(x.begin(), shortData2.size(), shortData2.begin());
- return shortData2;
- })).RetiresOnSaturation();
+ std::copy_n(x.begin(), shortData2.size(), shortData2.begin());
+ return shortData2;
+ }))
+ .RetiresOnSaturation();
// test read pattern
EXPECT_CALL(mock, read(_))
.WillOnce(Invoke([](std::span<std::byte> x) {
- std::copy_n(shortData1.begin(), shortData1.size(), x.data());
- std::span ret(shortData1);
- return ret;
- })).RetiresOnSaturation();
+ std::copy_n(shortData1.begin(), shortData1.size(), x.data());
+ std::span ret(shortData1);
+ return ret;
+ }))
+ .RetiresOnSaturation();
EXPECT_CALL(mock, read(_))
.WillOnce(Invoke([](std::span<std::byte> x) {
- std::copy_n(restOfData.begin(), restOfData.size(), x.data());
- std::span ret(restOfData);
- return ret;
- })).RetiresOnSaturation();
+ std::copy_n(restOfData.begin(), restOfData.size(), x.data());
+ std::span ret(restOfData);
+ return ret;
+ }))
+ .RetiresOnSaturation();
EXPECT_CALL(mock, read(_))
.WillOnce(Invoke([](std::span<std::byte> x) {
- std::copy_n(shortData2.begin(), shortData2.size(), x.data());
- std::span ret(shortData2);
- return ret;
- })).RetiresOnSaturation();
+ std::copy_n(shortData2.begin(), shortData2.size(), x.data());
+ std::span ret(shortData2);
+ return ret;
+ }))
+ .RetiresOnSaturation();
EXPECT_NO_THROW(pass.writePattern(size, mock));
EXPECT_NO_THROW(pass.verifyPattern(size, mock));
@@ -160,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 ee9dd50..a681d6d 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 e2fdcc3..2736777 100644
--- a/src/test/util_test.cpp
+++ b/src/test/util_test.cpp
@@ -132,8 +132,8 @@
/* Look for the device file. */
std::filesystem::path deviceFile, sysfsDir;
std::string luksName, locationCode;
- auto result = estoraged::util::findDevice(data,
- std::filesystem::path("./"));
+ auto result =
+ estoraged::util::findDevice(data, std::filesystem::path("./"));
EXPECT_TRUE(result.has_value());
/* Validate the results. */
@@ -190,8 +190,8 @@
/* Look for the device file. */
std::filesystem::path deviceFile, sysfsDir;
std::string luksName, locationCode;
- auto result = estoraged::util::findDevice(data,
- std::filesystem::path("./"));
+ auto result =
+ estoraged::util::findDevice(data, std::filesystem::path("./"));
EXPECT_TRUE(result.has_value());
/* Validate the results. */
@@ -237,8 +237,8 @@
typeFile.close();
/* Look for the device file. */
- auto result = estoraged::util::findDevice(data,
- std::filesystem::path("./"));
+ auto result =
+ estoraged::util::findDevice(data, std::filesystem::path("./"));
EXPECT_FALSE(result.has_value());
/* Delete the dummy files. */
@@ -276,8 +276,8 @@
typeFile.close();
/* Look for the device file. */
- auto result = estoraged::util::findDevice(data,
- std::filesystem::path("./"));
+ auto result =
+ estoraged::util::findDevice(data, std::filesystem::path("./"));
EXPECT_FALSE(result.has_value());
/* Delete the dummy files. */
@@ -308,8 +308,8 @@
std::filesystem::create_directories("def/device");
/* Look for the device file. */
- auto result = estoraged::util::findDevice(data,
- std::filesystem::path("./"));
+ auto result =
+ estoraged::util::findDevice(data, std::filesystem::path("./"));
EXPECT_FALSE(result.has_value());
/* Delete the dummy files. */