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: I133f4f43d4955ba1b86b924fc741aa5a56f34239
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/libbej/bej_dictionary.h b/include/libbej/bej_dictionary.h
index b22404d..81d77dc 100644
--- a/include/libbej/bej_dictionary.h
+++ b/include/libbej/bej_dictionary.h
@@ -109,11 +109,10 @@
* pointer if this is not needed.
* @return 0 if successful.
*/
-int bejDictGetPropertyByName(const uint8_t* dictionary,
- uint16_t startingPropertyOffset,
- const char* propertyName,
- const struct BejDictionaryProperty** property,
- uint16_t* propertyOffset);
+int bejDictGetPropertyByName(
+ const uint8_t* dictionary, uint16_t startingPropertyOffset,
+ const char* propertyName, const struct BejDictionaryProperty** property,
+ uint16_t* propertyOffset);
#ifdef __cplusplus
}
diff --git a/src/bej_decoder_core.c b/src/bej_decoder_core.c
index fe6dad6..09a9430 100644
--- a/src/bej_decoder_core.c
+++ b/src/bej_decoder_core.c
@@ -75,8 +75,8 @@
// Number of bytes need to represent the value length.
const uint8_t valueLengthSize = *(enSegment + valueLenNnintOffset);
// Start of the Value.
- const uint32_t valueOffset = valueLenNnintOffset + sizeof(uint8_t) +
- valueLengthSize;
+ const uint32_t valueOffset =
+ valueLenNnintOffset + sizeof(uint8_t) + valueLengthSize;
offsets->formatOffset = formatOffset;
offsets->valueLenNnintOffset = valueLenNnintOffset;
@@ -150,11 +150,10 @@
* property in a dictionary.
* @return 0 if successful.
*/
-static int
- bejGetDictionaryAndProperty(const struct BejHandleTypeFuncParam* params,
- uint8_t schemaType, uint32_t sequenceNumber,
- const uint8_t** dictionary,
- const struct BejDictionaryProperty** prop)
+static int bejGetDictionaryAndProperty(
+ const struct BejHandleTypeFuncParam* params, uint8_t schemaType,
+ uint32_t sequenceNumber, const uint8_t** dictionary,
+ const struct BejDictionaryProperty** prop)
{
uint16_t dictPropOffset;
// We need to pick the correct dictionary.
@@ -175,8 +174,8 @@
return bejErrorInvalidSchemaType;
}
- int ret = bejDictGetProperty(*dictionary, dictPropOffset, sequenceNumber,
- prop);
+ int ret =
+ bejDictGetProperty(*dictionary, dictPropOffset, sequenceNumber, prop);
if (ret != 0)
{
fprintf(stderr, "Failed to get dictionary property for offset: %u\n",
@@ -580,11 +579,11 @@
// nnint - Length of exp
// bejInteger - exp (includes sign for the exponent)
uint8_t wholeByteLen = (uint8_t)bejGetNnint(params->sflv.value);
- const uint8_t* wholeBejInt = params->sflv.value +
- bejGetNnintSize(params->sflv.value);
+ const uint8_t* wholeBejInt =
+ params->sflv.value + bejGetNnintSize(params->sflv.value);
const uint8_t* fractZeroCountNnint = wholeBejInt + wholeByteLen;
- const uint8_t* fractNnint = fractZeroCountNnint +
- bejGetNnintSize(fractZeroCountNnint);
+ const uint8_t* fractNnint =
+ fractZeroCountNnint + bejGetNnintSize(fractZeroCountNnint);
const uint8_t* lenExpNnint = fractNnint + bejGetNnintSize(fractNnint);
const uint8_t* expBejInt = lenExpNnint + bejGetNnintSize(lenExpNnint);
@@ -669,8 +668,8 @@
// We might have to change this for nested annotations.
params->state.mainDictPropOffset = outerProp->childPointerOffset;
// Point to the start of the value for next decoding.
- params->state.encodedStreamOffset = params->sflv.valueEndOffset -
- params->sflv.valueLength;
+ params->state.encodedStreamOffset =
+ params->sflv.valueEndOffset - params->sflv.valueLength;
return 0;
}
@@ -723,8 +722,8 @@
while (params.state.encodedStreamOffset < streamLen)
{
// Go to the next encoded segment in the encoded stream.
- params.state.encodedSubStream = enStream +
- params.state.encodedStreamOffset;
+ params.state.encodedSubStream =
+ enStream + params.state.encodedStreamOffset;
bejInitSFLVStruct(¶ms);
if (params.sflv.format.readOnlyProperty)
diff --git a/src/bej_decoder_json.cpp b/src/bej_decoder_json.cpp
index f6624c7..5f8ddac 100644
--- a/src/bej_decoder_json.cpp
+++ b/src/bej_decoder_json.cpp
@@ -367,10 +367,10 @@
.output = &output,
};
- return bejDecodePldmBlock(&dictionaries, encodedPldmBlock.data(),
- encodedPldmBlock.size_bytes(), &stackCallback,
- &decodedCallback, (void*)(&callbackData),
- (void*)(&stack));
+ return bejDecodePldmBlock(
+ &dictionaries, encodedPldmBlock.data(), encodedPldmBlock.size_bytes(),
+ &stackCallback, &decodedCallback, (void*)(&callbackData),
+ (void*)(&stack));
}
std::string BejDecoderJson::getOutput()
diff --git a/src/bej_dictionary.c b/src/bej_dictionary.c
index b4d99ae..c0481b3 100644
--- a/src/bej_dictionary.c
+++ b/src/bej_dictionary.c
@@ -114,11 +114,10 @@
return (const char*)(dictionary + nameOffset);
}
-int bejDictGetPropertyByName(const uint8_t* dictionary,
- uint16_t startingPropertyOffset,
- const char* propertyName,
- const struct BejDictionaryProperty** property,
- uint16_t* propertyOffset)
+int bejDictGetPropertyByName(
+ const uint8_t* dictionary, uint16_t startingPropertyOffset,
+ const char* propertyName, const struct BejDictionaryProperty** property,
+ uint16_t* propertyOffset)
{
NULL_CHECK(property, "property in bejDictGetPropertyByName");
diff --git a/src/bej_encoder_metadata.c b/src/bej_encoder_metadata.c
index 5e5ce23..76f78c3 100644
--- a/src/bej_encoder_metadata.c
+++ b/src/bej_encoder_metadata.c
@@ -58,10 +58,9 @@
* doesn't have a name.
* @return a pointer to the dictionary to be used.
*/
-static const uint8_t*
- bejGetRelatedDictionary(const struct BejDictionaries* dictionaries,
- const uint8_t* parentDictionary,
- const char* nodeName)
+static const uint8_t* bejGetRelatedDictionary(
+ const struct BejDictionaries* dictionaries, const uint8_t* parentDictionary,
+ const char* nodeName)
{
// If the node name is NULL, we have to use parent dictionary.
if (nodeName == NULL)
@@ -206,11 +205,10 @@
return 0;
}
-static int bejUpdateStringMetaData(const struct BejDictionaries* dictionaries,
- const uint8_t* parentDictionary,
- struct RedfishPropertyLeafString* node,
- uint16_t nodeIndex,
- uint16_t dictStartingOffset)
+static int bejUpdateStringMetaData(
+ const struct BejDictionaries* dictionaries, const uint8_t* parentDictionary,
+ struct RedfishPropertyLeafString* node, uint16_t nodeIndex,
+ uint16_t dictStartingOffset)
{
uint32_t sequenceNumber;
RETURN_IF_IERROR(bejFindSeqNumAndChildDictOffset(
@@ -232,11 +230,10 @@
return 0;
}
-static int bejUpdateRealMetaData(const struct BejDictionaries* dictionaries,
- const uint8_t* parentDictionary,
- struct RedfishPropertyLeafReal* node,
- uint16_t nodeIndex,
- uint16_t dictStartingOffset)
+static int bejUpdateRealMetaData(
+ const struct BejDictionaries* dictionaries, const uint8_t* parentDictionary,
+ struct RedfishPropertyLeafReal* node, uint16_t nodeIndex,
+ uint16_t dictStartingOffset)
{
uint32_t sequenceNumber;
RETURN_IF_IERROR(bejFindSeqNumAndChildDictOffset(
@@ -313,11 +310,10 @@
return 0;
}
-static int bejUpdateEnumMetaData(const struct BejDictionaries* dictionaries,
- const uint8_t* parentDictionary,
- struct RedfishPropertyLeafEnum* node,
- uint16_t nodeIndex,
- uint16_t dictStartingOffset)
+static int bejUpdateEnumMetaData(
+ const struct BejDictionaries* dictionaries, const uint8_t* parentDictionary,
+ struct RedfishPropertyLeafEnum* node, uint16_t nodeIndex,
+ uint16_t dictStartingOffset)
{
const uint8_t* nodeDictionary;
uint16_t childEntryOffset;
@@ -366,11 +362,10 @@
return 0;
}
-static int bejUpdateBoolMetaData(const struct BejDictionaries* dictionaries,
- const uint8_t* parentDictionary,
- struct RedfishPropertyLeafBool* node,
- uint16_t nodeIndex,
- uint16_t dictStartingOffset)
+static int bejUpdateBoolMetaData(
+ const struct BejDictionaries* dictionaries, const uint8_t* parentDictionary,
+ struct RedfishPropertyLeafBool* node, uint16_t nodeIndex,
+ uint16_t dictStartingOffset)
{
uint32_t sequenceNumber;
RETURN_IF_IERROR(bejFindSeqNumAndChildDictOffset(
@@ -390,11 +385,10 @@
return 0;
}
-static int bejUpdateNullMetaData(const struct BejDictionaries* dictionaries,
- const uint8_t* parentDictionary,
- struct RedfishPropertyLeafNull* node,
- uint16_t nodeIndex,
- uint16_t dictStartingOffset)
+static int bejUpdateNullMetaData(
+ const struct BejDictionaries* dictionaries, const uint8_t* parentDictionary,
+ struct RedfishPropertyLeafNull* node, uint16_t nodeIndex,
+ uint16_t dictStartingOffset)
{
uint32_t sequenceNumber;
RETURN_IF_IERROR(bejFindSeqNumAndChildDictOffset(
@@ -426,10 +420,9 @@
* node's parent.
* @return 0 if successful.
*/
-static int bejUpdateLeafNodeMetaData(const struct BejDictionaries* dictionaries,
- const uint8_t* parentDictionary,
- void* childPtr, uint16_t childIndex,
- uint16_t dictStartingOffset)
+static int bejUpdateLeafNodeMetaData(
+ const struct BejDictionaries* dictionaries, const uint8_t* parentDictionary,
+ void* childPtr, uint16_t childIndex, uint16_t dictStartingOffset)
{
struct RedfishPropertyLeaf* chNode = childPtr;
@@ -484,11 +477,10 @@
* @param nodeIndex - If this node is an array element, this is the array index.
* @return 0 if successful.
*/
-static int bejUpdateParentMetaData(const struct BejDictionaries* dictionaries,
- const uint8_t* parentDictionary,
- uint16_t dictStartingOffset,
- struct RedfishPropertyParent* node,
- uint16_t nodeIndex)
+static int bejUpdateParentMetaData(
+ const struct BejDictionaries* dictionaries, const uint8_t* parentDictionary,
+ uint16_t dictStartingOffset, struct RedfishPropertyParent* node,
+ uint16_t nodeIndex)
{
const uint8_t* nodeDictionary;
uint16_t childEntryOffset;
@@ -557,10 +549,10 @@
return 0;
}
- RETURN_IF_IERROR(
- bejUpdateLeafNodeMetaData(dictionaries, parent->metaData.dictionary,
- childPtr, parent->metaData.nextChildIndex,
- parent->metaData.childrenDictPropOffset));
+ RETURN_IF_IERROR(bejUpdateLeafNodeMetaData(
+ dictionaries, parent->metaData.dictionary, childPtr,
+ parent->metaData.nextChildIndex,
+ parent->metaData.childrenDictPropOffset));
// Use the child value size to update the parent value size.
struct RedfishPropertyLeaf* leafChild = childPtr;
// V: Include the child size in parent's value size.
diff --git a/test/bej_decoder_test.cpp b/test/bej_decoder_test.cpp
index 16cd19a..2aa9f0e 100644
--- a/test/bej_decoder_test.cpp
+++ b/test/bej_decoder_test.cpp
@@ -91,7 +91,7 @@
{"DummySimple", dummySimpleTestFiles},
}),
[](const testing::TestParamInfo<BejDecoderTest::ParamType>& info) {
- return info.param.testName;
-});
+ return info.param.testName;
+ });
} // namespace libbej
diff --git a/test/bej_dictionary_test.cpp b/test/bej_dictionary_test.cpp
index 0591f7d..60b2d03 100644
--- a/test/bej_dictionary_test.cpp
+++ b/test/bej_dictionary_test.cpp
@@ -85,10 +85,10 @@
std::get<1>(propertyNameSeq[index]),
&property),
0);
- EXPECT_THAT(bejDictGetPropertyName(dummySimpleDict.data(),
- property->nameOffset,
- property->nameLength),
- std::get<0>(propertyNameSeq[index]));
+ EXPECT_THAT(
+ bejDictGetPropertyName(dummySimpleDict.data(), property->nameOffset,
+ property->nameLength),
+ std::get<0>(propertyNameSeq[index]));
}
}
diff --git a/test/bej_encoder_test.cpp b/test/bej_encoder_test.cpp
index d258b4b..c1d6de6 100644
--- a/test/bej_encoder_test.cpp
+++ b/test/bej_encoder_test.cpp
@@ -261,11 +261,10 @@
bejTreeLinkChildToParent(parent, linkSet);
}
-void redfishCreateArrayOfLinksJson(struct RedfishPropertyParent* parent,
- const char* arrayName, int linkCount,
- const char* const links[],
- struct RedfishArrayOfLinksJson* linksInfo,
- struct RedfishLinkJson* linkJsonArray)
+void redfishCreateArrayOfLinksJson(
+ struct RedfishPropertyParent* parent, const char* arrayName, int linkCount,
+ const char* const links[], struct RedfishArrayOfLinksJson* linksInfo,
+ struct RedfishLinkJson* linkJsonArray)
{
bejTreeInitArray(&linksInfo->array, arrayName);
bejTreeLinkChildToParent(parent, &linksInfo->array);
@@ -436,7 +435,7 @@
{"Chassis", chassisTestFiles, "", &createChassisResource},
}),
[](const testing::TestParamInfo<BejEncoderTest::ParamType>& info) {
- return info.param.testName;
-});
+ return info.param.testName;
+ });
} // namespace libbej