reformat for clang-format-18
Google-Bug-Id: 340631818
Change-Id: I9cbb2e9a18fb3344e25660ea80a5645417d37942
Signed-off-by: Vamsy Krishna Nooney <vamsykn@google.com>
diff --git a/.clang-format b/.clang-format
index 52ac0a1..27681a9 100644
--- a/.clang-format
+++ b/.clang-format
@@ -6,55 +6,62 @@
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
-AllowShortIfStatementsOnASingleLine: false
+AllowShortFunctionsOnASingleLine: Empty
+AllowShortIfStatementsOnASingleLine: Never
+AllowShortLambdasOnASingleLine: true
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: true
BinPackParameters: true
+BitFieldColonSpacing: None
BraceWrapping:
AfterCaseLabel: true
AfterClass: true
AfterControlStatement: true
AfterEnum: true
+ AfterExternBlock: true
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: true
AfterStruct: true
AfterUnion: true
- AfterExternBlock: true
BeforeCatch: true
BeforeElse: true
+ BeforeLambdaBody: false
+ BeforeWhile: false
IndentBraces: false
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
-ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
-PointerAlignment: Left
DisableFormat: false
-ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
-ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
+ForEachMacros:
+ - foreach
+ - Q_FOREACH
+ - BOOST_FOREACH
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^[<"](gtest|gmock)'
@@ -74,9 +81,14 @@
- Regex: '.*'
Priority: 6
IndentCaseLabels: true
+IndentExternBlock: NoIndent
+IndentRequiresClause: true
IndentWidth: 4
IndentWrappedFunctionNames: true
-KeepEmptyLinesAtTheStartOfBlocks: true
+InsertNewlineAtEOF: true
+KeepEmptyLinesAtTheStartOfBlocks: false
+LambdaBodyIndentation: Signature
+LineEnding: LF
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
@@ -84,14 +96,23 @@
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
-PenaltyBreakBeforeFirstCallParameter: 19
+PackConstructorInitializers: BinPack
+PenaltyBreakAssignment: 25
+PenaltyBreakBeforeFirstCallParameter: 50
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
+PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
+PenaltyIndentedWhitespace: 1
+PointerAlignment: Left
+QualifierAlignment: Left
+ReferenceAlignment: Left
ReflowComments: true
-SortIncludes: true
+RequiresClausePosition: OwnLine
+RequiresExpressionIndentation: Keyword
+SortIncludes: CaseSensitive
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
@@ -103,7 +124,7 @@
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
-SpacesInAngles: false
+SpacesInAngles: Never
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
@@ -112,4 +133,3 @@
TabWidth: 4
UseTab: Never
...
-
diff --git a/hello.c b/hello.c
index 05d38cc..9b1286e 100644
--- a/hello.c
+++ b/hello.c
@@ -15,5 +15,4 @@
*/
// Dummy executable needed to work around coverage
-int main()
-{}
+int main() {}
diff --git a/subprojects/flasher/internal/flasher/logging.hpp b/subprojects/flasher/internal/flasher/logging.hpp
index 9a4fe8e..c5f083c 100644
--- a/subprojects/flasher/internal/flasher/logging.hpp
+++ b/subprojects/flasher/internal/flasher/logging.hpp
@@ -37,8 +37,7 @@
switch (0) \
default: \
if ((level > ::flasher::logLevel)) \
- { \
- } \
+ {} \
else \
::stdplus::print(stderr, __VA_ARGS__)
diff --git a/subprojects/flasher/internal/flasher/modutil.hpp b/subprojects/flasher/internal/flasher/modutil.hpp
index af11c6e..572cf51 100644
--- a/subprojects/flasher/internal/flasher/modutil.hpp
+++ b/subprojects/flasher/internal/flasher/modutil.hpp
@@ -30,8 +30,8 @@
std::unordered_map<std::string_view, std::unique_ptr<ModType>>;
template <typename Mod, typename Type, typename... Ts>
-static std::unique_ptr<Mod> openMod(const ModTypeMap<Type>& map,
- const ModArgs& args, Ts&&... ts)
+static std::unique_ptr<Mod>
+ openMod(const ModTypeMap<Type>& map, const ModArgs& args, Ts&&... ts)
{
if (args.arr.empty())
{
diff --git a/subprojects/flasher/internal/flasher/util.hpp b/subprojects/flasher/internal/flasher/util.hpp
index 8512d68..940b133 100644
--- a/subprojects/flasher/internal/flasher/util.hpp
+++ b/subprojects/flasher/internal/flasher/util.hpp
@@ -41,9 +41,9 @@
}
template <typename Func, typename Fd, typename Byte, typename... Args>
-static std::span<Byte> opAt(Func&& func, Fd& fd, size_t& cur_offset,
- std::span<Byte> data, size_t new_offset,
- Args&&... args)
+static std::span<Byte>
+ opAt(Func&& func, Fd& fd, size_t& cur_offset, std::span<Byte> data,
+ size_t new_offset, Args&&... args)
{
if (cur_offset != new_offset)
{
diff --git a/subprojects/flasher/src/device.cpp b/subprojects/flasher/src/device.cpp
index 4711b5e..7f93450 100644
--- a/subprojects/flasher/src/device.cpp
+++ b/subprojects/flasher/src/device.cpp
@@ -159,10 +159,10 @@
std::span<const std::byte> new_data) const
{
auto max = std::min(flash_data.size(), new_data.size());
- return max - shrinkWrite(info.type,
- flash_data.rbegin() + flash_data.size() - max,
- new_data.rbegin() + new_data.size() - max,
- new_data.rend());
+ return max -
+ shrinkWrite(info.type, flash_data.rbegin() + flash_data.size() - max,
+ new_data.rbegin() + new_data.size() - max,
+ new_data.rend());
}
void Device::mockErase(std::span<std::byte> data) const
diff --git a/subprojects/flasher/src/device/mutated.cpp b/subprojects/flasher/src/device/mutated.cpp
index 18475e2..07f4d7e 100644
--- a/subprojects/flasher/src/device/mutated.cpp
+++ b/subprojects/flasher/src/device/mutated.cpp
@@ -33,8 +33,8 @@
return ret;
}
-std::span<const std::byte> Mutated::writeAt(std::span<const std::byte> data,
- size_t offset)
+std::span<const std::byte>
+ Mutated::writeAt(std::span<const std::byte> data, size_t offset)
{
if (buf.size() < data.size())
buf.resize(data.size());
diff --git a/subprojects/flasher/test/device/mutated.cpp b/subprojects/flasher/test/device/mutated.cpp
index dafa3e6..d397698 100644
--- a/subprojects/flasher/test/device/mutated.cpp
+++ b/subprojects/flasher/test/device/mutated.cpp
@@ -37,8 +37,7 @@
class MutatedTest : public testing::Test
{
protected:
- MutatedTest() : dev(Device::Type::Nor, 4, 4), mdev(mut, dev)
- {}
+ MutatedTest() : dev(Device::Type::Nor, 4, 4), mdev(mut, dev) {}
testing::StrictMock<Mock> dev;
mutate::Asymmetric mut;
diff --git a/subprojects/flasher/test/ops/util.hpp b/subprojects/flasher/test/ops/util.hpp
index 9bbd310..96d6e75 100644
--- a/subprojects/flasher/test/ops/util.hpp
+++ b/subprojects/flasher/test/ops/util.hpp
@@ -76,8 +76,7 @@
class OpTest : public testing::Test
{
protected:
- OpTest() : d(fillFileInc(df, 0, 12), Device::Type::Nor, 4)
- {}
+ OpTest() : d(fillFileInc(df, 0, 12), Device::Type::Nor, 4) {}
file::Memory df, f;
Dev d;
diff --git a/subprojects/flashupdate/include/flashupdate/flash.hpp b/subprojects/flashupdate/include/flashupdate/flash.hpp
index 0a88d3f..83cd090 100644
--- a/subprojects/flashupdate/include/flashupdate/flash.hpp
+++ b/subprojects/flashupdate/include/flashupdate/flash.hpp
@@ -99,9 +99,8 @@
* @return pair of device block name and size if valid, std::nullopt
* otherwise.
*/
- virtual std::optional<std::pair<std::string, uint32_t>>
- getFlash(bool primary,
- std::optional<size_t> expectedSize = std::nullopt);
+ virtual std::optional<std::pair<std::string, uint32_t>> getFlash(
+ bool primary, std::optional<size_t> expectedSize = std::nullopt);
/** @brief Find the flash partiion for the Flash update
*
diff --git a/subprojects/flashupdate/include/flashupdate/validator/cr51.hpp b/subprojects/flashupdate/include/flashupdate/validator/cr51.hpp
index cdd5aef..f32ad6c 100644
--- a/subprojects/flashupdate/include/flashupdate/validator/cr51.hpp
+++ b/subprojects/flashupdate/include/flashupdate/validator/cr51.hpp
@@ -50,9 +50,8 @@
*
* @return return the span of the hash
*/
- virtual std::span<const uint8_t>
- hashDescriptor(struct libcr51sign_ctx* ctx,
- std::span<std::byte> imageDescriptor) = 0;
+ virtual std::span<const uint8_t> hashDescriptor(
+ struct libcr51sign_ctx* ctx, std::span<std::byte> imageDescriptor) = 0;
/** @brief Validate the CR51 Sign Descriptor and return the list of image
* regions
diff --git a/subprojects/flashupdate/internal/flashupdate/logging.hpp b/subprojects/flashupdate/internal/flashupdate/logging.hpp
index 14d4570..e2a0d6a 100644
--- a/subprojects/flashupdate/internal/flashupdate/logging.hpp
+++ b/subprojects/flashupdate/internal/flashupdate/logging.hpp
@@ -38,8 +38,7 @@
switch (0) \
default: \
if ((level > ::flashupdate::logLevel)) \
- { \
- } \
+ {} \
else \
::stdplus::println(stderr, "<{}> {}", \
static_cast<u_int8_t>(level), \
diff --git a/subprojects/flashupdate/src/flash.cpp b/subprojects/flashupdate/src/flash.cpp
index 87eb7f9..4eed2a7 100644
--- a/subprojects/flashupdate/src/flash.cpp
+++ b/subprojects/flashupdate/src/flash.cpp
@@ -130,9 +130,8 @@
expectedSize);
}
-std::optional<std::pair<std::string, uint32_t>>
- Flash::getFlash(std::optional<uint8_t> secondary,
- std::optional<size_t> expectedSize)
+std::optional<std::pair<std::string, uint32_t>> Flash::getFlash(
+ std::optional<uint8_t> secondary, std::optional<size_t> expectedSize)
{
auto partition = secondary.has_value() ? config.flash.secondary[*secondary]
: config.flash.primary;
@@ -166,7 +165,7 @@
uint32_t size = std::filesystem::file_size(path);
return std::make_pair(partition.location, size);
}
- catch (std::filesystem::filesystem_error const& e)
+ catch (const std::filesystem::filesystem_error& e)
{
LOG(LogLevel::Error, "failed find the partition: {}", e.what());
return std::nullopt;
diff --git a/subprojects/flashupdate/src/info.cpp b/subprojects/flashupdate/src/info.cpp
index e7c8aa2..d61f80d 100644
--- a/subprojects/flashupdate/src/info.cpp
+++ b/subprojects/flashupdate/src/info.cpp
@@ -69,7 +69,6 @@
nlohmann::json output;
if (args.checkStagedVersion)
{
-
output["Staged Version"] = info.stage.format();
print(output["Staged Version"], args.cleanOutput);
}
@@ -102,9 +101,9 @@
if (args.otherInfo)
{
output["Stage CR51 Descriptor Hash"] =
- bytesToHex(std::span<const uint8_t>(&info.stageDescriptor.hash[0],
- &info.stageDescriptor.hash[0] +
- SHA256_DIGEST_LENGTH));
+ bytesToHex(std::span<const uint8_t>(
+ &info.stageDescriptor.hash[0],
+ &info.stageDescriptor.hash[0] + SHA256_DIGEST_LENGTH));
print(output["Stage CR51 Descriptor Hash"], args.cleanOutput);
}
diff --git a/subprojects/flashupdate/src/ops/write.cpp b/subprojects/flashupdate/src/ops/write.cpp
index e0f2567..1f127de 100644
--- a/subprojects/flashupdate/src/ops/write.cpp
+++ b/subprojects/flashupdate/src/ops/write.cpp
@@ -39,10 +39,9 @@
using stdplus::fd::OpenFlag;
using stdplus::fd::OpenFlags;
-inline void
- writeWithoutValidation(flash::Flash* flashHelper,
- flasher::Reader& inputImage,
- std::span<std::pair<size_t, size_t>> partitions)
+inline void writeWithoutValidation(
+ flash::Flash* flashHelper, flasher::Reader& inputImage,
+ std::span<std::pair<size_t, size_t>> partitions)
{
// Secondary partition only.
auto flash = flashHelper->getFlash(false, inputImage.getSize());
diff --git a/subprojects/flashupdate/src/validator/cr51.cpp b/subprojects/flashupdate/src/validator/cr51.cpp
index eb29261..bdc7d7e 100644
--- a/subprojects/flashupdate/src/validator/cr51.cpp
+++ b/subprojects/flashupdate/src/validator/cr51.cpp
@@ -125,8 +125,8 @@
return LIBCR51SIGN_ERROR_RETRIEVING_STORED_IMAGE_MAUV_DATA;
}
- *size = std::min(maxSize, static_cast<uint32_t>(sizeof(struct image_mauv) +
- denyListSize));
+ *size = std::min(maxSize, static_cast<uint32_t>(
+ sizeof(struct image_mauv) + denyListSize));
return LIBCR51SIGN_SUCCESS;
}
@@ -158,9 +158,8 @@
namespace cr51
{
-std::span<const uint8_t>
- Cr51SignValidatorIpml::hashDescriptor(struct libcr51sign_ctx* ctx,
- std::span<std::byte> imageDescriptor)
+std::span<const uint8_t> Cr51SignValidatorIpml::hashDescriptor(
+ struct libcr51sign_ctx* ctx, std::span<std::byte> imageDescriptor)
{
// Create the HASH of the CR51 descriptor on the firmware
size_t size = 0;
@@ -374,9 +373,9 @@
LOG(LogLevel::Notice, "Passed CR51 Sign Validation");
valid = true;
- regions = std::vector<struct image_region>(&imageRegions.image_regions[0],
- &imageRegions.image_regions[0] +
- imageRegions.region_count);
+ regions = std::vector<struct image_region>(
+ &imageRegions.image_regions[0],
+ &imageRegions.image_regions[0] + imageRegions.region_count);
version = formatImageVersion(context.descriptor);
LOG(LogLevel::Notice, "BIOS Version: {}", version);
@@ -469,8 +468,8 @@
image_type::IMAGE_PROD;
}
-struct image_descriptor Cr51::imageDescriptor(flasher::ModArgs mod,
- uint32_t offset, uint32_t size)
+struct image_descriptor
+ Cr51::imageDescriptor(flasher::ModArgs mod, uint32_t offset, uint32_t size)
{
auto readDev = flasher::openDevice(mod);
std::vector<std::byte> fileIn(size);
diff --git a/subprojects/flashupdate/test/flash.cpp b/subprojects/flashupdate/test/flash.cpp
index 8f515c5..cbaf9cf 100644
--- a/subprojects/flashupdate/test/flash.cpp
+++ b/subprojects/flashupdate/test/flash.cpp
@@ -151,8 +151,9 @@
EXPECT_CALL(flashHelper, findMtdDevice(expectedName))
.WillOnce(Return(expectedDev));
- EXPECT_CALL(flashHelper, readMtdFileText(std::format(
- "/sys/class/mtd/{}/size", expectedDev)))
+ EXPECT_CALL(
+ flashHelper,
+ readMtdFileText(std::format("/sys/class/mtd/{}/size", expectedDev)))
.WillOnce(Return(std::to_string(expectedSize)));
EXPECT_EQ(flash.getFlash(/*primary=*/true),
@@ -167,8 +168,9 @@
EXPECT_CALL(flashHelper, findMtdDevice(expectedName))
.WillOnce(Return(expectedDev));
- EXPECT_CALL(flashHelper, readMtdFileText(std::format(
- "/sys/class/mtd/{}/size", expectedDev)))
+ EXPECT_CALL(
+ flashHelper,
+ readMtdFileText(std::format("/sys/class/mtd/{}/size", expectedDev)))
.WillOnce(Return(std::to_string(expectedSize)));
EXPECT_EQ(flash.getFlash(/*primary=*/false),
diff --git a/subprojects/flashupdate/test/ops/write.cpp b/subprojects/flashupdate/test/ops/write.cpp
index cfda406..6e7bae9 100644
--- a/subprojects/flashupdate/test/ops/write.cpp
+++ b/subprojects/flashupdate/test/ops/write.cpp
@@ -127,7 +127,7 @@
EXPECT_CALL(validatorMockHelper, prodImage())
.WillOnce(Return(false)); // Next image is dev
EXPECT_CALL(validatorMockHelper, isProdImage(_, _, _))
- .WillOnce(Return(true)); // The current image it prod image
+ .WillOnce(Return(true)); // The current image it prod image
EXPECT_CALL(flashMockHelper, getFlash(_, _))
.WillOnce(Return(std::make_pair(createTestDev(), inputData.size())));
@@ -425,9 +425,9 @@
Args args;
args.primary = true;
- args.config.supportedVersion =
- std::vector<Config::SupportedVersion>{Config::SupportedVersion{
- version::Version(version0), version::Version(version1)}};
+ args.config.supportedVersion = std::vector<Config::SupportedVersion>{
+ Config::SupportedVersion{version::Version(version0),
+ version::Version(version1)}};
args.file.emplace(createTestBin());
args.stagingIndex = 0;
std::string filename = CaseTmpDir() + "/write_primary_metadata-XXXXXX";