diff --git a/src/access/examples/ExampleAccessControlDelegate.cpp b/src/access/examples/ExampleAccessControlDelegate.cpp index 95c659a493c155..6d9b5595994ee4 100644 --- a/src/access/examples/ExampleAccessControlDelegate.cpp +++ b/src/access/examples/ExampleAccessControlDelegate.cpp @@ -870,7 +870,7 @@ class EntryDelegate : public Entry::Delegate { return CHIP_NO_ERROR; } - else if (auto * storage = EntryStorage::Find(nullptr)) + if (auto * storage = EntryStorage::Find(nullptr)) { *storage = *mStorage; mStorage = storage; diff --git a/src/app/AttributePathExpandIterator.cpp b/src/app/AttributePathExpandIterator.cpp index 0d893c5886a98a..235d45185a2dee 100644 --- a/src/app/AttributePathExpandIterator.cpp +++ b/src/app/AttributePathExpandIterator.cpp @@ -205,7 +205,7 @@ bool AttributePathExpandIterator::Next() // Return true will skip the increment of mClusterIndex, mEndpointIndex and mpClusterInfo. return true; } - else if (mGlobalAttributeIndex < mGlobalAttributeEndIndex) + if (mGlobalAttributeIndex < mGlobalAttributeEndIndex) { // Return a path pointing to the next global attribute. mOutputPath.mAttributeId = GlobalAttributesNotInMetadata[mGlobalAttributeIndex]; diff --git a/src/app/ChunkedWriteCallback.cpp b/src/app/ChunkedWriteCallback.cpp index af5215627b0b26..ffef2641ed1653 100644 --- a/src/app/ChunkedWriteCallback.cpp +++ b/src/app/ChunkedWriteCallback.cpp @@ -38,11 +38,9 @@ void ChunkedWriteCallback::OnResponse(const WriteClient * apWriteClient, const C } return; } - else - { - // This is a response to another attribute write. Report the final result of last attribute write. - callback->OnResponse(apWriteClient, mLastAttributePath.Value(), mAttributeStatus); - } + + // This is a response to another attribute write. Report the final result of last attribute write. + callback->OnResponse(apWriteClient, mLastAttributePath.Value(), mAttributeStatus); } // This is the first report for a new attribute. We assume it will never be a list item operation. diff --git a/src/app/CommandHandler.cpp b/src/app/CommandHandler.cpp index 56f60e1fbd9d1e..0532f0852f6b0b 100644 --- a/src/app/CommandHandler.cpp +++ b/src/app/CommandHandler.cpp @@ -546,10 +546,8 @@ TLV::TLVWriter * CommandHandler::GetCommandDataIBTLVWriter() { return nullptr; } - else - { - return mInvokeResponseBuilder.GetInvokeResponses().GetInvokeResponse().GetCommand().GetWriter(); - } + + return mInvokeResponseBuilder.GetInvokeResponses().GetInvokeResponse().GetCommand().GetWriter(); } FabricIndex CommandHandler::GetAccessingFabricIndex() const diff --git a/src/app/CommandSender.cpp b/src/app/CommandSender.cpp index 05b183d59211e1..24c97e3eb8b69c 100644 --- a/src/app/CommandSender.cpp +++ b/src/app/CommandSender.cpp @@ -372,10 +372,8 @@ TLV::TLVWriter * CommandSender::GetCommandDataIBTLVWriter() { return nullptr; } - else - { - return mInvokeRequestBuilder.GetInvokeRequests().GetCommandData().GetWriter(); - } + + return mInvokeRequestBuilder.GetInvokeRequests().GetCommandData().GetWriter(); } CHIP_ERROR CommandSender::HandleTimedStatus(const PayloadHeader & aPayloadHeader, System::PacketBufferHandle && aPayload) diff --git a/src/app/EventManagement.cpp b/src/app/EventManagement.cpp index a48d790f01d631..1adb330321a2d9 100644 --- a/src/app/EventManagement.cpp +++ b/src/app/EventManagement.cpp @@ -399,7 +399,7 @@ CHIP_ERROR EventManagement::CopyAndAdjustDeltaTime(const TLVReader & aReader, si // Does not go on the wire. return CHIP_NO_ERROR; } - else if ((aReader.GetTag() == TLV::ContextTag(to_underlying(EventDataIB::Tag::kSystemTimestamp))) && !(ctx->mpContext->mFirst)) + if ((aReader.GetTag() == TLV::ContextTag(to_underlying(EventDataIB::Tag::kSystemTimestamp))) && !(ctx->mpContext->mFirst)) { return ctx->mpWriter->Put(TLV::ContextTag(to_underlying(EventDataIB::Tag::kDeltaSystemTimestamp)), ctx->mpContext->mCurrentTime.mValue - ctx->mpContext->mPreviousTime.mValue); @@ -501,12 +501,10 @@ CHIP_ERROR EventManagement::LogEventPrivate(EventLoggingDelegate * apDelegate, c { break; } - else - { - buffer = buffer->GetNextCircularEventBuffer(); - assert(buffer != nullptr); - // code guarantees that every PriorityLevel has a buffer destination. - } + + buffer = buffer->GetNextCircularEventBuffer(); + assert(buffer != nullptr); + // code guarantees that every PriorityLevel has a buffer destination. } mBytesWritten += writer.GetLengthWritten(); diff --git a/src/app/ReadClient.cpp b/src/app/ReadClient.cpp index 0595d9bb1e1674..4966a71c93d131 100644 --- a/src/app/ReadClient.cpp +++ b/src/app/ReadClient.cpp @@ -904,12 +904,11 @@ bool ReadClient::ResubscribeIfNeeded() ChipLogProgress(DataManagement, "Fail to resubscribe with error %" CHIP_ERROR_FORMAT, err.Format()); return false; } - else - { - ChipLogProgress(DataManagement, - "Will try to Resubscribe to %02x:" ChipLogFormatX64 " at retry index %" PRIu32 " after %" PRIu32 "ms", - mFabricIndex, ChipLogValueX64(mPeerNodeId), mNumRetries, intervalMsec); - } + + ChipLogProgress(DataManagement, + "Will try to Resubscribe to %02x:" ChipLogFormatX64 " at retry index %" PRIu32 " after %" PRIu32 "ms", + mFabricIndex, ChipLogValueX64(mPeerNodeId), mNumRetries, intervalMsec); + return true; } diff --git a/src/app/WriteClient.cpp b/src/app/WriteClient.cpp index 2a162a5291b079..e8f3490b896142 100644 --- a/src/app/WriteClient.cpp +++ b/src/app/WriteClient.cpp @@ -322,10 +322,8 @@ CHIP_ERROR WriteClient::PutPreencodedAttribute(const ConcreteDataAttributePath & } return err; } - else // We are writing a non-list attribute, or we are writing a single element of a list. - { - return PutSinglePreencodedAttributeWritePayload(attributePath, data); - } + // We are writing a non-list attribute, or we are writing a single element of a list. + return PutSinglePreencodedAttributeWritePayload(attributePath, data); } const char * WriteClient::GetStateStr() const diff --git a/src/app/WriteClient.h b/src/app/WriteClient.h index 92b6e98d7f9793..eec72a5f12f0ab 100644 --- a/src/app/WriteClient.h +++ b/src/app/WriteClient.h @@ -196,10 +196,8 @@ class WriteClient : public Messaging::ExchangeDelegate attributePath.mClusterId, attributePath.mAttributeId, aDataVersion), value); } - else - { - return EncodeAttribute(attributePath, value.Value()); - } + + return EncodeAttribute(attributePath, value.Value()); } /** diff --git a/src/app/data-model/DecodableList.h b/src/app/data-model/DecodableList.h index a620f0ad36d7b9..d06332ab84f8a5 100644 --- a/src/app/data-model/DecodableList.h +++ b/src/app/data-model/DecodableList.h @@ -134,10 +134,8 @@ class DecodableList { return CHIP_NO_ERROR; } - else - { - return mStatus; - } + + return mStatus; } private: @@ -194,10 +192,8 @@ class DecodableList *size = 0; return CHIP_NO_ERROR; } - else - { - return mReader.CountRemainingInContainer(size); - } + + return mReader.CountRemainingInContainer(size); } CHIP_ERROR Decode(TLV::TLVReader & reader) diff --git a/src/app/reporting/Engine.cpp b/src/app/reporting/Engine.cpp index 1e4f7eb9942404..557f6f185ae5d7 100644 --- a/src/app/reporting/Engine.cpp +++ b/src/app/reporting/Engine.cpp @@ -763,10 +763,9 @@ CHIP_ERROR Engine::ScheduleEventDelivery(ConcreteEventPath & aPath, uint32_t aBy ChipLogDetail(DataManagement, "urgent event schedule run"); return ScheduleRun(); } - else - { - return ScheduleBufferPressureEventDelivery(aBytesWritten); - } + + return ScheduleBufferPressureEventDelivery(aBytesWritten); + return CHIP_NO_ERROR; } diff --git a/src/app/server/Server.h b/src/app/server/Server.h index e108629c87f694..0b717ce7cca056 100644 --- a/src/app/server/Server.h +++ b/src/app/server/Server.h @@ -122,11 +122,9 @@ class Server { return CHIP_ERROR_INVALID_ARGUMENT; } - else - { - // When size is zero, let's give a non-nullptr to the KVS backend - buffer = &emptyPlaceholder; - } + + // When size is zero, let's give a non-nullptr to the KVS backend + buffer = &emptyPlaceholder; } size_t bytesRead = 0; diff --git a/src/app/tests/suites/pics/PICSBooleanExpressionParser.cpp b/src/app/tests/suites/pics/PICSBooleanExpressionParser.cpp index 7de152f876313d..c8df5aff939f46 100644 --- a/src/app/tests/suites/pics/PICSBooleanExpressionParser.cpp +++ b/src/app/tests/suites/pics/PICSBooleanExpressionParser.cpp @@ -115,17 +115,15 @@ bool PICSBooleanExpressionParser::EvaluateExpression(std::vector & bool rightExpr = EvaluateExpression(tokens, PICS, index); return leftExpr && rightExpr; } - else if (token == "||") + if (token == "||") { index++; bool rightExpr = EvaluateExpression(tokens, PICS, index); return leftExpr || rightExpr; } - else - { - ChipLogError(chipTool, "Unknown token: '%s'", token.c_str()); - chipDie(); - } + + ChipLogError(chipTool, "Unknown token: '%s'", token.c_str()); + chipDie(); } bool PICSBooleanExpressionParser::EvaluateSubExpression(std::vector & tokens, std::map & PICS, @@ -145,23 +143,21 @@ bool PICSBooleanExpressionParser::EvaluateSubExpression(std::vector index++; return expr; } - else if (token == "!") + if (token == "!") { index++; bool expr = EvaluateSubExpression(tokens, PICS, index); return !expr; } - else - { - index++; - if (PICS.find(token) == PICS.end()) - { - // By default, let's consider that if a PICS item is not defined, it is |false|. - // It allows to create a file that only contains enabled features. - return false; - } + index++; - return PICS[token]; + if (PICS.find(token) == PICS.end()) + { + // By default, let's consider that if a PICS item is not defined, it is |false|. + // It allows to create a file that only contains enabled features. + return false; } + + return PICS[token]; } diff --git a/src/app/util/af-event.cpp b/src/app/util/af-event.cpp index 59b69ed18bacee..0ced20d5af59aa 100644 --- a/src/app/util/af-event.cpp +++ b/src/app/util/af-event.cpp @@ -195,10 +195,8 @@ EmberStatus emberAfEventControlSetDelayQS(EmberEventControl * control, uint32_t { return emberEventControlSetDelayMS(control, delayQs << 8); } - else - { - return EMBER_BAD_ARGUMENT; - } + + return EMBER_BAD_ARGUMENT; } EmberStatus emberAfEventControlSetDelayMinutes(EmberEventControl * control, uint16_t delayM) @@ -207,10 +205,8 @@ EmberStatus emberAfEventControlSetDelayMinutes(EmberEventControl * control, uint { return emberEventControlSetDelayMS(control, static_cast(delayM) << 16); } - else - { - return EMBER_BAD_ARGUMENT; - } + + return EMBER_BAD_ARGUMENT; } EmberStatus emberAfScheduleTickExtended(EndpointId endpoint, ClusterId clusterId, bool isClient, uint32_t delayMs, diff --git a/src/app/util/attribute-storage.cpp b/src/app/util/attribute-storage.cpp index bd439ad25823f3..8340282cedf51a 100644 --- a/src/app/util/attribute-storage.cpp +++ b/src/app/util/attribute-storage.cpp @@ -370,19 +370,17 @@ EmberAfStatus emAfClusterPreAttributeChangedCallback(const app::ConcreteAttribut { return EMBER_ZCL_STATUS_UNSUPPORTED_ATTRIBUTE; } - else + + EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; + // Casting and calling a function pointer on the same line results in ignoring the return + // of the call on gcc-arm-none-eabi-9-2019-q4-major + EmberAfClusterPreAttributeChangedCallback f = (EmberAfClusterPreAttributeChangedCallback)( + emberAfFindClusterFunction(cluster, CLUSTER_MASK_PRE_ATTRIBUTE_CHANGED_FUNCTION)); + if (f != NULL) { - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; - // Casting and calling a function pointer on the same line results in ignoring the return - // of the call on gcc-arm-none-eabi-9-2019-q4-major - EmberAfClusterPreAttributeChangedCallback f = (EmberAfClusterPreAttributeChangedCallback)( - emberAfFindClusterFunction(cluster, CLUSTER_MASK_PRE_ATTRIBUTE_CHANGED_FUNCTION)); - if (f != NULL) - { - status = f(attributePath, attributeType, size, value); - } - return status; + status = f(attributePath, attributeType, size, value); } + return status; } static void initializeEndpoint(EmberAfDefinedEndpoint * definedEndpoint) @@ -623,17 +621,15 @@ EmberAfStatus emAfReadOrWriteAttribute(EmberAfAttributeSearchRecord * attRecord, : emberAfExternalAttributeReadCallback(attRecord->endpoint, attRecord->clusterId, am, buffer, emberAfAttributeSize(am))); } + + // Internal storage is only supported for fixed endpoints + if (!isDynamicEndpoint) + { + return typeSensitiveMemCopy(attRecord->clusterId, dst, src, am, write, readLength); + } else { - // Internal storage is only supported for fixed endpoints - if (!isDynamicEndpoint) - { - return typeSensitiveMemCopy(attRecord->clusterId, dst, src, am, write, readLength); - } - else - { - return EMBER_ZCL_STATUS_FAILURE; - } + return EMBER_ZCL_STATUS_FAILURE; } } } @@ -750,10 +746,8 @@ bool emberAfContainsServerFromIndex(uint16_t index, ClusterId clusterId) { return false; } - else - { - return emberAfFindClusterInType(emAfEndpoints[index].endpointType, clusterId, CLUSTER_MASK_SERVER); - } + + return emberAfFindClusterInType(emAfEndpoints[index].endpointType, clusterId, CLUSTER_MASK_SERVER); } namespace chip { @@ -797,10 +791,8 @@ const EmberAfCluster * emberAfFindCluster(EndpointId endpoint, ClusterId cluster { return NULL; } - else - { - return emberAfFindClusterInType(emAfEndpoints[ep].endpointType, clusterId, mask); - } + + return emberAfFindClusterInType(emAfEndpoints[ep].endpointType, clusterId, mask); } // Returns cluster within the endpoint; Does not ignore disabled endpoints diff --git a/src/app/util/binding-table.cpp b/src/app/util/binding-table.cpp index ea15e94e68b497..d92df75454461a 100644 --- a/src/app/util/binding-table.cpp +++ b/src/app/util/binding-table.cpp @@ -64,23 +64,21 @@ CHIP_ERROR BindingTable::Add(const EmberBindingTableEntry & entry) mBindingTable[newIndex].type = EMBER_UNUSED_BINDING; return error; } + + if (mTail == kNextNullIndex) + { + mTail = newIndex; + mHead = newIndex; + } else { - if (mTail == kNextNullIndex) - { - mTail = newIndex; - mHead = newIndex; - } - else - { - mNextIndex[mTail] = newIndex; - mNextIndex[newIndex] = kNextNullIndex; - mTail = newIndex; - } - - mSize++; - return CHIP_NO_ERROR; + mNextIndex[mTail] = newIndex; + mNextIndex[newIndex] = kNextNullIndex; + mTail = newIndex; } + + mSize++; + return CHIP_NO_ERROR; } const EmberBindingTableEntry & BindingTable::GetAt(uint8_t index) diff --git a/src/app/util/ember-compatibility-functions.cpp b/src/app/util/ember-compatibility-functions.cpp index 1627d80c0a94fa..f9a5090fd52548 100644 --- a/src/app/util/ember-compatibility-functions.cpp +++ b/src/app/util/ember-compatibility-functions.cpp @@ -482,10 +482,8 @@ CHIP_ERROR ReadSingleClusterData(const SubjectDescriptor & aSubjectDescriptor, b { return CHIP_NO_ERROR; } - else - { - return SendFailureStatus(aPath, aAttributeReports, Protocols::InteractionModel::Status::UnsupportedAccess, nullptr); - } + + return SendFailureStatus(aPath, aAttributeReports, Protocols::InteractionModel::Status::UnsupportedAccess, nullptr); } } @@ -969,10 +967,8 @@ bool IsClusterDataVersionEqual(const ConcreteClusterPath & aConcreteClusterPath, aConcreteClusterPath.mEndpointId, ChipLogValueMEI(aConcreteClusterPath.mClusterId)); return false; } - else - { - return (*(version)) == aRequiredVersion; - } + + return (*(version)) == aRequiredVersion; } } // namespace app diff --git a/src/app/util/message.cpp b/src/app/util/message.cpp index cd59151cecbf5d..562211966d5938 100644 --- a/src/app/util/message.cpp +++ b/src/app/util/message.cpp @@ -102,10 +102,8 @@ uint16_t * emberAfPutInt16uInResp(uint16_t value) { return (uint16_t *) low; } - else - { - return NULL; - } + + return NULL; } uint32_t * emberAfPutInt32uInResp(uint32_t value) @@ -119,10 +117,8 @@ uint32_t * emberAfPutInt32uInResp(uint32_t value) { return (uint32_t *) a; } - else - { - return NULL; - } + + return NULL; } uint32_t * emberAfPutInt24uInResp(uint32_t value) @@ -135,10 +131,8 @@ uint32_t * emberAfPutInt24uInResp(uint32_t value) { return (uint32_t *) a; } - else - { - return NULL; - } + + return NULL; } uint8_t * emberAfPutBlockInResp(const uint8_t * data, uint16_t length) @@ -149,10 +143,8 @@ uint8_t * emberAfPutBlockInResp(const uint8_t * data, uint16_t length) appResponseLength = static_cast(appResponseLength + length); return &appResponseData[appResponseLength - length]; } - else - { - return NULL; - } + + return NULL; } uint8_t * emberAfPutStringInResp(const uint8_t * buffer) @@ -172,10 +164,8 @@ uint8_t * emberAfPutDateInResp(EmberAfDate * value) { return a; } - else - { - return NULL; - } + + return NULL; } void emberAfPutInt16sInResp(int16_t value) diff --git a/src/app/util/util.cpp b/src/app/util/util.cpp index d0bfa582928ccb..8a1149159692bf 100644 --- a/src/app/util/util.cpp +++ b/src/app/util/util.cpp @@ -316,10 +316,8 @@ uint16_t emberAfGetMfgCodeFromCurrentCommand(void) { return emberAfCurrentCommand()->mfgCode; } - else - { - return EMBER_AF_NULL_MANUFACTURER_CODE; - } + + return EMBER_AF_NULL_MANUFACTURER_CODE; } uint8_t emberAfNextSequence(void) @@ -365,7 +363,7 @@ void emAfApplyRetryOverride(EmberApsOption * options) { return; } - else if (emberAfApsRetryOverride == EMBER_AF_RETRY_OVERRIDE_SET) + if (emberAfApsRetryOverride == EMBER_AF_RETRY_OVERRIDE_SET) { *options |= EMBER_APS_OPTION_RETRY; } @@ -399,7 +397,7 @@ void emAfApplyDisableDefaultResponse(uint8_t * frame_control) { return; } - else if (emAfDisableDefaultResponse == EMBER_AF_DISABLE_DEFAULT_RESPONSE_ONE_SHOT) + if (emAfDisableDefaultResponse == EMBER_AF_DISABLE_DEFAULT_RESPONSE_ONE_SHOT) { emAfDisableDefaultResponse = emAfSavedDisableDefaultResponseVale; *frame_control |= ZCL_DISABLE_DEFAULT_RESPONSE_MASK; @@ -551,7 +549,7 @@ int8_t emberAfCompareValues(const uint8_t * val1, const uint8_t * val2, uint16_t { return 1; } - else if (accum1 < accum2) + if (accum1 < accum2) { return -1; } @@ -576,7 +574,7 @@ int8_t emberAfCompareValues(const uint8_t * val1, const uint8_t * val2, uint16_t { return 1; } - else if (k > j) + if (k > j) { return -1; } diff --git a/src/controller/AutoCommissioner.cpp b/src/controller/AutoCommissioner.cpp index 5947a8d3220a59..d8c3b30e1a1206 100644 --- a/src/controller/AutoCommissioner.cpp +++ b/src/controller/AutoCommissioner.cpp @@ -142,8 +142,8 @@ CommissioningStage AutoCommissioner::GetNextCommissioningStage(CommissioningStag { return CommissioningStage::kWiFiNetworkSetup; } - else if (mParams.GetThreadOperationalDataset().HasValue() && - mDeviceCommissioningInfo.network.thread.endpoint != kInvalidEndpointId) + if (mParams.GetThreadOperationalDataset().HasValue() && + mDeviceCommissioningInfo.network.thread.endpoint != kInvalidEndpointId) { return CommissioningStage::kThreadNetworkSetup; } diff --git a/src/controller/CHIPCluster.h b/src/controller/CHIPCluster.h index 42706a1f9576e1..5dbbb8aaa91204 100644 --- a/src/controller/CHIPCluster.h +++ b/src/controller/CHIPCluster.h @@ -150,12 +150,10 @@ class DLL_EXPORT ClusterBase requestData, onSuccessCb, onFailureCb, aTimedWriteTimeoutMs, onDoneCb, aDataVersion); } - else - { - return chip::Controller::WriteAttribute(mDevice->GetSecureSession().Value(), mEndpoint, clusterId, - attributeId, requestData, onSuccessCb, onFailureCb, - aTimedWriteTimeoutMs, onDoneCb, aDataVersion); - } + + return chip::Controller::WriteAttribute(mDevice->GetSecureSession().Value(), mEndpoint, clusterId, attributeId, + requestData, onSuccessCb, onFailureCb, aTimedWriteTimeoutMs, onDoneCb, + aDataVersion); } template diff --git a/src/controller/CHIPCommissionableNodeController.cpp b/src/controller/CHIPCommissionableNodeController.cpp index 6081cf92d0f500..59b8ecc559fa03 100644 --- a/src/controller/CHIPCommissionableNodeController.cpp +++ b/src/controller/CHIPCommissionableNodeController.cpp @@ -40,13 +40,11 @@ CHIP_ERROR CommissionableNodeController::DiscoverCommissioners(Dnssd::DiscoveryF mDNSResolver.SetCommissioningDelegate(this); return mDNSResolver.FindCommissioners(discoveryFilter); } - else - { + #if CONFIG_DEVICE_LAYER - ReturnErrorOnFailure(mResolver->Init(DeviceLayer::UDPEndPointManager())); + ReturnErrorOnFailure(mResolver->Init(DeviceLayer::UDPEndPointManager())); #endif - return mResolver->FindCommissioners(discoveryFilter); - } + return mResolver->FindCommissioners(discoveryFilter); } const Dnssd::DiscoveredNodeData * CommissionableNodeController::GetDiscoveredCommissioner(int idx) diff --git a/src/controller/CHIPDeviceController.cpp b/src/controller/CHIPDeviceController.cpp index 161d56d3dd4b28..0d66b3ec6f6e59 100644 --- a/src/controller/CHIPDeviceController.cpp +++ b/src/controller/CHIPDeviceController.cpp @@ -1112,17 +1112,15 @@ void DeviceCommissioner::OnDeviceAttestationInformationVerification(void * conte commissioner->CommissioningStageComplete(CHIP_ERROR_NOT_IMPLEMENTED, report); return; } - else - { - ChipLogError(Controller, - "Failed in verifying 'Attestation Information' command received from the device: err %hu. Look at " - "AttestationVerificationResult enum to understand the errors", - static_cast(result)); - // Go look at AttestationVerificationResult enum in src/credentials/attestation_verifier/DeviceAttestationVerifier.h to - // understand the errors. - commissioner->CommissioningStageComplete(CHIP_ERROR_INTERNAL, report); - return; - } + + ChipLogError(Controller, + "Failed in verifying 'Attestation Information' command received from the device: err %hu. Look at " + "AttestationVerificationResult enum to understand the errors", + static_cast(result)); + // Go look at AttestationVerificationResult enum in src/credentials/attestation_verifier/DeviceAttestationVerifier.h to + // understand the errors. + commissioner->CommissioningStageComplete(CHIP_ERROR_INTERNAL, report); + return; } ChipLogProgress(Controller, "Successfully validated 'Attestation Information' command received from the device."); diff --git a/src/credentials/CHIPCert.cpp b/src/credentials/CHIPCert.cpp index 130ede10847afb..4b92d0e9e79686 100644 --- a/src/credentials/CHIPCert.cpp +++ b/src/credentials/CHIPCert.cpp @@ -526,10 +526,8 @@ bool ChipRDN::IsEqual(const ChipRDN & other) const { return mChipVal == other.mChipVal; } - else - { - return mString.data_equal(other.mString); - } + + return mString.data_equal(other.mString); } ChipDN::ChipDN() {} diff --git a/src/credentials/GroupDataProviderImpl.cpp b/src/credentials/GroupDataProviderImpl.cpp index 99d49af2634b19..5dc549fb5b7e89 100644 --- a/src/credentials/GroupDataProviderImpl.cpp +++ b/src/credentials/GroupDataProviderImpl.cpp @@ -929,13 +929,11 @@ CHIP_ERROR GroupDataProviderImpl::SetGroupInfo(chip::FabricIndex fabric_index, c group.SetName(info.name); return group.Save(mStorage); } - else - { - // New group_id - group.group_id = info.group_id; - group.SetName(info.name); - return SetGroupInfoAt(fabric_index, fabric.group_count, group); - } + + // New group_id + group.group_id = info.group_id; + group.SetName(info.name); + return SetGroupInfoAt(fabric_index, fabric.group_count, group); } CHIP_ERROR GroupDataProviderImpl::GetGroupInfo(chip::FabricIndex fabric_index, chip::GroupId group_id, GroupInfo & info) @@ -985,7 +983,7 @@ CHIP_ERROR GroupDataProviderImpl::SetGroupInfoAt(chip::FabricIndex fabric_index, // Update existing entry return group.Save(mStorage); } - else if (index < fabric.group_count) + if (index < fabric.group_count) { // Replace existing entry with a new group GroupData old_group; @@ -1631,16 +1629,14 @@ CHIP_ERROR GroupDataProviderImpl::SetKeySet(chip::FabricIndex fabric_index, cons // Update existing keyset info, keep next return keyset.Save(mStorage); } - else - { - // New keyset, insert first - keyset.next = fabric.first_keyset; - ReturnErrorOnFailure(keyset.Save(mStorage)); - // Update fabric - fabric.keyset_count++; - fabric.first_keyset = in_keyset.keyset_id; - return fabric.Save(mStorage); - } + + // New keyset, insert first + keyset.next = fabric.first_keyset; + ReturnErrorOnFailure(keyset.Save(mStorage)); + // Update fabric + fabric.keyset_count++; + fabric.first_keyset = in_keyset.keyset_id; + return fabric.Save(mStorage); } CHIP_ERROR GroupDataProviderImpl::GetKeySet(chip::FabricIndex fabric_index, uint16_t target_id, KeySet & out_keyset) diff --git a/src/crypto/CHIPCryptoPAL.cpp b/src/crypto/CHIPCryptoPAL.cpp index 84f355f6c55af2..738614f52f3d77 100644 --- a/src/crypto/CHIPCryptoPAL.cpp +++ b/src/crypto/CHIPCryptoPAL.cpp @@ -67,11 +67,9 @@ CHIP_ERROR ReadDerLength(Reader & reader, uint8_t & length) // We only support lengths of 0..255 over 2 bytes return CHIP_ERROR_INVALID_ARGUMENT; } - else - { - // Next byte has length 0..255. - return reader.Read8(&length).StatusCode(); - } + + // Next byte has length 0..255. + return reader.Read8(&length).StatusCode(); } /** diff --git a/src/inet/TCPEndPointImplSockets.cpp b/src/inet/TCPEndPointImplSockets.cpp index f542d6d46fd3fd..c34603e2099a46 100644 --- a/src/inet/TCPEndPointImplSockets.cpp +++ b/src/inet/TCPEndPointImplSockets.cpp @@ -1030,10 +1030,8 @@ void TCPEndPointImplSockets::HandleIncomingConnection() { return; } - else - { - err = CHIP_ERROR_POSIX(errno); - } + + err = CHIP_ERROR_POSIX(errno); } // If there's no callback available, fail with an error. diff --git a/src/lib/address_resolve/AddressResolve_DefaultImpl.cpp b/src/lib/address_resolve/AddressResolve_DefaultImpl.cpp index f98d1439e97d5b..ad410e4f9dea6d 100644 --- a/src/lib/address_resolve/AddressResolve_DefaultImpl.cpp +++ b/src/lib/address_resolve/AddressResolve_DefaultImpl.cpp @@ -63,7 +63,7 @@ IpScore ScoreIpAddress(const Inet::IPAddress & ip, Inet::InterfaceId interfaceId { return IpScore::kGlobalUnicastWithSharedPrefix; } - else if (ip.IsIPv6ULA()) + if (ip.IsIPv6ULA()) { return IpScore::kUniqueLocalWithSharedPrefix; } @@ -85,10 +85,8 @@ IpScore ScoreIpAddress(const Inet::IPAddress & ip, Inet::InterfaceId interfaceId return IpScore::kOtherIpv6; } - else - { - return IpScore::kIpv4; - } + + return IpScore::kIpv4; } } // namespace @@ -142,7 +140,7 @@ System::Clock::Timeout NodeLookupHandle::NextEventTimeout(System::Clock::Timesta { return mRequest.GetMinLookupTime() - elapsed; } - else if (elapsed < mRequest.GetMaxLookupTime()) + if (elapsed < mRequest.GetMaxLookupTime()) { return mRequest.GetMaxLookupTime() - elapsed; } diff --git a/src/lib/address_resolve/tool.cpp b/src/lib/address_resolve/tool.cpp index 1d852d280e7d46..9a87d1f2c63ec6 100644 --- a/src/lib/address_resolve/tool.cpp +++ b/src/lib/address_resolve/tool.cpp @@ -141,7 +141,7 @@ extern "C" int main(int argc, const char ** argv) ChipLogError(NotSpecified, "Please specify a command, or 'help' for help."); return -1; } - else if (strcasecmp(argv[1], "help") == 0 || strcasecmp(argv[1], "--help") == 0 || strcasecmp(argv[1], "-h") == 0) + if (strcasecmp(argv[1], "help") == 0 || strcasecmp(argv[1], "--help") == 0 || strcasecmp(argv[1], "-h") == 0) { fputs(sHelp, stdout); return 0; @@ -158,9 +158,7 @@ extern "C" int main(int argc, const char ** argv) { return Cmd_Node(argc - 2, argv + 2) ? 0 : 1; } - else - { - ChipLogError(NotSpecified, "Unrecognized command: %s", argv[1]); - return 1; - } + + ChipLogError(NotSpecified, "Unrecognized command: %s", argv[1]); + return 1; } diff --git a/src/lib/asn1/ASN1Reader.cpp b/src/lib/asn1/ASN1Reader.cpp index 309af285b55e1e..a6aaec2548b3a8 100644 --- a/src/lib/asn1/ASN1Reader.cpp +++ b/src/lib/asn1/ASN1Reader.cpp @@ -342,8 +342,7 @@ CHIP_ERROR DumpASN1(ASN1Reader & asn1Parser, const char * prefix, const char * i nestLevel--; continue; } - else - break; + break; } printf("ASN1Reader::Next() failed: %" CHIP_ERROR_FORMAT "\n", err.Format()); return err; diff --git a/src/lib/asn1/ASN1Writer.cpp b/src/lib/asn1/ASN1Writer.cpp index d899805a004f17..6b3d313e825456 100644 --- a/src/lib/asn1/ASN1Writer.cpp +++ b/src/lib/asn1/ASN1Writer.cpp @@ -282,8 +282,7 @@ CHIP_ERROR ASN1Writer::PutTime(const ASN1UniversalTime & val) // if (val.Year >= 2050) return PutValue(kASN1TagClass_Universal, kASN1UniversalTag_GeneralizedTime, false, buf, 15); - else - return PutValue(kASN1TagClass_Universal, kASN1UniversalTag_UTCTime, false, buf + 2, 13); + return PutValue(kASN1TagClass_Universal, kASN1UniversalTag_UTCTime, false, buf + 2, 13); } CHIP_ERROR ASN1Writer::PutNull() diff --git a/src/lib/dnssd/ActiveResolveAttempts.cpp b/src/lib/dnssd/ActiveResolveAttempts.cpp index 9137b1bdb169b4..c645c0ed98fc22 100644 --- a/src/lib/dnssd/ActiveResolveAttempts.cpp +++ b/src/lib/dnssd/ActiveResolveAttempts.cpp @@ -110,7 +110,7 @@ void ActiveResolveAttempts::MarkPending(const ScheduledAttempt & attempt) entryToUse = entry; continue; } - else if (entryToUse->attempt.IsEmpty()) + if (entryToUse->attempt.IsEmpty()) { continue; } diff --git a/src/lib/dnssd/Advertiser_ImplMinimalMdns.cpp b/src/lib/dnssd/Advertiser_ImplMinimalMdns.cpp index 1ec47d9cd7123c..ee842dc6a577c0 100644 --- a/src/lib/dnssd/Advertiser_ImplMinimalMdns.cpp +++ b/src/lib/dnssd/Advertiser_ImplMinimalMdns.cpp @@ -627,10 +627,8 @@ FullQName AdvertiserMinMdns::GetOperationalTxtEntries(const OperationalAdvertisi { return allocator->AllocateQNameFromArray(mEmptyTextEntries, 1); } - else - { - return allocator->AllocateQNameFromArray(txtFields, numTxtFields); - } + + return allocator->AllocateQNameFromArray(txtFields, numTxtFields); } FullQName AdvertiserMinMdns::GetCommissioningTxtEntries(const CommissionAdvertisingParameters & params) @@ -707,10 +705,8 @@ FullQName AdvertiserMinMdns::GetCommissioningTxtEntries(const CommissionAdvertis { return allocator->AllocateQNameFromArray(mEmptyTextEntries, 1); } - else - { - return allocator->AllocateQNameFromArray(txtFields, numTxtFields); - } + + return allocator->AllocateQNameFromArray(txtFields, numTxtFields); } bool AdvertiserMinMdns::ShouldAdvertiseOn(const chip::Inet::InterfaceId id, const chip::Inet::IPAddress & addr) diff --git a/src/lib/dnssd/DnssdCache.h b/src/lib/dnssd/DnssdCache.h index bdc3d1a69bdaa8..bdbb23433ef36a 100644 --- a/src/lib/dnssd/DnssdCache.h +++ b/src/lib/dnssd/DnssdCache.h @@ -160,8 +160,7 @@ class DnssdCache MarkEntryUnused(entry); break; // return nullptr } - else - return &entry; + return &entry; } if (entry.mPeerId != nullPeerId && entry.mExpiryTime < current_time) { diff --git a/src/lib/dnssd/MinimalMdnsServer.h b/src/lib/dnssd/MinimalMdnsServer.h index e956fa017d9cf7..9b1507002f748a 100644 --- a/src/lib/dnssd/MinimalMdnsServer.h +++ b/src/lib/dnssd/MinimalMdnsServer.h @@ -84,10 +84,8 @@ class GlobalMinimalMdnsServer : public mdns::Minimal::ServerDelegate { return *Instance().mReplacementServer; } - else - { - return Instance().mServer; - } + + return Instance().mServer; } /// Calls Server().Listen() on all available interfaces diff --git a/src/lib/dnssd/Resolver.h b/src/lib/dnssd/Resolver.h index 8db57e3d6133a8..c09b0f36d1a70b 100644 --- a/src/lib/dnssd/Resolver.h +++ b/src/lib/dnssd/Resolver.h @@ -273,10 +273,8 @@ struct DiscoveryFilter { return (instanceName != nullptr) && (other.instanceName != nullptr) && (strcmp(instanceName, other.instanceName) == 0); } - else - { - return code == other.code; - } + + return code == other.code; } }; enum class DiscoveryType diff --git a/src/lib/support/BytesCircularBuffer.cpp b/src/lib/support/BytesCircularBuffer.cpp index e25d6b640891ad..b0eba364308dfb 100644 --- a/src/lib/support/BytesCircularBuffer.cpp +++ b/src/lib/support/BytesCircularBuffer.cpp @@ -80,10 +80,8 @@ size_t BytesCircularBuffer::StorageUsed() const { return mDataEnd - mDataStart; } - else - { - return mCapacity + mDataEnd - mDataStart; - } + + return mCapacity + mDataEnd - mDataStart; } CHIP_ERROR BytesCircularBuffer::Push(const ByteSpan & payload) diff --git a/src/lib/support/BytesToHex.cpp b/src/lib/support/BytesToHex.cpp index 21b8b9a123bc8a..bb9681532d6f8f 100644 --- a/src/lib/support/BytesToHex.cpp +++ b/src/lib/support/BytesToHex.cpp @@ -34,10 +34,8 @@ char NibbleToHex(uint8_t nibble, bool uppercase) { return static_cast((x - 10) + (uppercase ? 'A' : 'a')); } - else - { - return static_cast(x + '0'); - } + + return static_cast(x + '0'); } CHIP_ERROR MakeU8FromAsciiHex(const char * src, const size_t srcLen, uint8_t * val, BitFlags flags) @@ -104,7 +102,7 @@ CHIP_ERROR BytesToHex(const uint8_t * src_bytes, size_t src_size, char * dest_he { return CHIP_ERROR_INVALID_ARGUMENT; } - else if (src_size > ((SIZE_MAX - 1) / 2u)) + if (src_size > ((SIZE_MAX - 1) / 2u)) { // Output would overflow a size_t, let's bail out to avoid computation wraparounds below. // This condition will hit with slightly less than the very max, but is unlikely to diff --git a/src/lib/support/Pool.cpp b/src/lib/support/Pool.cpp index 77454ef052bff7..fe0a01143ed06c 100644 --- a/src/lib/support/Pool.cpp +++ b/src/lib/support/Pool.cpp @@ -50,10 +50,8 @@ void * StaticAllocatorBitmap::Allocate() IncreaseUsage(); return At(word * kBitChunkSize + offset); } - else - { - value = usage.load(std::memory_order_relaxed); // if there is a race, update new usage - } + + value = usage.load(std::memory_order_relaxed); // if there is a race, update new usage } } } diff --git a/src/lib/support/Pool.h b/src/lib/support/Pool.h index a3750b7d4f960d..b311d4de73efd8 100644 --- a/src/lib/support/Pool.h +++ b/src/lib/support/Pool.h @@ -222,8 +222,7 @@ class BitMapObjectPool : public internal::StaticAllocatorBitmap, public internal T * element = static_cast(Allocate()); if (element != nullptr) return new (element) T(std::forward(args)...); - else - return nullptr; + return nullptr; } void ReleaseObject(T * element) diff --git a/src/lib/support/ThreadOperationalDataset.cpp b/src/lib/support/ThreadOperationalDataset.cpp index a30c6a82cd489f..59eaae1db0d4dd 100644 --- a/src/lib/support/ThreadOperationalDataset.cpp +++ b/src/lib/support/ThreadOperationalDataset.cpp @@ -498,8 +498,7 @@ const ThreadTLV * OperationalDataset::Locate(uint8_t aType) const { if (tlv->GetType() == aType) break; - else - tlv = tlv->GetNext(); + tlv = tlv->GetNext(); } assert(tlv < reinterpret_cast(&mData[sizeof(mData)])); diff --git a/src/lib/support/Variant.h b/src/lib/support/Variant.h index 1eb2c574038608..1752c21780fbaa 100644 --- a/src/lib/support/Variant.h +++ b/src/lib/support/Variant.h @@ -73,10 +73,8 @@ struct VariantCurry { return *reinterpret_cast(this_v) == *reinterpret_cast(that_v); } - else - { - return VariantCurry::Equal(type_t, that_v, this_v); - } + + return VariantCurry::Equal(type_t, that_v, this_v); } }; diff --git a/src/messaging/ExchangeContext.cpp b/src/messaging/ExchangeContext.cpp index 303dcbafcc3193..2da44602fe1aef 100644 --- a/src/messaging/ExchangeContext.cpp +++ b/src/messaging/ExchangeContext.cpp @@ -490,12 +490,10 @@ CHIP_ERROR ExchangeContext::HandleMessage(uint32_t messageCounter, const Payload { return mDelegate->OnMessageReceived(this, payloadHeader, std::move(msgBuf)); } - else - { - DefaultOnMessageReceived(this, payloadHeader.GetProtocolID(), payloadHeader.GetMessageType(), messageCounter, - std::move(msgBuf)); - return CHIP_NO_ERROR; - } + + DefaultOnMessageReceived(this, payloadHeader.GetProtocolID(), payloadHeader.GetMessageType(), messageCounter, + std::move(msgBuf)); + return CHIP_NO_ERROR; } void ExchangeContext::MessageHandled() diff --git a/src/messaging/ReliableMessageContext.cpp b/src/messaging/ReliableMessageContext.cpp index 6ee0a9882cd07f..ec4264d3742331 100644 --- a/src/messaging/ReliableMessageContext.cpp +++ b/src/messaging/ReliableMessageContext.cpp @@ -156,24 +156,22 @@ CHIP_ERROR ReliableMessageContext::HandleNeedsAckInner(uint32_t messageCounter, return err; } // Otherwise, the message IS NOT a duplicate. - else - { - if (IsAckPending()) - { - ChipLogDetail(ExchangeManager, - "Pending ack queue full; forcing tx of solitary ack for MessageCounter:" ChipLogFormatMessageCounter - " on exchange " ChipLogFormatExchange, - mPendingPeerAckMessageCounter, ChipLogValueExchange(GetExchangeContext())); - // Send the Ack for the currently pending Ack in a SecureChannel::StandaloneAck message. - ReturnErrorOnFailure(SendStandaloneAckMessage()); - } - // Replace the Pending ack message counter. - SetPendingPeerAckMessageCounter(messageCounter); - using namespace System::Clock::Literals; - mNextAckTime = System::SystemClock().GetMonotonicTimestamp() + CHIP_CONFIG_RMP_DEFAULT_ACK_TIMEOUT; - return CHIP_NO_ERROR; + if (IsAckPending()) + { + ChipLogDetail(ExchangeManager, + "Pending ack queue full; forcing tx of solitary ack for MessageCounter:" ChipLogFormatMessageCounter + " on exchange " ChipLogFormatExchange, + mPendingPeerAckMessageCounter, ChipLogValueExchange(GetExchangeContext())); + // Send the Ack for the currently pending Ack in a SecureChannel::StandaloneAck message. + ReturnErrorOnFailure(SendStandaloneAckMessage()); } + + // Replace the Pending ack message counter. + SetPendingPeerAckMessageCounter(messageCounter); + using namespace System::Clock::Literals; + mNextAckTime = System::SystemClock().GetMonotonicTimestamp() + CHIP_CONFIG_RMP_DEFAULT_ACK_TIMEOUT; + return CHIP_NO_ERROR; } CHIP_ERROR ReliableMessageContext::SendStandaloneAckMessage() diff --git a/src/platform/Linux/KeyValueStoreManagerImpl.cpp b/src/platform/Linux/KeyValueStoreManagerImpl.cpp index d9a7db6fbf3f71..6e1774759bcb42 100644 --- a/src/platform/Linux/KeyValueStoreManagerImpl.cpp +++ b/src/platform/Linux/KeyValueStoreManagerImpl.cpp @@ -52,11 +52,11 @@ CHIP_ERROR KeyValueStoreManagerImpl::_Get(const char * key, void * value, size_t { return CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND; } - else if ((err != CHIP_NO_ERROR) && (err != CHIP_ERROR_BUFFER_TOO_SMALL)) + if ((err != CHIP_NO_ERROR) && (err != CHIP_ERROR_BUFFER_TOO_SMALL)) { return err; } - else if (offset_bytes > read_size) + if (offset_bytes > read_size) { return CHIP_ERROR_INVALID_ARGUMENT; } diff --git a/src/platform/Linux/NetworkCommissioningThreadDriver.cpp b/src/platform/Linux/NetworkCommissioningThreadDriver.cpp index 2ba9c2099023d9..e8f079e1ae0e7e 100644 --- a/src/platform/Linux/NetworkCommissioningThreadDriver.cpp +++ b/src/platform/Linux/NetworkCommissioningThreadDriver.cpp @@ -98,7 +98,7 @@ Status LinuxThreadDriver::RemoveNetwork(ByteSpan networkId) { return Status::kNetworkNotFound; } - else if (mStagingNetwork.GetExtendedPanId(extpanid) != CHIP_NO_ERROR) + if (mStagingNetwork.GetExtendedPanId(extpanid) != CHIP_NO_ERROR) { return Status::kUnknownError; } @@ -116,7 +116,7 @@ Status LinuxThreadDriver::ReorderNetwork(ByteSpan networkId, uint8_t index) { return Status::kNetworkNotFound; } - else if (mStagingNetwork.GetExtendedPanId(extpanid) != CHIP_NO_ERROR) + if (mStagingNetwork.GetExtendedPanId(extpanid) != CHIP_NO_ERROR) { return Status::kUnknownError; } diff --git a/src/platform/Linux/ThreadStackManagerImpl.cpp b/src/platform/Linux/ThreadStackManagerImpl.cpp index 02d89ca6b293f4..96ca50f464c0bd 100644 --- a/src/platform/Linux/ThreadStackManagerImpl.cpp +++ b/src/platform/Linux/ThreadStackManagerImpl.cpp @@ -426,7 +426,7 @@ ConnectivityManager::ThreadDeviceType ThreadStackManagerImpl::_GetThreadDeviceTy { return ConnectivityManager::ThreadDeviceType::kThreadDeviceType_NotSupported; } - else if (strcmp(role.get(), kOpenthreadDeviceRoleChild) == 0) + if (strcmp(role.get(), kOpenthreadDeviceRoleChild) == 0) { std::unique_ptr linkMode(openthread_io_openthread_border_router_dup_link_mode(mProxy.get())); if (!linkMode) @@ -446,15 +446,13 @@ ConnectivityManager::ThreadDeviceType ThreadStackManagerImpl::_GetThreadDeviceTy } return type; } - else if (strcmp(role.get(), kOpenthreadDeviceRoleLeader) == 0 || strcmp(role.get(), kOpenthreadDeviceRoleRouter) == 0) + if (strcmp(role.get(), kOpenthreadDeviceRoleLeader) == 0 || strcmp(role.get(), kOpenthreadDeviceRoleRouter) == 0) { return ConnectivityManager::ThreadDeviceType::kThreadDeviceType_Router; } - else - { - ChipLogError(DeviceLayer, "Unknown Thread role: %s", role.get()); - return ConnectivityManager::ThreadDeviceType::kThreadDeviceType_NotSupported; - } + + ChipLogError(DeviceLayer, "Unknown Thread role: %s", role.get()); + return ConnectivityManager::ThreadDeviceType::kThreadDeviceType_NotSupported; } CHIP_ERROR ThreadStackManagerImpl::_SetThreadDeviceType(ConnectivityManager::ThreadDeviceType deviceType) diff --git a/src/protocols/secure_channel/MessageCounterManager.cpp b/src/protocols/secure_channel/MessageCounterManager.cpp index fe986b5c5f2a3a..cf9d9552422e72 100644 --- a/src/protocols/secure_channel/MessageCounterManager.cpp +++ b/src/protocols/secure_channel/MessageCounterManager.cpp @@ -95,7 +95,7 @@ CHIP_ERROR MessageCounterManager::OnMessageReceived(Messaging::ExchangeContext * { return HandleMsgCounterSyncReq(exchangeContext, std::move(msgBuf)); } - else if (payloadHeader.HasMessageType(Protocols::SecureChannel::MsgType::MsgCounterSyncRsp)) + if (payloadHeader.HasMessageType(Protocols::SecureChannel::MsgType::MsgCounterSyncRsp)) { return HandleMsgCounterSyncResp(exchangeContext, std::move(msgBuf)); } diff --git a/src/system/SystemLayerImplSelect.cpp b/src/system/SystemLayerImplSelect.cpp index e3b75eb81faee3..74357f9d195b57 100644 --- a/src/system/SystemLayerImplSelect.cpp +++ b/src/system/SystemLayerImplSelect.cpp @@ -219,7 +219,7 @@ CHIP_ERROR LayerImplSelect::StartWatchingSocket(int fd, SocketWatchToken * token // Duplicate registration is an error. return CHIP_ERROR_INVALID_ARGUMENT; } - else if ((w.mFD == kInvalidFd) && (watch == nullptr)) + if ((w.mFD == kInvalidFd) && (watch == nullptr)) { watch = &w; } diff --git a/src/transport/SessionManager.cpp b/src/transport/SessionManager.cpp index 7fef5e0a5d537b..6dcbbdb5275613 100644 --- a/src/transport/SessionManager.cpp +++ b/src/transport/SessionManager.cpp @@ -320,11 +320,9 @@ CHIP_ERROR SessionManager::SendPreparedMessage(const SessionHandle & sessionHand { return mTransportMgr->SendMessage(*destination, std::move(msgBuf)); } - else - { - ChipLogError(Inet, "The transport manager is not initialized. Unable to send the message"); - return CHIP_ERROR_INCORRECT_STATE; - } + + ChipLogError(Inet, "The transport manager is not initialized. Unable to send the message"); + return CHIP_ERROR_INCORRECT_STATE; } void SessionManager::ExpirePairing(const SessionHandle & sessionHandle) diff --git a/src/transport/SessionManager.h b/src/transport/SessionManager.h index f96a1367a3b4d1..87aef5649a4959 100644 --- a/src/transport/SessionManager.h +++ b/src/transport/SessionManager.h @@ -302,10 +302,8 @@ class DLL_EXPORT SessionManager : public TransportMgrDelegate { return mGlobalEncryptedMessageCounter; } - else - { - return state.GetSessionMessageCounter().GetLocalMessageCounter(); - } + + return state.GetSessionMessageCounter().GetLocalMessageCounter(); } }; diff --git a/src/transport/UnauthenticatedSessionTable.h b/src/transport/UnauthenticatedSessionTable.h index 213afb1661235a..4ed209e066cd84 100644 --- a/src/transport/UnauthenticatedSessionTable.h +++ b/src/transport/UnauthenticatedSessionTable.h @@ -101,10 +101,8 @@ class UnauthenticatedSession : public Session, public ReferenceCounted(*result); } - else - { - return Optional::Missing(); - } + + return Optional::Missing(); } CHECK_RETURN_VALUE Optional FindInitiator(NodeId ephemeralInitiatorNodeID) @@ -171,10 +167,8 @@ class UnauthenticatedSessionTable { return MakeOptional(*result); } - else - { - return Optional::Missing(); - } + + return Optional::Missing(); } CHECK_RETURN_VALUE Optional AllocInitiator(NodeId ephemeralInitiatorNodeID, const PeerAddress & peerAddress, @@ -187,10 +181,8 @@ class UnauthenticatedSessionTable result->SetPeerAddress(peerAddress); return MakeOptional(*result); } - else - { - return Optional::Missing(); - } + + return Optional::Missing(); } private: diff --git a/src/transport/raw/TCP.cpp b/src/transport/raw/TCP.cpp index 70b7b8027b3ccf..b8ab3ddbed9306 100644 --- a/src/transport/raw/TCP.cpp +++ b/src/transport/raw/TCP.cpp @@ -192,10 +192,8 @@ CHIP_ERROR TCPBase::SendMessage(const Transport::PeerAddress & address, System:: { return connection->mEndPoint->Send(std::move(msgBuf)); } - else - { - return SendAfterConnect(address, std::move(msgBuf)); - } + + return SendAfterConnect(address, std::move(msgBuf)); } CHIP_ERROR TCPBase::SendAfterConnect(const PeerAddress & addr, System::PacketBufferHandle && msg) @@ -272,7 +270,7 @@ CHIP_ERROR TCPBase::ProcessReceivedBuffer(Inet::TCPEndPoint * endPoint, const Pe // We don't have enough data to read the message size. Wait until there's more. return CHIP_NO_ERROR; } - else if (err != CHIP_NO_ERROR) + if (err != CHIP_NO_ERROR) { return err; } diff --git a/src/transport/raw/UDP.cpp b/src/transport/raw/UDP.cpp index c27190ad7b1e6f..fb21d390082c80 100644 --- a/src/transport/raw/UDP.cpp +++ b/src/transport/raw/UDP.cpp @@ -142,11 +142,9 @@ CHIP_ERROR UDP::MulticastGroupJoinLeave(const Transport::PeerAddress & address, ChipLogProgress(Inet, "Joining Multicast Group with address %s", addressStr); return mUDPEndPoint->JoinMulticastGroup(mUDPEndPoint->GetBoundInterface(), address.GetIPAddress()); } - else - { - ChipLogProgress(Inet, "Leaving Multicast Group with address %s", addressStr); - return mUDPEndPoint->LeaveMulticastGroup(mUDPEndPoint->GetBoundInterface(), address.GetIPAddress()); - } + + ChipLogProgress(Inet, "Leaving Multicast Group with address %s", addressStr); + return mUDPEndPoint->LeaveMulticastGroup(mUDPEndPoint->GetBoundInterface(), address.GetIPAddress()); } } // namespace Transport diff --git a/third_party/inipp/repo/inipp/inipp/inipp.h b/third_party/inipp/repo/inipp/inipp/inipp.h index 41391567378ff8..54b0892fe95dfe 100644 --- a/third_party/inipp/repo/inipp/inipp/inipp.h +++ b/third_party/inipp/repo/inipp/inipp/inipp.h @@ -79,9 +79,8 @@ inline bool extract(const std::basic_string & value, T & dst) { dst = result; return true; } - else { - return false; - } + return false; + } template @@ -135,7 +134,7 @@ class Ini if (front == char_comment) { continue; } - else if (front == char_section_start) { + if (front == char_section_start) { if (line.back() == char_section_end) section = line.substr(1, length - 2); else