From 1ce1262521f87e4ff0adfba92af271745ae5a236 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Tue, 31 Oct 2023 06:10:02 +0000 Subject: [PATCH] Restyled by clang-format --- .../diagnostic-logs-provider-delegate-impl.h | 4 +-- .../all-clusters-app/linux/AppOptions.cpp | 11 ++++--- .../all-clusters-app/linux/main-common.cpp | 1 - .../bdx/DiagnosticLogsBDXTransferHandler.cpp | 12 +++---- .../bdx/DiagnosticLogsBDXTransferHandler.h | 5 ++- .../diagnostic-logs-server.cpp | 13 ++++---- .../diagnostic-logs-server.h | 3 +- src/darwin/Framework/CHIP/MTRDevice.mm | 31 ++++++++----------- .../CHIP/MTRDiagnosticLogsTransferHandler.mm | 17 +++++----- 9 files changed, 45 insertions(+), 52 deletions(-) diff --git a/examples/all-clusters-app/all-clusters-common/include/diagnostic-logs-provider-delegate-impl.h b/examples/all-clusters-app/all-clusters-common/include/diagnostic-logs-provider-delegate-impl.h index 85dc68eeb79bb6..f39b5dfc595fa3 100644 --- a/examples/all-clusters-app/all-clusters-common/include/diagnostic-logs-provider-delegate-impl.h +++ b/examples/all-clusters-app/all-clusters-common/include/diagnostic-logs-provider-delegate-impl.h @@ -52,9 +52,9 @@ class LogProvider : public LogProviderDelegate void SetCrashLogFileDesignator(const char * logFileName); - LogProvider() { }; + LogProvider(){}; - ~LogProvider() { }; + ~LogProvider(){}; static inline LogProvider & getLogProvider() { return sInstance; } diff --git a/examples/all-clusters-app/linux/AppOptions.cpp b/examples/all-clusters-app/linux/AppOptions.cpp index 734b75e2ed0e4b..ee79f7a0e1c0cd 100644 --- a/examples/all-clusters-app/linux/AppOptions.cpp +++ b/examples/all-clusters-app/linux/AppOptions.cpp @@ -18,9 +18,9 @@ #include "AppOptions.h" +#include #include #include -#include using namespace chip::ArgParser; using namespace chip::app::Clusters::DiagnosticLogs; @@ -59,7 +59,8 @@ bool AppOptions::HandleOptions(const char * program, OptionSet * options, int id ChipLogError(BDX, "kOptionEndUserSupportFilePath setting end user fd"); if (strlen(value) > kLogFileDesignatorMaxLen) { - PrintArgError("%s: Invalid file path length. Must be less that %d: %d\n", program, kLogFileDesignatorMaxLen, strlen(value)); + PrintArgError("%s: Invalid file path length. Must be less that %d: %d\n", program, kLogFileDesignatorMaxLen, + strlen(value)); } strncpy(mEndUserSupportLogFileDesignator, value, strlen(value)); break; @@ -67,7 +68,8 @@ bool AppOptions::HandleOptions(const char * program, OptionSet * options, int id case kOptionNetworkDiagnosticsFilePath: { if (strlen(value) > kLogFileDesignatorMaxLen) { - PrintArgError("%s: Invalid file path length. Must be less that %d: %d\n", program, kLogFileDesignatorMaxLen, strlen(value)); + PrintArgError("%s: Invalid file path length. Must be less that %d: %d\n", program, kLogFileDesignatorMaxLen, + strlen(value)); } strncpy(mNetworkDiagnosticsLogFileDesignator, value, strlen(value)); break; @@ -75,7 +77,8 @@ bool AppOptions::HandleOptions(const char * program, OptionSet * options, int id case kOptionCrashFilePath: { if (strlen(value) > kLogFileDesignatorMaxLen) { - PrintArgError("%s: Invalid file path length. Must be less that %d: %d\n", program, kLogFileDesignatorMaxLen, strlen(value)); + PrintArgError("%s: Invalid file path length. Must be less that %d: %d\n", program, kLogFileDesignatorMaxLen, + strlen(value)); } strncpy(mCrashLogFileDesignator, value, strlen(value)); break; diff --git a/examples/all-clusters-app/linux/main-common.cpp b/examples/all-clusters-app/linux/main-common.cpp index 3b965823119b60..9a8678428d7209 100644 --- a/examples/all-clusters-app/linux/main-common.cpp +++ b/examples/all-clusters-app/linux/main-common.cpp @@ -278,5 +278,4 @@ void emberAfDiagnosticLogsClusterInitCallback(chip::EndpointId endpoint) LogProvider::getLogProvider().SetEndUserSupportLogFileDesignator(AppOptions::GetEndUserSupportLogFileDesignator()); LogProvider::getLogProvider().SetNetworkDiagnosticsLogFileDesignator(AppOptions::GetNetworkDiagnosticsLogFileDesignator()); LogProvider::getLogProvider().SetCrashLogFileDesignator(AppOptions::GetCrashLogFileDesignator()); - } diff --git a/src/app/bdx/DiagnosticLogsBDXTransferHandler.cpp b/src/app/bdx/DiagnosticLogsBDXTransferHandler.cpp index ba82e957260251..dbf96eba804681 100644 --- a/src/app/bdx/DiagnosticLogsBDXTransferHandler.cpp +++ b/src/app/bdx/DiagnosticLogsBDXTransferHandler.cpp @@ -145,8 +145,7 @@ void DiagnosticLogsBDXTransferHandler::HandleTransferSessionOutput(TransferSessi break; } - case TransferSession::OutputEventType::kAcceptReceived: - { + case TransferSession::OutputEventType::kAcceptReceived: { mLogSessionHandle = mDelegate->StartLogCollection(mIntent); if (mLogSessionHandle == kInvalidLogSessionHandle) @@ -160,8 +159,7 @@ void DiagnosticLogsBDXTransferHandler::HandleTransferSessionOutput(TransferSessi DiagnosticLogsServer::Instance().HandleBDXResponse(CHIP_NO_ERROR); } // Fallthrough - case TransferSession::OutputEventType::kAckReceived: - { + case TransferSession::OutputEventType::kAckReceived: { uint16_t blockSize = mTransfer.GetTransferBlockSize(); uint16_t bytesToRead = blockSize; @@ -242,11 +240,11 @@ void DiagnosticLogsBDXTransferHandler::Reset() if (mDelegate != nullptr) { mDelegate->EndLogCollection(mLogSessionHandle); - mDelegate = nullptr; + mDelegate = nullptr; } mLogSessionHandle = kInvalidLogSessionHandle; - mInitialized = false; - mNumBytesSent = 0; + mInitialized = false; + mNumBytesSent = 0; } #endif diff --git a/src/app/bdx/DiagnosticLogsBDXTransferHandler.h b/src/app/bdx/DiagnosticLogsBDXTransferHandler.h index 09e9ed5f72b08b..cce34f5778940f 100644 --- a/src/app/bdx/DiagnosticLogsBDXTransferHandler.h +++ b/src/app/bdx/DiagnosticLogsBDXTransferHandler.h @@ -38,8 +38,8 @@ namespace DiagnosticLogs { class DiagnosticLogsBDXTransferHandler : public chip::bdx::Initiator { public: - DiagnosticLogsBDXTransferHandler() {}; - ~DiagnosticLogsBDXTransferHandler() {}; + DiagnosticLogsBDXTransferHandler(){}; + ~DiagnosticLogsBDXTransferHandler(){}; CHIP_ERROR Init(); @@ -52,7 +52,6 @@ class DiagnosticLogsBDXTransferHandler : public chip::bdx::Initiator void Reset(); private: - void SendNextBlock(MutableByteSpan & buffer); chip::Optional mFabricIndex; diff --git a/src/app/clusters/diagnostic-logs-server/diagnostic-logs-server.cpp b/src/app/clusters/diagnostic-logs-server/diagnostic-logs-server.cpp index e363d3215b3376..489c1956ca4fee 100644 --- a/src/app/clusters/diagnostic-logs-server/diagnostic-logs-server.cpp +++ b/src/app/clusters/diagnostic-logs-server/diagnostic-logs-server.cpp @@ -111,8 +111,8 @@ CHIP_ERROR DiagnosticLogsServer::HandleLogRequestForBDXProtocol(Messaging::Excha VerifyOrReturnError(!(DiagnosticLogs::isLogProviderDelegateNull(logProviderDelegate, endpointId)), CHIP_ERROR_INCORRECT_STATE); - mDiagnosticLogsBDXTransferHandler = new DiagnosticLogsBDXTransferHandler(); - CHIP_ERROR error = mDiagnosticLogsBDXTransferHandler->InitializeTransfer( + mDiagnosticLogsBDXTransferHandler = new DiagnosticLogsBDXTransferHandler(); + CHIP_ERROR error = mDiagnosticLogsBDXTransferHandler->InitializeTransfer( exchangeCtx, scopedPeerNodeId.GetFabricIndex(), scopedPeerNodeId.GetNodeId(), logProviderDelegate, intent, fileDesignator); return error; } @@ -138,7 +138,7 @@ void DiagnosticLogsServer::HandleBDXResponse(CHIP_ERROR error) } else { - SendErrorResponseAndReset(commandHandle, mRequestPath, StatusEnum::kNoLogs); + SendErrorResponseAndReset(commandHandle, mRequestPath, StatusEnum::kNoLogs); } } @@ -148,7 +148,8 @@ void DiagnosticLogsServer::SetAsyncCommandHandleAndPath(CommandHandler * command mRequestPath = commandPath; } -void DiagnosticLogsServer::SendErrorResponseAndReset(chip::app::CommandHandler * commandHandler, chip::app::ConcreteCommandPath path, StatusEnum status) +void DiagnosticLogsServer::SendErrorResponseAndReset(chip::app::CommandHandler * commandHandler, + chip::app::ConcreteCommandPath path, StatusEnum status) { Commands::RetrieveLogsResponse::Type response; if (commandHandler != nullptr) @@ -156,8 +157,8 @@ void DiagnosticLogsServer::SendErrorResponseAndReset(chip::app::CommandHandler * response.status = status; commandHandler->AddResponse(path, response); } - //mDiagnosticLogsBDXTransferHandler->Reset(); - //delete(mDiagnosticLogsBDXTransferHandler); + // mDiagnosticLogsBDXTransferHandler->Reset(); + // delete(mDiagnosticLogsBDXTransferHandler); } #endif diff --git a/src/app/clusters/diagnostic-logs-server/diagnostic-logs-server.h b/src/app/clusters/diagnostic-logs-server/diagnostic-logs-server.h index b248dd88b34506..ffec67fed78bc4 100644 --- a/src/app/clusters/diagnostic-logs-server/diagnostic-logs-server.h +++ b/src/app/clusters/diagnostic-logs-server/diagnostic-logs-server.h @@ -71,7 +71,8 @@ class DiagnosticLogsServer bool IsBDXProtocolRequested(TransferProtocolEnum requestedProtocol); - void SendErrorResponseAndReset(chip::app::CommandHandler * commandHandler, chip::app::ConcreteCommandPath path, StatusEnum status); + void SendErrorResponseAndReset(chip::app::CommandHandler * commandHandler, chip::app::ConcreteCommandPath path, + StatusEnum status); #endif diff --git a/src/darwin/Framework/CHIP/MTRDevice.mm b/src/darwin/Framework/CHIP/MTRDevice.mm index 00a37878cab59d..b9ff6d2ec4023e 100644 --- a/src/darwin/Framework/CHIP/MTRDevice.mm +++ b/src/darwin/Framework/CHIP/MTRDevice.mm @@ -1353,9 +1353,8 @@ - (void)_startTimerForDownload:(NSTimeInterval)timeout dispatch_source_set_event_handler(_timerSource, ^{ dispatch_async(self.queue, ^{ - if (self->_diagnosticLogsTransferHandler != nil) - { - self->_diagnosticLogsTransferHandler->AbortTransfer( chip::bdx::StatusCode::kUnknown); + if (self->_diagnosticLogsTransferHandler != nil) { + self->_diagnosticLogsTransferHandler->AbortTransfer(chip::bdx::StatusCode::kUnknown); } }); dispatch_source_cancel(self->_timerSource); @@ -1398,28 +1397,26 @@ - (bool)_isErrorResponse:(MTRDiagnosticLogsClusterRetrieveLogsResponseParams * _ return (response == nil || (response.status != nil && [response.status intValue] != 0 && [response.status intValue] != 1) || response.logContent.length == 0); } --(void)_invokeCompletion:(void (^)(NSURL * _Nullable logResult, NSError * error))completion - filepath:(NSURL * _Nullable)filepath - queue:(dispatch_queue_t)queue - error:(NSError * _Nullable)error +- (void)_invokeCompletion:(void (^)(NSURL * _Nullable logResult, NSError * error))completion + filepath:(NSURL * _Nullable)filepath + queue:(dispatch_queue_t)queue + error:(NSError * _Nullable)error { - if (self->_diagnosticLogsTransferHandler != nil) - { - delete(self->_diagnosticLogsTransferHandler); + if (self->_diagnosticLogsTransferHandler != nil) { + delete (self->_diagnosticLogsTransferHandler); } dispatch_async(queue, ^{ completion(filepath, error); }); } --(void)_invokeCompletionWithError:(void (^)(NSURL * _Nullable logResult, NSError * error))completion - queue:(dispatch_queue_t)queue - error:(NSError * _Nullable)error +- (void)_invokeCompletionWithError:(void (^)(NSURL * _Nullable logResult, NSError * error))completion + queue:(dispatch_queue_t)queue + error:(NSError * _Nullable)error { [self _invokeCompletion:completion filepath:nil queue:queue error:error]; } - - (void)_downloadLogOfType:(MTRDiagnosticLogType)type timeout:(NSTimeInterval)timeout queue:(dispatch_queue_t)queue @@ -1441,8 +1438,7 @@ - (void)_downloadLogOfType:(MTRDiagnosticLogType)type [self _invokeCompletionWithError:completion queue:queue error:[NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeInvalidState userInfo:nil]]; } - if (self->_diagnosticLogsTransferHandler != nullptr && self->_diagnosticLogsTransferHandler->IsInBDXSession()) - { + if (self->_diagnosticLogsTransferHandler != nullptr && self->_diagnosticLogsTransferHandler->IsInBDXSession()) { [self _invokeCompletionWithError:completion queue:queue error:[NSError errorWithDomain:MTRInteractionErrorDomain code:MTRInteractionErrorCodeBusy userInfo:nil]]; } @@ -1465,8 +1461,7 @@ - (void)_downloadLogOfType:(MTRDiagnosticLogType)type dispatch_async(self.queue, ^{ // Start a timer if a timeout is provided - if (timeout > 0) - { + if (timeout > 0) { [self _startTimerForDownload:timeout]; } diff --git a/src/darwin/Framework/CHIP/MTRDiagnosticLogsTransferHandler.mm b/src/darwin/Framework/CHIP/MTRDiagnosticLogsTransferHandler.mm index 77dce1c90b4bde..c3292b45c89b98 100644 --- a/src/darwin/Framework/CHIP/MTRDiagnosticLogsTransferHandler.mm +++ b/src/darwin/Framework/CHIP/MTRDiagnosticLogsTransferHandler.mm @@ -96,8 +96,7 @@ error = CHIP_ERROR_INTERNAL; } // Notify the MTRDevice via the callback that the BDX transfer has completed with error or success. - if (mCallback) - { + if (mCallback) { mCallback(error != CHIP_NO_ERROR ? NO : YES); } Reset(); @@ -196,23 +195,21 @@ } break; case TransferSession::OutputEventType::kAckEOFReceived: - // Need to call OnTransferSessionEnd(event). Need to fix this and remove isBlockEOFSent. - break; + // Need to call OnTransferSessionEnd(event). Need to fix this and remove isBlockEOFSent. + break; case TransferSession::OutputEventType::kMsgToSend: err = OnMessageToSend(event); - if (event.msgTypeData.HasMessageType(MessageType::BlockAckEOF)) - { + if (event.msgTypeData.HasMessageType(MessageType::BlockAckEOF)) { // TODO: This is a hack for determinin that the Ack EOF is sent before cleaning up. // Need to fix this. isBlockEOFSent = true; } break; case TransferSession::OutputEventType::kNone: - if (isBlockEOFSent) - { + if (isBlockEOFSent) { OnTransferSessionEnd(event); - } - break; + } + break; case TransferSession::OutputEventType::kQueryWithSkipReceived: case TransferSession::OutputEventType::kQueryReceived: case TransferSession::OutputEventType::kAckReceived: