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: I28d013e312a5f3f7d5d3331e4c98feee86b514f5
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/slp_message_handler.cpp b/slp_message_handler.cpp
index 20f0358..0535f4b 100644
--- a/slp_message_handler.cpp
+++ b/slp_message_handler.cpp
@@ -92,17 +92,17 @@
bool firstIteration = true;
for_each(svcList.cbegin(), svcList.cend(),
[&service, &firstIteration](const auto& svc) {
- if (firstIteration == true)
- {
- service = svc.first;
- firstIteration = false;
- }
- else
- {
- service += ",";
- service += svc.first;
- }
- });
+ if (firstIteration == true)
+ {
+ service = svc.first;
+ firstIteration = false;
+ }
+ else
+ {
+ service += ",";
+ service += svc.first;
+ }
+ });
buff = prepareHeader(req);
@@ -226,12 +226,12 @@
auto pos = slp::response::OFFSET_URL_ENTRY + slp::response::SIZE_URL_COUNT;
for (const auto& addr : ifaddrList)
{
- std::string url = svc.name + ':' + svc.type + "//" + addr + ',' +
- svc.port;
+ std::string url =
+ svc.name + ':' + svc.type + "//" + addr + ',' + svc.port;
// See if total response size exceeds our max
- uint32_t totalLength = buff.size() + slp::response::SIZE_URL_ENTRY +
- url.length();
+ uint32_t totalLength =
+ buff.size() + slp::response::SIZE_URL_ENTRY + url.length();
if (totalLength > slp::MAX_LEN)
{
std::cerr << "Message response size exceeds maximum allowed: "
@@ -287,8 +287,9 @@
return addrList;
}
- slp::deleted_unique_ptr<ifaddrs> ifaddrPtr(
- ifaddr, [](ifaddrs* addr) { freeifaddrs(addr); });
+ slp::deleted_unique_ptr<ifaddrs> ifaddrPtr(ifaddr, [](ifaddrs* addr) {
+ freeifaddrs(addr);
+ });
ifaddr = nullptr;
@@ -370,8 +371,8 @@
switch (msg.header.functionID)
{
case (uint8_t)slp::FunctionType::SRVTYPERQST:
- std::tie(rc,
- resp) = slp::handler::internal::processSrvTypeRequest(msg);
+ std::tie(rc, resp) =
+ slp::handler::internal::processSrvTypeRequest(msg);
break;
case (uint8_t)slp::FunctionType::SRVRQST:
std::tie(rc, resp) = slp::handler::internal::processSrvRequest(msg);
diff --git a/slp_server.hpp b/slp_server.hpp
index dd96cfe..b18db28 100644
--- a/slp_server.hpp
+++ b/slp_server.hpp
@@ -24,9 +24,9 @@
class Server
{
public:
- Server() : Server(slp::PORT, nullptr){};
+ Server() : Server(slp::PORT, nullptr) {};
- Server(uint16_t port, sd_event_io_handler_t cb) : port(port), callme(cb){};
+ Server(uint16_t port, sd_event_io_handler_t cb) : port(port), callme(cb) {};
Server(const Server&) = delete;
Server& operator=(const Server&) = delete;
diff --git a/slp_service_info.hpp b/slp_service_info.hpp
index a67fde6..de7ec45 100644
--- a/slp_service_info.hpp
+++ b/slp_service_info.hpp
@@ -27,8 +27,8 @@
delimtrPos = line.find(DELIMITER, delimtrPrevPos);
while (delimtrPos != std::string::npos)
{
- tokens[count] = line.substr(delimtrPrevPos,
- (delimtrPos - delimtrPrevPos));
+ tokens[count] =
+ line.substr(delimtrPrevPos, (delimtrPos - delimtrPrevPos));
delimtrPrevPos = delimtrPos + 1;
delimtrPos = line.find(DELIMITER, delimtrPrevPos);