Skip to content

Commit

Permalink
Restyled by clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
restyled-commits committed Jan 17, 2022
1 parent 09c9d01 commit 6ddeb63
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 35 deletions.
40 changes: 20 additions & 20 deletions examples/common/tracing/TraceHandlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;
Expand All @@ -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<NodeId> & sourceNodeId = packetHeader->GetSourceNodeId();
const Optional<NodeId> & destNodeId = packetHeader->GetDestinationNodeId();
const Optional<GroupId> & groupId = packetHeader->GetDestinationGroupId();
uint16_t sessionId = packetHeader->GetSessionId();
uint8_t messageFlags = packetHeader->GetMessageFlags();
uint8_t securityFlags = packetHeader->GetSecurityFlags();
const Optional<NodeId> & destNodeId = packetHeader->GetDestinationNodeId();
const Optional<GroupId> & 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));

Expand Down Expand Up @@ -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<uint32_t> & 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;

Expand All @@ -208,7 +208,7 @@ bool SecureMessageSentHandler(const TraceEventFields & eventFields, TraceHandler
}

const auto * eventData = reinterpret_cast<const TraceSecureMessageSentData *>(eventFields.dataBuffer);
std::string jsonBody = "{";
std::string jsonBody = "{";
jsonBody += PacketHeaderToJson(eventData->packetHeader);
jsonBody += ", ";
jsonBody += PayloadHeaderToJson(eventData->payloadHeader);
Expand All @@ -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();

Expand Down Expand Up @@ -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();

Expand All @@ -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);
}
Expand Down
13 changes: 4 additions & 9 deletions examples/common/tracing/TraceHandlers.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class TraceStreamLog : public TraceStream
public:
void StartEvent(const std::string & label) override
{
mStreamLine = ">>>" + label + "<<<\t";
mStreamLine = ">>>" + label + "<<<\t";
mIsFirstField = true;
}

Expand All @@ -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;
Expand Down Expand Up @@ -84,10 +82,7 @@ class TraceStreamFile : public TraceStream
}
}

void FinishEvent() override
{

}
void FinishEvent() override {}

private:
std::ofstream mFile;
Expand Down
2 changes: 1 addition & 1 deletion examples/platform/linux/pw_trace_chip/trace.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void TraceEvent(const char * module, const char * label, TraceEventType eventTyp
void RegisterTraceHandler(TraceHandlerCallback callback, void * context)
{
std::lock_guard<std::mutex> guard(handlerLock);
traceHandlers.push_back(TraceHandlerEntry{callback, context});
traceHandlers.push_back(TraceHandlerEntry{ callback, context });
}

void UnregisterAllTraceHandlers()
Expand Down
2 changes: 1 addition & 1 deletion src/transport/SessionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <inttypes.h>
#include <string.h>

#include "transport/TraceMessage.h"
#include <app/util/basic-types.h>
#include <credentials/GroupDataProvider.h>
#include <lib/core/CHIPKeyIds.h>
Expand All @@ -40,7 +41,6 @@
#include <transport/GroupSession.h>
#include <transport/PairingSession.h>
#include <transport/SecureMessageCodec.h>
#include "transport/TraceMessage.h"
#include <transport/TransportMgr.h>

#include <inttypes.h>
Expand Down
8 changes: 4 additions & 4 deletions src/transport/TraceMessage.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<const void *>(&_trace_data), sizeof(_trace_data)); \
} while (0)
Expand All @@ -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
Expand Down

0 comments on commit 6ddeb63

Please sign in to comment.