diff --git a/examples/ota-provider-app/ota-provider-common/OTAProviderExample.cpp b/examples/ota-provider-app/ota-provider-common/OTAProviderExample.cpp index 6cff3589e21cf7..7abfa8e3bb30a5 100644 --- a/examples/ota-provider-app/ota-provider-common/OTAProviderExample.cpp +++ b/examples/ota-provider-app/ota-provider-common/OTAProviderExample.cpp @@ -282,7 +282,7 @@ CHIP_ERROR OTAProviderExample::SendQueryImageResponse(chip::app::CommandHandler response.metadataForRequestor.Emplace(chip::ByteSpan()); } - VerifyOrReturnError(commandObj->AddResponse(commandPath, response) == CHIP_NO_ERROR, EMBER_ZCL_STATUS_FAILURE); + commandObj->AddResponse(commandPath, response); return CHIP_NO_ERROR; } @@ -389,7 +389,7 @@ EmberAfStatus OTAProviderExample::HandleApplyUpdateRequest(chip::app::CommandHan // Reset back to success case for subsequent uses mUpdateAction = OTAApplyUpdateAction::kProceed; - VerifyOrReturnError(commandObj->AddResponse(commandPath, response) == CHIP_NO_ERROR, EMBER_ZCL_STATUS_FAILURE); + commandObj->AddResponse(commandPath, response); return EMBER_ZCL_STATUS_SUCCESS; } diff --git a/src/app/CommandResponseHelper.h b/src/app/CommandResponseHelper.h index b95ecdba446f9d..a85e92b72cc587 100644 --- a/src/app/CommandResponseHelper.h +++ b/src/app/CommandResponseHelper.h @@ -36,12 +36,9 @@ class CommandResponseHelper CHIP_ERROR Success(const CommandData & aResponse) { - CHIP_ERROR err = mCommandHandler->AddResponse(mCommandPath, aResponse); - if (err == CHIP_NO_ERROR) - { - mSentResponse = true; - } - return err; + mCommandHandler->AddResponse(mCommandPath, aResponse); + mSentResponse = true; + return CHIP_NO_ERROR; }; CHIP_ERROR Success(ClusterStatus aClusterStatus) diff --git a/src/app/clusters/door-lock-server/door-lock-server.cpp b/src/app/clusters/door-lock-server/door-lock-server.cpp index f437950af4ac34..f0347d9cbd038d 100644 --- a/src/app/clusters/door-lock-server/door-lock-server.cpp +++ b/src/app/clusters/door-lock-server/door-lock-server.cpp @@ -2169,11 +2169,10 @@ DlStatus DoorLockServer::clearSchedules(chip::EndpointId endpointId, uint16_t us return DlStatus::kSuccess; } -CHIP_ERROR DoorLockServer::sendGetWeekDayScheduleResponse(chip::app::CommandHandler * commandObj, - const chip::app::ConcreteCommandPath & commandPath, uint8_t weekdayIndex, - uint16_t userIndex, DlStatus status, DlDaysMaskMap daysMask, - uint8_t startHour, uint8_t startMinute, uint8_t endHour, - uint8_t endMinute) +void DoorLockServer::sendGetWeekDayScheduleResponse(chip::app::CommandHandler * commandObj, + const chip::app::ConcreteCommandPath & commandPath, uint8_t weekdayIndex, + uint16_t userIndex, DlStatus status, DlDaysMaskMap daysMask, uint8_t startHour, + uint8_t startMinute, uint8_t endHour, uint8_t endMinute) { VerifyOrDie(nullptr != commandObj); @@ -2190,7 +2189,7 @@ CHIP_ERROR DoorLockServer::sendGetWeekDayScheduleResponse(chip::app::CommandHand response.endMinute = Optional(endMinute); } - return commandObj->AddResponse(commandPath, response); + commandObj->AddResponse(commandPath, response); } bool DoorLockServer::yearDayIndexValid(chip::EndpointId endpointId, uint8_t yearDayIndex) @@ -2242,10 +2241,10 @@ DlStatus DoorLockServer::clearYearDaySchedules(chip::EndpointId endpointId, uint return DlStatus::kSuccess; } -CHIP_ERROR DoorLockServer::sendGetYearDayScheduleResponse(chip::app::CommandHandler * commandObj, - const chip::app::ConcreteCommandPath & commandPath, uint8_t yearDayIndex, - uint16_t userIndex, DlStatus status, uint32_t localStartTime, - uint32_t localEndTime) +void DoorLockServer::sendGetYearDayScheduleResponse(chip::app::CommandHandler * commandObj, + const chip::app::ConcreteCommandPath & commandPath, uint8_t yearDayIndex, + uint16_t userIndex, DlStatus status, uint32_t localStartTime, + uint32_t localEndTime) { VerifyOrDie(nullptr != commandObj); @@ -2259,7 +2258,7 @@ CHIP_ERROR DoorLockServer::sendGetYearDayScheduleResponse(chip::app::CommandHand response.localEndTime = Optional(localEndTime); } - return commandObj->AddResponse(commandPath, response); + commandObj->AddResponse(commandPath, response); } EmberAfStatus DoorLockServer::clearCredential(chip::EndpointId endpointId, chip::FabricIndex modifier, chip::NodeId sourceNodeId, diff --git a/src/app/clusters/door-lock-server/door-lock-server.h b/src/app/clusters/door-lock-server/door-lock-server.h index 3e61471d5e4a7c..01fa48942eb6cc 100644 --- a/src/app/clusters/door-lock-server/door-lock-server.h +++ b/src/app/clusters/door-lock-server/door-lock-server.h @@ -238,21 +238,19 @@ class DoorLockServer DlStatus clearWeekDaySchedules(chip::EndpointId endpointId, uint16_t userIndex); DlStatus clearSchedules(chip::EndpointId endpointId, uint16_t userIndex); - CHIP_ERROR sendGetWeekDayScheduleResponse(chip::app::CommandHandler * commandObj, - const chip::app::ConcreteCommandPath & commandPath, uint8_t weekdayIndex, - uint16_t userIndex, DlStatus status, DlDaysMaskMap daysMask = DlDaysMaskMap(0), - uint8_t startHour = 0, uint8_t startMinute = 0, uint8_t endHour = 0, - uint8_t endMinute = 0); + void sendGetWeekDayScheduleResponse(chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, + uint8_t weekdayIndex, uint16_t userIndex, DlStatus status, + DlDaysMaskMap daysMask = DlDaysMaskMap(0), uint8_t startHour = 0, uint8_t startMinute = 0, + uint8_t endHour = 0, uint8_t endMinute = 0); bool yearDayIndexValid(chip::EndpointId endpointId, uint8_t yearDayIndex); DlStatus clearYearDaySchedule(chip::EndpointId endpointId, uint16_t userIndex, uint8_t weekDayIndex); DlStatus clearYearDaySchedules(chip::EndpointId endpointId, uint16_t userIndex); - CHIP_ERROR sendGetYearDayScheduleResponse(chip::app::CommandHandler * commandObj, - const chip::app::ConcreteCommandPath & commandPath, uint8_t yearDayIndex, - uint16_t userIndex, DlStatus status, uint32_t localStartTime = 0, - uint32_t localEndTime = 0); + void sendGetYearDayScheduleResponse(chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, + uint8_t yearDayIndex, uint16_t userIndex, DlStatus status, uint32_t localStartTime = 0, + uint32_t localEndTime = 0); bool sendRemoteLockUserChange(chip::EndpointId endpointId, DlLockDataType dataType, DlDataOperationType operation, chip::NodeId nodeId, chip::FabricIndex fabricIndex, uint16_t userIndex = 0, diff --git a/src/app/clusters/general-commissioning-server/general-commissioning-server.cpp b/src/app/clusters/general-commissioning-server/general-commissioning-server.cpp index e8c2a07cc393d6..557a14deab4e69 100644 --- a/src/app/clusters/general-commissioning-server/general-commissioning-server.cpp +++ b/src/app/clusters/general-commissioning-server/general-commissioning-server.cpp @@ -149,12 +149,12 @@ bool emberAfGeneralCommissioningClusterArmFailSafeCallback(app::CommandHandler * CheckSuccess(failSafeContext.ArmFailSafe(accessingFabricIndex, System::Clock::Seconds16(commandData.expiryLengthSeconds)), Failure); response.errorCode = CommissioningError::kOk; - CheckSuccess(commandObj->AddResponse(commandPath, response), Failure); + commandObj->AddResponse(commandPath, response); } else { response.errorCode = CommissioningError::kBusyWithOtherAdmin; - CheckSuccess(commandObj->AddResponse(commandPath, response), Failure); + commandObj->AddResponse(commandPath, response); } return true; @@ -178,7 +178,7 @@ bool emberAfGeneralCommissioningClusterCommissioningCompleteCallback( Commands::CommissioningCompleteResponse::Type response; response.errorCode = CommissioningError::kOk; - CheckSuccess(commandObj->AddResponse(commandPath, response), Failure); + commandObj->AddResponse(commandPath, response); return true; } @@ -195,7 +195,7 @@ bool emberAfGeneralCommissioningClusterSetRegulatoryConfigCallback(app::CommandH Commands::SetRegulatoryConfigResponse::Type response; response.errorCode = CommissioningError::kOk; - CheckSuccess(commandObj->AddResponse(commandPath, response), Failure); + commandObj->AddResponse(commandPath, response); return true; } diff --git a/src/app/clusters/group-key-mgmt-server/group-key-mgmt-server.cpp b/src/app/clusters/group-key-mgmt-server/group-key-mgmt-server.cpp index 2bb02f51cd0733..8e3ba46ba12021 100644 --- a/src/app/clusters/group-key-mgmt-server/group-key-mgmt-server.cpp +++ b/src/app/clusters/group-key-mgmt-server/group-key-mgmt-server.cpp @@ -438,12 +438,7 @@ bool emberAfGroupKeyManagementClusterKeySetReadCallback( } response.groupKeySet.epochKey2.SetNull(); - CHIP_ERROR err = commandObj->AddResponse(commandPath, response); - if (CHIP_NO_ERROR != err) - { - ChipLogDetail(Zcl, "GroupKeyManagementCluster: KeySetRead failed: %s", ErrorStr(err)); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); - } + commandObj->AddResponse(commandPath, response); return true; } @@ -530,11 +525,7 @@ bool emberAfGroupKeyManagementClusterKeySetReadAllIndicesCallback( return true; } - CHIP_ERROR err = commandObj->AddResponse(commandPath, KeySetReadAllIndicesResponse(keysIt)); - if (CHIP_NO_ERROR != err) - { - ChipLogDetail(Zcl, "GroupKeyManagementCluster: KeySetReadAllIndices failed: %s", ErrorStr(err)); - } + commandObj->AddResponse(commandPath, KeySetReadAllIndicesResponse(keysIt)); keysIt->Release(); return true; } diff --git a/src/app/clusters/groups-server/groups-server.cpp b/src/app/clusters/groups-server/groups-server.cpp index 0f24e587fd9357..0760154d80878f 100644 --- a/src/app/clusters/groups-server/groups-server.cpp +++ b/src/app/clusters/groups-server/groups-server.cpp @@ -137,7 +137,6 @@ bool emberAfGroupsClusterAddGroupCallback(app::CommandHandler * commandObj, cons { auto fabricIndex = commandObj->GetAccessingFabricIndex(); Groups::Commands::AddGroupResponse::Type response; - CHIP_ERROR err = CHIP_NO_ERROR; // For all networks, Add Group commands are only responded to when // they are addressed to a single device. @@ -148,12 +147,7 @@ bool emberAfGroupsClusterAddGroupCallback(app::CommandHandler * commandObj, cons response.groupId = commandData.groupId; response.status = GroupAdd(fabricIndex, commandPath.mEndpointId, commandData.groupId, commandData.groupName); - err = commandObj->AddResponse(commandPath, response); - if (CHIP_NO_ERROR != err) - { - ChipLogDetail(Zcl, "GroupsCluster: AddGroup failed: %s", err.AsString()); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); - } + commandObj->AddResponse(commandPath, response); return true; } @@ -185,12 +179,7 @@ bool emberAfGroupsClusterViewGroupCallback(app::CommandHandler * commandObj, con exit: response.groupId = groupId; response.status = status; - err = commandObj->AddResponse(commandPath, response); - if (CHIP_NO_ERROR != err) - { - ChipLogDetail(Zcl, "GroupsCluster: ViewGroup failed: %s", err.AsString()); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); - } + commandObj->AddResponse(commandPath, response); return true; } @@ -284,14 +273,12 @@ bool emberAfGroupsClusterGetGroupMembershipCallback(app::CommandHandler * comman { GroupDataProvider::EndpointIterator * iter = nullptr; - CHIP_ERROR err = CHIP_NO_ERROR; iter = provider->IterateEndpoints(fabricIndex); VerifyOrExit(nullptr != iter, status = EMBER_ZCL_STATUS_FAILURE); - err = commandObj->AddResponse(commandPath, GroupMembershipResponse(commandData, commandPath.mEndpointId, iter)); + commandObj->AddResponse(commandPath, GroupMembershipResponse(commandData, commandPath.mEndpointId, iter)); iter->Release(); - status = (CHIP_NO_ERROR == err) ? EMBER_ZCL_STATUS_SUCCESS : EMBER_ZCL_STATUS_FAILURE; } exit: @@ -308,7 +295,6 @@ bool emberAfGroupsClusterRemoveGroupCallback(app::CommandHandler * commandObj, c { auto fabricIndex = commandObj->GetAccessingFabricIndex(); Groups::Commands::RemoveGroupResponse::Type response; - CHIP_ERROR err = CHIP_NO_ERROR; // For all networks, Remove Group commands are only responded to when // they are addressed to a single device. @@ -324,12 +310,7 @@ bool emberAfGroupsClusterRemoveGroupCallback(app::CommandHandler * commandObj, c response.groupId = commandData.groupId; response.status = GroupRemove(fabricIndex, commandPath.mEndpointId, commandData.groupId); - err = commandObj->AddResponse(commandPath, response); - if (CHIP_NO_ERROR != err) - { - ChipLogDetail(Zcl, "GroupsCluster: RemoveGroup failed: %s", err.AsString()); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); - } + commandObj->AddResponse(commandPath, response); return true; } diff --git a/src/app/clusters/operational-credentials-server/operational-credentials-server.cpp b/src/app/clusters/operational-credentials-server/operational-credentials-server.cpp index 8b0123e4610211..3057f3446f8f44 100644 --- a/src/app/clusters/operational-credentials-server/operational-credentials-server.cpp +++ b/src/app/clusters/operational-credentials-server/operational-credentials-server.cpp @@ -61,8 +61,8 @@ using namespace chip::Protocols::InteractionModel; namespace { -CHIP_ERROR SendNOCResponse(app::CommandHandler * commandObj, const ConcreteCommandPath & path, OperationalCertStatus status, - uint8_t index, const CharSpan & debug_text); +void SendNOCResponse(app::CommandHandler * commandObj, const ConcreteCommandPath & path, OperationalCertStatus status, + uint8_t index, const CharSpan & debug_text); OperationalCertStatus ConvertToNOCResponseStatus(CHIP_ERROR err); constexpr uint8_t kDACCertificate = 1; @@ -519,8 +519,8 @@ namespace { // TODO: Manage ephemeral RCAC/ICAC/NOC storage to avoid a full FabricInfo being needed here. FabricInfo gFabricBeingCommissioned; -CHIP_ERROR SendNOCResponse(app::CommandHandler * commandObj, const ConcreteCommandPath & path, OperationalCertStatus status, - uint8_t index, const CharSpan & debug_text) +void SendNOCResponse(app::CommandHandler * commandObj, const ConcreteCommandPath & path, OperationalCertStatus status, + uint8_t index, const CharSpan & debug_text) { Commands::NOCResponse::Type payload; payload.statusCode = status; @@ -535,7 +535,7 @@ CHIP_ERROR SendNOCResponse(app::CommandHandler * commandObj, const ConcreteComma payload.debugText.Emplace(to_send); } - return commandObj->AddResponse(path, payload); + commandObj->AddResponse(path, payload); } OperationalCertStatus ConvertToNOCResponseStatus(CHIP_ERROR err) @@ -774,7 +774,7 @@ bool emberAfOperationalCredentialsClusterCertificateChainRequestCallback( } response.certificate = derBufSpan; - SuccessOrExit(err = commandObj->AddResponse(commandPath, response)); + commandObj->AddResponse(commandPath, response); exit: if (err != CHIP_NO_ERROR) @@ -834,7 +834,7 @@ bool emberAfOperationalCredentialsClusterAttestationRequestCallback(app::Command response.attestationElements = attestationElementsSpan; response.signature = signatureSpan; - SuccessOrExit(err = commandObj->AddResponse(commandPath, response)); + commandObj->AddResponse(commandPath, response); } exit: @@ -922,7 +922,7 @@ bool emberAfOperationalCredentialsClusterCSRRequestCallback(app::CommandHandler response.NOCSRElements = nocsrElementsSpan; response.attestationSignature = signatureSpan; - SuccessOrExit(err = commandObj->AddResponse(commandPath, response)); + commandObj->AddResponse(commandPath, response); } exit: diff --git a/src/app/clusters/test-cluster-server/test-cluster-server.cpp b/src/app/clusters/test-cluster-server/test-cluster-server.cpp index 282ffa3c971363..ebbc8be7e70468 100644 --- a/src/app/clusters/test-cluster-server/test-cluster-server.cpp +++ b/src/app/clusters/test-cluster-server/test-cluster-server.cpp @@ -714,11 +714,7 @@ bool emberAfTestClusterClusterTestSpecificCallback(CommandHandler * apCommandObj { TestSpecificResponse::Type responseData; responseData.returnValue = 7; - CHIP_ERROR err = apCommandObj->AddResponse(commandPath, responseData); - if (CHIP_NO_ERROR != err) - { - ChipLogError(Zcl, "Test Cluster: failed to send TestSpecific response: %" CHIP_ERROR_FORMAT, err.Format()); - } + apCommandObj->AddResponse(commandPath, responseData); return true; } @@ -738,11 +734,7 @@ bool emberAfTestClusterClusterTestAddArgumentsCallback(CommandHandler * apComman TestAddArgumentsResponse::Type responseData; responseData.returnValue = static_cast(commandData.arg1 + commandData.arg2); - CHIP_ERROR err = apCommandObj->AddResponse(commandPath, responseData); - if (CHIP_NO_ERROR != err) - { - ChipLogError(Zcl, "Test Cluster: failed to send TestAddArguments response: %" CHIP_ERROR_FORMAT, err.Format()); - } + apCommandObj->AddResponse(commandPath, responseData); return true; } @@ -750,11 +742,7 @@ static bool SendBooleanResponse(CommandHandler * commandObj, const ConcreteComma { Commands::BooleanResponse::Type response; response.value = value; - CHIP_ERROR err = commandObj->AddResponse(commandPath, response); - if (err != CHIP_NO_ERROR) - { - commandObj->AddStatus(commandPath, Protocols::InteractionModel::Status::Failure); - } + commandObj->AddResponse(commandPath, response); return true; } @@ -923,7 +911,7 @@ bool emberAfTestClusterClusterTestListInt8UReverseRequestCallback( Commands::TestListInt8UReverseResponse::Type responseData; if (count == 0) { - SuccessOrExit(commandObj->AddResponse(commandPath, responseData)); + commandObj->AddResponse(commandPath, responseData); return true; } size_t cur = count; @@ -937,7 +925,7 @@ bool emberAfTestClusterClusterTestListInt8UReverseRequestCallback( VerifyOrExit(cur == 0, ); VerifyOrExit(iter.GetStatus() == CHIP_NO_ERROR, ); responseData.arg1 = DataModel::List(responseBuf.Get(), count); - SuccessOrExit(commandObj->AddResponse(commandPath, responseData)); + commandObj->AddResponse(commandPath, responseData); return true; } @@ -953,11 +941,7 @@ bool emberAfTestClusterClusterTestEnumsRequestCallback(CommandHandler * commandO response.arg1 = commandData.arg1; response.arg2 = commandData.arg2; - CHIP_ERROR err = commandObj->AddResponse(commandPath, response); - if (err != CHIP_NO_ERROR) - { - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); - } + commandObj->AddResponse(commandPath, response); return true; } @@ -979,11 +963,7 @@ bool emberAfTestClusterClusterTestNullableOptionalRequestCallback( response.originalValue.Emplace(commandData.arg1.Value()); } - CHIP_ERROR err = commandObj->AddResponse(commandPath, response); - if (err != CHIP_NO_ERROR) - { - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); - } + commandObj->AddResponse(commandPath, response); return true; } @@ -1000,11 +980,7 @@ bool emberAfTestClusterClusterSimpleStructEchoRequestCallback(CommandHandler * c response.arg1.g = commandData.arg1.g; response.arg1.h = commandData.arg1.h; - CHIP_ERROR err = commandObj->AddResponse(commandPath, response); - if (err != CHIP_NO_ERROR) - { - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); - } + commandObj->AddResponse(commandPath, response); return true; } diff --git a/src/app/tests/TestCommandInteraction.cpp b/src/app/tests/TestCommandInteraction.cpp index 8492654771ee5b..bdd5c77d099f24 100644 --- a/src/app/tests/TestCommandInteraction.cpp +++ b/src/app/tests/TestCommandInteraction.cpp @@ -547,8 +547,7 @@ void TestCommandInteraction::TestCommandHandlerCommandDataEncoding(nlTestSuite * auto path = MakeTestCommandPath(); - err = commandHandler.AddResponse(ConcreteCommandPath(path.mEndpointId, path.mClusterId, path.mCommandId), Fields()); - NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR); + commandHandler.AddResponse(ConcreteCommandPath(path.mEndpointId, path.mClusterId, path.mCommandId), Fields()); err = commandHandler.Finalize(commandPacket); NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR); @@ -575,8 +574,7 @@ void TestCommandInteraction::TestCommandHandlerCommandEncodeFailure(nlTestSuite auto path = MakeTestCommandPath(); - err = commandHandler.AddResponse(ConcreteCommandPath(path.mEndpointId, path.mClusterId, path.mCommandId), BadFields()); - NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR); + commandHandler.AddResponse(ConcreteCommandPath(path.mEndpointId, path.mClusterId, path.mCommandId), BadFields()); err = commandHandler.Finalize(commandPacket); NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);