From 6ddeb6307dc2d5da8da34abe092d74bbcb151fdf Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Mon, 17 Jan 2022 20:23:58 +0000 Subject: [PATCH] Restyled by clang-format --- examples/common/tracing/TraceHandlers.cpp | 40 +++++++++---------- examples/common/tracing/TraceHandlers.h | 13 ++---- .../platform/linux/pw_trace_chip/trace.cc | 2 +- src/transport/SessionManager.cpp | 2 +- src/transport/TraceMessage.h | 8 ++-- 5 files changed, 30 insertions(+), 35 deletions(-) diff --git a/examples/common/tracing/TraceHandlers.cpp b/examples/common/tracing/TraceHandlers.cpp index 63c58b47574e82..91ced7be09efef 100644 --- a/examples/common/tracing/TraceHandlers.cpp +++ b/examples/common/tracing/TraceHandlers.cpp @@ -101,12 +101,12 @@ std::string AsJsonKey(const std::string & key, const std::string & value, bool p std::string AsFirstJsonKey(const std::string & key, const std::string & value) { - return AsJsonKey(key, value, /* prepend_comma = */false); + return AsJsonKey(key, value, /* prepend_comma = */ false); } std::string AsNextJsonKey(const std::string & key, const std::string & value) { - return AsJsonKey(key, value, /* prepend_comma = */true); + return AsJsonKey(key, value, /* prepend_comma = */ true); } std::string AsJsonString(const std::string & value) @@ -116,7 +116,7 @@ std::string AsJsonString(const std::string & value) std::string AsJsonString(const Transport::PeerAddress * peerAddress) { - char convBuf[Transport::PeerAddress::kMaxToStringSize] = {0}; + char convBuf[Transport::PeerAddress::kMaxToStringSize] = { 0 }; peerAddress->ToString(convBuf); return convBuf; @@ -141,13 +141,13 @@ std::string PacketHeaderToJson(const PacketHeader * packetHeader) { std::string jsonBody; - uint32_t messageCounter = packetHeader->GetMessageCounter(); + uint32_t messageCounter = packetHeader->GetMessageCounter(); const Optional & sourceNodeId = packetHeader->GetSourceNodeId(); - const Optional & destNodeId = packetHeader->GetDestinationNodeId(); - const Optional & groupId = packetHeader->GetDestinationGroupId(); - uint16_t sessionId = packetHeader->GetSessionId(); - uint8_t messageFlags = packetHeader->GetMessageFlags(); - uint8_t securityFlags = packetHeader->GetSecurityFlags(); + const Optional & destNodeId = packetHeader->GetDestinationNodeId(); + const Optional & groupId = packetHeader->GetDestinationGroupId(); + uint16_t sessionId = packetHeader->GetSessionId(); + uint8_t messageFlags = packetHeader->GetMessageFlags(); + uint8_t securityFlags = packetHeader->GetSecurityFlags(); jsonBody += AsFirstJsonKey("msg_counter", std::to_string(messageCounter)); @@ -175,13 +175,13 @@ std::string PacketHeaderToJson(const PacketHeader * packetHeader) std::string PayloadHeaderToJson(const PayloadHeader * payloadHeader) { - uint16_t exchangeId = payloadHeader->GetExchangeID(); - uint32_t protocolId = payloadHeader->GetProtocolID().ToFullyQualifiedSpecForm(); - uint8_t protocolOpcode = payloadHeader->GetMessageType(); + uint16_t exchangeId = payloadHeader->GetExchangeID(); + uint32_t protocolId = payloadHeader->GetProtocolID().ToFullyQualifiedSpecForm(); + uint8_t protocolOpcode = payloadHeader->GetMessageType(); const Optional & acknowledgedMessageCounter = payloadHeader->GetAckMessageCounter(); - bool isInitiator = payloadHeader->IsInitiator(); - bool needsAck = payloadHeader->NeedsAck(); - uint8_t exchangeFlags = payloadHeader->GetExhangeFlags(); + bool isInitiator = payloadHeader->IsInitiator(); + bool needsAck = payloadHeader->NeedsAck(); + uint8_t exchangeFlags = payloadHeader->GetExhangeFlags(); std::string jsonBody; @@ -208,7 +208,7 @@ bool SecureMessageSentHandler(const TraceEventFields & eventFields, TraceHandler } const auto * eventData = reinterpret_cast(eventFields.dataBuffer); - std::string jsonBody = "{"; + std::string jsonBody = "{"; jsonBody += PacketHeaderToJson(eventData->packetHeader); jsonBody += ", "; jsonBody += PayloadHeaderToJson(eventData->payloadHeader); @@ -219,7 +219,7 @@ bool SecureMessageSentHandler(const TraceEventFields & eventFields, TraceHandler jsonBody += "}"; TraceOutput * sink = context->sink; - sink->StartEvent(std::string{kTraceMessageEvent} + "." + kTraceMessageSentDataFormat); + sink->StartEvent(std::string{ kTraceMessageEvent } + "." + kTraceMessageSentDataFormat); sink->AddField("json", jsonBody); sink->FinishEvent(); @@ -248,7 +248,7 @@ bool SecureMessageReceivedHandler(const TraceEventFields & eventFields, TraceHan jsonBody += "}"; TraceOutput * sink = context->sink; - sink->StartEvent(std::string{kTraceMessageEvent} + "." + kTraceMessageReceivedDataFormat); + sink->StartEvent(std::string{ kTraceMessageEvent } + "." + kTraceMessageReceivedDataFormat); sink->AddField("json", jsonBody); sink->FinishEvent(); @@ -266,11 +266,11 @@ bool TraceDefaultHandler(const TraceEventFields & eventFields, void * context) return false; } - if (std::string{eventFields.dataFormat} == kTraceMessageSentDataFormat) + if (std::string{ eventFields.dataFormat } == kTraceMessageSentDataFormat) { return SecureMessageSentHandler(eventFields, ourContext); } - else if (std::string{eventFields.dataFormat} == kTraceMessageReceivedDataFormat) + else if (std::string{ eventFields.dataFormat } == kTraceMessageReceivedDataFormat) { return SecureMessageReceivedHandler(eventFields, ourContext); } diff --git a/examples/common/tracing/TraceHandlers.h b/examples/common/tracing/TraceHandlers.h index ed27f83d2c7226..fb60e3e4db316d 100644 --- a/examples/common/tracing/TraceHandlers.h +++ b/examples/common/tracing/TraceHandlers.h @@ -39,7 +39,7 @@ class TraceStreamLog : public TraceStream public: void StartEvent(const std::string & label) override { - mStreamLine = ">>>" + label + "<<<\t"; + mStreamLine = ">>>" + label + "<<<\t"; mIsFirstField = true; } @@ -49,10 +49,8 @@ class TraceStreamLog : public TraceStream mIsFirstField = false; } - void FinishEvent() override - { - ChipLogAutomation("TraceStream:%s", mStreamLine.c_str()); - } + void FinishEvent() override { ChipLogAutomation("TraceStream:%s", mStreamLine.c_str()); } + protected: std::string mStreamLine; bool mIsFirstField = true; @@ -84,10 +82,7 @@ class TraceStreamFile : public TraceStream } } - void FinishEvent() override - { - - } + void FinishEvent() override {} private: std::ofstream mFile; diff --git a/examples/platform/linux/pw_trace_chip/trace.cc b/examples/platform/linux/pw_trace_chip/trace.cc index 7ab1c414abab01..bf005c518933fd 100644 --- a/examples/platform/linux/pw_trace_chip/trace.cc +++ b/examples/platform/linux/pw_trace_chip/trace.cc @@ -58,7 +58,7 @@ void TraceEvent(const char * module, const char * label, TraceEventType eventTyp void RegisterTraceHandler(TraceHandlerCallback callback, void * context) { std::lock_guard guard(handlerLock); - traceHandlers.push_back(TraceHandlerEntry{callback, context}); + traceHandlers.push_back(TraceHandlerEntry{ callback, context }); } void UnregisterAllTraceHandlers() diff --git a/src/transport/SessionManager.cpp b/src/transport/SessionManager.cpp index 15ca283d0685b9..2aca1cdcaf8445 100644 --- a/src/transport/SessionManager.cpp +++ b/src/transport/SessionManager.cpp @@ -29,6 +29,7 @@ #include #include +#include "transport/TraceMessage.h" #include #include #include @@ -40,7 +41,6 @@ #include #include #include -#include "transport/TraceMessage.h" #include #include diff --git a/src/transport/TraceMessage.h b/src/transport/TraceMessage.h index 6524d54f7503f8..0863bf0cc9cec8 100644 --- a/src/transport/TraceMessage.h +++ b/src/transport/TraceMessage.h @@ -37,8 +37,8 @@ #define CHIP_TRACE_MESSAGE_RECEIVED(payloadHeader, packetHeader, session, peerAddress, data, dataLen) \ do \ { \ - const ::chip::trace::TraceSecureMessageReceivedData _trace_data { \ - &payloadHeader, &packetHeader, session, &peerAddress, data, dataLen }; \ + const ::chip::trace::TraceSecureMessageReceivedData _trace_data{ &payloadHeader, &packetHeader, session, \ + &peerAddress, data, dataLen }; \ PW_TRACE_INSTANT_DATA("SecureMsg", ::chip::trace::kTraceMessageReceivedDataFormat, \ reinterpret_cast(&_trace_data), sizeof(_trace_data)); \ } while (0) @@ -59,8 +59,8 @@ namespace chip { namespace trace { -constexpr const char * kTraceMessageEvent = "SecureMsg"; -constexpr const char * kTraceMessageSentDataFormat = "SecMsgSent"; +constexpr const char * kTraceMessageEvent = "SecureMsg"; +constexpr const char * kTraceMessageSentDataFormat = "SecMsgSent"; constexpr const char * kTraceMessageReceivedDataFormat = "SecMsgReceived"; struct TraceSecureMessageSentData