diff --git a/examples/air-quality-sensor-app/silabs/src/SensorManager.cpp b/examples/air-quality-sensor-app/silabs/src/SensorManager.cpp index 3b76450e171a86..209cd3b93428df 100644 --- a/examples/air-quality-sensor-app/silabs/src/SensorManager.cpp +++ b/examples/air-quality-sensor-app/silabs/src/SensorManager.cpp @@ -159,7 +159,7 @@ void SensorManager::SensorTimerEventHandler(void * arg) static uint8_t simulatedIndex = 0; // Ensure the simulatedIndex wraps around the array size to avoid out-of-bounds access - simulatedIndex = simulatedIndex % ArraySize(mSimulatedAirQuality); + simulatedIndex = simulatedIndex % MATTER_ARRAY_SIZE(mSimulatedAirQuality); // Retrieve the current air quality value from the simulated data array using the simulatedIndex air_quality = mSimulatedAirQuality[simulatedIndex]; diff --git a/examples/all-clusters-app/all-clusters-common/src/dishwasher-mode.cpp b/examples/all-clusters-app/all-clusters-common/src/dishwasher-mode.cpp index 607bb5578787f2..edea4e98a4514d 100644 --- a/examples/all-clusters-app/all-clusters-common/src/dishwasher-mode.cpp +++ b/examples/all-clusters-app/all-clusters-common/src/dishwasher-mode.cpp @@ -41,7 +41,7 @@ void DishwasherModeDelegate::HandleChangeToMode(uint8_t NewMode, ModeBase::Comma CHIP_ERROR DishwasherModeDelegate::GetModeLabelByIndex(uint8_t modeIndex, chip::MutableCharSpan & label) { - if (modeIndex >= ArraySize(kModeOptions)) + if (modeIndex >= MATTER_ARRAY_SIZE(kModeOptions)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } @@ -50,7 +50,7 @@ CHIP_ERROR DishwasherModeDelegate::GetModeLabelByIndex(uint8_t modeIndex, chip:: CHIP_ERROR DishwasherModeDelegate::GetModeValueByIndex(uint8_t modeIndex, uint8_t & value) { - if (modeIndex >= ArraySize(kModeOptions)) + if (modeIndex >= MATTER_ARRAY_SIZE(kModeOptions)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } @@ -60,7 +60,7 @@ CHIP_ERROR DishwasherModeDelegate::GetModeValueByIndex(uint8_t modeIndex, uint8_ CHIP_ERROR DishwasherModeDelegate::GetModeTagsByIndex(uint8_t modeIndex, List & tags) { - if (modeIndex >= ArraySize(kModeOptions)) + if (modeIndex >= MATTER_ARRAY_SIZE(kModeOptions)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } diff --git a/examples/all-clusters-app/all-clusters-common/src/energy-preference-delegate.cpp b/examples/all-clusters-app/all-clusters-common/src/energy-preference-delegate.cpp index cd9b47dd7979e6..cfdaac5c4d9fd4 100644 --- a/examples/all-clusters-app/all-clusters-common/src/energy-preference-delegate.cpp +++ b/examples/all-clusters-app/all-clusters-common/src/energy-preference-delegate.cpp @@ -71,12 +71,12 @@ EPrefDelegate::~EPrefDelegate() size_t EPrefDelegate::GetNumEnergyBalances(chip::EndpointId aEndpoint) { - return (ArraySize(gsEnergyBalances)); + return (MATTER_ARRAY_SIZE(gsEnergyBalances)); } size_t EPrefDelegate::GetNumLowPowerModeSensitivities(chip::EndpointId aEndpoint) { - return (ArraySize(gsEnergyBalances)); + return (MATTER_ARRAY_SIZE(gsEnergyBalances)); } CHIP_ERROR @@ -104,7 +104,7 @@ EPrefDelegate::GetEnergyPriorityAtIndex(chip::EndpointId aEndpoint, size_t aInde { static EnergyPriorityEnum priorities[] = { EnergyPriorityEnum::kEfficiency, EnergyPriorityEnum::kComfort }; - if (aIndex < ArraySize(priorities)) + if (aIndex < MATTER_ARRAY_SIZE(priorities)) { priority = priorities[aIndex]; return CHIP_NO_ERROR; diff --git a/examples/all-clusters-app/all-clusters-common/src/laundry-dryer-controls-delegate-impl.cpp b/examples/all-clusters-app/all-clusters-common/src/laundry-dryer-controls-delegate-impl.cpp index d404680f2a87d2..b3cd2008d57ce2 100644 --- a/examples/all-clusters-app/all-clusters-common/src/laundry-dryer-controls-delegate-impl.cpp +++ b/examples/all-clusters-app/all-clusters-common/src/laundry-dryer-controls-delegate-impl.cpp @@ -31,7 +31,7 @@ LaundryDryerControlDelegate LaundryDryerControlDelegate::instance; // TODO: Add EndpointId to the API so that different values per endpoint may be possible in some implementations. CHIP_ERROR LaundryDryerControlDelegate::GetSupportedDrynessLevelAtIndex(size_t index, DrynessLevelEnum & supportedDrynessLevel) { - if (index >= ArraySize(supportedDrynessLevelOptions)) + if (index >= MATTER_ARRAY_SIZE(supportedDrynessLevelOptions)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } diff --git a/examples/all-clusters-app/all-clusters-common/src/laundry-washer-controls-delegate-impl.cpp b/examples/all-clusters-app/all-clusters-common/src/laundry-washer-controls-delegate-impl.cpp index 6c70ef98cb4736..35a66b56e6293e 100644 --- a/examples/all-clusters-app/all-clusters-common/src/laundry-washer-controls-delegate-impl.cpp +++ b/examples/all-clusters-app/all-clusters-common/src/laundry-washer-controls-delegate-impl.cpp @@ -38,7 +38,7 @@ LaundryWasherControlDelegate LaundryWasherControlDelegate::instance; CHIP_ERROR LaundryWasherControlDelegate::GetSpinSpeedAtIndex(size_t index, MutableCharSpan & spinSpeed) { - if (index >= ArraySize(spinSpeedsNameOptions)) + if (index >= MATTER_ARRAY_SIZE(spinSpeedsNameOptions)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } @@ -47,7 +47,7 @@ CHIP_ERROR LaundryWasherControlDelegate::GetSpinSpeedAtIndex(size_t index, Mutab CHIP_ERROR LaundryWasherControlDelegate::GetSupportedRinseAtIndex(size_t index, NumberOfRinsesEnum & supportedRinse) { - if (index >= ArraySize(supportRinsesOptions)) + if (index >= MATTER_ARRAY_SIZE(supportRinsesOptions)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } diff --git a/examples/all-clusters-app/all-clusters-common/src/laundry-washer-mode.cpp b/examples/all-clusters-app/all-clusters-common/src/laundry-washer-mode.cpp index 16bb21158b612b..38ff8d8636837d 100644 --- a/examples/all-clusters-app/all-clusters-common/src/laundry-washer-mode.cpp +++ b/examples/all-clusters-app/all-clusters-common/src/laundry-washer-mode.cpp @@ -40,7 +40,7 @@ void LaundryWasherModeDelegate::HandleChangeToMode(uint8_t NewMode, ModeBase::Co CHIP_ERROR LaundryWasherModeDelegate::GetModeLabelByIndex(uint8_t modeIndex, chip::MutableCharSpan & label) { - if (modeIndex >= ArraySize(kModeOptions)) + if (modeIndex >= MATTER_ARRAY_SIZE(kModeOptions)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } @@ -49,7 +49,7 @@ CHIP_ERROR LaundryWasherModeDelegate::GetModeLabelByIndex(uint8_t modeIndex, chi CHIP_ERROR LaundryWasherModeDelegate::GetModeValueByIndex(uint8_t modeIndex, uint8_t & value) { - if (modeIndex >= ArraySize(kModeOptions)) + if (modeIndex >= MATTER_ARRAY_SIZE(kModeOptions)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } @@ -59,7 +59,7 @@ CHIP_ERROR LaundryWasherModeDelegate::GetModeValueByIndex(uint8_t modeIndex, uin CHIP_ERROR LaundryWasherModeDelegate::GetModeTagsByIndex(uint8_t modeIndex, List & tags) { - if (modeIndex >= ArraySize(kModeOptions)) + if (modeIndex >= MATTER_ARRAY_SIZE(kModeOptions)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } diff --git a/examples/all-clusters-app/all-clusters-common/src/microwave-oven-mode.cpp b/examples/all-clusters-app/all-clusters-common/src/microwave-oven-mode.cpp index a7ab998dbdec9f..76366d1d727d41 100644 --- a/examples/all-clusters-app/all-clusters-common/src/microwave-oven-mode.cpp +++ b/examples/all-clusters-app/all-clusters-common/src/microwave-oven-mode.cpp @@ -42,7 +42,7 @@ void ExampleMicrowaveOvenModeDelegate::HandleChangeToMode(uint8_t NewMode, CHIP_ERROR ExampleMicrowaveOvenModeDelegate::GetModeLabelByIndex(uint8_t modeIndex, chip::MutableCharSpan & label) { - if (modeIndex >= ArraySize(kModeOptions)) + if (modeIndex >= MATTER_ARRAY_SIZE(kModeOptions)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } @@ -51,7 +51,7 @@ CHIP_ERROR ExampleMicrowaveOvenModeDelegate::GetModeLabelByIndex(uint8_t modeInd CHIP_ERROR ExampleMicrowaveOvenModeDelegate::GetModeValueByIndex(uint8_t modeIndex, uint8_t & value) { - if (modeIndex >= ArraySize(kModeOptions)) + if (modeIndex >= MATTER_ARRAY_SIZE(kModeOptions)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } @@ -61,7 +61,7 @@ CHIP_ERROR ExampleMicrowaveOvenModeDelegate::GetModeValueByIndex(uint8_t modeInd CHIP_ERROR ExampleMicrowaveOvenModeDelegate::GetModeTagsByIndex(uint8_t modeIndex, List & tags) { - if (modeIndex >= ArraySize(kModeOptions)) + if (modeIndex >= MATTER_ARRAY_SIZE(kModeOptions)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } diff --git a/examples/all-clusters-app/all-clusters-common/src/oven-modes.cpp b/examples/all-clusters-app/all-clusters-common/src/oven-modes.cpp index a3b8e4ac2a0761..b860562cae8298 100644 --- a/examples/all-clusters-app/all-clusters-common/src/oven-modes.cpp +++ b/examples/all-clusters-app/all-clusters-common/src/oven-modes.cpp @@ -42,7 +42,7 @@ void OvenModeDelegate::HandleChangeToMode(uint8_t NewMode, ModeBase::Commands::C CHIP_ERROR OvenModeDelegate::GetModeLabelByIndex(uint8_t modeIndex, chip::MutableCharSpan & label) { - if (modeIndex >= ArraySize(kModeOptions)) + if (modeIndex >= MATTER_ARRAY_SIZE(kModeOptions)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } @@ -51,7 +51,7 @@ CHIP_ERROR OvenModeDelegate::GetModeLabelByIndex(uint8_t modeIndex, chip::Mutabl CHIP_ERROR OvenModeDelegate::GetModeValueByIndex(uint8_t modeIndex, uint8_t & value) { - if (modeIndex >= ArraySize(kModeOptions)) + if (modeIndex >= MATTER_ARRAY_SIZE(kModeOptions)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } @@ -61,7 +61,7 @@ CHIP_ERROR OvenModeDelegate::GetModeValueByIndex(uint8_t modeIndex, uint8_t & va CHIP_ERROR OvenModeDelegate::GetModeTagsByIndex(uint8_t modeIndex, List & tags) { - if (modeIndex >= ArraySize(kModeOptions)) + if (modeIndex >= MATTER_ARRAY_SIZE(kModeOptions)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } diff --git a/examples/all-clusters-app/all-clusters-common/src/rvc-modes.cpp b/examples/all-clusters-app/all-clusters-common/src/rvc-modes.cpp index 5571834c375646..f03edd9dcb2a2f 100644 --- a/examples/all-clusters-app/all-clusters-common/src/rvc-modes.cpp +++ b/examples/all-clusters-app/all-clusters-common/src/rvc-modes.cpp @@ -68,7 +68,7 @@ void RvcRunModeDelegate::HandleChangeToMode(uint8_t NewMode, ModeBase::Commands: CHIP_ERROR RvcRunModeDelegate::GetModeLabelByIndex(uint8_t modeIndex, chip::MutableCharSpan & label) { - if (modeIndex >= ArraySize(kModeOptions)) + if (modeIndex >= MATTER_ARRAY_SIZE(kModeOptions)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } @@ -77,7 +77,7 @@ CHIP_ERROR RvcRunModeDelegate::GetModeLabelByIndex(uint8_t modeIndex, chip::Muta CHIP_ERROR RvcRunModeDelegate::GetModeValueByIndex(uint8_t modeIndex, uint8_t & value) { - if (modeIndex >= ArraySize(kModeOptions)) + if (modeIndex >= MATTER_ARRAY_SIZE(kModeOptions)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } @@ -87,7 +87,7 @@ CHIP_ERROR RvcRunModeDelegate::GetModeValueByIndex(uint8_t modeIndex, uint8_t & CHIP_ERROR RvcRunModeDelegate::GetModeTagsByIndex(uint8_t modeIndex, List & tags) { - if (modeIndex >= ArraySize(kModeOptions)) + if (modeIndex >= MATTER_ARRAY_SIZE(kModeOptions)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } @@ -161,7 +161,7 @@ void RvcCleanModeDelegate::HandleChangeToMode(uint8_t NewMode, ModeBase::Command CHIP_ERROR RvcCleanModeDelegate::GetModeLabelByIndex(uint8_t modeIndex, chip::MutableCharSpan & label) { - if (modeIndex >= ArraySize(kModeOptions)) + if (modeIndex >= MATTER_ARRAY_SIZE(kModeOptions)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } @@ -170,7 +170,7 @@ CHIP_ERROR RvcCleanModeDelegate::GetModeLabelByIndex(uint8_t modeIndex, chip::Mu CHIP_ERROR RvcCleanModeDelegate::GetModeValueByIndex(uint8_t modeIndex, uint8_t & value) { - if (modeIndex >= ArraySize(kModeOptions)) + if (modeIndex >= MATTER_ARRAY_SIZE(kModeOptions)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } @@ -180,7 +180,7 @@ CHIP_ERROR RvcCleanModeDelegate::GetModeValueByIndex(uint8_t modeIndex, uint8_t CHIP_ERROR RvcCleanModeDelegate::GetModeTagsByIndex(uint8_t modeIndex, List & tags) { - if (modeIndex >= ArraySize(kModeOptions)) + if (modeIndex >= MATTER_ARRAY_SIZE(kModeOptions)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } diff --git a/examples/all-clusters-app/all-clusters-common/src/tcc-mode.cpp b/examples/all-clusters-app/all-clusters-common/src/tcc-mode.cpp index 8f3c865aecaf0e..8e55ac31b64dc8 100644 --- a/examples/all-clusters-app/all-clusters-common/src/tcc-mode.cpp +++ b/examples/all-clusters-app/all-clusters-common/src/tcc-mode.cpp @@ -40,7 +40,7 @@ void TccModeDelegate::HandleChangeToMode(uint8_t NewMode, ModeBase::Commands::Ch CHIP_ERROR TccModeDelegate::GetModeLabelByIndex(uint8_t modeIndex, chip::MutableCharSpan & label) { - if (modeIndex >= ArraySize(kModeOptions)) + if (modeIndex >= MATTER_ARRAY_SIZE(kModeOptions)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } @@ -49,7 +49,7 @@ CHIP_ERROR TccModeDelegate::GetModeLabelByIndex(uint8_t modeIndex, chip::Mutable CHIP_ERROR TccModeDelegate::GetModeValueByIndex(uint8_t modeIndex, uint8_t & value) { - if (modeIndex >= ArraySize(kModeOptions)) + if (modeIndex >= MATTER_ARRAY_SIZE(kModeOptions)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } @@ -59,7 +59,7 @@ CHIP_ERROR TccModeDelegate::GetModeValueByIndex(uint8_t modeIndex, uint8_t & val CHIP_ERROR TccModeDelegate::GetModeTagsByIndex(uint8_t modeIndex, List & tags) { - if (modeIndex >= ArraySize(kModeOptions)) + if (modeIndex >= MATTER_ARRAY_SIZE(kModeOptions)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } diff --git a/examples/all-clusters-app/ameba/main/BindingHandler.cpp b/examples/all-clusters-app/ameba/main/BindingHandler.cpp index 1c0fef656c7913..2052abdf377560 100644 --- a/examples/all-clusters-app/ameba/main/BindingHandler.cpp +++ b/examples/all-clusters-app/ameba/main/BindingHandler.cpp @@ -584,32 +584,37 @@ static void RegisterSwitchCommands() // Register groups command sShellSwitchGroupsIdentifySubCommands.RegisterCommands(sSwitchGroupsIdentifySubCommands, - ArraySize(sSwitchGroupsIdentifySubCommands)); - sShellSwitchGroupsOnOffSubCommands.RegisterCommands(sSwitchGroupsOnOffSubCommands, ArraySize(sSwitchGroupsOnOffSubCommands)); + MATTER_ARRAY_SIZE(sSwitchGroupsIdentifySubCommands)); + sShellSwitchGroupsOnOffSubCommands.RegisterCommands(sSwitchGroupsOnOffSubCommands, + MATTER_ARRAY_SIZE(sSwitchGroupsOnOffSubCommands)); sShellSwitchGroupsLevelControlSubCommands.RegisterCommands(sSwitchGroupsLevelControlSubCommands, - ArraySize(sSwitchGroupsLevelControlSubCommands)); + MATTER_ARRAY_SIZE(sSwitchGroupsLevelControlSubCommands)); sShellSwitchGroupsColorControlSubCommands.RegisterCommands(sSwitchGroupsColorControlSubCommands, - ArraySize(sSwitchGroupsColorControlSubCommands)); + MATTER_ARRAY_SIZE(sSwitchGroupsColorControlSubCommands)); sShellSwitchGroupsThermostatSubCommands.RegisterCommands(sSwitchGroupsThermostatSubCommands, - ArraySize(sSwitchGroupsThermostatSubCommands)); + MATTER_ARRAY_SIZE(sSwitchGroupsThermostatSubCommands)); // Register commands - sShellSwitchIdentifySubCommands.RegisterCommands(sSwitchIdentifySubCommands, ArraySize(sSwitchIdentifySubCommands)); - sShellSwitchIdentifyReadSubCommands.RegisterCommands(sSwitchIdentifyReadSubCommands, ArraySize(sSwitchIdentifyReadSubCommands)); - sShellSwitchOnOffSubCommands.RegisterCommands(sSwitchOnOffSubCommands, ArraySize(sSwitchOnOffSubCommands)); - sShellSwitchOnOffReadSubCommands.RegisterCommands(sSwitchOnOffReadSubCommands, ArraySize(sSwitchOnOffReadSubCommands)); - sShellSwitchLevelControlSubCommands.RegisterCommands(sSwitchLevelControlSubCommands, ArraySize(sSwitchLevelControlSubCommands)); + sShellSwitchIdentifySubCommands.RegisterCommands(sSwitchIdentifySubCommands, MATTER_ARRAY_SIZE(sSwitchIdentifySubCommands)); + sShellSwitchIdentifyReadSubCommands.RegisterCommands(sSwitchIdentifyReadSubCommands, + MATTER_ARRAY_SIZE(sSwitchIdentifyReadSubCommands)); + sShellSwitchOnOffSubCommands.RegisterCommands(sSwitchOnOffSubCommands, MATTER_ARRAY_SIZE(sSwitchOnOffSubCommands)); + sShellSwitchOnOffReadSubCommands.RegisterCommands(sSwitchOnOffReadSubCommands, MATTER_ARRAY_SIZE(sSwitchOnOffReadSubCommands)); + sShellSwitchLevelControlSubCommands.RegisterCommands(sSwitchLevelControlSubCommands, + MATTER_ARRAY_SIZE(sSwitchLevelControlSubCommands)); sShellSwitchLevelControlReadSubCommands.RegisterCommands(sSwitchLevelControlReadSubCommands, - ArraySize(sSwitchLevelControlReadSubCommands)); - sShellSwitchColorControlSubCommands.RegisterCommands(sSwitchColorControlSubCommands, ArraySize(sSwitchColorControlSubCommands)); + MATTER_ARRAY_SIZE(sSwitchLevelControlReadSubCommands)); + sShellSwitchColorControlSubCommands.RegisterCommands(sSwitchColorControlSubCommands, + MATTER_ARRAY_SIZE(sSwitchColorControlSubCommands)); sShellSwitchColorControlReadSubCommands.RegisterCommands(sSwitchColorControlReadSubCommands, - ArraySize(sSwitchColorControlReadSubCommands)); - sShellSwitchThermostatSubCommands.RegisterCommands(sSwitchThermostatSubCommands, ArraySize(sSwitchThermostatSubCommands)); + MATTER_ARRAY_SIZE(sSwitchColorControlReadSubCommands)); + sShellSwitchThermostatSubCommands.RegisterCommands(sSwitchThermostatSubCommands, + MATTER_ARRAY_SIZE(sSwitchThermostatSubCommands)); sShellSwitchThermostatReadSubCommands.RegisterCommands(sSwitchThermostatReadSubCommands, - ArraySize(sSwitchThermostatReadSubCommands)); - sShellSwitchGroupsSubCommands.RegisterCommands(sSwitchGroupsSubCommands, ArraySize(sSwitchGroupsSubCommands)); - sShellSwitchBindingSubCommands.RegisterCommands(sSwitchBindingSubCommands, ArraySize(sSwitchBindingSubCommands)); - sShellSwitchSubCommands.RegisterCommands(sSwitchSubCommands, ArraySize(sSwitchSubCommands)); + MATTER_ARRAY_SIZE(sSwitchThermostatReadSubCommands)); + sShellSwitchGroupsSubCommands.RegisterCommands(sSwitchGroupsSubCommands, MATTER_ARRAY_SIZE(sSwitchGroupsSubCommands)); + sShellSwitchBindingSubCommands.RegisterCommands(sSwitchBindingSubCommands, MATTER_ARRAY_SIZE(sSwitchBindingSubCommands)); + sShellSwitchSubCommands.RegisterCommands(sSwitchSubCommands, MATTER_ARRAY_SIZE(sSwitchSubCommands)); Engine::Root().RegisterCommands(&sSwitchCommand, 1); } diff --git a/examples/all-clusters-app/ameba/main/ManualOperationCommand.cpp b/examples/all-clusters-app/ameba/main/ManualOperationCommand.cpp index d03dbcd42ae0bd..258a6c076365e7 100644 --- a/examples/all-clusters-app/ameba/main/ManualOperationCommand.cpp +++ b/examples/all-clusters-app/ameba/main/ManualOperationCommand.cpp @@ -136,20 +136,22 @@ static void RegisterManualOperationCommands() "Manual Operation commands. Usage: manual " }; // Register commands - sShellManualOperationSubCommands.RegisterCommands(sManualOperationSubCommands, ArraySize(sManualOperationSubCommands)); + sShellManualOperationSubCommands.RegisterCommands(sManualOperationSubCommands, MATTER_ARRAY_SIZE(sManualOperationSubCommands)); sShellManualOperationalStateSubCommands.RegisterCommands(sManualOperationalStateSubCommands, - ArraySize(sManualOperationalStateSubCommands)); - sShellManualRVCSubCommands.RegisterCommands(sManualRVCSubCommands, ArraySize(sManualRVCSubCommands)); + MATTER_ARRAY_SIZE(sManualOperationalStateSubCommands)); + sShellManualRVCSubCommands.RegisterCommands(sManualRVCSubCommands, MATTER_ARRAY_SIZE(sManualRVCSubCommands)); sShellManualRVCOperationalStateSubCommands.RegisterCommands(sManualRVCOperationalStateSubCommands, - ArraySize(sManualRVCOperationalStateSubCommands)); - sShellManualRVCRunModeSubCommands.RegisterCommands(sManualRVCRunModeSubCommands, ArraySize(sManualRVCRunModeSubCommands)); - sShellManualRVCCleanModeSubCommands.RegisterCommands(sManualRVCCleanModeSubCommands, ArraySize(sManualRVCCleanModeSubCommands)); + MATTER_ARRAY_SIZE(sManualRVCOperationalStateSubCommands)); + sShellManualRVCRunModeSubCommands.RegisterCommands(sManualRVCRunModeSubCommands, + MATTER_ARRAY_SIZE(sManualRVCRunModeSubCommands)); + sShellManualRVCCleanModeSubCommands.RegisterCommands(sManualRVCCleanModeSubCommands, + MATTER_ARRAY_SIZE(sManualRVCCleanModeSubCommands)); sShellManualRefrigeratorAlarmStateSubCommands.RegisterCommands(sManualRefrigeratorAlarmStateSubCommands, - ArraySize(sManualRefrigeratorAlarmStateSubCommands)); + MATTER_ARRAY_SIZE(sManualRefrigeratorAlarmStateSubCommands)); sShellManualDishWasherAlarmStateSubCommands.RegisterCommands(sManualDishWasherAlarmSubCommands, - ArraySize(sManualDishWasherAlarmSubCommands)); - sShellManualOvenCavityOperationalStateSubCommands.RegisterCommands(sManualOvenCavityOperationalStateSubCommands, - ArraySize(sManualOvenCavityOperationalStateSubCommands)); + MATTER_ARRAY_SIZE(sManualDishWasherAlarmSubCommands)); + sShellManualOvenCavityOperationalStateSubCommands.RegisterCommands( + sManualOvenCavityOperationalStateSubCommands, MATTER_ARRAY_SIZE(sManualOvenCavityOperationalStateSubCommands)); Engine::Root().RegisterCommands(&sManualOperationCommand, 1); } diff --git a/examples/all-clusters-app/esp32/main/ShellCommands.cpp b/examples/all-clusters-app/esp32/main/ShellCommands.cpp index 3c7b4822d21558..046a80034564e2 100644 --- a/examples/all-clusters-app/esp32/main/ShellCommands.cpp +++ b/examples/all-clusters-app/esp32/main/ShellCommands.cpp @@ -26,7 +26,7 @@ void OnOffCommands::Register() static const shell_command_t subCommands[] = { { &OnLightHandler, "on", "Usage: OnOff on endpoint-id" }, { &OffLightHandler, "off", "Usage: OnOff off endpoint-id" }, { &ToggleLightHandler, "toggle", "Usage: OnOff toggle endpoint-id" } }; - sSubShell.RegisterCommands(subCommands, ArraySize(subCommands)); + sSubShell.RegisterCommands(subCommands, MATTER_ARRAY_SIZE(subCommands)); // Register the root `OnOff` command in the top-level shell. static const shell_command_t onOffCommand = { &OnOffHandler, "OnOff", "OnOff commands" }; @@ -43,7 +43,7 @@ void CASECommands::Register() static const shell_command_t subCommands[] = { { &ConnectToNodeHandler, "connect", "Establish CASESession to a node, Usage: case connect " }, }; - sSubShell.RegisterCommands(subCommands, ArraySize(subCommands)); + sSubShell.RegisterCommands(subCommands, MATTER_ARRAY_SIZE(subCommands)); static const shell_command_t CASECommand = { &CASEHandler, "case", "Case Commands" }; Engine::Root().RegisterCommands(&CASECommand, 1); diff --git a/examples/all-clusters-app/infineon/psoc6/src/AppTask.cpp b/examples/all-clusters-app/infineon/psoc6/src/AppTask.cpp index f763b5442c574f..ad63cf585f49fc 100644 --- a/examples/all-clusters-app/infineon/psoc6/src/AppTask.cpp +++ b/examples/all-clusters-app/infineon/psoc6/src/AppTask.cpp @@ -157,7 +157,7 @@ CHIP_ERROR AppTask::StartAppTask() appError(APP_ERROR_EVENT_QUEUE_FAILED); } // Start App task. - sAppTaskHandle = xTaskCreateStatic(AppTaskMain, APP_TASK_NAME, ArraySize(appStack), NULL, 1, appStack, &appTaskStruct); + sAppTaskHandle = xTaskCreateStatic(AppTaskMain, APP_TASK_NAME, MATTER_ARRAY_SIZE(appStack), NULL, 1, appStack, &appTaskStruct); return (sAppTaskHandle == nullptr) ? APP_ERROR_CREATE_TASK_FAILED : CHIP_NO_ERROR; } diff --git a/examples/all-clusters-minimal-app/esp32/main/ShellCommands.cpp b/examples/all-clusters-minimal-app/esp32/main/ShellCommands.cpp index 3c7b4822d21558..046a80034564e2 100644 --- a/examples/all-clusters-minimal-app/esp32/main/ShellCommands.cpp +++ b/examples/all-clusters-minimal-app/esp32/main/ShellCommands.cpp @@ -26,7 +26,7 @@ void OnOffCommands::Register() static const shell_command_t subCommands[] = { { &OnLightHandler, "on", "Usage: OnOff on endpoint-id" }, { &OffLightHandler, "off", "Usage: OnOff off endpoint-id" }, { &ToggleLightHandler, "toggle", "Usage: OnOff toggle endpoint-id" } }; - sSubShell.RegisterCommands(subCommands, ArraySize(subCommands)); + sSubShell.RegisterCommands(subCommands, MATTER_ARRAY_SIZE(subCommands)); // Register the root `OnOff` command in the top-level shell. static const shell_command_t onOffCommand = { &OnOffHandler, "OnOff", "OnOff commands" }; @@ -43,7 +43,7 @@ void CASECommands::Register() static const shell_command_t subCommands[] = { { &ConnectToNodeHandler, "connect", "Establish CASESession to a node, Usage: case connect " }, }; - sSubShell.RegisterCommands(subCommands, ArraySize(subCommands)); + sSubShell.RegisterCommands(subCommands, MATTER_ARRAY_SIZE(subCommands)); static const shell_command_t CASECommand = { &CASEHandler, "case", "Case Commands" }; Engine::Root().RegisterCommands(&CASECommand, 1); diff --git a/examples/all-clusters-minimal-app/infineon/psoc6/src/AppTask.cpp b/examples/all-clusters-minimal-app/infineon/psoc6/src/AppTask.cpp index f1f774a0e00743..ea8d747adf5996 100644 --- a/examples/all-clusters-minimal-app/infineon/psoc6/src/AppTask.cpp +++ b/examples/all-clusters-minimal-app/infineon/psoc6/src/AppTask.cpp @@ -154,7 +154,7 @@ CHIP_ERROR AppTask::StartAppTask() appError(APP_ERROR_EVENT_QUEUE_FAILED); } // Start App task. - sAppTaskHandle = xTaskCreateStatic(AppTaskMain, APP_TASK_NAME, ArraySize(appStack), NULL, 1, appStack, &appTaskStruct); + sAppTaskHandle = xTaskCreateStatic(AppTaskMain, APP_TASK_NAME, MATTER_ARRAY_SIZE(appStack), NULL, 1, appStack, &appTaskStruct); return (sAppTaskHandle == nullptr) ? APP_ERROR_CREATE_TASK_FAILED : CHIP_NO_ERROR; } diff --git a/examples/android/CHIPTool/app/src/main/cpp/native-lib.cpp b/examples/android/CHIPTool/app/src/main/cpp/native-lib.cpp index abf57152cd153d..5b1cf06656fddf 100644 --- a/examples/android/CHIPTool/app/src/main/cpp/native-lib.cpp +++ b/examples/android/CHIPTool/app/src/main/cpp/native-lib.cpp @@ -33,7 +33,7 @@ std::string base38Encode(void) { const uint8_t buf[] = { 0, 1, 2, 3, 4, 5 }; - size_t size = ArraySize(buf); + size_t size = MATTER_ARRAY_SIZE(buf); return chip::base38Encode(&buf[0], size); } diff --git a/examples/bridge-app/asr/subdevice/subdevice_test.cpp b/examples/bridge-app/asr/subdevice/subdevice_test.cpp index ad1752557663bb..cef412ae72fa00 100644 --- a/examples/bridge-app/asr/subdevice/subdevice_test.cpp +++ b/examples/bridge-app/asr/subdevice/subdevice_test.cpp @@ -102,10 +102,10 @@ DECLARE_DYNAMIC_CLUSTER(OnOff::Id, onOffAttrs, ZAP_CLUSTER_MASK(SERVER), onOffIn // Declare Bridged Light endpoint DECLARE_DYNAMIC_ENDPOINT(bridgedLightEndpoint, bridgedLightClusters); -DataVersion gLight1DataVersions[ArraySize(bridgedLightClusters)]; -DataVersion gLight2DataVersions[ArraySize(bridgedLightClusters)]; -DataVersion gLight3DataVersions[ArraySize(bridgedLightClusters)]; -DataVersion gLight4DataVersions[ArraySize(bridgedLightClusters)]; +DataVersion gLight1DataVersions[MATTER_ARRAY_SIZE(bridgedLightClusters)]; +DataVersion gLight2DataVersions[MATTER_ARRAY_SIZE(bridgedLightClusters)]; +DataVersion gLight3DataVersions[MATTER_ARRAY_SIZE(bridgedLightClusters)]; +DataVersion gLight4DataVersions[MATTER_ARRAY_SIZE(bridgedLightClusters)]; const EmberAfDeviceType gRootDeviceTypes[] = { { DEVICE_TYPE_ROOT_NODE, DEVICE_VERSION_DEFAULT } }; const EmberAfDeviceType gAggregateNodeDeviceTypes[] = { { DEVICE_TYPE_BRIDGE, DEVICE_VERSION_DEFAULT } }; diff --git a/examples/bridge-app/esp32/main/main.cpp b/examples/bridge-app/esp32/main/main.cpp index 2cc68ef559f260..ae56a1d8b53d39 100644 --- a/examples/bridge-app/esp32/main/main.cpp +++ b/examples/bridge-app/esp32/main/main.cpp @@ -145,10 +145,10 @@ DECLARE_DYNAMIC_CLUSTER(OnOff::Id, onOffAttrs, ZAP_CLUSTER_MASK(SERVER), onOffIn // Declare Bridged Light endpoint DECLARE_DYNAMIC_ENDPOINT(bridgedLightEndpoint, bridgedLightClusters); -DataVersion gLight1DataVersions[ArraySize(bridgedLightClusters)]; -DataVersion gLight2DataVersions[ArraySize(bridgedLightClusters)]; -DataVersion gLight3DataVersions[ArraySize(bridgedLightClusters)]; -DataVersion gLight4DataVersions[ArraySize(bridgedLightClusters)]; +DataVersion gLight1DataVersions[MATTER_ARRAY_SIZE(bridgedLightClusters)]; +DataVersion gLight2DataVersions[MATTER_ARRAY_SIZE(bridgedLightClusters)]; +DataVersion gLight3DataVersions[MATTER_ARRAY_SIZE(bridgedLightClusters)]; +DataVersion gLight4DataVersions[MATTER_ARRAY_SIZE(bridgedLightClusters)]; /* REVISION definitions: */ diff --git a/examples/bridge-app/linux/main.cpp b/examples/bridge-app/linux/main.cpp index 192fa3424de681..10f2f27b1efb59 100644 --- a/examples/bridge-app/linux/main.cpp +++ b/examples/bridge-app/linux/main.cpp @@ -152,8 +152,8 @@ DECLARE_DYNAMIC_CLUSTER(OnOff::Id, onOffAttrs, ZAP_CLUSTER_MASK(SERVER), onOffIn // Declare Bridged Light endpoint DECLARE_DYNAMIC_ENDPOINT(bridgedLightEndpoint, bridgedLightClusters); -DataVersion gLight1DataVersions[ArraySize(bridgedLightClusters)]; -DataVersion gLight2DataVersions[ArraySize(bridgedLightClusters)]; +DataVersion gLight1DataVersions[MATTER_ARRAY_SIZE(bridgedLightClusters)]; +DataVersion gLight2DataVersions[MATTER_ARRAY_SIZE(bridgedLightClusters)]; DeviceOnOff Light1("Light 1", "Office"); DeviceOnOff Light2("Light 2", "Office"); @@ -162,10 +162,10 @@ DeviceTempSensor TempSensor1("TempSensor 1", "Office", minMeasuredValue, maxMeas DeviceTempSensor TempSensor2("TempSensor 2", "Office", minMeasuredValue, maxMeasuredValue, initialMeasuredValue); // Declare Bridged endpoints used for Action clusters -DataVersion gActionLight1DataVersions[ArraySize(bridgedLightClusters)]; -DataVersion gActionLight2DataVersions[ArraySize(bridgedLightClusters)]; -DataVersion gActionLight3DataVersions[ArraySize(bridgedLightClusters)]; -DataVersion gActionLight4DataVersions[ArraySize(bridgedLightClusters)]; +DataVersion gActionLight1DataVersions[MATTER_ARRAY_SIZE(bridgedLightClusters)]; +DataVersion gActionLight2DataVersions[MATTER_ARRAY_SIZE(bridgedLightClusters)]; +DataVersion gActionLight3DataVersions[MATTER_ARRAY_SIZE(bridgedLightClusters)]; +DataVersion gActionLight4DataVersions[MATTER_ARRAY_SIZE(bridgedLightClusters)]; DeviceOnOff ActionLight1("Action Light 1", "Room 1"); DeviceOnOff ActionLight2("Action Light 2", "Room 1"); @@ -209,8 +209,8 @@ DECLARE_DYNAMIC_CLUSTER(TemperatureMeasurement::Id, tempSensorAttrs, ZAP_CLUSTER // Declare Bridged Light endpoint DECLARE_DYNAMIC_ENDPOINT(bridgedTempSensorEndpoint, bridgedTempSensorClusters); -DataVersion gTempSensor1DataVersions[ArraySize(bridgedTempSensorClusters)]; -DataVersion gTempSensor2DataVersions[ArraySize(bridgedTempSensorClusters)]; +DataVersion gTempSensor1DataVersions[MATTER_ARRAY_SIZE(bridgedTempSensorClusters)]; +DataVersion gTempSensor2DataVersions[MATTER_ARRAY_SIZE(bridgedTempSensorClusters)]; // --------------------------------------------------------------------------- // @@ -237,9 +237,9 @@ DECLARE_DYNAMIC_CLUSTER(Descriptor::Id, descriptorAttrs, ZAP_CLUSTER_MASK(SERVER DECLARE_DYNAMIC_CLUSTER_LIST_END; DECLARE_DYNAMIC_ENDPOINT(bridgedComposedDeviceEndpoint, bridgedComposedDeviceClusters); -DataVersion gComposedDeviceDataVersions[ArraySize(bridgedComposedDeviceClusters)]; -DataVersion gComposedTempSensor1DataVersions[ArraySize(bridgedTempSensorClusters)]; -DataVersion gComposedTempSensor2DataVersions[ArraySize(bridgedTempSensorClusters)]; +DataVersion gComposedDeviceDataVersions[MATTER_ARRAY_SIZE(bridgedComposedDeviceClusters)]; +DataVersion gComposedTempSensor1DataVersions[MATTER_ARRAY_SIZE(bridgedTempSensorClusters)]; +DataVersion gComposedTempSensor2DataVersions[MATTER_ARRAY_SIZE(bridgedTempSensorClusters)]; } // namespace diff --git a/examples/bridge-app/telink/src/AppTask.cpp b/examples/bridge-app/telink/src/AppTask.cpp index 79644c2860ae21..0f59c3d7751936 100644 --- a/examples/bridge-app/telink/src/AppTask.cpp +++ b/examples/bridge-app/telink/src/AppTask.cpp @@ -163,16 +163,16 @@ DECLARE_DYNAMIC_CLUSTER(Clusters::TemperatureMeasurement::Id, tempSensorAttrs, Z // Declare Bridged Light endpoint DECLARE_DYNAMIC_ENDPOINT(bridgedTempSensorEndpoint, bridgedTempSensorClusters); -DataVersion gTempSensor1DataVersions[ArraySize(bridgedTempSensorClusters)]; +DataVersion gTempSensor1DataVersions[MATTER_ARRAY_SIZE(bridgedTempSensorClusters)]; // Declare Bridged Light endpoint DECLARE_DYNAMIC_ENDPOINT(bridgedLightEndpoint, bridgedLightClusters); -DataVersion gLight1DataVersions[ArraySize(bridgedLightClusters)]; -DataVersion gLight2DataVersions[ArraySize(bridgedLightClusters)]; -DataVersion gLight3DataVersions[ArraySize(bridgedLightClusters)]; -DataVersion gLight4DataVersions[ArraySize(bridgedLightClusters)]; -// DataVersion gThermostatDataVersions[ArraySize(thermostatAttrs)]; +DataVersion gLight1DataVersions[MATTER_ARRAY_SIZE(bridgedLightClusters)]; +DataVersion gLight2DataVersions[MATTER_ARRAY_SIZE(bridgedLightClusters)]; +DataVersion gLight3DataVersions[MATTER_ARRAY_SIZE(bridgedLightClusters)]; +DataVersion gLight4DataVersions[MATTER_ARRAY_SIZE(bridgedLightClusters)]; +// DataVersion gThermostatDataVersions[MATTER_ARRAY_SIZE(thermostatAttrs)]; const EmberAfDeviceType gRootDeviceTypes[] = { { DEVICE_TYPE_ROOT_NODE, DEVICE_VERSION_DEFAULT } }; const EmberAfDeviceType gAggregateNodeDeviceTypes[] = { { DEVICE_TYPE_BRIDGE, DEVICE_VERSION_DEFAULT } }; diff --git a/examples/camera-app/linux/src/clusters/chime/chime-manager.cpp b/examples/camera-app/linux/src/clusters/chime/chime-manager.cpp index fb4b5db67b928f..eb7c9740e0bc7d 100644 --- a/examples/camera-app/linux/src/clusters/chime/chime-manager.cpp +++ b/examples/camera-app/linux/src/clusters/chime/chime-manager.cpp @@ -31,7 +31,7 @@ using namespace Camera; // Chime Cluster Methods CHIP_ERROR ChimeManager::GetChimeSoundByIndex(uint8_t chimeIndex, uint8_t & chimeID, MutableCharSpan & name) { - if (chimeIndex >= ArraySize(mChimeSounds)) + if (chimeIndex >= MATTER_ARRAY_SIZE(mChimeSounds)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } @@ -42,7 +42,7 @@ CHIP_ERROR ChimeManager::GetChimeSoundByIndex(uint8_t chimeIndex, uint8_t & chim CHIP_ERROR ChimeManager::GetChimeIDByIndex(uint8_t chimeIndex, uint8_t & chimeID) { - if (chimeIndex >= ArraySize(mChimeSounds)) + if (chimeIndex >= MATTER_ARRAY_SIZE(mChimeSounds)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } diff --git a/examples/chef/common/chef-dishwasher-mode-delegate-impl.cpp b/examples/chef/common/chef-dishwasher-mode-delegate-impl.cpp index 397f13ad2b21a4..a8ef369222038d 100644 --- a/examples/chef/common/chef-dishwasher-mode-delegate-impl.cpp +++ b/examples/chef/common/chef-dishwasher-mode-delegate-impl.cpp @@ -46,7 +46,7 @@ void DishwasherModeDelegate::HandleChangeToMode(uint8_t NewMode, ModeBase::Comma CHIP_ERROR DishwasherModeDelegate::GetModeLabelByIndex(uint8_t modeIndex, chip::MutableCharSpan & label) { - if (modeIndex >= ArraySize(kModeOptions)) + if (modeIndex >= MATTER_ARRAY_SIZE(kModeOptions)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } @@ -55,7 +55,7 @@ CHIP_ERROR DishwasherModeDelegate::GetModeLabelByIndex(uint8_t modeIndex, chip:: CHIP_ERROR DishwasherModeDelegate::GetModeValueByIndex(uint8_t modeIndex, uint8_t & value) { - if (modeIndex >= ArraySize(kModeOptions)) + if (modeIndex >= MATTER_ARRAY_SIZE(kModeOptions)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } @@ -65,7 +65,7 @@ CHIP_ERROR DishwasherModeDelegate::GetModeValueByIndex(uint8_t modeIndex, uint8_ CHIP_ERROR DishwasherModeDelegate::GetModeTagsByIndex(uint8_t modeIndex, List & tags) { - if (modeIndex >= ArraySize(kModeOptions)) + if (modeIndex >= MATTER_ARRAY_SIZE(kModeOptions)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } diff --git a/examples/chef/common/chef-laundry-washer-controls-delegate-impl.cpp b/examples/chef/common/chef-laundry-washer-controls-delegate-impl.cpp index f63acf8938bb9f..88bc8e92ae3edc 100644 --- a/examples/chef/common/chef-laundry-washer-controls-delegate-impl.cpp +++ b/examples/chef/common/chef-laundry-washer-controls-delegate-impl.cpp @@ -40,7 +40,7 @@ LaundryWasherControlDelegate LaundryWasherControlDelegate::instance; CHIP_ERROR LaundryWasherControlDelegate::GetSpinSpeedAtIndex(size_t index, MutableCharSpan & spinSpeed) { - if (index >= ArraySize(spinSpeedsNameOptions)) + if (index >= MATTER_ARRAY_SIZE(spinSpeedsNameOptions)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } @@ -49,7 +49,7 @@ CHIP_ERROR LaundryWasherControlDelegate::GetSpinSpeedAtIndex(size_t index, Mutab CHIP_ERROR LaundryWasherControlDelegate::GetSupportedRinseAtIndex(size_t index, NumberOfRinsesEnum & supportedRinse) { - if (index >= ArraySize(supportRinsesOptions)) + if (index >= MATTER_ARRAY_SIZE(supportRinsesOptions)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } diff --git a/examples/chef/common/chef-laundry-washer-mode.cpp b/examples/chef/common/chef-laundry-washer-mode.cpp index 8ca637ca29404a..099e268f3e8111 100644 --- a/examples/chef/common/chef-laundry-washer-mode.cpp +++ b/examples/chef/common/chef-laundry-washer-mode.cpp @@ -41,7 +41,7 @@ void LaundryWasherModeDelegate::HandleChangeToMode(uint8_t NewMode, ModeBase::Co CHIP_ERROR LaundryWasherModeDelegate::GetModeLabelByIndex(uint8_t modeIndex, chip::MutableCharSpan & label) { - if (modeIndex >= ArraySize(kModeOptions)) + if (modeIndex >= MATTER_ARRAY_SIZE(kModeOptions)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } @@ -50,7 +50,7 @@ CHIP_ERROR LaundryWasherModeDelegate::GetModeLabelByIndex(uint8_t modeIndex, chi CHIP_ERROR LaundryWasherModeDelegate::GetModeValueByIndex(uint8_t modeIndex, uint8_t & value) { - if (modeIndex >= ArraySize(kModeOptions)) + if (modeIndex >= MATTER_ARRAY_SIZE(kModeOptions)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } @@ -60,7 +60,7 @@ CHIP_ERROR LaundryWasherModeDelegate::GetModeValueByIndex(uint8_t modeIndex, uin CHIP_ERROR LaundryWasherModeDelegate::GetModeTagsByIndex(uint8_t modeIndex, List & tags) { - if (modeIndex >= ArraySize(kModeOptions)) + if (modeIndex >= MATTER_ARRAY_SIZE(kModeOptions)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } diff --git a/examples/chef/common/chef-rvc-mode-delegate.cpp b/examples/chef/common/chef-rvc-mode-delegate.cpp index e5444e03737c32..f6c10412812dea 100644 --- a/examples/chef/common/chef-rvc-mode-delegate.cpp +++ b/examples/chef/common/chef-rvc-mode-delegate.cpp @@ -56,7 +56,7 @@ void RvcRunModeDelegate::HandleChangeToMode(uint8_t NewMode, ModeBase::Commands: CHIP_ERROR RvcRunModeDelegate::GetModeLabelByIndex(uint8_t modeIndex, chip::MutableCharSpan & label) { - if (modeIndex >= ArraySize(kModeOptions)) + if (modeIndex >= MATTER_ARRAY_SIZE(kModeOptions)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } @@ -65,7 +65,7 @@ CHIP_ERROR RvcRunModeDelegate::GetModeLabelByIndex(uint8_t modeIndex, chip::Muta CHIP_ERROR RvcRunModeDelegate::GetModeValueByIndex(uint8_t modeIndex, uint8_t & value) { - if (modeIndex >= ArraySize(kModeOptions)) + if (modeIndex >= MATTER_ARRAY_SIZE(kModeOptions)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } @@ -75,7 +75,7 @@ CHIP_ERROR RvcRunModeDelegate::GetModeValueByIndex(uint8_t modeIndex, uint8_t & CHIP_ERROR RvcRunModeDelegate::GetModeTagsByIndex(uint8_t modeIndex, List & tags) { - if (modeIndex >= ArraySize(kModeOptions)) + if (modeIndex >= MATTER_ARRAY_SIZE(kModeOptions)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } @@ -189,7 +189,7 @@ void RvcCleanModeDelegate::HandleChangeToMode(uint8_t NewMode, ModeBase::Command CHIP_ERROR RvcCleanModeDelegate::GetModeLabelByIndex(uint8_t modeIndex, chip::MutableCharSpan & label) { - if (modeIndex >= ArraySize(kModeOptions)) + if (modeIndex >= MATTER_ARRAY_SIZE(kModeOptions)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } @@ -198,7 +198,7 @@ CHIP_ERROR RvcCleanModeDelegate::GetModeLabelByIndex(uint8_t modeIndex, chip::Mu CHIP_ERROR RvcCleanModeDelegate::GetModeValueByIndex(uint8_t modeIndex, uint8_t & value) { - if (modeIndex >= ArraySize(kModeOptions)) + if (modeIndex >= MATTER_ARRAY_SIZE(kModeOptions)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } @@ -208,7 +208,7 @@ CHIP_ERROR RvcCleanModeDelegate::GetModeValueByIndex(uint8_t modeIndex, uint8_t CHIP_ERROR RvcCleanModeDelegate::GetModeTagsByIndex(uint8_t modeIndex, List & tags) { - if (modeIndex >= ArraySize(kModeOptions)) + if (modeIndex >= MATTER_ARRAY_SIZE(kModeOptions)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } diff --git a/examples/chef/common/clusters/refrigerator-and-temperature-controlled-cabinet-mode/tcc-mode.cpp b/examples/chef/common/clusters/refrigerator-and-temperature-controlled-cabinet-mode/tcc-mode.cpp index bee737011195e2..78daa3d15a6083 100644 --- a/examples/chef/common/clusters/refrigerator-and-temperature-controlled-cabinet-mode/tcc-mode.cpp +++ b/examples/chef/common/clusters/refrigerator-and-temperature-controlled-cabinet-mode/tcc-mode.cpp @@ -42,7 +42,7 @@ void TccModeDelegate::HandleChangeToMode(uint8_t NewMode, ModeBase::Commands::Ch CHIP_ERROR TccModeDelegate::GetModeLabelByIndex(uint8_t modeIndex, chip::MutableCharSpan & label) { - if (modeIndex >= ArraySize(kModeOptions)) + if (modeIndex >= MATTER_ARRAY_SIZE(kModeOptions)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } @@ -51,7 +51,7 @@ CHIP_ERROR TccModeDelegate::GetModeLabelByIndex(uint8_t modeIndex, chip::Mutable CHIP_ERROR TccModeDelegate::GetModeValueByIndex(uint8_t modeIndex, uint8_t & value) { - if (modeIndex >= ArraySize(kModeOptions)) + if (modeIndex >= MATTER_ARRAY_SIZE(kModeOptions)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } @@ -61,7 +61,7 @@ CHIP_ERROR TccModeDelegate::GetModeValueByIndex(uint8_t modeIndex, uint8_t & val CHIP_ERROR TccModeDelegate::GetModeTagsByIndex(uint8_t modeIndex, List & tags) { - if (modeIndex >= ArraySize(kModeOptions)) + if (modeIndex >= MATTER_ARRAY_SIZE(kModeOptions)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } diff --git a/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.cpp b/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.cpp index 7ebbd0f8132487..479cf8965251fb 100644 --- a/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.cpp +++ b/examples/chef/common/clusters/temperature-control/static-supported-temperature-levels.cpp @@ -35,7 +35,7 @@ CharSpan AppSupportedTemperatureLevelsDelegate::temperatureLevelOptions[] = { "L const AppSupportedTemperatureLevelsDelegate::EndpointPair AppSupportedTemperatureLevelsDelegate::supportedOptionsByEndpoints [MATTER_DM_TEMPERATURE_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT] = { EndpointPair( 1 /* endpointId */, AppSupportedTemperatureLevelsDelegate::temperatureLevelOptions, - ArraySize(AppSupportedTemperatureLevelsDelegate::temperatureLevelOptions)) }; + MATTER_ARRAY_SIZE(AppSupportedTemperatureLevelsDelegate::temperatureLevelOptions)) }; uint8_t AppSupportedTemperatureLevelsDelegate::Size() { diff --git a/examples/chip-tool/commands/clusters/CustomArgument.h b/examples/chip-tool/commands/clusters/CustomArgument.h index 05da3a37936119..1dcfdc2a18feb6 100644 --- a/examples/chip-tool/commands/clusters/CustomArgument.h +++ b/examples/chip-tool/commands/clusters/CustomArgument.h @@ -34,11 +34,11 @@ static constexpr char kPayloadSignedPrefix[] = "s:"; static constexpr char kPayloadUnsignedPrefix[] = "u:"; static constexpr char kPayloadFloatPrefix[] = "f:"; static constexpr char kPayloadDoublePrefix[] = "d:"; -static constexpr size_t kPayloadHexPrefixLen = ArraySize(kPayloadHexPrefix) - 1; // ignore null character -static constexpr size_t kPayloadSignedPrefixLen = ArraySize(kPayloadSignedPrefix) - 1; // ignore null character -static constexpr size_t kPayloadUnsignedPrefixLen = ArraySize(kPayloadUnsignedPrefix) - 1; // ignore null character -static constexpr size_t kPayloadFloatPrefixLen = ArraySize(kPayloadFloatPrefix) - 1; // ignore null character -static constexpr size_t kPayloadDoublePrefixLen = ArraySize(kPayloadDoublePrefix) - 1; // ignore null character +static constexpr size_t kPayloadHexPrefixLen = MATTER_ARRAY_SIZE(kPayloadHexPrefix) - 1; // ignore null character +static constexpr size_t kPayloadSignedPrefixLen = MATTER_ARRAY_SIZE(kPayloadSignedPrefix) - 1; // ignore null character +static constexpr size_t kPayloadUnsignedPrefixLen = MATTER_ARRAY_SIZE(kPayloadUnsignedPrefix) - 1; // ignore null character +static constexpr size_t kPayloadFloatPrefixLen = MATTER_ARRAY_SIZE(kPayloadFloatPrefix) - 1; // ignore null character +static constexpr size_t kPayloadDoublePrefixLen = MATTER_ARRAY_SIZE(kPayloadDoublePrefix) - 1; // ignore null character } // namespace class CustomArgumentParser @@ -236,7 +236,7 @@ class CustomArgument { Json::Value value; static constexpr char kHexNumPrefix[] = "0x"; - constexpr size_t kHexNumPrefixLen = ArraySize(kHexNumPrefix) - 1; + constexpr size_t kHexNumPrefixLen = MATTER_ARRAY_SIZE(kHexNumPrefix) - 1; if (strncmp(json, kPayloadHexPrefix, kPayloadHexPrefixLen) == 0 || strncmp(json, kPayloadSignedPrefix, kPayloadSignedPrefixLen) == 0 || strncmp(json, kPayloadUnsignedPrefix, kPayloadUnsignedPrefixLen) == 0 || diff --git a/examples/chip-tool/commands/clusters/DataModelLogger.h b/examples/chip-tool/commands/clusters/DataModelLogger.h index 7186b833ff5153..ce144d586ee8b6 100644 --- a/examples/chip-tool/commands/clusters/DataModelLogger.h +++ b/examples/chip-tool/commands/clusters/DataModelLogger.h @@ -59,27 +59,28 @@ class DataModelLogger // buffer. char buffer[CHIP_CONFIG_LOG_MESSAGE_MAX_SIZE / 2]; size_t prefixSize = ComputePrefixSize(label, indent); - if (prefixSize > ArraySize(buffer)) + if (prefixSize > MATTER_ARRAY_SIZE(buffer)) { DataModelLogger::LogString("", 0, "Prefix is too long to fit in buffer"); return CHIP_ERROR_INTERNAL; } - const size_t availableSize = ArraySize(buffer) - prefixSize; + const size_t availableSize = MATTER_ARRAY_SIZE(buffer) - prefixSize; // Each byte ends up as two hex characters. const size_t bytesPerLogCall = availableSize / 2; std::string labelStr(label); while (value.size() > bytesPerLogCall) { ReturnErrorOnFailure( - chip::Encoding::BytesToUppercaseHexString(value.data(), bytesPerLogCall, &buffer[0], ArraySize(buffer))); + chip::Encoding::BytesToUppercaseHexString(value.data(), bytesPerLogCall, &buffer[0], MATTER_ARRAY_SIZE(buffer))); LogString(labelStr, indent, buffer); value = value.SubSpan(bytesPerLogCall); // For the second and following lines, make it clear that they are // continuation lines by replacing the label with "....". labelStr.replace(labelStr.begin(), labelStr.end(), labelStr.size(), '.'); } - ReturnErrorOnFailure(chip::Encoding::BytesToUppercaseHexString(value.data(), value.size(), &buffer[0], ArraySize(buffer))); + ReturnErrorOnFailure( + chip::Encoding::BytesToUppercaseHexString(value.data(), value.size(), &buffer[0], MATTER_ARRAY_SIZE(buffer))); LogString(labelStr, indent, buffer); return CHIP_NO_ERROR; diff --git a/examples/chip-tool/commands/common/BDXDiagnosticLogsServerDelegate.cpp b/examples/chip-tool/commands/common/BDXDiagnosticLogsServerDelegate.cpp index 9be365ab27e2bf..2c0452a7273390 100644 --- a/examples/chip-tool/commands/common/BDXDiagnosticLogsServerDelegate.cpp +++ b/examples/chip-tool/commands/common/BDXDiagnosticLogsServerDelegate.cpp @@ -153,7 +153,7 @@ CHIP_ERROR BDXDiagnosticLogsServerDelegate::OnTransferBegin(chip::bdx::BDXTransf ReturnErrorOnFailure(GetFilePath(fileDesignator, outputFilePathSpan)); // Ensure null-termination of the filename, since we will be passing it around as a char *. - VerifyOrReturnError(outputFilePathSpan.size() < ArraySize(outputFilePath), CHIP_ERROR_INTERNAL); + VerifyOrReturnError(outputFilePathSpan.size() < MATTER_ARRAY_SIZE(outputFilePath), CHIP_ERROR_INTERNAL); outputFilePath[outputFilePathSpan.size()] = '\0'; ReturnErrorOnFailure(CheckFileDoesNotExist(outputFilePath)); diff --git a/examples/chip-tool/commands/common/CustomStringPrefix.h b/examples/chip-tool/commands/common/CustomStringPrefix.h index 63196f78dbe3da..00da143e6a297a 100644 --- a/examples/chip-tool/commands/common/CustomStringPrefix.h +++ b/examples/chip-tool/commands/common/CustomStringPrefix.h @@ -23,16 +23,16 @@ #include static constexpr char kJsonStringPrefix[] = "json:"; -inline constexpr size_t kJsonStringPrefixLen = ArraySize(kJsonStringPrefix) - 1; // Don't count the null +inline constexpr size_t kJsonStringPrefixLen = MATTER_ARRAY_SIZE(kJsonStringPrefix) - 1; // Don't count the null static constexpr char kBase64StringPrefix[] = "base64:"; -inline constexpr size_t kBase64StringPrefixLen = ArraySize(kBase64StringPrefix) - 1; // Don't count the null +inline constexpr size_t kBase64StringPrefixLen = MATTER_ARRAY_SIZE(kBase64StringPrefix) - 1; // Don't count the null static constexpr char kHexStringPrefix[] = "hex:"; -inline constexpr size_t kHexStringPrefixLen = ArraySize(kHexStringPrefix) - 1; // Don't count the null +inline constexpr size_t kHexStringPrefixLen = MATTER_ARRAY_SIZE(kHexStringPrefix) - 1; // Don't count the null static constexpr char kStrStringPrefix[] = "str:"; -inline constexpr size_t kStrStringPrefixLen = ArraySize(kStrStringPrefix) - 1; // Don't count the null +inline constexpr size_t kStrStringPrefixLen = MATTER_ARRAY_SIZE(kStrStringPrefix) - 1; // Don't count the null inline bool IsJsonString(const char * str) { diff --git a/examples/chip-tool/commands/pairing/ToTLVCert.cpp b/examples/chip-tool/commands/pairing/ToTLVCert.cpp index 3a54d37d1a29e8..095d8b53016676 100644 --- a/examples/chip-tool/commands/pairing/ToTLVCert.cpp +++ b/examples/chip-tool/commands/pairing/ToTLVCert.cpp @@ -24,7 +24,7 @@ #include constexpr char kBase64Header[] = "base64:"; -constexpr size_t kBase64HeaderLen = ArraySize(kBase64Header) - 1; +constexpr size_t kBase64HeaderLen = MATTER_ARRAY_SIZE(kBase64Header) - 1; CHIP_ERROR ToBase64(const chip::ByteSpan & input, std::string & outputAsPrefixedBase64) { diff --git a/examples/common/pigweed/rpc_services/Device.h b/examples/common/pigweed/rpc_services/Device.h index 0b2f38bc5dfd99..1285c8426eccc4 100644 --- a/examples/common/pigweed/rpc_services/Device.h +++ b/examples/common/pigweed/rpc_services/Device.h @@ -306,7 +306,7 @@ class Device : public pw_rpc::nanopb::Device::Service DeviceLayer::StackLock lock; for (const FabricInfo & fabricInfo : Server::GetInstance().GetFabricTable()) { - if (count < ArraySize(response.fabric_info)) + if (count < MATTER_ARRAY_SIZE(response.fabric_info)) { response.fabric_info[count].fabric_id = fabricInfo.GetFabricId(); response.fabric_info[count].node_id = fabricInfo.GetPeerId().GetNodeId(); diff --git a/examples/contact-sensor-app/bouffalolab/common/AppTask.cpp b/examples/contact-sensor-app/bouffalolab/common/AppTask.cpp index 3acb94cd6aaf7a..fc0e7c90545703 100644 --- a/examples/contact-sensor-app/bouffalolab/common/AppTask.cpp +++ b/examples/contact-sensor-app/bouffalolab/common/AppTask.cpp @@ -85,8 +85,9 @@ CHIP_ERROR AppTask::StartAppShellTask() void StartAppTask(void) { - GetAppTask().sAppTaskHandle = xTaskCreateStatic(GetAppTask().AppTaskMain, APP_TASK_NAME, ArraySize(GetAppTask().appStack), NULL, - APP_TASK_PRIORITY, GetAppTask().appStack, &GetAppTask().appTaskStruct); + GetAppTask().sAppTaskHandle = + xTaskCreateStatic(GetAppTask().AppTaskMain, APP_TASK_NAME, MATTER_ARRAY_SIZE(GetAppTask().appStack), NULL, + APP_TASK_PRIORITY, GetAppTask().appStack, &GetAppTask().appTaskStruct); if (GetAppTask().sAppTaskHandle == NULL) { ChipLogError(NotSpecified, "Failed to create app task"); diff --git a/examples/darwin-framework-tool/commands/common/CHIPCommandBridge.mm b/examples/darwin-framework-tool/commands/common/CHIPCommandBridge.mm index d4154de024a988..1586e506dfe934 100644 --- a/examples/darwin-framework-tool/commands/common/CHIPCommandBridge.mm +++ b/examples/darwin-framework-tool/commands/common/CHIPCommandBridge.mm @@ -172,7 +172,7 @@ constexpr const char * identities[] = { kIdentityAlpha, kIdentityBeta, kIdentityGamma }; std::string commissionerName = mCommissionerName.HasValue() ? mCommissionerName.Value() : kIdentityAlpha; - for (size_t i = 0; i < ArraySize(identities); ++i) { + for (size_t i = 0; i < MATTER_ARRAY_SIZE(identities); ++i) { __auto_type * fabricId = GetCommissionerFabricId(identities[i]); __auto_type * uuidString = [NSString stringWithFormat:@"%@%@", @(kControllerIdPrefix), fabricId]; __auto_type * controllerId = [[NSUUID alloc] initWithUUIDString:uuidString]; @@ -249,7 +249,7 @@ constexpr const char * identities[] = { kIdentityAlpha, kIdentityBeta, kIdentityGamma }; std::string commissionerName = mCommissionerName.HasValue() ? mCommissionerName.Value() : kIdentityAlpha; - for (size_t i = 0; i < ArraySize(identities); ++i) { + for (size_t i = 0; i < MATTER_ARRAY_SIZE(identities); ++i) { __auto_type * fabricId = GetCommissionerFabricId(identities[i]); __auto_type * params = [[MTRDeviceControllerStartupParams alloc] initWithIPK:certificateIssuer.ipk fabricID:fabricId @@ -368,7 +368,7 @@ auto factory = [MTRDeviceControllerFactory sharedInstance]; constexpr const char * identities[] = { kIdentityAlpha, kIdentityBeta, kIdentityGamma }; - for (size_t i = 0; i < ArraySize(identities); ++i) { + for (size_t i = 0; i < MATTER_ARRAY_SIZE(identities); ++i) { __auto_type * certificateIssuer = [CertificateIssuer sharedInstance]; auto controllerParams = [[MTRDeviceControllerStartupParams alloc] initWithIPK:certificateIssuer.ipk fabricID:@(i + 1) nocSigner:certificateIssuer.signingKey]; diff --git a/examples/dishwasher-app/silabs/src/ElectricalSensorManager.cpp b/examples/dishwasher-app/silabs/src/ElectricalSensorManager.cpp index cf7e4806a7828a..a3d11c6219b269 100644 --- a/examples/dishwasher-app/silabs/src/ElectricalSensorManager.cpp +++ b/examples/dishwasher-app/silabs/src/ElectricalSensorManager.cpp @@ -199,9 +199,9 @@ void ElectricalSensorManager::UpdateEPMAttributes(OperationalStateEnum state) uint8_t updateState = to_underlying(state); // Check state range - if (updateState >= ArraySize(kAttributes)) + if (updateState >= MATTER_ARRAY_SIZE(kAttributes)) { - updateState = ArraySize(kAttributes) - 1; + updateState = MATTER_ARRAY_SIZE(kAttributes) - 1; } ChipLogDetail(AppServer, "UpdateAllAttributes to Operational State : %d", updateState); diff --git a/examples/dishwasher-app/silabs/src/PowerTopologyDelegateImpl.cpp b/examples/dishwasher-app/silabs/src/PowerTopologyDelegateImpl.cpp index 7e3a68a707e31b..d1a7ddb4cc018f 100644 --- a/examples/dishwasher-app/silabs/src/PowerTopologyDelegateImpl.cpp +++ b/examples/dishwasher-app/silabs/src/PowerTopologyDelegateImpl.cpp @@ -28,7 +28,7 @@ using namespace chip::app::Clusters::PowerTopology; CHIP_ERROR PowerTopologyDelegateImpl::GetAvailableEndpointAtIndex(size_t index, EndpointId & endpointId) { - VerifyOrReturnError(index < ArraySize(mAvailableEndpointIdList), CHIP_ERROR_PROVIDER_LIST_EXHAUSTED); + VerifyOrReturnError(index < MATTER_ARRAY_SIZE(mAvailableEndpointIdList), CHIP_ERROR_PROVIDER_LIST_EXHAUSTED); endpointId = mAvailableEndpointIdList[index]; @@ -37,7 +37,7 @@ CHIP_ERROR PowerTopologyDelegateImpl::GetAvailableEndpointAtIndex(size_t index, CHIP_ERROR PowerTopologyDelegateImpl::GetActiveEndpointAtIndex(size_t index, EndpointId & endpointId) { - VerifyOrReturnError(index < ArraySize(mActiveEndpointIdList), CHIP_ERROR_PROVIDER_LIST_EXHAUSTED); + VerifyOrReturnError(index < MATTER_ARRAY_SIZE(mActiveEndpointIdList), CHIP_ERROR_PROVIDER_LIST_EXHAUSTED); endpointId = mActiveEndpointIdList[index]; diff --git a/examples/energy-management-app/energy-management-common/device-energy-management/src/device-energy-management-mode.cpp b/examples/energy-management-app/energy-management-common/device-energy-management/src/device-energy-management-mode.cpp index 330c0b0e389512..3f757bba409bf7 100644 --- a/examples/energy-management-app/energy-management-common/device-energy-management/src/device-energy-management-mode.cpp +++ b/examples/energy-management-app/energy-management-common/device-energy-management/src/device-energy-management-mode.cpp @@ -50,7 +50,7 @@ void DeviceEnergyManagementModeDelegate::HandleChangeToMode(uint8_t NewMode, CHIP_ERROR DeviceEnergyManagementModeDelegate::GetModeLabelByIndex(uint8_t modeIndex, chip::MutableCharSpan & label) { - if (modeIndex >= ArraySize(kModeOptions)) + if (modeIndex >= MATTER_ARRAY_SIZE(kModeOptions)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } @@ -59,7 +59,7 @@ CHIP_ERROR DeviceEnergyManagementModeDelegate::GetModeLabelByIndex(uint8_t modeI CHIP_ERROR DeviceEnergyManagementModeDelegate::GetModeValueByIndex(uint8_t modeIndex, uint8_t & value) { - if (modeIndex >= ArraySize(kModeOptions)) + if (modeIndex >= MATTER_ARRAY_SIZE(kModeOptions)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } @@ -69,7 +69,7 @@ CHIP_ERROR DeviceEnergyManagementModeDelegate::GetModeValueByIndex(uint8_t modeI CHIP_ERROR DeviceEnergyManagementModeDelegate::GetModeTagsByIndex(uint8_t modeIndex, List & tags) { - if (modeIndex >= ArraySize(kModeOptions)) + if (modeIndex >= MATTER_ARRAY_SIZE(kModeOptions)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } diff --git a/examples/energy-management-app/energy-management-common/energy-evse/src/energy-evse-mode.cpp b/examples/energy-management-app/energy-management-common/energy-evse/src/energy-evse-mode.cpp index ce147839a9496f..065df15d18f69e 100644 --- a/examples/energy-management-app/energy-management-common/energy-evse/src/energy-evse-mode.cpp +++ b/examples/energy-management-app/energy-management-common/energy-evse/src/energy-evse-mode.cpp @@ -41,7 +41,7 @@ void EnergyEvseModeDelegate::HandleChangeToMode(uint8_t NewMode, ModeBase::Comma CHIP_ERROR EnergyEvseModeDelegate::GetModeLabelByIndex(uint8_t modeIndex, chip::MutableCharSpan & label) { - if (modeIndex >= ArraySize(kModeOptions)) + if (modeIndex >= MATTER_ARRAY_SIZE(kModeOptions)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } @@ -50,7 +50,7 @@ CHIP_ERROR EnergyEvseModeDelegate::GetModeLabelByIndex(uint8_t modeIndex, chip:: CHIP_ERROR EnergyEvseModeDelegate::GetModeValueByIndex(uint8_t modeIndex, uint8_t & value) { - if (modeIndex >= ArraySize(kModeOptions)) + if (modeIndex >= MATTER_ARRAY_SIZE(kModeOptions)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } @@ -60,7 +60,7 @@ CHIP_ERROR EnergyEvseModeDelegate::GetModeValueByIndex(uint8_t modeIndex, uint8_ CHIP_ERROR EnergyEvseModeDelegate::GetModeTagsByIndex(uint8_t modeIndex, List & tags) { - if (modeIndex >= ArraySize(kModeOptions)) + if (modeIndex >= MATTER_ARRAY_SIZE(kModeOptions)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } diff --git a/examples/energy-management-app/energy-management-common/energy-reporting/src/ElectricalPowerMeasurementDelegate.cpp b/examples/energy-management-app/energy-management-common/energy-reporting/src/ElectricalPowerMeasurementDelegate.cpp index a99f7f42054062..6fe03ae01e2beb 100644 --- a/examples/energy-management-app/energy-management-common/energy-reporting/src/ElectricalPowerMeasurementDelegate.cpp +++ b/examples/energy-management-app/energy-management-common/energy-reporting/src/ElectricalPowerMeasurementDelegate.cpp @@ -166,7 +166,7 @@ static const Structs::MeasurementAccuracyStruct::Type kMeasurementAccuracies[] = uint8_t ElectricalPowerMeasurementDelegate::GetNumberOfMeasurementTypes() { - return ArraySize(kMeasurementAccuracies); + return MATTER_ARRAY_SIZE(kMeasurementAccuracies); }; /* @brief This function is called by the cluster server at the start of read cycle @@ -181,7 +181,7 @@ CHIP_ERROR ElectricalPowerMeasurementDelegate::StartAccuracyRead() CHIP_ERROR ElectricalPowerMeasurementDelegate::GetAccuracyByIndex(uint8_t accuracyIndex, Structs::MeasurementAccuracyStruct::Type & accuracy) { - if (accuracyIndex >= ArraySize(kMeasurementAccuracies)) + if (accuracyIndex >= MATTER_ARRAY_SIZE(kMeasurementAccuracies)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } @@ -225,7 +225,7 @@ CHIP_ERROR ElectricalPowerMeasurementDelegate::GetRangeByIndex(uint8_t rangeInde * - .maxTimestamp (the time at which the maximum value was recorded) * (and optionally use sys time equivalents) * - * if (rangeIndex >= ArraySize(mMeasurementRanges)) + * if (rangeIndex >= MATTER_ARRAY_SIZE(mMeasurementRanges)) * { * return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; * } @@ -277,7 +277,7 @@ ElectricalPowerMeasurementDelegate::GetHarmonicCurrentsByIndex(uint8_t harmonicC */ /* Added to support testing using a static array for now */ - if (harmonicCurrentsIndex >= ArraySize(kHarmonicCurrentMeasurements)) + if (harmonicCurrentsIndex >= MATTER_ARRAY_SIZE(kHarmonicCurrentMeasurements)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } @@ -322,7 +322,7 @@ CHIP_ERROR ElectricalPowerMeasurementDelegate::GetHarmonicPhasesByIndex(uint8_t */ /* Added to support testing using a static array for now */ - if (harmonicPhaseIndex >= ArraySize(kHarmonicPhaseMeasurements)) + if (harmonicPhaseIndex >= MATTER_ARRAY_SIZE(kHarmonicPhaseMeasurements)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } diff --git a/examples/energy-management-app/energy-management-common/water-heater/src/water-heater-mode.cpp b/examples/energy-management-app/energy-management-common/water-heater/src/water-heater-mode.cpp index 76f61b72b97fd8..d4cae5c71c0993 100755 --- a/examples/energy-management-app/energy-management-common/water-heater/src/water-heater-mode.cpp +++ b/examples/energy-management-app/energy-management-common/water-heater/src/water-heater-mode.cpp @@ -44,7 +44,7 @@ void ExampleWaterHeaterModeDelegate::HandleChangeToMode(uint8_t NewMode, ModeBas CHIP_ERROR ExampleWaterHeaterModeDelegate::GetModeLabelByIndex(uint8_t modeIndex, chip::MutableCharSpan & label) { - if (modeIndex >= ArraySize(kModeOptions)) + if (modeIndex >= MATTER_ARRAY_SIZE(kModeOptions)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } @@ -53,7 +53,7 @@ CHIP_ERROR ExampleWaterHeaterModeDelegate::GetModeLabelByIndex(uint8_t modeIndex CHIP_ERROR ExampleWaterHeaterModeDelegate::GetModeValueByIndex(uint8_t modeIndex, uint8_t & value) { - if (modeIndex >= ArraySize(kModeOptions)) + if (modeIndex >= MATTER_ARRAY_SIZE(kModeOptions)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } @@ -63,7 +63,7 @@ CHIP_ERROR ExampleWaterHeaterModeDelegate::GetModeValueByIndex(uint8_t modeIndex CHIP_ERROR ExampleWaterHeaterModeDelegate::GetModeTagsByIndex(uint8_t modeIndex, List & tags) { - if (modeIndex >= ArraySize(kModeOptions)) + if (modeIndex >= MATTER_ARRAY_SIZE(kModeOptions)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } diff --git a/examples/fabric-admin/commands/clusters/CustomArgument.h b/examples/fabric-admin/commands/clusters/CustomArgument.h index 3769c0052236cd..7e48446f3d986d 100644 --- a/examples/fabric-admin/commands/clusters/CustomArgument.h +++ b/examples/fabric-admin/commands/clusters/CustomArgument.h @@ -34,11 +34,11 @@ static constexpr char kPayloadSignedPrefix[] = "s:"; static constexpr char kPayloadUnsignedPrefix[] = "u:"; static constexpr char kPayloadFloatPrefix[] = "f:"; static constexpr char kPayloadDoublePrefix[] = "d:"; -static constexpr size_t kPayloadHexPrefixLen = ArraySize(kPayloadHexPrefix) - 1; // ignore null character -static constexpr size_t kPayloadSignedPrefixLen = ArraySize(kPayloadSignedPrefix) - 1; // ignore null character -static constexpr size_t kPayloadUnsignedPrefixLen = ArraySize(kPayloadUnsignedPrefix) - 1; // ignore null character -static constexpr size_t kPayloadFloatPrefixLen = ArraySize(kPayloadFloatPrefix) - 1; // ignore null character -static constexpr size_t kPayloadDoublePrefixLen = ArraySize(kPayloadDoublePrefix) - 1; // ignore null character +static constexpr size_t kPayloadHexPrefixLen = MATTER_ARRAY_SIZE(kPayloadHexPrefix) - 1; // ignore null character +static constexpr size_t kPayloadSignedPrefixLen = MATTER_ARRAY_SIZE(kPayloadSignedPrefix) - 1; // ignore null character +static constexpr size_t kPayloadUnsignedPrefixLen = MATTER_ARRAY_SIZE(kPayloadUnsignedPrefix) - 1; // ignore null character +static constexpr size_t kPayloadFloatPrefixLen = MATTER_ARRAY_SIZE(kPayloadFloatPrefix) - 1; // ignore null character +static constexpr size_t kPayloadDoublePrefixLen = MATTER_ARRAY_SIZE(kPayloadDoublePrefix) - 1; // ignore null character } // namespace class CustomArgumentParser @@ -242,7 +242,7 @@ class CustomArgument { Json::Value value; static constexpr char kHexNumPrefix[] = "0x"; - constexpr size_t kHexNumPrefixLen = ArraySize(kHexNumPrefix) - 1; + constexpr size_t kHexNumPrefixLen = MATTER_ARRAY_SIZE(kHexNumPrefix) - 1; if (strncmp(json, kPayloadHexPrefix, kPayloadHexPrefixLen) == 0 || strncmp(json, kPayloadSignedPrefix, kPayloadSignedPrefixLen) == 0 || strncmp(json, kPayloadUnsignedPrefix, kPayloadUnsignedPrefixLen) == 0 || diff --git a/examples/fabric-admin/commands/clusters/DataModelLogger.h b/examples/fabric-admin/commands/clusters/DataModelLogger.h index 36f53ba3811c24..c009269a27d70c 100644 --- a/examples/fabric-admin/commands/clusters/DataModelLogger.h +++ b/examples/fabric-admin/commands/clusters/DataModelLogger.h @@ -59,27 +59,28 @@ class DataModelLogger // buffer. char buffer[CHIP_CONFIG_LOG_MESSAGE_MAX_SIZE / 2]; size_t prefixSize = ComputePrefixSize(label, indent); - if (prefixSize > ArraySize(buffer)) + if (prefixSize > MATTER_ARRAY_SIZE(buffer)) { DataModelLogger::LogString("", 0, "Prefix is too long to fit in buffer"); return CHIP_ERROR_INTERNAL; } - const size_t availableSize = ArraySize(buffer) - prefixSize; + const size_t availableSize = MATTER_ARRAY_SIZE(buffer) - prefixSize; // Each byte ends up as two hex characters. const size_t bytesPerLogCall = availableSize / 2; std::string labelStr(label); while (value.size() > bytesPerLogCall) { ReturnErrorOnFailure( - chip::Encoding::BytesToUppercaseHexString(value.data(), bytesPerLogCall, &buffer[0], ArraySize(buffer))); + chip::Encoding::BytesToUppercaseHexString(value.data(), bytesPerLogCall, &buffer[0], MATTER_ARRAY_SIZE(buffer))); LogString(labelStr, indent, buffer); value = value.SubSpan(bytesPerLogCall); // For the second and following lines, make it clear that they are // continuation lines by replacing the label with "....". labelStr.replace(labelStr.begin(), labelStr.end(), labelStr.size(), '.'); } - ReturnErrorOnFailure(chip::Encoding::BytesToUppercaseHexString(value.data(), value.size(), &buffer[0], ArraySize(buffer))); + ReturnErrorOnFailure( + chip::Encoding::BytesToUppercaseHexString(value.data(), value.size(), &buffer[0], MATTER_ARRAY_SIZE(buffer))); LogString(labelStr, indent, buffer); return CHIP_NO_ERROR; diff --git a/examples/fabric-admin/commands/common/CustomStringPrefix.h b/examples/fabric-admin/commands/common/CustomStringPrefix.h index be8442993d1bf2..f0e9f58c12e914 100644 --- a/examples/fabric-admin/commands/common/CustomStringPrefix.h +++ b/examples/fabric-admin/commands/common/CustomStringPrefix.h @@ -23,16 +23,16 @@ #include static constexpr char kJsonStringPrefix[] = "json:"; -inline constexpr size_t kJsonStringPrefixLen = ArraySize(kJsonStringPrefix) - 1; // Don't count the null +inline constexpr size_t kJsonStringPrefixLen = MATTER_ARRAY_SIZE(kJsonStringPrefix) - 1; // Don't count the null static constexpr char kBase64StringPrefix[] = "base64:"; -inline constexpr size_t kBase64StringPrefixLen = ArraySize(kBase64StringPrefix) - 1; // Don't count the null +inline constexpr size_t kBase64StringPrefixLen = MATTER_ARRAY_SIZE(kBase64StringPrefix) - 1; // Don't count the null static constexpr char kHexStringPrefix[] = "hex:"; -inline constexpr size_t kHexStringPrefixLen = ArraySize(kHexStringPrefix) - 1; // Don't count the null +inline constexpr size_t kHexStringPrefixLen = MATTER_ARRAY_SIZE(kHexStringPrefix) - 1; // Don't count the null static constexpr char kStrStringPrefix[] = "str:"; -inline constexpr size_t kStrStringPrefixLen = ArraySize(kStrStringPrefix) - 1; // Don't count the null +inline constexpr size_t kStrStringPrefixLen = MATTER_ARRAY_SIZE(kStrStringPrefix) - 1; // Don't count the null inline bool IsJsonString(const char * str) { diff --git a/examples/fabric-admin/commands/pairing/ToTLVCert.cpp b/examples/fabric-admin/commands/pairing/ToTLVCert.cpp index 01f9156f744593..fcb3962a6c2568 100644 --- a/examples/fabric-admin/commands/pairing/ToTLVCert.cpp +++ b/examples/fabric-admin/commands/pairing/ToTLVCert.cpp @@ -24,7 +24,7 @@ #include constexpr char kBase64Header[] = "base64:"; -constexpr size_t kBase64HeaderLen = ArraySize(kBase64Header) - 1; +constexpr size_t kBase64HeaderLen = MATTER_ARRAY_SIZE(kBase64Header) - 1; CHIP_ERROR ToBase64(const chip::ByteSpan & input, std::string & outputAsPrefixedBase64) { diff --git a/examples/fabric-bridge-app/fabric-bridge-common/src/BridgedDeviceManager.cpp b/examples/fabric-bridge-app/fabric-bridge-common/src/BridgedDeviceManager.cpp index 5c53d413cbb344..491f5fb255f917 100644 --- a/examples/fabric-bridge-app/fabric-bridge-common/src/BridgedDeviceManager.cpp +++ b/examples/fabric-bridge-app/fabric-bridge-common/src/BridgedDeviceManager.cpp @@ -170,7 +170,7 @@ DECLARE_DYNAMIC_ENDPOINT(sIcdBridgedNodeEndpoint, icdBridgedNodeClusters); // TODO: this is a single version array, however we may have many // different clusters that are independent. -DataVersion sBridgedNodeDataVersions[ArraySize(bridgedNodeClusters)]; +DataVersion sBridgedNodeDataVersions[MATTER_ARRAY_SIZE(bridgedNodeClusters)]; const EmberAfDeviceType sBridgedDeviceTypes[] = { { DEVICE_TYPE_BRIDGED_NODE, DEVICE_VERSION_DEFAULT } }; diff --git a/examples/fabric-sync/bridge/src/BridgedDeviceManager.cpp b/examples/fabric-sync/bridge/src/BridgedDeviceManager.cpp index 5057f5f68f80ef..7a66f782cff5c0 100644 --- a/examples/fabric-sync/bridge/src/BridgedDeviceManager.cpp +++ b/examples/fabric-sync/bridge/src/BridgedDeviceManager.cpp @@ -169,7 +169,7 @@ DECLARE_DYNAMIC_ENDPOINT(sIcdBridgedNodeEndpoint, icdBridgedNodeClusters); // TODO: this is a single version array, however we may have many // different clusters that are independent. -DataVersion sBridgedNodeDataVersions[ArraySize(bridgedNodeClusters)]; +DataVersion sBridgedNodeDataVersions[MATTER_ARRAY_SIZE(bridgedNodeClusters)]; const EmberAfDeviceType sBridgedDeviceTypes[] = { { DEVICE_TYPE_BRIDGED_NODE, DEVICE_VERSION_DEFAULT } }; diff --git a/examples/laundry-washer-app/nxp/common/main/laundry-washer-mode.cpp b/examples/laundry-washer-app/nxp/common/main/laundry-washer-mode.cpp index 2dedf4c1f8c69b..cfbf57afb46575 100644 --- a/examples/laundry-washer-app/nxp/common/main/laundry-washer-mode.cpp +++ b/examples/laundry-washer-app/nxp/common/main/laundry-washer-mode.cpp @@ -40,7 +40,7 @@ void LaundryWasherModeDelegate::HandleChangeToMode(uint8_t NewMode, ModeBase::Co CHIP_ERROR LaundryWasherModeDelegate::GetModeLabelByIndex(uint8_t modeIndex, chip::MutableCharSpan & label) { - if (modeIndex >= ArraySize(kModeOptions)) + if (modeIndex >= MATTER_ARRAY_SIZE(kModeOptions)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } @@ -49,7 +49,7 @@ CHIP_ERROR LaundryWasherModeDelegate::GetModeLabelByIndex(uint8_t modeIndex, chi CHIP_ERROR LaundryWasherModeDelegate::GetModeValueByIndex(uint8_t modeIndex, uint8_t & value) { - if (modeIndex >= ArraySize(kModeOptions)) + if (modeIndex >= MATTER_ARRAY_SIZE(kModeOptions)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } @@ -59,7 +59,7 @@ CHIP_ERROR LaundryWasherModeDelegate::GetModeValueByIndex(uint8_t modeIndex, uin CHIP_ERROR LaundryWasherModeDelegate::GetModeTagsByIndex(uint8_t modeIndex, List & tags) { - if (modeIndex >= ArraySize(kModeOptions)) + if (modeIndex >= MATTER_ARRAY_SIZE(kModeOptions)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } diff --git a/examples/light-switch-app/ameba/main/BindingHandler.cpp b/examples/light-switch-app/ameba/main/BindingHandler.cpp index 580b2bec197a44..1b0cc8a227f0b9 100644 --- a/examples/light-switch-app/ameba/main/BindingHandler.cpp +++ b/examples/light-switch-app/ameba/main/BindingHandler.cpp @@ -386,11 +386,12 @@ static void RegisterSwitchCommands() static const shell_command_t sSwitchCommand = { &SwitchCommandHandler, "switch", "Light-switch commands. Usage: switch " }; - sShellSwitchGroupsOnOffSubCommands.RegisterCommands(sSwitchGroupsOnOffSubCommands, ArraySize(sSwitchGroupsOnOffSubCommands)); - sShellSwitchOnOffSubCommands.RegisterCommands(sSwitchOnOffSubCommands, ArraySize(sSwitchOnOffSubCommands)); - sShellSwitchGroupsSubCommands.RegisterCommands(sSwitchGroupsSubCommands, ArraySize(sSwitchGroupsSubCommands)); - sShellSwitchBindingSubCommands.RegisterCommands(sSwitchBindingSubCommands, ArraySize(sSwitchBindingSubCommands)); - sShellSwitchSubCommands.RegisterCommands(sSwitchSubCommands, ArraySize(sSwitchSubCommands)); + sShellSwitchGroupsOnOffSubCommands.RegisterCommands(sSwitchGroupsOnOffSubCommands, + MATTER_ARRAY_SIZE(sSwitchGroupsOnOffSubCommands)); + sShellSwitchOnOffSubCommands.RegisterCommands(sSwitchOnOffSubCommands, MATTER_ARRAY_SIZE(sSwitchOnOffSubCommands)); + sShellSwitchGroupsSubCommands.RegisterCommands(sSwitchGroupsSubCommands, MATTER_ARRAY_SIZE(sSwitchGroupsSubCommands)); + sShellSwitchBindingSubCommands.RegisterCommands(sSwitchBindingSubCommands, MATTER_ARRAY_SIZE(sSwitchBindingSubCommands)); + sShellSwitchSubCommands.RegisterCommands(sSwitchSubCommands, MATTER_ARRAY_SIZE(sSwitchSubCommands)); Engine::Root().RegisterCommands(&sSwitchCommand, 1); } diff --git a/examples/light-switch-app/esp32/main/BindingHandler.cpp b/examples/light-switch-app/esp32/main/BindingHandler.cpp index cc1a66a1e28878..4867d2ed8d5d89 100644 --- a/examples/light-switch-app/esp32/main/BindingHandler.cpp +++ b/examples/light-switch-app/esp32/main/BindingHandler.cpp @@ -384,11 +384,12 @@ static void RegisterSwitchCommands() static const shell_command_t sSwitchCommand = { &SwitchCommandHandler, "switch", "Light-switch commands. Usage: switch " }; - sShellSwitchGroupsOnOffSubCommands.RegisterCommands(sSwitchGroupsOnOffSubCommands, ArraySize(sSwitchGroupsOnOffSubCommands)); - sShellSwitchOnOffSubCommands.RegisterCommands(sSwitchOnOffSubCommands, ArraySize(sSwitchOnOffSubCommands)); - sShellSwitchGroupsSubCommands.RegisterCommands(sSwitchGroupsSubCommands, ArraySize(sSwitchGroupsSubCommands)); - sShellSwitchBindingSubCommands.RegisterCommands(sSwitchBindingSubCommands, ArraySize(sSwitchBindingSubCommands)); - sShellSwitchSubCommands.RegisterCommands(sSwitchSubCommands, ArraySize(sSwitchSubCommands)); + sShellSwitchGroupsOnOffSubCommands.RegisterCommands(sSwitchGroupsOnOffSubCommands, + MATTER_ARRAY_SIZE(sSwitchGroupsOnOffSubCommands)); + sShellSwitchOnOffSubCommands.RegisterCommands(sSwitchOnOffSubCommands, MATTER_ARRAY_SIZE(sSwitchOnOffSubCommands)); + sShellSwitchGroupsSubCommands.RegisterCommands(sSwitchGroupsSubCommands, MATTER_ARRAY_SIZE(sSwitchGroupsSubCommands)); + sShellSwitchBindingSubCommands.RegisterCommands(sSwitchBindingSubCommands, MATTER_ARRAY_SIZE(sSwitchBindingSubCommands)); + sShellSwitchSubCommands.RegisterCommands(sSwitchSubCommands, MATTER_ARRAY_SIZE(sSwitchSubCommands)); Engine::Root().RegisterCommands(&sSwitchCommand, 1); } diff --git a/examples/light-switch-app/genio/src/AppTask.cpp b/examples/light-switch-app/genio/src/AppTask.cpp index bcb5f58ce13a5d..503e4baf5f67e7 100644 --- a/examples/light-switch-app/genio/src/AppTask.cpp +++ b/examples/light-switch-app/genio/src/AppTask.cpp @@ -102,7 +102,7 @@ CHIP_ERROR AppTask::StartAppTask() } // Start App task. - sAppTaskHandle = xTaskCreateStatic(AppTaskMain, APP_TASK_NAME, ArraySize(appStack), NULL, 1, appStack, &appTaskStruct); + sAppTaskHandle = xTaskCreateStatic(AppTaskMain, APP_TASK_NAME, MATTER_ARRAY_SIZE(appStack), NULL, 1, appStack, &appTaskStruct); if (sAppTaskHandle == nullptr) return APP_ERROR_CREATE_TASK_FAILED; diff --git a/examples/light-switch-app/genio/src/BindingHandler.cpp b/examples/light-switch-app/genio/src/BindingHandler.cpp index 218a44671486d7..f6b9fab04d5cf3 100644 --- a/examples/light-switch-app/genio/src/BindingHandler.cpp +++ b/examples/light-switch-app/genio/src/BindingHandler.cpp @@ -382,11 +382,12 @@ static void RegisterSwitchCommands() static const shell_command_t sSwitchCommand = { &SwitchCommandHandler, "switch", "Light-switch commands. Usage: switch " }; - sShellSwitchGroupsOnOffSubCommands.RegisterCommands(sSwitchGroupsOnOffSubCommands, ArraySize(sSwitchGroupsOnOffSubCommands)); - sShellSwitchOnOffSubCommands.RegisterCommands(sSwitchOnOffSubCommands, ArraySize(sSwitchOnOffSubCommands)); - sShellSwitchGroupsSubCommands.RegisterCommands(sSwitchGroupsSubCommands, ArraySize(sSwitchGroupsSubCommands)); - sShellSwitchBindingSubCommands.RegisterCommands(sSwitchBindingSubCommands, ArraySize(sSwitchBindingSubCommands)); - sShellSwitchSubCommands.RegisterCommands(sSwitchSubCommands, ArraySize(sSwitchSubCommands)); + sShellSwitchGroupsOnOffSubCommands.RegisterCommands(sSwitchGroupsOnOffSubCommands, + MATTER_ARRAY_SIZE(sSwitchGroupsOnOffSubCommands)); + sShellSwitchOnOffSubCommands.RegisterCommands(sSwitchOnOffSubCommands, MATTER_ARRAY_SIZE(sSwitchOnOffSubCommands)); + sShellSwitchGroupsSubCommands.RegisterCommands(sSwitchGroupsSubCommands, MATTER_ARRAY_SIZE(sSwitchGroupsSubCommands)); + sShellSwitchBindingSubCommands.RegisterCommands(sSwitchBindingSubCommands, MATTER_ARRAY_SIZE(sSwitchBindingSubCommands)); + sShellSwitchSubCommands.RegisterCommands(sSwitchSubCommands, MATTER_ARRAY_SIZE(sSwitchSubCommands)); Engine::Root().RegisterCommands(&sSwitchCommand, 1); } diff --git a/examples/light-switch-app/infineon/cyw30739/src/AppShellCommands.cpp b/examples/light-switch-app/infineon/cyw30739/src/AppShellCommands.cpp index 9be05feafe4ea6..edbde49628d901 100644 --- a/examples/light-switch-app/infineon/cyw30739/src/AppShellCommands.cpp +++ b/examples/light-switch-app/infineon/cyw30739/src/AppShellCommands.cpp @@ -463,14 +463,16 @@ void RegisterAppShellCommands() &AppCmdCommandHandler, "switch", "Light switch commands. Usage: switch [local|onoff|groups|debug][identify]" }; - AppCmdSubCommands.RegisterCommands(ifxAppCmdSubCommands, ArraySize(ifxAppCmdSubCommands)); - AppCmdLocalSubCommands.RegisterCommands(ifxAppCmdLocalSubCommands, ArraySize(ifxAppCmdLocalSubCommands)); - AppCmdOnOffSubCommands.RegisterCommands(ifxAppCmdOnOffSubCommands, ArraySize(ifxAppCmdOnOffSubCommands)); - AppCmdGroupsSubCommands.RegisterCommands(ifxAppCmdGroupsSubCommands, ArraySize(ifxAppCmdGroupsSubCommands)); - AppCmdGroupsOnOffSubCommands.RegisterCommands(ifxAppCmdGroupsOnOffSubCommands, ArraySize(ifxAppCmdGroupsOnOffSubCommands)); - AppCmdDebugSubCommands.RegisterCommands(ifxAppCmdDebugSubCommands, ArraySize(ifxAppCmdDebugSubCommands)); - AppCmdIdentifySubCommands.RegisterCommands(ifxAppCmdIdentifySubCommands, ArraySize(ifxAppCmdIdentifySubCommands)); - AppCmdIdentifyReadSubCommands.RegisterCommands(ifxAppCmdIdentifyReadSubCommands, ArraySize(ifxAppCmdIdentifyReadSubCommands)); + AppCmdSubCommands.RegisterCommands(ifxAppCmdSubCommands, MATTER_ARRAY_SIZE(ifxAppCmdSubCommands)); + AppCmdLocalSubCommands.RegisterCommands(ifxAppCmdLocalSubCommands, MATTER_ARRAY_SIZE(ifxAppCmdLocalSubCommands)); + AppCmdOnOffSubCommands.RegisterCommands(ifxAppCmdOnOffSubCommands, MATTER_ARRAY_SIZE(ifxAppCmdOnOffSubCommands)); + AppCmdGroupsSubCommands.RegisterCommands(ifxAppCmdGroupsSubCommands, MATTER_ARRAY_SIZE(ifxAppCmdGroupsSubCommands)); + AppCmdGroupsOnOffSubCommands.RegisterCommands(ifxAppCmdGroupsOnOffSubCommands, + MATTER_ARRAY_SIZE(ifxAppCmdGroupsOnOffSubCommands)); + AppCmdDebugSubCommands.RegisterCommands(ifxAppCmdDebugSubCommands, MATTER_ARRAY_SIZE(ifxAppCmdDebugSubCommands)); + AppCmdIdentifySubCommands.RegisterCommands(ifxAppCmdIdentifySubCommands, MATTER_ARRAY_SIZE(ifxAppCmdIdentifySubCommands)); + AppCmdIdentifyReadSubCommands.RegisterCommands(ifxAppCmdIdentifyReadSubCommands, + MATTER_ARRAY_SIZE(ifxAppCmdIdentifyReadSubCommands)); Engine::Root().RegisterCommands(&AppLightSwitchCommand, 1); } diff --git a/examples/light-switch-app/infineon/cyw30739/src/AppTask.cpp b/examples/light-switch-app/infineon/cyw30739/src/AppTask.cpp index 1bb443c74bb0ec..f0cea4222e3d9f 100644 --- a/examples/light-switch-app/infineon/cyw30739/src/AppTask.cpp +++ b/examples/light-switch-app/infineon/cyw30739/src/AppTask.cpp @@ -57,7 +57,7 @@ void AppTaskMain(intptr_t args) { ChipLogError(Zcl, "ERROR app_button_init %d\n", result); } - LEDWid().Init(chip_lighting_led_config, ArraySize(chip_lighting_led_config)); + LEDWid().Init(chip_lighting_led_config, MATTER_ARRAY_SIZE(chip_lighting_led_config)); LightSwitch::GetInstance().Init(kLightDimmerSwitchEndpointId); CYW30739MatterConfig::InitApp(); diff --git a/examples/light-switch-app/nrfconnect/main/ShellCommands.cpp b/examples/light-switch-app/nrfconnect/main/ShellCommands.cpp index 235b9f9aedb336..ee10c5ad4cf0a1 100644 --- a/examples/light-switch-app/nrfconnect/main/ShellCommands.cpp +++ b/examples/light-switch-app/nrfconnect/main/ShellCommands.cpp @@ -213,10 +213,11 @@ void RegisterSwitchCommands() static const shell_command_t sSwitchCommand = { &SwitchCommandHandler, "switch", "Light-switch commands. Usage: switch [onoff|groups]" }; - sShellSwitchGroupsOnOffSubCommands.RegisterCommands(sSwichGroupsOnOffSubCommands, ArraySize(sSwichGroupsOnOffSubCommands)); - sShellSwitchOnOffSubCommands.RegisterCommands(sSwitchOnOffSubCommands, ArraySize(sSwitchOnOffSubCommands)); - sShellSwitchGroupsSubCommands.RegisterCommands(sSwitchGroupsSubCommands, ArraySize(sSwitchGroupsSubCommands)); - sShellSwitchSubCommands.RegisterCommands(sSwitchSubCommands, ArraySize(sSwitchSubCommands)); + sShellSwitchGroupsOnOffSubCommands.RegisterCommands(sSwichGroupsOnOffSubCommands, + MATTER_ARRAY_SIZE(sSwichGroupsOnOffSubCommands)); + sShellSwitchOnOffSubCommands.RegisterCommands(sSwitchOnOffSubCommands, MATTER_ARRAY_SIZE(sSwitchOnOffSubCommands)); + sShellSwitchGroupsSubCommands.RegisterCommands(sSwitchGroupsSubCommands, MATTER_ARRAY_SIZE(sSwitchGroupsSubCommands)); + sShellSwitchSubCommands.RegisterCommands(sSwitchSubCommands, MATTER_ARRAY_SIZE(sSwitchSubCommands)); Engine::Root().RegisterCommands(&sSwitchCommand, 1); } diff --git a/examples/light-switch-app/qpg/src/AppTask.cpp b/examples/light-switch-app/qpg/src/AppTask.cpp index 959f2e63aa4274..32ed7963517e8b 100644 --- a/examples/light-switch-app/qpg/src/AppTask.cpp +++ b/examples/light-switch-app/qpg/src/AppTask.cpp @@ -192,7 +192,8 @@ CHIP_ERROR AppTask::StartAppTask() } // Start App task. - sAppTaskHandle = xTaskCreateStatic(AppTaskMain, APP_TASK_NAME, ArraySize(appStack), nullptr, 1, appStack, &appTaskStruct); + sAppTaskHandle = + xTaskCreateStatic(AppTaskMain, APP_TASK_NAME, MATTER_ARRAY_SIZE(appStack), nullptr, 1, appStack, &appTaskStruct); if (sAppTaskHandle == nullptr) { return CHIP_ERROR_NO_MEMORY; diff --git a/examples/light-switch-app/silabs/src/ShellCommands.cpp b/examples/light-switch-app/silabs/src/ShellCommands.cpp index 167453906ee32c..e514a4c9fdecd3 100644 --- a/examples/light-switch-app/silabs/src/ShellCommands.cpp +++ b/examples/light-switch-app/silabs/src/ShellCommands.cpp @@ -277,11 +277,12 @@ void RegisterSwitchCommands() static const shell_command_t sSwitchCommand = { &SwitchCommandHandler, "switch", "Light-switch commands. Usage: switch " }; - sShellSwitchGroupsOnOffSubCommands.RegisterCommands(sSwitchGroupsOnOffSubCommands, ArraySize(sSwitchGroupsOnOffSubCommands)); - sShellSwitchOnOffSubCommands.RegisterCommands(sSwitchOnOffSubCommands, ArraySize(sSwitchOnOffSubCommands)); - sShellSwitchGroupsSubCommands.RegisterCommands(sSwitchGroupsSubCommands, ArraySize(sSwitchGroupsSubCommands)); - sShellSwitchBindingSubCommands.RegisterCommands(sSwitchBindingSubCommands, ArraySize(sSwitchBindingSubCommands)); - sShellSwitchSubCommands.RegisterCommands(sSwitchSubCommands, ArraySize(sSwitchSubCommands)); + sShellSwitchGroupsOnOffSubCommands.RegisterCommands(sSwitchGroupsOnOffSubCommands, + MATTER_ARRAY_SIZE(sSwitchGroupsOnOffSubCommands)); + sShellSwitchOnOffSubCommands.RegisterCommands(sSwitchOnOffSubCommands, MATTER_ARRAY_SIZE(sSwitchOnOffSubCommands)); + sShellSwitchGroupsSubCommands.RegisterCommands(sSwitchGroupsSubCommands, MATTER_ARRAY_SIZE(sSwitchGroupsSubCommands)); + sShellSwitchBindingSubCommands.RegisterCommands(sSwitchBindingSubCommands, MATTER_ARRAY_SIZE(sSwitchBindingSubCommands)); + sShellSwitchSubCommands.RegisterCommands(sSwitchSubCommands, MATTER_ARRAY_SIZE(sSwitchSubCommands)); Engine::Root().RegisterCommands(&sSwitchCommand, 1); } diff --git a/examples/light-switch-app/telink/src/binding-handler.cpp b/examples/light-switch-app/telink/src/binding-handler.cpp index 22c83a8b9fd788..ba75b2c5745340 100644 --- a/examples/light-switch-app/telink/src/binding-handler.cpp +++ b/examples/light-switch-app/telink/src/binding-handler.cpp @@ -422,14 +422,16 @@ static void RegisterSwitchCommands() "Light-switch commands. Usage: switch " }; sShellSwitchGroupsIdentifySubCommands.RegisterCommands(sSwitchGroupsIdentifySubCommands, - ArraySize(sSwitchGroupsIdentifySubCommands)); - sShellSwitchGroupsOnOffSubCommands.RegisterCommands(sSwitchGroupsOnOffSubCommands, ArraySize(sSwitchGroupsOnOffSubCommands)); - sShellSwitchIdentifySubCommands.RegisterCommands(sSwitchIdentifySubCommands, ArraySize(sSwitchIdentifySubCommands)); - sShellSwitchIdentifyReadSubCommands.RegisterCommands(sSwitchIdentifyReadSubCommands, ArraySize(sSwitchIdentifyReadSubCommands)); - sShellSwitchOnOffSubCommands.RegisterCommands(sSwitchOnOffSubCommands, ArraySize(sSwitchOnOffSubCommands)); - sShellSwitchGroupsSubCommands.RegisterCommands(sSwitchGroupsSubCommands, ArraySize(sSwitchGroupsSubCommands)); - sShellSwitchBindingSubCommands.RegisterCommands(sSwitchBindingSubCommands, ArraySize(sSwitchBindingSubCommands)); - sShellSwitchSubCommands.RegisterCommands(sSwitchSubCommands, ArraySize(sSwitchSubCommands)); + MATTER_ARRAY_SIZE(sSwitchGroupsIdentifySubCommands)); + sShellSwitchGroupsOnOffSubCommands.RegisterCommands(sSwitchGroupsOnOffSubCommands, + MATTER_ARRAY_SIZE(sSwitchGroupsOnOffSubCommands)); + sShellSwitchIdentifySubCommands.RegisterCommands(sSwitchIdentifySubCommands, MATTER_ARRAY_SIZE(sSwitchIdentifySubCommands)); + sShellSwitchIdentifyReadSubCommands.RegisterCommands(sSwitchIdentifyReadSubCommands, + MATTER_ARRAY_SIZE(sSwitchIdentifyReadSubCommands)); + sShellSwitchOnOffSubCommands.RegisterCommands(sSwitchOnOffSubCommands, MATTER_ARRAY_SIZE(sSwitchOnOffSubCommands)); + sShellSwitchGroupsSubCommands.RegisterCommands(sSwitchGroupsSubCommands, MATTER_ARRAY_SIZE(sSwitchGroupsSubCommands)); + sShellSwitchBindingSubCommands.RegisterCommands(sSwitchBindingSubCommands, MATTER_ARRAY_SIZE(sSwitchBindingSubCommands)); + sShellSwitchSubCommands.RegisterCommands(sSwitchSubCommands, MATTER_ARRAY_SIZE(sSwitchSubCommands)); Engine::Root().RegisterCommands(&sSwitchCommand, 1); } diff --git a/examples/lighting-app/bouffalolab/common/AppTask.cpp b/examples/lighting-app/bouffalolab/common/AppTask.cpp index 99fb0a4c07ea04..b301217fc0e0bc 100644 --- a/examples/lighting-app/bouffalolab/common/AppTask.cpp +++ b/examples/lighting-app/bouffalolab/common/AppTask.cpp @@ -94,8 +94,9 @@ StaticTask_t AppTask::appTaskStruct; void StartAppTask(void) { - GetAppTask().sAppTaskHandle = xTaskCreateStatic(GetAppTask().AppTaskMain, APP_TASK_NAME, ArraySize(GetAppTask().appStack), NULL, - APP_TASK_PRIORITY, GetAppTask().appStack, &GetAppTask().appTaskStruct); + GetAppTask().sAppTaskHandle = + xTaskCreateStatic(GetAppTask().AppTaskMain, APP_TASK_NAME, MATTER_ARRAY_SIZE(GetAppTask().appStack), NULL, + APP_TASK_PRIORITY, GetAppTask().appStack, &GetAppTask().appTaskStruct); if (GetAppTask().sAppTaskHandle == NULL) { ChipLogError(NotSpecified, "Failed to create app task"); diff --git a/examples/lighting-app/genio/src/AppTask.cpp b/examples/lighting-app/genio/src/AppTask.cpp index 61c958c9ad554f..1a6434a61c1dbb 100644 --- a/examples/lighting-app/genio/src/AppTask.cpp +++ b/examples/lighting-app/genio/src/AppTask.cpp @@ -283,10 +283,10 @@ static void RegisterLightCommands() }, }; - sShellLightOnOffSubCommands.RegisterCommands(sLightOnOffSubCommands, ArraySize(sLightOnOffSubCommands)); - sShellLightSubCommands.RegisterCommands(sLightSubCommands, ArraySize(sLightSubCommands)); + sShellLightOnOffSubCommands.RegisterCommands(sLightOnOffSubCommands, MATTER_ARRAY_SIZE(sLightOnOffSubCommands)); + sShellLightSubCommands.RegisterCommands(sLightSubCommands, MATTER_ARRAY_SIZE(sLightSubCommands)); - Engine::Root().RegisterCommands(sLightCommand, ArraySize(sLightCommand)); + Engine::Root().RegisterCommands(sLightCommand, MATTER_ARRAY_SIZE(sLightCommand)); } #endif // ENABLE_CHIP_SHELL @@ -300,7 +300,7 @@ CHIP_ERROR AppTask::StartAppTask() } // Start App task. - sAppTaskHandle = xTaskCreateStatic(AppTaskMain, APP_TASK_NAME, ArraySize(appStack), NULL, 1, appStack, &appTaskStruct); + sAppTaskHandle = xTaskCreateStatic(AppTaskMain, APP_TASK_NAME, MATTER_ARRAY_SIZE(appStack), NULL, 1, appStack, &appTaskStruct); if (sAppTaskHandle == nullptr) return APP_ERROR_CREATE_TASK_FAILED; diff --git a/examples/lighting-app/infineon/cyw30739/src/AppShellCommands.cpp b/examples/lighting-app/infineon/cyw30739/src/AppShellCommands.cpp index 84f7b74adefc94..0e452815c954e8 100644 --- a/examples/lighting-app/infineon/cyw30739/src/AppShellCommands.cpp +++ b/examples/lighting-app/infineon/cyw30739/src/AppShellCommands.cpp @@ -50,7 +50,7 @@ void RegisterAppShellCommands(void) .cmd_help = "App commands", }; - sAppSubcommands.RegisterCommands(sAppSubCommands, ArraySize(sAppSubCommands)); + sAppSubcommands.RegisterCommands(sAppSubCommands, MATTER_ARRAY_SIZE(sAppSubCommands)); Engine::Root().RegisterCommands(&sAppCommand, 1); } diff --git a/examples/lighting-app/infineon/cyw30739/src/AppTask.cpp b/examples/lighting-app/infineon/cyw30739/src/AppTask.cpp index 620fd4620de61c..e38c6b206177e4 100644 --- a/examples/lighting-app/infineon/cyw30739/src/AppTask.cpp +++ b/examples/lighting-app/infineon/cyw30739/src/AppTask.cpp @@ -78,7 +78,7 @@ void AppTaskMain(intptr_t args) { ChipLogError(Zcl, "ERROR app_button_init %d\n", result); } - LEDWid().Init(chip_lighting_led_config, ArraySize(chip_lighting_led_config)); + LEDWid().Init(chip_lighting_led_config, MATTER_ARRAY_SIZE(chip_lighting_led_config)); LightMgr().SetCallbacks(LightManagerCallback, nullptr); CYW30739MatterConfig::InitApp(); diff --git a/examples/lighting-app/infineon/psoc6/src/AppTask.cpp b/examples/lighting-app/infineon/psoc6/src/AppTask.cpp index 871a44fb637e60..aaea4eaeef3a18 100644 --- a/examples/lighting-app/infineon/psoc6/src/AppTask.cpp +++ b/examples/lighting-app/infineon/psoc6/src/AppTask.cpp @@ -167,7 +167,7 @@ CHIP_ERROR AppTask::StartAppTask() } // Start App task. - sAppTaskHandle = xTaskCreateStatic(AppTaskMain, APP_TASK_NAME, ArraySize(appStack), NULL, 1, appStack, &appTaskStruct); + sAppTaskHandle = xTaskCreateStatic(AppTaskMain, APP_TASK_NAME, MATTER_ARRAY_SIZE(appStack), NULL, 1, appStack, &appTaskStruct); return (sAppTaskHandle == nullptr) ? APP_ERROR_CREATE_TASK_FAILED : CHIP_NO_ERROR; } diff --git a/examples/lighting-app/qpg/src/AppTask.cpp b/examples/lighting-app/qpg/src/AppTask.cpp index b74f02b5997310..0cc292d047615f 100644 --- a/examples/lighting-app/qpg/src/AppTask.cpp +++ b/examples/lighting-app/qpg/src/AppTask.cpp @@ -247,7 +247,8 @@ CHIP_ERROR AppTask::StartAppTask() } // Start App task. - sAppTaskHandle = xTaskCreateStatic(AppTaskMain, APP_TASK_NAME, ArraySize(appStack), nullptr, 1, appStack, &appTaskStruct); + sAppTaskHandle = + xTaskCreateStatic(AppTaskMain, APP_TASK_NAME, MATTER_ARRAY_SIZE(appStack), nullptr, 1, appStack, &appTaskStruct); if (sAppTaskHandle == nullptr) { return CHIP_ERROR_NO_MEMORY; diff --git a/examples/lock-app/cc13x4_26x4/src/LockManager.cpp b/examples/lock-app/cc13x4_26x4/src/LockManager.cpp index 5f4d6e2ff1c578..002272b7c66f0e 100644 --- a/examples/lock-app/cc13x4_26x4/src/LockManager.cpp +++ b/examples/lock-app/cc13x4_26x4/src/LockManager.cpp @@ -144,10 +144,10 @@ bool LockManager::ReadConfigValues() { size_t outLen; KeyValueStoreMgr().Get(LockUser, reinterpret_cast(&mLockUsers), - sizeof(EmberAfPluginDoorLockUserInfo) * ArraySize(mLockUsers), &outLen); + sizeof(EmberAfPluginDoorLockUserInfo) * MATTER_ARRAY_SIZE(mLockUsers), &outLen); KeyValueStoreMgr().Get(Credential, reinterpret_cast(&mLockCredentials), - sizeof(EmberAfPluginDoorLockCredentialInfo) * ArraySize(mLockCredentials), &outLen); + sizeof(EmberAfPluginDoorLockCredentialInfo) * MATTER_ARRAY_SIZE(mLockCredentials), &outLen); KeyValueStoreMgr().Get(LockUserName, reinterpret_cast(mUserNames), sizeof(mUserNames), &outLen); diff --git a/examples/lock-app/cc13x4_26x4/src/LockManager.h b/examples/lock-app/cc13x4_26x4/src/LockManager.h index 13b30b2eccadb0..bf19e77b38f352 100644 --- a/examples/lock-app/cc13x4_26x4/src/LockManager.h +++ b/examples/lock-app/cc13x4_26x4/src/LockManager.h @@ -207,7 +207,7 @@ class LockManager YearDayScheduleInfo mYeardaySchedule[kMaxUsers][kMaxYeardaySchedulesPerUser]; HolidayScheduleInfo mHolidaySchedule[kMaxHolidaySchedules]; - char mUserNames[ArraySize(mLockUsers)][DOOR_LOCK_MAX_USER_NAME_SIZE]; + char mUserNames[MATTER_ARRAY_SIZE(mLockUsers)][DOOR_LOCK_MAX_USER_NAME_SIZE]; uint8_t mCredentialData[kMaxCredentials][kMaxCredentialSize]; CredentialStruct mCredentials[kMaxUsers][kMaxCredentialsPerUser]; diff --git a/examples/lock-app/esp32/main/AppTask.cpp b/examples/lock-app/esp32/main/AppTask.cpp index 84182fe46a7159..961b7aaf02fd79 100644 --- a/examples/lock-app/esp32/main/AppTask.cpp +++ b/examples/lock-app/esp32/main/AppTask.cpp @@ -72,7 +72,7 @@ CHIP_ERROR AppTask::StartAppTask() } // Start App task. - sAppTaskHandle = xTaskCreate(AppTaskMain, APP_TASK_NAME, ArraySize(appStack), NULL, 1, NULL); + sAppTaskHandle = xTaskCreate(AppTaskMain, APP_TASK_NAME, MATTER_ARRAY_SIZE(appStack), NULL, 1, NULL); return sAppTaskHandle ? CHIP_NO_ERROR : APP_ERROR_CREATE_TASK_FAILED; } diff --git a/examples/lock-app/genio/include/LockManager.h b/examples/lock-app/genio/include/LockManager.h index 6361706e11a5e8..926e15efa761cd 100644 --- a/examples/lock-app/genio/include/LockManager.h +++ b/examples/lock-app/genio/include/LockManager.h @@ -211,7 +211,7 @@ class LockManager YearDayScheduleInfo mYeardaySchedule[kMaxUsers][kMaxYeardaySchedulesPerUser]; HolidayScheduleInfo mHolidaySchedule[kMaxHolidaySchedules]; - char mUserNames[ArraySize(mLockUsers)][DOOR_LOCK_MAX_USER_NAME_SIZE]; + char mUserNames[MATTER_ARRAY_SIZE(mLockUsers)][DOOR_LOCK_MAX_USER_NAME_SIZE]; uint8_t mCredentialData[kMaxCredentials][kMaxCredentialSize]; CredentialStruct mCredentials[kMaxUsers][kMaxCredentialsPerUser]; diff --git a/examples/lock-app/genio/src/AppTask.cpp b/examples/lock-app/genio/src/AppTask.cpp index 20806f989d1422..91df6a443e7832 100644 --- a/examples/lock-app/genio/src/AppTask.cpp +++ b/examples/lock-app/genio/src/AppTask.cpp @@ -116,7 +116,7 @@ CHIP_ERROR AppTask::StartAppTask() } // Start App task. - sAppTaskHandle = xTaskCreateStatic(AppTaskMain, APP_TASK_NAME, ArraySize(appStack), NULL, 1, appStack, &appTaskStruct); + sAppTaskHandle = xTaskCreateStatic(AppTaskMain, APP_TASK_NAME, MATTER_ARRAY_SIZE(appStack), NULL, 1, appStack, &appTaskStruct); if (sAppTaskHandle == nullptr) return APP_ERROR_CREATE_TASK_FAILED; diff --git a/examples/lock-app/genio/src/LockManager.cpp b/examples/lock-app/genio/src/LockManager.cpp index aa934e3042506a..8085d38159466a 100644 --- a/examples/lock-app/genio/src/LockManager.cpp +++ b/examples/lock-app/genio/src/LockManager.cpp @@ -132,10 +132,10 @@ bool LockManager::ReadConfigValues() { size_t outLen; MT793XConfig::ReadConfigValueBin(MT793XConfig::kConfigKey_LockUser, reinterpret_cast(&mLockUsers), - sizeof(EmberAfPluginDoorLockUserInfo) * ArraySize(mLockUsers), outLen); + sizeof(EmberAfPluginDoorLockUserInfo) * MATTER_ARRAY_SIZE(mLockUsers), outLen); MT793XConfig::ReadConfigValueBin(MT793XConfig::kConfigKey_Credential, reinterpret_cast(&mLockCredentials), - sizeof(EmberAfPluginDoorLockCredentialInfo) * ArraySize(mLockCredentials), outLen); + sizeof(EmberAfPluginDoorLockCredentialInfo) * MATTER_ARRAY_SIZE(mLockCredentials), outLen); MT793XConfig::ReadConfigValueBin(MT793XConfig::kConfigKey_LockUserName, reinterpret_cast(mUserNames), sizeof(mUserNames), outLen); diff --git a/examples/lock-app/infineon/cyw30739/include/LockManager.h b/examples/lock-app/infineon/cyw30739/include/LockManager.h index 19a336bb094fa9..eb46ed74a0b12f 100644 --- a/examples/lock-app/infineon/cyw30739/include/LockManager.h +++ b/examples/lock-app/infineon/cyw30739/include/LockManager.h @@ -211,7 +211,7 @@ class LockManager WeekDaysScheduleInfo mWeekdaySchedule[kMaxUsers][kMaxWeekdaySchedulesPerUser]; YearDayScheduleInfo mYeardaySchedule[kMaxUsers][kMaxYeardaySchedulesPerUser]; HolidayScheduleInfo mHolidaySchedule[kMaxHolidaySchedules]; - char mUserNames[ArraySize(mLockUsers)][DOOR_LOCK_MAX_USER_NAME_SIZE]; + char mUserNames[MATTER_ARRAY_SIZE(mLockUsers)][DOOR_LOCK_MAX_USER_NAME_SIZE]; uint8_t mCredentialData[kMaxCredentials][kMaxCredentialSize]; CredentialStruct mCredentials[kMaxUsers][kMaxCredentialsPerUser]; diff --git a/examples/lock-app/infineon/cyw30739/src/AppShellCommands.cpp b/examples/lock-app/infineon/cyw30739/src/AppShellCommands.cpp index 3161272d070a17..0828b0d1a95f8a 100644 --- a/examples/lock-app/infineon/cyw30739/src/AppShellCommands.cpp +++ b/examples/lock-app/infineon/cyw30739/src/AppShellCommands.cpp @@ -52,7 +52,7 @@ void RegisterAppShellCommands(void) .cmd_help = "App commands", }; - sAppSubcommands.RegisterCommands(sAppSubCommands, ArraySize(sAppSubCommands)); + sAppSubcommands.RegisterCommands(sAppSubCommands, MATTER_ARRAY_SIZE(sAppSubCommands)); Engine::Root().RegisterCommands(&sAppCommand, 1); } diff --git a/examples/lock-app/infineon/cyw30739/src/AppTask.cpp b/examples/lock-app/infineon/cyw30739/src/AppTask.cpp index 2277049316d803..7807a4457e968c 100644 --- a/examples/lock-app/infineon/cyw30739/src/AppTask.cpp +++ b/examples/lock-app/infineon/cyw30739/src/AppTask.cpp @@ -71,7 +71,7 @@ void AppTaskMain(intptr_t args) { ChipLogError(Zcl, "ERROR app_button_init %d\n", result); } - LEDWid().Init(chip_lighting_led_config, ArraySize(chip_lighting_led_config)); + LEDWid().Init(chip_lighting_led_config, MATTER_ARRAY_SIZE(chip_lighting_led_config)); CYW30739MatterConfig::InitApp(); diff --git a/examples/lock-app/infineon/cyw30739/src/LockManager.cpp b/examples/lock-app/infineon/cyw30739/src/LockManager.cpp index 30d680d96500ca..37e3a9a4a84141 100644 --- a/examples/lock-app/infineon/cyw30739/src/LockManager.cpp +++ b/examples/lock-app/infineon/cyw30739/src/LockManager.cpp @@ -128,10 +128,10 @@ bool LockManager::ReadConfigValues() { size_t outLen; CYW30739Config::ReadConfigValueBin(CYW30739Config::kConfigKey_LockUser, reinterpret_cast(&mLockUsers), - sizeof(EmberAfPluginDoorLockUserInfo) * ArraySize(mLockUsers), outLen); + sizeof(EmberAfPluginDoorLockUserInfo) * MATTER_ARRAY_SIZE(mLockUsers), outLen); CYW30739Config::ReadConfigValueBin(CYW30739Config::kConfigKey_Credential, reinterpret_cast(&mLockCredentials), - sizeof(EmberAfPluginDoorLockCredentialInfo) * ArraySize(mLockCredentials), outLen); + sizeof(EmberAfPluginDoorLockCredentialInfo) * MATTER_ARRAY_SIZE(mLockCredentials), outLen); CYW30739Config::ReadConfigValueBin(CYW30739Config::kConfigKey_LockUserName, reinterpret_cast(mUserNames), sizeof(mUserNames), outLen); diff --git a/examples/lock-app/infineon/psoc6/include/LockManager.h b/examples/lock-app/infineon/psoc6/include/LockManager.h index d08cab2cc104b3..d95de32cd87564 100644 --- a/examples/lock-app/infineon/psoc6/include/LockManager.h +++ b/examples/lock-app/infineon/psoc6/include/LockManager.h @@ -209,7 +209,7 @@ class LockManager YearDayScheduleInfo mYeardaySchedule[kMaxUsers][kMaxYeardaySchedulesPerUser]; HolidayScheduleInfo mHolidaySchedule[kMaxHolidaySchedules]; - char mUserNames[ArraySize(mLockUsers)][DOOR_LOCK_MAX_USER_NAME_SIZE]; + char mUserNames[MATTER_ARRAY_SIZE(mLockUsers)][DOOR_LOCK_MAX_USER_NAME_SIZE]; uint8_t mCredentialData[kNumCredentialTypes][kMaxCredentials][kMaxCredentialSize]; CredentialStruct mCredentials[kMaxUsers][kMaxCredentials]; diff --git a/examples/lock-app/infineon/psoc6/src/AppTask.cpp b/examples/lock-app/infineon/psoc6/src/AppTask.cpp index b5aaf64defc105..d0647212c77837 100644 --- a/examples/lock-app/infineon/psoc6/src/AppTask.cpp +++ b/examples/lock-app/infineon/psoc6/src/AppTask.cpp @@ -186,7 +186,7 @@ CHIP_ERROR AppTask::StartAppTask() } // Start App task. - sAppTaskHandle = xTaskCreateStatic(AppTaskMain, APP_TASK_NAME, ArraySize(appStack), NULL, 1, appStack, &appTaskStruct); + sAppTaskHandle = xTaskCreateStatic(AppTaskMain, APP_TASK_NAME, MATTER_ARRAY_SIZE(appStack), NULL, 1, appStack, &appTaskStruct); return (sAppTaskHandle == nullptr) ? APP_ERROR_CREATE_TASK_FAILED : CHIP_NO_ERROR; } diff --git a/examples/lock-app/infineon/psoc6/src/LockManager.cpp b/examples/lock-app/infineon/psoc6/src/LockManager.cpp index 70af147902c8a6..be248c3a206e22 100644 --- a/examples/lock-app/infineon/psoc6/src/LockManager.cpp +++ b/examples/lock-app/infineon/psoc6/src/LockManager.cpp @@ -142,7 +142,7 @@ bool LockManager::ReadConfigValues() { size_t outLen; PSOC6Config::ReadConfigValueBin(PSOC6Config::kConfigKey_LockUser, reinterpret_cast(&mLockUsers), - sizeof(EmberAfPluginDoorLockUserInfo) * ArraySize(mLockUsers), outLen); + sizeof(EmberAfPluginDoorLockUserInfo) * MATTER_ARRAY_SIZE(mLockUsers), outLen); PSOC6Config::ReadConfigValueBin(PSOC6Config::kConfigKey_Credential, reinterpret_cast(&mLockCredentials), sizeof(EmberAfPluginDoorLockCredentialInfo) * kMaxCredentials * kNumCredentialTypes, outLen); diff --git a/examples/lock-app/qpg/src/AppTask.cpp b/examples/lock-app/qpg/src/AppTask.cpp index 6b147e85b4d29c..5caeebfe87e1bd 100644 --- a/examples/lock-app/qpg/src/AppTask.cpp +++ b/examples/lock-app/qpg/src/AppTask.cpp @@ -190,7 +190,8 @@ CHIP_ERROR AppTask::StartAppTask() } // Start App task. - sAppTaskHandle = xTaskCreateStatic(AppTaskMain, APP_TASK_NAME, ArraySize(appStack), nullptr, 1, appStack, &appTaskStruct); + sAppTaskHandle = + xTaskCreateStatic(AppTaskMain, APP_TASK_NAME, MATTER_ARRAY_SIZE(appStack), nullptr, 1, appStack, &appTaskStruct); if (sAppTaskHandle == nullptr) { return CHIP_ERROR_NO_MEMORY; diff --git a/examples/lock-app/silabs/include/LockManager.h b/examples/lock-app/silabs/include/LockManager.h index 00a4407c349e39..671aedb81c4e56 100644 --- a/examples/lock-app/silabs/include/LockManager.h +++ b/examples/lock-app/silabs/include/LockManager.h @@ -250,7 +250,7 @@ class LockManager YearDayScheduleInfo mYeardaySchedule[kMaxUsers][kMaxYeardaySchedulesPerUser]; HolidayScheduleInfo mHolidaySchedule[kMaxHolidaySchedules]; - char mUserNames[ArraySize(mLockUsers)][DOOR_LOCK_MAX_USER_NAME_SIZE]; + char mUserNames[MATTER_ARRAY_SIZE(mLockUsers)][DOOR_LOCK_MAX_USER_NAME_SIZE]; uint8_t mCredentialData[kNumCredentialTypes][kMaxCredentials][kMaxCredentialSize]; CredentialStruct mCredentials[kMaxUsers][kMaxCredentials]; diff --git a/examples/lock-app/silabs/src/EventHandlerLibShell.cpp b/examples/lock-app/silabs/src/EventHandlerLibShell.cpp index d9b9244fc6049a..62c994410a1f96 100644 --- a/examples/lock-app/silabs/src/EventHandlerLibShell.cpp +++ b/examples/lock-app/silabs/src/EventHandlerLibShell.cpp @@ -170,13 +170,14 @@ CHIP_ERROR RegisterLockEvents() static const shell_command_t sDoorLockCommand = { &DoorlockCommandHandler, "doorlock", "doorlock commands. Usage: doorlock " }; - sShellDoorlockEventAlarmSubCommands.RegisterCommands(sDoorlockEventAlarmSubCommands, ArraySize(sDoorlockEventAlarmSubCommands)); + sShellDoorlockEventAlarmSubCommands.RegisterCommands(sDoorlockEventAlarmSubCommands, + MATTER_ARRAY_SIZE(sDoorlockEventAlarmSubCommands)); sShellDoorlockEventDoorStateSubCommands.RegisterCommands(sDoorlockEventDoorStateSubCommands, - ArraySize(sDoorlockEventDoorStateSubCommands)); + MATTER_ARRAY_SIZE(sDoorlockEventDoorStateSubCommands)); - sShellDoorlockEventSubCommands.RegisterCommands(sDoorlockEventSubCommands, ArraySize(sDoorlockEventSubCommands)); - sShellDoorlockSubCommands.RegisterCommands(sDoorlockSubCommands, ArraySize(sDoorlockSubCommands)); + sShellDoorlockEventSubCommands.RegisterCommands(sDoorlockEventSubCommands, MATTER_ARRAY_SIZE(sDoorlockEventSubCommands)); + sShellDoorlockSubCommands.RegisterCommands(sDoorlockSubCommands, MATTER_ARRAY_SIZE(sDoorlockSubCommands)); Engine::Root().RegisterCommands(&sDoorLockCommand, 1); diff --git a/examples/lock-app/silabs/src/LockManager.cpp b/examples/lock-app/silabs/src/LockManager.cpp index 6f5aba9147f6b2..66050da62a1bec 100644 --- a/examples/lock-app/silabs/src/LockManager.cpp +++ b/examples/lock-app/silabs/src/LockManager.cpp @@ -140,7 +140,7 @@ bool LockManager::ReadConfigValues() { size_t outLen; SilabsConfig::ReadConfigValueBin(SilabsConfig::kConfigKey_LockUser, reinterpret_cast(&mLockUsers), - sizeof(EmberAfPluginDoorLockUserInfo) * ArraySize(mLockUsers), outLen); + sizeof(EmberAfPluginDoorLockUserInfo) * MATTER_ARRAY_SIZE(mLockUsers), outLen); SilabsConfig::ReadConfigValueBin(SilabsConfig::kConfigKey_Credential, reinterpret_cast(&mLockCredentials), sizeof(EmberAfPluginDoorLockCredentialInfo) * kMaxCredentials * kNumCredentialTypes, outLen); diff --git a/examples/lock-app/telink/include/LockManager.h b/examples/lock-app/telink/include/LockManager.h index 4420b4789562ec..2333dc31025ae1 100644 --- a/examples/lock-app/telink/include/LockManager.h +++ b/examples/lock-app/telink/include/LockManager.h @@ -204,7 +204,7 @@ class LockManager YearDayScheduleInfo mYeardaySchedule[APP_MAX_USERS][APP_MAX_YEARDAY_SCHEDULE_PER_USER]; HolidayScheduleInfo mHolidaySchedule[APP_MAX_HOLYDAY_SCHEDULE_PER_USER]; - char mUserNames[ArraySize(mLockUsers)][DOOR_LOCK_MAX_USER_NAME_SIZE]; + char mUserNames[MATTER_ARRAY_SIZE(mLockUsers)][DOOR_LOCK_MAX_USER_NAME_SIZE]; uint8_t mCredentialData[kNumCredentialTypes][APP_MAX_CREDENTIAL][kMaxCredentialSize]; CredentialStruct mCredentials[APP_MAX_USERS][APP_MAX_CREDENTIAL]; #endif diff --git a/examples/microwave-oven-app/microwave-oven-common/src/microwave-oven-device.cpp b/examples/microwave-oven-app/microwave-oven-common/src/microwave-oven-device.cpp index 5ba3eedbc99a03..778fa8706b0c52 100644 --- a/examples/microwave-oven-app/microwave-oven-common/src/microwave-oven-device.cpp +++ b/examples/microwave-oven-app/microwave-oven-common/src/microwave-oven-device.cpp @@ -38,8 +38,8 @@ void ExampleMicrowaveOvenDevice::MicrowaveOvenInit() // set default value for attribute SelectedWattIndex and WattRating if (mMicrowaveOvenControlInstance.HasFeature(MicrowaveOvenControl::Feature::kPowerInWatts)) { - static_assert(ArraySize(mWattSettingList) > 0, "Watt setting list is empty!"); - mSelectedWattIndex = ArraySize(mWattSettingList) - 1; + static_assert(MATTER_ARRAY_SIZE(mWattSettingList) > 0, "Watt setting list is empty!"); + mSelectedWattIndex = MATTER_ARRAY_SIZE(mWattSettingList) - 1; mWattRating = mWattSettingList[mSelectedWattIndex]; } else @@ -99,7 +99,7 @@ Protocols::InteractionModel::Status ExampleMicrowaveOvenDevice::HandleModifyCook CHIP_ERROR ExampleMicrowaveOvenDevice::GetWattSettingByIndex(uint8_t index, uint16_t & wattSetting) { - VerifyOrReturnError(index < ArraySize(mWattSettingList), CHIP_ERROR_NOT_FOUND); + VerifyOrReturnError(index < MATTER_ARRAY_SIZE(mWattSettingList), CHIP_ERROR_NOT_FOUND); wattSetting = mWattSettingList[index]; return CHIP_NO_ERROR; @@ -205,7 +205,7 @@ void ExampleMicrowaveOvenDevice::HandleChangeToMode(uint8_t NewMode, ModeBase::C CHIP_ERROR ExampleMicrowaveOvenDevice::GetModeLabelByIndex(uint8_t modeIndex, chip::MutableCharSpan & label) { - if (modeIndex >= ArraySize(kModeOptions)) + if (modeIndex >= MATTER_ARRAY_SIZE(kModeOptions)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } @@ -214,7 +214,7 @@ CHIP_ERROR ExampleMicrowaveOvenDevice::GetModeLabelByIndex(uint8_t modeIndex, ch CHIP_ERROR ExampleMicrowaveOvenDevice::GetModeValueByIndex(uint8_t modeIndex, uint8_t & value) { - if (modeIndex >= ArraySize(kModeOptions)) + if (modeIndex >= MATTER_ARRAY_SIZE(kModeOptions)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } @@ -224,7 +224,7 @@ CHIP_ERROR ExampleMicrowaveOvenDevice::GetModeValueByIndex(uint8_t modeIndex, ui CHIP_ERROR ExampleMicrowaveOvenDevice::GetModeTagsByIndex(uint8_t modeIndex, List & tags) { - if (modeIndex >= ArraySize(kModeOptions)) + if (modeIndex >= MATTER_ARRAY_SIZE(kModeOptions)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } diff --git a/examples/ota-provider-app/esp32/main/OTAProviderCommands.cpp b/examples/ota-provider-app/esp32/main/OTAProviderCommands.cpp index 2a722fb179d25e..ba1398f137cc4e 100644 --- a/examples/ota-provider-app/esp32/main/OTAProviderCommands.cpp +++ b/examples/ota-provider-app/esp32/main/OTAProviderCommands.cpp @@ -95,7 +95,7 @@ void OTAProviderCommands::Register() "Usage: OTAProvider applyUpdateAction " }, }; - sSubShell.RegisterCommands(subCommands, ArraySize(subCommands)); + sSubShell.RegisterCommands(subCommands, MATTER_ARRAY_SIZE(subCommands)); // Register the root `OTA Provider` command in the top-level shell. static const shell_command_t otaProviderCommand = { &OTAProviderHandler, "OTAProvider", "OTA Provider commands" }; diff --git a/examples/ota-requestor-app/genio/src/AppTask.cpp b/examples/ota-requestor-app/genio/src/AppTask.cpp index 9da5ca25bad573..7fc9587aa4567c 100644 --- a/examples/ota-requestor-app/genio/src/AppTask.cpp +++ b/examples/ota-requestor-app/genio/src/AppTask.cpp @@ -85,7 +85,7 @@ constexpr chip::EndpointId kNetworkCommissioningEndpointSecondary = 0xFFFE; CHIP_ERROR AppTask::StartAppTask() { // Start App task. - sAppTaskHandle = xTaskCreateStatic(AppTaskMain, APP_TASK_NAME, ArraySize(appStack), NULL, 1, appStack, &appTaskStruct); + sAppTaskHandle = xTaskCreateStatic(AppTaskMain, APP_TASK_NAME, MATTER_ARRAY_SIZE(appStack), NULL, 1, appStack, &appTaskStruct); if (sAppTaskHandle == nullptr) return APP_ERROR_CREATE_TASK_FAILED; diff --git a/examples/platform/ameba/Rpc.cpp b/examples/platform/ameba/Rpc.cpp index cd33631f078155..8ff5c27502bc06 100644 --- a/examples/platform/ameba/Rpc.cpp +++ b/examples/platform/ameba/Rpc.cpp @@ -174,7 +174,7 @@ void Init() PigweedLogger::init(); // Start App task. - sRpcTaskHandle = xTaskCreateStatic(RunRpcService, "RPC_TASK", ArraySize(sRpcTaskStack), nullptr, RPC_TASK_PRIORITY, + sRpcTaskHandle = xTaskCreateStatic(RunRpcService, "RPC_TASK", MATTER_ARRAY_SIZE(sRpcTaskStack), nullptr, RPC_TASK_PRIORITY, sRpcTaskStack, &sRpcTaskBuffer); } diff --git a/examples/platform/bouffalolab/common/rpc/Rpc.cpp b/examples/platform/bouffalolab/common/rpc/Rpc.cpp index ba71648b68c42b..9fd8ab1e25bbb7 100644 --- a/examples/platform/bouffalolab/common/rpc/Rpc.cpp +++ b/examples/platform/bouffalolab/common/rpc/Rpc.cpp @@ -235,7 +235,7 @@ void RunRpcService(void *) void Init() { // Start App task. - sRpcTaskHandle = xTaskCreateStatic(RunRpcService, "RPC_TASK", ArraySize(sRpcTaskStack), nullptr, RPC_TASK_PRIORITY, + sRpcTaskHandle = xTaskCreateStatic(RunRpcService, "RPC_TASK", MATTER_ARRAY_SIZE(sRpcTaskStack), nullptr, RPC_TASK_PRIORITY, sRpcTaskStack, &sRpcTaskBuffer); } diff --git a/examples/platform/esp32/Rpc.cpp b/examples/platform/esp32/Rpc.cpp index 7c00267be89780..339961590dfa73 100644 --- a/examples/platform/esp32/Rpc.cpp +++ b/examples/platform/esp32/Rpc.cpp @@ -392,7 +392,7 @@ void Init() PigweedLogger::init(); // Start App task. - sRpcTaskHandle = xTaskCreateStatic(RunRpcService, "RPC_TASK", ArraySize(sRpcTaskStack), nullptr, RPC_TASK_PRIORITY, + sRpcTaskHandle = xTaskCreateStatic(RunRpcService, "RPC_TASK", MATTER_ARRAY_SIZE(sRpcTaskStack), nullptr, RPC_TASK_PRIORITY, sRpcTaskStack, &sRpcTaskBuffer); } diff --git a/examples/platform/esp32/lock/BoltLockManager.cpp b/examples/platform/esp32/lock/BoltLockManager.cpp index 262a5991ff0be9..0ddb2268ddbe18 100644 --- a/examples/platform/esp32/lock/BoltLockManager.cpp +++ b/examples/platform/esp32/lock/BoltLockManager.cpp @@ -134,10 +134,10 @@ bool BoltLockManager::ReadConfigValues() { size_t outLen; ESP32Config::ReadConfigValueBin(ESP32Config::kConfigKey_LockUser, reinterpret_cast(&mLockUsers), - sizeof(EmberAfPluginDoorLockUserInfo) * ArraySize(mLockUsers), outLen); + sizeof(EmberAfPluginDoorLockUserInfo) * MATTER_ARRAY_SIZE(mLockUsers), outLen); ESP32Config::ReadConfigValueBin(ESP32Config::kConfigKey_Credential, reinterpret_cast(&mLockCredentials), - sizeof(EmberAfPluginDoorLockCredentialInfo) * ArraySize(mLockCredentials), outLen); + sizeof(EmberAfPluginDoorLockCredentialInfo) * MATTER_ARRAY_SIZE(mLockCredentials), outLen); ESP32Config::ReadConfigValueBin(ESP32Config::kConfigKey_LockUserName, reinterpret_cast(mUserNames), sizeof(mUserNames), outLen); diff --git a/examples/platform/esp32/lock/BoltLockManager.h b/examples/platform/esp32/lock/BoltLockManager.h index 5e3c2de9f35a9a..9d32738a0e8e21 100644 --- a/examples/platform/esp32/lock/BoltLockManager.h +++ b/examples/platform/esp32/lock/BoltLockManager.h @@ -212,7 +212,7 @@ class BoltLockManager YearDayScheduleInfo mYeardaySchedule[kMaxUsers][kMaxYeardaySchedulesPerUser]; HolidayScheduleInfo mHolidaySchedule[kMaxHolidaySchedules]; - char mUserNames[ArraySize(mLockUsers)][DOOR_LOCK_MAX_USER_NAME_SIZE]; + char mUserNames[MATTER_ARRAY_SIZE(mLockUsers)][DOOR_LOCK_MAX_USER_NAME_SIZE]; uint8_t mCredentialData[kMaxCredentials][kMaxCredentialSize]; CredentialStruct mCredentials[kMaxUsers][kMaxCredentialsPerUser]; diff --git a/examples/platform/esp32/ota/OTAHelper.cpp b/examples/platform/esp32/ota/OTAHelper.cpp index 0b254f5d13e86e..da59d76c4190fc 100644 --- a/examples/platform/esp32/ota/OTAHelper.cpp +++ b/examples/platform/esp32/ota/OTAHelper.cpp @@ -171,7 +171,7 @@ void OTARequestorCommands::Register() }; - sSubShell.RegisterCommands(subCommands, ArraySize(subCommands)); + sSubShell.RegisterCommands(subCommands, MATTER_ARRAY_SIZE(subCommands)); // Register the root `OTA Requestor` command in the top-level shell. static const shell_command_t otaRequestorCommand = { &OTARequestorHandler, "OTARequestor", "OTA Requestor commands" }; diff --git a/examples/platform/esp32/shell_extension/heap_trace.cpp b/examples/platform/esp32/shell_extension/heap_trace.cpp index e1e593df188b5f..c3aa88bb57f1a7 100644 --- a/examples/platform/esp32/shell_extension/heap_trace.cpp +++ b/examples/platform/esp32/shell_extension/heap_trace.cpp @@ -137,7 +137,7 @@ void RegisterHeapTraceCommands() { &HeapTraceTaskHandler, "task", "Dump heap usage of each task" }, #endif // CONFIG_HEAP_TASK_TRACKING }; - sShellHeapSubCommands.RegisterCommands(sHeapSubCommands, ArraySize(sHeapSubCommands)); + sShellHeapSubCommands.RegisterCommands(sHeapSubCommands, MATTER_ARRAY_SIZE(sHeapSubCommands)); #if CONFIG_HEAP_TRACING_STANDALONE ESP_ERROR_CHECK(heap_trace_init_standalone(sTraceRecords, kNumHeapTraceRecords)); diff --git a/examples/platform/linux/Options.cpp b/examples/platform/linux/Options.cpp index 2101c2cbdd7d02..3789c5723a1e2f 100644 --- a/examples/platform/linux/Options.cpp +++ b/examples/platform/linux/Options.cpp @@ -741,7 +741,7 @@ bool HandleOption(const char * aProgram, OptionSet * aOptions, int aIdentifier, Inet::FaultInjection::GetManager, System::FaultInjection::GetManager }; Platform::ScopedMemoryString mutableArg(aValue, strlen(aValue)); // ParseFaultInjectionStr may mutate - if (!nl::FaultInjection::ParseFaultInjectionStr(mutableArg.Get(), faultManagerFns, ArraySize(faultManagerFns))) + if (!nl::FaultInjection::ParseFaultInjectionStr(mutableArg.Get(), faultManagerFns, MATTER_ARRAY_SIZE(faultManagerFns))) { PrintArgError("%s: Invalid fault injection specification\n", aProgram); retval = false; diff --git a/examples/platform/mt793x/matter_shell.cpp b/examples/platform/mt793x/matter_shell.cpp index fcbcda2842652d..5c6efb4e63892f 100644 --- a/examples/platform/mt793x/matter_shell.cpp +++ b/examples/platform/mt793x/matter_shell.cpp @@ -79,8 +79,8 @@ void startShellTask(void) cmd_misc_init(); cmd_otcli_init(); - shellTaskHandle = xTaskCreateStatic(MatterShellTask, "matter_cli", ArraySize(shellStack), NULL, SHELL_TASK_PRIORITY, shellStack, - &shellTaskStruct); + shellTaskHandle = xTaskCreateStatic(MatterShellTask, "matter_cli", MATTER_ARRAY_SIZE(shellStack), NULL, SHELL_TASK_PRIORITY, + shellStack, &shellTaskStruct); } } // namespace chip diff --git a/examples/platform/qpg/Rpc.cpp b/examples/platform/qpg/Rpc.cpp index c57865ec4602d1..9febf193edc332 100644 --- a/examples/platform/qpg/Rpc.cpp +++ b/examples/platform/qpg/Rpc.cpp @@ -156,7 +156,7 @@ bool Init(void) PigweedLogger::init(); // Start App task. - sRpcTaskHandle = xTaskCreateStatic(RunRpcService, "RPC_TASK", ArraySize(sRpcTaskStack), nullptr, RPC_TASK_PRIORITY, + sRpcTaskHandle = xTaskCreateStatic(RunRpcService, "RPC_TASK", MATTER_ARRAY_SIZE(sRpcTaskStack), nullptr, RPC_TASK_PRIORITY, sRpcTaskStack, &sRpcTaskBuffer); return (sRpcTaskHandle == nullptr); } diff --git a/examples/platform/qpg/shell_common/shell.cpp b/examples/platform/qpg/shell_common/shell.cpp index 07fadfcfd0b99b..327149277c6f13 100644 --- a/examples/platform/qpg/shell_common/shell.cpp +++ b/examples/platform/qpg/shell_common/shell.cpp @@ -77,7 +77,7 @@ int ShellTask::Start(void) // Start App task. sShellTaskHandle = - xTaskCreateStatic(ShellTask::Main, "SHELL_TASK", ArraySize(shellStack), nullptr, 1, shellStack, &shellTaskStruct); + xTaskCreateStatic(ShellTask::Main, "SHELL_TASK", MATTER_ARRAY_SIZE(shellStack), nullptr, 1, shellStack, &shellTaskStruct); if (sShellTaskHandle == nullptr) { return 1; diff --git a/examples/platform/silabs/shell/icd/ICDShellCommands.cpp b/examples/platform/silabs/shell/icd/ICDShellCommands.cpp index 4bd3910634b6a1..0be215c435784a 100644 --- a/examples/platform/silabs/shell/icd/ICDShellCommands.cpp +++ b/examples/platform/silabs/shell/icd/ICDShellCommands.cpp @@ -101,7 +101,7 @@ void RegisterCommands() #endif // defined(CHIP_CONFIG_ENABLE_ICD_DSLS) && CHIP_CONFIG_ENABLE_ICD_DSLS { &HelpHandler, "help", "Usage: icd " } }; - sShellICDSubCommands.RegisterCommands(sLitICDSubCommands, ArraySize(sLitICDSubCommands)); + sShellICDSubCommands.RegisterCommands(sLitICDSubCommands, MATTER_ARRAY_SIZE(sLitICDSubCommands)); #if defined(CHIP_CONFIG_ENABLE_ICD_DSLS) && CHIP_CONFIG_ENABLE_ICD_DSLS static const shell_command_t sDynamicSitLitSubCommands[] = { @@ -109,7 +109,7 @@ void RegisterCommands() { &DynamicSitLit::RemoveSitModeReq, "remove", "Removes SIT mode requirement." }, { &DynamicSitLit::HelpHandler, "help", "Usage : icd dsls ." } }; - sShellDynamicSitLitSubCommands.RegisterCommands(sDynamicSitLitSubCommands, ArraySize(sDynamicSitLitSubCommands)); + sShellDynamicSitLitSubCommands.RegisterCommands(sDynamicSitLitSubCommands, MATTER_ARRAY_SIZE(sDynamicSitLitSubCommands)); #endif // defined(CHIP_CONFIG_ENABLE_ICD_DSLS) && CHIP_CONFIG_ENABLE_ICD_DSLS static const shell_command_t sICDCommand = { &CommandHandler, "icd", "ICD commands. Usage: icd " }; diff --git a/examples/platform/silabs/uart.cpp b/examples/platform/silabs/uart.cpp index 4ef720f6a6336c..f60828d1949376 100644 --- a/examples/platform/silabs/uart.cpp +++ b/examples/platform/silabs/uart.cpp @@ -545,13 +545,13 @@ void uartSendBytes(UartTxStruct_t & bufferStruct) { #if SLI_SI91X_MCU_INTERFACE // ensuring null termination of buffer - if (bufferStruct.length < ArraySize(bufferStruct.data) && bufferStruct.data[bufferStruct.length - 1] != '\0') + if (bufferStruct.length < MATTER_ARRAY_SIZE(bufferStruct.data) && bufferStruct.data[bufferStruct.length - 1] != '\0') { bufferStruct.data[bufferStruct.length] = '\0'; } else { - bufferStruct.data[ArraySize(bufferStruct.data) - 1] = '\0'; + bufferStruct.data[MATTER_ARRAY_SIZE(bufferStruct.data) - 1] = '\0'; } Board_UARTPutSTR(bufferStruct.data); #else @@ -594,13 +594,13 @@ void uartFlushTxQueue(void) { #if SLI_SI91X_MCU_INTERFACE // ensuring null termination of buffer - if (workBuffer.length < ArraySize(workBuffer.data) && workBuffer.data[workBuffer.length - 1] != '\0') + if (workBuffer.length < MATTER_ARRAY_SIZE(workBuffer.data) && workBuffer.data[workBuffer.length - 1] != '\0') { workBuffer.data[workBuffer.length] = '\0'; } else { - workBuffer.data[ArraySize(workBuffer.data) - 1] = '\0'; + workBuffer.data[MATTER_ARRAY_SIZE(workBuffer.data) - 1] = '\0'; } Board_UARTPutSTR(workBuffer.data); #else diff --git a/examples/platform/telink/common/src/SensorManagerCommon.cpp b/examples/platform/telink/common/src/SensorManagerCommon.cpp index 0164749ce7167b..6e280dffdba0b5 100644 --- a/examples/platform/telink/common/src/SensorManagerCommon.cpp +++ b/examples/platform/telink/common/src/SensorManagerCommon.cpp @@ -119,7 +119,7 @@ CHIP_ERROR SensorManager::GetTempAndHumMeasurValue(int16_t * pTempMeasured, uint /* Temperature simulation is used */ static uint8_t nbOfRepetition = 0; static uint8_t simulatedIndex = 0; - if (simulatedIndex >= ArraySize(mSimulatedTemp)) + if (simulatedIndex >= MATTER_ARRAY_SIZE(mSimulatedTemp)) { simulatedIndex = 0; } diff --git a/examples/refrigerator-app/refrigerator-common/src/static-supported-temperature-levels.cpp b/examples/refrigerator-app/refrigerator-common/src/static-supported-temperature-levels.cpp index a7198c0cf0a3b6..9cba3a6f79de5a 100644 --- a/examples/refrigerator-app/refrigerator-common/src/static-supported-temperature-levels.cpp +++ b/examples/refrigerator-app/refrigerator-common/src/static-supported-temperature-levels.cpp @@ -32,9 +32,9 @@ CharSpan AppSupportedTemperatureLevelsDelegate::temperatureLevelOptions[] = { Ch const AppSupportedTemperatureLevelsDelegate::EndpointPair AppSupportedTemperatureLevelsDelegate::supportedOptionsByEndpoints [MATTER_DM_TEMPERATURE_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT] = { EndpointPair(2, AppSupportedTemperatureLevelsDelegate::temperatureLevelOptions, - ArraySize(AppSupportedTemperatureLevelsDelegate::temperatureLevelOptions)), // Options for Endpoint 2 + MATTER_ARRAY_SIZE(AppSupportedTemperatureLevelsDelegate::temperatureLevelOptions)), // Options for Endpoint 2 EndpointPair(3, AppSupportedTemperatureLevelsDelegate::temperatureLevelOptions, - ArraySize(AppSupportedTemperatureLevelsDelegate::temperatureLevelOptions)), // Options for Endpoint 3 + MATTER_ARRAY_SIZE(AppSupportedTemperatureLevelsDelegate::temperatureLevelOptions)), // Options for Endpoint 3 }; uint8_t AppSupportedTemperatureLevelsDelegate::Size() diff --git a/examples/refrigerator-app/silabs/src/EventHandlerLibShell.cpp b/examples/refrigerator-app/silabs/src/EventHandlerLibShell.cpp index 212b2ac8d892ae..451f213aaee2d2 100644 --- a/examples/refrigerator-app/silabs/src/EventHandlerLibShell.cpp +++ b/examples/refrigerator-app/silabs/src/EventHandlerLibShell.cpp @@ -146,9 +146,10 @@ CHIP_ERROR RegisterRefrigeratorEvents() "refrigerator alarm commands. Usage: refrigeratoralarm " }; sShellRefrigeratorEventAlarmDoorSubCommands.RegisterCommands(sRefrigeratorEventAlarmDoorSubCommands, - ArraySize(sRefrigeratorEventAlarmDoorSubCommands)); - sShellRefrigeratorEventSubCommands.RegisterCommands(sRefrigeratorEventSubCommands, ArraySize(sRefrigeratorEventSubCommands)); - sShellRefrigeratorSubCommands.RegisterCommands(sRefrigeratorSubCommands, ArraySize(sRefrigeratorSubCommands)); + MATTER_ARRAY_SIZE(sRefrigeratorEventAlarmDoorSubCommands)); + sShellRefrigeratorEventSubCommands.RegisterCommands(sRefrigeratorEventSubCommands, + MATTER_ARRAY_SIZE(sRefrigeratorEventSubCommands)); + sShellRefrigeratorSubCommands.RegisterCommands(sRefrigeratorSubCommands, MATTER_ARRAY_SIZE(sRefrigeratorSubCommands)); Engine::Root().RegisterCommands(&sRefrigeratorCommand, 1); diff --git a/examples/refrigerator-app/silabs/src/refrigerator-and-temperature-controlled-cabinet-mode.cpp b/examples/refrigerator-app/silabs/src/refrigerator-and-temperature-controlled-cabinet-mode.cpp index 443dcb7f6dae30..d69b6314353029 100644 --- a/examples/refrigerator-app/silabs/src/refrigerator-and-temperature-controlled-cabinet-mode.cpp +++ b/examples/refrigerator-app/silabs/src/refrigerator-and-temperature-controlled-cabinet-mode.cpp @@ -42,7 +42,7 @@ void RefrigeratorAndTemperatureControlledCabinetModeDelegate::HandleChangeToMode CHIP_ERROR RefrigeratorAndTemperatureControlledCabinetModeDelegate::GetModeLabelByIndex(uint8_t modeIndex, chip::MutableCharSpan & label) { - if (modeIndex >= ArraySize(kModeOptions)) + if (modeIndex >= MATTER_ARRAY_SIZE(kModeOptions)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } @@ -51,7 +51,7 @@ CHIP_ERROR RefrigeratorAndTemperatureControlledCabinetModeDelegate::GetModeLabel CHIP_ERROR RefrigeratorAndTemperatureControlledCabinetModeDelegate::GetModeValueByIndex(uint8_t modeIndex, uint8_t & value) { - if (modeIndex >= ArraySize(kModeOptions)) + if (modeIndex >= MATTER_ARRAY_SIZE(kModeOptions)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } @@ -62,7 +62,7 @@ CHIP_ERROR RefrigeratorAndTemperatureControlledCabinetModeDelegate::GetModeValue CHIP_ERROR RefrigeratorAndTemperatureControlledCabinetModeDelegate::GetModeTagsByIndex(uint8_t modeIndex, List & tags) { - if (modeIndex >= ArraySize(kModeOptions)) + if (modeIndex >= MATTER_ARRAY_SIZE(kModeOptions)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } diff --git a/examples/rvc-app/rvc-common/src/rvc-mode-delegates.cpp b/examples/rvc-app/rvc-common/src/rvc-mode-delegates.cpp index 8757b5e1666f58..9326cbab061c39 100644 --- a/examples/rvc-app/rvc-common/src/rvc-mode-delegates.cpp +++ b/examples/rvc-app/rvc-common/src/rvc-mode-delegates.cpp @@ -38,7 +38,7 @@ void RvcRunModeDelegate::HandleChangeToMode(uint8_t NewMode, ModeBase::Commands: CHIP_ERROR RvcRunModeDelegate::GetModeLabelByIndex(uint8_t modeIndex, chip::MutableCharSpan & label) { - if (modeIndex >= ArraySize(kModeOptions)) + if (modeIndex >= MATTER_ARRAY_SIZE(kModeOptions)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } @@ -47,7 +47,7 @@ CHIP_ERROR RvcRunModeDelegate::GetModeLabelByIndex(uint8_t modeIndex, chip::Muta CHIP_ERROR RvcRunModeDelegate::GetModeValueByIndex(uint8_t modeIndex, uint8_t & value) { - if (modeIndex >= ArraySize(kModeOptions)) + if (modeIndex >= MATTER_ARRAY_SIZE(kModeOptions)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } @@ -57,7 +57,7 @@ CHIP_ERROR RvcRunModeDelegate::GetModeValueByIndex(uint8_t modeIndex, uint8_t & CHIP_ERROR RvcRunModeDelegate::GetModeTagsByIndex(uint8_t modeIndex, List & tags) { - if (modeIndex >= ArraySize(kModeOptions)) + if (modeIndex >= MATTER_ARRAY_SIZE(kModeOptions)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } @@ -87,7 +87,7 @@ void RvcCleanModeDelegate::HandleChangeToMode(uint8_t NewMode, ModeBase::Command CHIP_ERROR RvcCleanModeDelegate::GetModeLabelByIndex(uint8_t modeIndex, chip::MutableCharSpan & label) { - if (modeIndex >= ArraySize(kModeOptions)) + if (modeIndex >= MATTER_ARRAY_SIZE(kModeOptions)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } @@ -96,7 +96,7 @@ CHIP_ERROR RvcCleanModeDelegate::GetModeLabelByIndex(uint8_t modeIndex, chip::Mu CHIP_ERROR RvcCleanModeDelegate::GetModeValueByIndex(uint8_t modeIndex, uint8_t & value) { - if (modeIndex >= ArraySize(kModeOptions)) + if (modeIndex >= MATTER_ARRAY_SIZE(kModeOptions)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } @@ -106,7 +106,7 @@ CHIP_ERROR RvcCleanModeDelegate::GetModeValueByIndex(uint8_t modeIndex, uint8_t CHIP_ERROR RvcCleanModeDelegate::GetModeTagsByIndex(uint8_t modeIndex, List & tags) { - if (modeIndex >= ArraySize(kModeOptions)) + if (modeIndex >= MATTER_ARRAY_SIZE(kModeOptions)) { return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } diff --git a/examples/rvc-app/rvc-common/src/rvc-operational-state-delegate.cpp b/examples/rvc-app/rvc-common/src/rvc-operational-state-delegate.cpp index 496d6b178cb936..e920a4bca59728 100644 --- a/examples/rvc-app/rvc-common/src/rvc-operational-state-delegate.cpp +++ b/examples/rvc-app/rvc-common/src/rvc-operational-state-delegate.cpp @@ -25,7 +25,7 @@ using namespace chip::app::Clusters::RvcOperationalState; CHIP_ERROR RvcOperationalStateDelegate::GetOperationalStateAtIndex(size_t index, OperationalState::GenericOperationalState & operationalState) { - if (index >= ArraySize(mOperationalStateList)) + if (index >= MATTER_ARRAY_SIZE(mOperationalStateList)) { return CHIP_ERROR_NOT_FOUND; } diff --git a/examples/shell/shell_common/cmd_misc.cpp b/examples/shell/shell_common/cmd_misc.cpp index ff8a5ad9739656..a292a0ca3b0cbe 100644 --- a/examples/shell/shell_common/cmd_misc.cpp +++ b/examples/shell/shell_common/cmd_misc.cpp @@ -68,5 +68,5 @@ static shell_command_t cmds_misc[] = { void cmd_misc_init() { - Engine::Root().RegisterCommands(cmds_misc, ArraySize(cmds_misc)); + Engine::Root().RegisterCommands(cmds_misc, MATTER_ARRAY_SIZE(cmds_misc)); } diff --git a/examples/shell/shell_common/cmd_server.cpp b/examples/shell/shell_common/cmd_server.cpp index eba9159a8e9a61..6329a6e6c35543 100644 --- a/examples/shell/shell_common/cmd_server.cpp +++ b/examples/shell/shell_common/cmd_server.cpp @@ -243,7 +243,7 @@ void cmd_app_server_init() std::atexit(CmdAppServerAtExit); // Register `server` subcommands with the local shell dispatcher. - sShellServerSubcommands.RegisterCommands(sServerSubCommands, ArraySize(sServerSubCommands)); + sShellServerSubcommands.RegisterCommands(sServerSubCommands, MATTER_ARRAY_SIZE(sServerSubCommands)); // Register the root `server` command with the top-level shell. Engine::Root().RegisterCommands(&sServerComand, 1); diff --git a/examples/thermostat/genio/src/AppTask.cpp b/examples/thermostat/genio/src/AppTask.cpp index 75c736b794dff4..7b9af2d64b13b6 100644 --- a/examples/thermostat/genio/src/AppTask.cpp +++ b/examples/thermostat/genio/src/AppTask.cpp @@ -101,7 +101,7 @@ CHIP_ERROR AppTask::StartAppTask() } // Start App task. - sAppTaskHandle = xTaskCreateStatic(AppTaskMain, APP_TASK_NAME, ArraySize(appStack), NULL, 1, appStack, &appTaskStruct); + sAppTaskHandle = xTaskCreateStatic(AppTaskMain, APP_TASK_NAME, MATTER_ARRAY_SIZE(appStack), NULL, 1, appStack, &appTaskStruct); if (sAppTaskHandle == nullptr) return APP_ERROR_CREATE_TASK_FAILED; diff --git a/examples/thermostat/qpg/src/AppTask.cpp b/examples/thermostat/qpg/src/AppTask.cpp index 695a9ae48a2851..d814ede3c16401 100644 --- a/examples/thermostat/qpg/src/AppTask.cpp +++ b/examples/thermostat/qpg/src/AppTask.cpp @@ -161,7 +161,8 @@ CHIP_ERROR AppTask::StartAppTask() } // Start App task. - sAppTaskHandle = xTaskCreateStatic(AppTaskMain, APP_TASK_NAME, ArraySize(appStack), nullptr, 1, appStack, &appTaskStruct); + sAppTaskHandle = + xTaskCreateStatic(AppTaskMain, APP_TASK_NAME, MATTER_ARRAY_SIZE(appStack), nullptr, 1, appStack, &appTaskStruct); if (sAppTaskHandle == nullptr) { return CHIP_ERROR_NO_MEMORY; diff --git a/examples/thermostat/silabs/src/SensorManager.cpp b/examples/thermostat/silabs/src/SensorManager.cpp index e4186664c6f36e..e423200e9699d6 100644 --- a/examples/thermostat/silabs/src/SensorManager.cpp +++ b/examples/thermostat/silabs/src/SensorManager.cpp @@ -108,7 +108,7 @@ void SensorManager::TemperatureUpdateEventHandler(AppEvent * aEvent) #else static uint8_t nbOfRepetition = 0; static uint8_t simulatedIndex = 0; - if (simulatedIndex >= ArraySize(mSimulatedTemp)) + if (simulatedIndex >= MATTER_ARRAY_SIZE(mSimulatedTemp)) { simulatedIndex = 0; } diff --git a/examples/thermostat/thermostat-common/src/thermostat-delegate-impl.cpp b/examples/thermostat/thermostat-common/src/thermostat-delegate-impl.cpp index da58c840049275..aabcac3ab8f260 100644 --- a/examples/thermostat/thermostat-common/src/thermostat-delegate-impl.cpp +++ b/examples/thermostat/thermostat-common/src/thermostat-delegate-impl.cpp @@ -45,7 +45,7 @@ void ThermostatDelegate::InitializePresets() { // Initialize the presets with 2 built in presets - occupied and unoccupied. PresetScenarioEnum presetScenarioEnumArray[2] = { PresetScenarioEnum::kOccupied, PresetScenarioEnum::kUnoccupied }; - static_assert(ArraySize(presetScenarioEnumArray) <= ArraySize(mPresets)); + static_assert(MATTER_ARRAY_SIZE(presetScenarioEnumArray) <= MATTER_ARRAY_SIZE(mPresets)); uint8_t index = 0; for (PresetScenarioEnum presetScenario : presetScenarioEnumArray) @@ -91,7 +91,7 @@ CHIP_ERROR ThermostatDelegate::GetPresetTypeAtIndex(size_t index, PresetTypeStru .numberOfPresets = kMaxNumberOfPresetsOfEachType, .presetTypeFeatures = to_underlying(PresetTypeFeaturesBitmap::kSupportsNames) }, }; - if (index < ArraySize(presetTypes)) + if (index < MATTER_ARRAY_SIZE(presetTypes)) { presetType = presetTypes[index]; return CHIP_NO_ERROR; @@ -182,7 +182,7 @@ void ThermostatDelegate::InitializePendingPresets() CHIP_ERROR ThermostatDelegate::AppendToPendingPresetList(const PresetStructWithOwnedMembers & preset) { - if (mNextFreeIndexInPendingPresetsList < ArraySize(mPendingPresets)) + if (mNextFreeIndexInPendingPresetsList < MATTER_ARRAY_SIZE(mPendingPresets)) { mPendingPresets[mNextFreeIndexInPendingPresetsList] = preset; if (preset.GetPresetHandle().IsNull()) diff --git a/examples/tv-app/android/java/AppImpl.cpp b/examples/tv-app/android/java/AppImpl.cpp index d33949a5d382d9..4420ce938f2447 100644 --- a/examples/tv-app/android/java/AppImpl.cpp +++ b/examples/tv-app/android/java/AppImpl.cpp @@ -255,7 +255,7 @@ DECLARE_DYNAMIC_ENDPOINT(contentAppEndpoint, contentAppClusters); namespace { -DataVersion gDataVersions[APP_LIBRARY_SIZE][ArraySize(contentAppClusters)]; +DataVersion gDataVersions[APP_LIBRARY_SIZE][MATTER_ARRAY_SIZE(contentAppClusters)]; EmberAfDeviceType gContentAppDeviceType[] = { { DEVICE_TYPE_CONTENT_APP, 1 } }; @@ -440,11 +440,11 @@ EndpointId ContentAppFactoryImpl::AddContentApp(const char * szVendorName, uint1 uint16_t productId, const char * szApplicationVersion, std::vector supportedClusters, jobject manager) { - DataVersion * dataVersionBuf = new DataVersion[ArraySize(contentAppClusters)]; + DataVersion * dataVersionBuf = new DataVersion[MATTER_ARRAY_SIZE(contentAppClusters)]; ContentAppImpl * app = new ContentAppImpl(szVendorName, vendorId, szApplicationName, productId, szApplicationVersion, "", std::move(supportedClusters), mAttributeDelegate, mCommandDelegate); EndpointId epId = ContentAppPlatform::GetInstance().AddContentApp( - app, &contentAppEndpoint, Span(dataVersionBuf, ArraySize(contentAppClusters)), + app, &contentAppEndpoint, Span(dataVersionBuf, MATTER_ARRAY_SIZE(contentAppClusters)), Span(gContentAppDeviceType)); ChipLogProgress(DeviceLayer, "ContentAppFactoryImpl AddContentApp endpoint returned %d. Endpoint set %d", epId, app->GetEndpointId()); @@ -461,11 +461,11 @@ EndpointId ContentAppFactoryImpl::AddContentApp(const char * szVendorName, uint1 std::vector supportedClusters, EndpointId desiredEndpointId, jobject manager) { - DataVersion * dataVersionBuf = new DataVersion[ArraySize(contentAppClusters)]; + DataVersion * dataVersionBuf = new DataVersion[MATTER_ARRAY_SIZE(contentAppClusters)]; ContentAppImpl * app = new ContentAppImpl(szVendorName, vendorId, szApplicationName, productId, szApplicationVersion, "", std::move(supportedClusters), mAttributeDelegate, mCommandDelegate); EndpointId epId = ContentAppPlatform::GetInstance().AddContentApp( - app, &contentAppEndpoint, Span(dataVersionBuf, ArraySize(contentAppClusters)), + app, &contentAppEndpoint, Span(dataVersionBuf, MATTER_ARRAY_SIZE(contentAppClusters)), Span(gContentAppDeviceType), desiredEndpointId); ChipLogProgress(DeviceLayer, "ContentAppFactoryImpl AddContentApp endpoint returned %d. Endpoint set %d", epId, app->GetEndpointId()); @@ -580,7 +580,7 @@ CHIP_ERROR InitVideoPlayerPlatform(jobject contentAppEndpointManager) gFactory.setContentAppCommandDelegate(new ContentAppCommandDelegate(contentAppEndpointManager)); ChipLogProgress(AppServer, "Starting registration of command handler delegates"); - for (size_t i = 0; i < ArraySize(contentAppClusters); i++) + for (size_t i = 0; i < MATTER_ARRAY_SIZE(contentAppClusters); i++) { ContentAppCommandDelegate * delegate = new ContentAppCommandDelegate(contentAppEndpointManager, contentAppClusters[i].clusterId); diff --git a/examples/tv-app/tv-common/src/AppTv.cpp b/examples/tv-app/tv-common/src/AppTv.cpp index 794c879b4c4da1..be36e1f5ace794 100644 --- a/examples/tv-app/tv-common/src/AppTv.cpp +++ b/examples/tv-app/tv-common/src/AppTv.cpp @@ -497,7 +497,7 @@ DECLARE_DYNAMIC_ENDPOINT(contentAppEndpoint, contentAppClusters); namespace { -DataVersion gDataVersions[APP_LIBRARY_SIZE][ArraySize(contentAppClusters)]; +DataVersion gDataVersions[APP_LIBRARY_SIZE][MATTER_ARRAY_SIZE(contentAppClusters)]; EmberAfDeviceType gContentAppDeviceType[] = { { DEVICE_TYPE_CONTENT_APP, 1 } }; diff --git a/src/access/examples/ExampleAccessControlDelegate.cpp b/src/access/examples/ExampleAccessControlDelegate.cpp index 9297740bf889ee..1f3c417e55deb9 100644 --- a/src/access/examples/ExampleAccessControlDelegate.cpp +++ b/src/access/examples/ExampleAccessControlDelegate.cpp @@ -348,7 +348,7 @@ class EntryStorage { ConvertIndex(index, *fabricIndex, ConvertDirection::kRelativeToAbsolute); } - if (index < ArraySize(acl)) + if (index < MATTER_ARRAY_SIZE(acl)) { auto * storage = acl + index; if (storage->InUse()) @@ -383,7 +383,7 @@ class EntryStorage bool InPool() const { - constexpr auto * end = pool + ArraySize(pool); + constexpr auto * end = pool + MATTER_ARRAY_SIZE(pool); return pool <= this && this < end; } @@ -475,7 +475,7 @@ class EntryStorage } absoluteIndex++; } - index = found ? toIndex : ArraySize(acl); + index = found ? toIndex : MATTER_ARRAY_SIZE(acl); } static constexpr size_t kMaxSubjects = CHIP_CONFIG_EXAMPLE_ACCESS_CONTROL_MAX_SUBJECTS_PER_ENTRY; @@ -516,7 +516,7 @@ class EntryDelegate : public Entry::Delegate static bool InPool(const Entry::Delegate & delegate) { - constexpr auto * end = pool + ArraySize(pool); + constexpr auto * end = pool + MATTER_ARRAY_SIZE(pool); return pool <= &delegate && &delegate < end; } @@ -742,7 +742,7 @@ class EntryDelegate : public Entry::Delegate void FixAfterDelete(EntryStorage & storage) { constexpr auto & acl = EntryStorage::acl; - constexpr auto * end = acl + ArraySize(acl); + constexpr auto * end = acl + MATTER_ARRAY_SIZE(acl); if (mStorage == &storage) { mEntry->ResetDelegate(); @@ -802,7 +802,7 @@ class EntryIteratorDelegate : public EntryIterator::Delegate static bool InPool(const EntryIterator::Delegate & delegate) { - constexpr auto * end = pool + ArraySize(pool); + constexpr auto * end = pool + MATTER_ARRAY_SIZE(pool); return pool <= &delegate && &delegate < end; } @@ -811,7 +811,7 @@ class EntryIteratorDelegate : public EntryIterator::Delegate CHIP_ERROR Next(Entry & entry) override { constexpr auto & acl = EntryStorage::acl; - constexpr auto * end = acl + ArraySize(acl); + constexpr auto * end = acl + MATTER_ARRAY_SIZE(acl); while (true) { if (mStorage == nullptr) @@ -866,7 +866,7 @@ class EntryIteratorDelegate : public EntryIterator::Delegate void FixAfterDelete(EntryStorage & storage) { constexpr auto & acl = EntryStorage::acl; - constexpr auto * end = acl + ArraySize(acl); + constexpr auto * end = acl + MATTER_ARRAY_SIZE(acl); if (&storage <= mStorage && mStorage < end) { if (mStorage == acl) @@ -987,7 +987,7 @@ class AccessControlDelegate : public AccessControl::Delegate CHIP_ERROR GetMaxEntryCount(size_t & value) const override { - value = ArraySize(EntryStorage::acl); + value = MATTER_ARRAY_SIZE(EntryStorage::acl); return CHIP_NO_ERROR; } @@ -1095,7 +1095,7 @@ class AccessControlDelegate : public AccessControl::Delegate // ...then go through the access control list starting at the deleted storage... constexpr auto & acl = EntryStorage::acl; - constexpr auto * end = acl + ArraySize(acl); + constexpr auto * end = acl + MATTER_ARRAY_SIZE(acl); for (auto * next = storage + 1; storage < end; ++storage, ++next) { // ...copying over each storage with its next one... diff --git a/src/access/tests/TestAccessControl.cpp b/src/access/tests/TestAccessControl.cpp index b528d4a3bc3b79..87c1d4ce2f960c 100644 --- a/src/access/tests/TestAccessControl.cpp +++ b/src/access/tests/TestAccessControl.cpp @@ -805,7 +805,7 @@ constexpr EntryData entryData1[] = { }, }; -constexpr size_t entryData1Count = ArraySize(entryData1); +constexpr size_t entryData1Count = MATTER_ARRAY_SIZE(entryData1); static_assert(entryData1Count == (kNumFabric1EntriesInEntryData1 + kNumFabric2EntriesInEntryData1), "Must maintain both fabric counts for some tests"); @@ -1772,22 +1772,22 @@ TEST_F(TestAccessControl, TestCreateReadEntry) TEST_F(TestAccessControl, TestDeleteEntry) { EntryData data[entryData1Count]; - for (size_t pos = 0; pos < ArraySize(data); ++pos) + for (size_t pos = 0; pos < MATTER_ARRAY_SIZE(data); ++pos) { - for (size_t count = ArraySize(data) - pos; count > 0; --count) + for (size_t count = MATTER_ARRAY_SIZE(data) - pos; count > 0; --count) { memcpy(data, entryData1, sizeof(data)); EXPECT_EQ(ClearAccessControl(accessControl), CHIP_NO_ERROR); - EXPECT_EQ(LoadAccessControl(accessControl, data, ArraySize(data)), CHIP_NO_ERROR); + EXPECT_EQ(LoadAccessControl(accessControl, data, MATTER_ARRAY_SIZE(data)), CHIP_NO_ERROR); - memmove(&data[pos], &data[pos + count], (ArraySize(data) - count - pos) * sizeof(data[0])); + memmove(&data[pos], &data[pos + count], (MATTER_ARRAY_SIZE(data) - count - pos) * sizeof(data[0])); for (size_t i = 0; i < count; ++i) { EXPECT_EQ(accessControl.DeleteEntry(pos), CHIP_NO_ERROR); } - EXPECT_EQ(CompareAccessControl(accessControl, data, ArraySize(data) - count), CHIP_NO_ERROR); + EXPECT_EQ(CompareAccessControl(accessControl, data, MATTER_ARRAY_SIZE(data) - count), CHIP_NO_ERROR); } } @@ -1795,7 +1795,7 @@ TEST_F(TestAccessControl, TestDeleteEntry) { memcpy(data, entryData1, sizeof(data)); EXPECT_EQ(ClearAccessControl(accessControl), CHIP_NO_ERROR); - EXPECT_EQ(LoadAccessControl(accessControl, data, ArraySize(data)), CHIP_NO_ERROR); + EXPECT_EQ(LoadAccessControl(accessControl, data, MATTER_ARRAY_SIZE(data)), CHIP_NO_ERROR); // After deleting Fabric index 1, we should have the number of entries of Fabric index 2 EXPECT_EQ(accessControl.DeleteAllEntriesForFabric(1), CHIP_NO_ERROR); @@ -1854,8 +1854,8 @@ TEST_F(TestAccessControl, TestFabricFilteredReadEntry) constexpr size_t indexes[] = { 0, 1, 2, 3, 4, 5 }; for (auto & index : indexes) { - constexpr size_t illegalIndex = entryData1Count; - constexpr size_t expectedIndexes[][ArraySize(indexes)] = { + constexpr size_t illegalIndex = entryData1Count; + constexpr size_t expectedIndexes[][MATTER_ARRAY_SIZE(indexes)] = { { 0, 1, 3, 6, illegalIndex, illegalIndex }, { 2, 4, 5, 7, 8, illegalIndex }, { illegalIndex, illegalIndex, illegalIndex, illegalIndex, illegalIndex, illegalIndex }, @@ -1909,7 +1909,7 @@ TEST_F(TestAccessControl, TestIterator) EXPECT_EQ(CompareEntry(entry, entryData1[fabric1[count]]), CHIP_NO_ERROR); count++; } - EXPECT_EQ(count, ArraySize(fabric1)); + EXPECT_EQ(count, MATTER_ARRAY_SIZE(fabric1)); fabricIndex = 2; EXPECT_EQ(accessControl.Entries(iterator, &fabricIndex), CHIP_NO_ERROR); @@ -1920,7 +1920,7 @@ TEST_F(TestAccessControl, TestIterator) EXPECT_EQ(CompareEntry(entry, entryData1[fabric2[count]]), CHIP_NO_ERROR); count++; } - EXPECT_EQ(count, ArraySize(fabric2)); + EXPECT_EQ(count, MATTER_ARRAY_SIZE(fabric2)); } TEST_F(TestAccessControl, TestPrepareEntry) @@ -1984,17 +1984,17 @@ TEST_F(TestAccessControl, TestPrepareEntry) EXPECT_EQ(entry.GetSubjectCount(subjectCount), CHIP_NO_ERROR); EXPECT_EQ(entry.GetTargetCount(targetCount), CHIP_NO_ERROR); - EXPECT_EQ(subjectCount, ArraySize(subjects[0])); - EXPECT_EQ(targetCount, ArraySize(targets)); + EXPECT_EQ(subjectCount, MATTER_ARRAY_SIZE(subjects[0])); + EXPECT_EQ(targetCount, MATTER_ARRAY_SIZE(targets)); - for (size_t i = 0; i < ArraySize(subjects[subjectIndex]); ++i) + for (size_t i = 0; i < MATTER_ARRAY_SIZE(subjects[subjectIndex]); ++i) { NodeId n; EXPECT_EQ(entry.GetSubject(i, n), CHIP_NO_ERROR); EXPECT_EQ(n, subjects[subjectIndex][i]); } - for (size_t i = 0; i < ArraySize(targets); ++i) + for (size_t i = 0; i < MATTER_ARRAY_SIZE(targets); ++i) { Target t; EXPECT_EQ(entry.GetTarget(i, t), CHIP_NO_ERROR); @@ -2170,17 +2170,17 @@ TEST_F(TestAccessControl, TestUpdateEntry) { EntryData data[entryData1Count]; memcpy(data, entryData1, sizeof(data)); - EXPECT_EQ(LoadAccessControl(accessControl, data, ArraySize(data)), CHIP_NO_ERROR); + EXPECT_EQ(LoadAccessControl(accessControl, data, MATTER_ARRAY_SIZE(data)), CHIP_NO_ERROR); - for (size_t i = 0; i < ArraySize(data); ++i) + for (size_t i = 0; i < MATTER_ARRAY_SIZE(data); ++i) { EntryData updateData; - updateData.authMode = authModes[i % ArraySize(authModes)]; - updateData.fabricIndex = fabricIndexes[i % ArraySize(fabricIndexes)]; - updateData.privilege = privileges[i % (ArraySize(privileges) - 1)]; + updateData.authMode = authModes[i % MATTER_ARRAY_SIZE(authModes)]; + updateData.fabricIndex = fabricIndexes[i % MATTER_ARRAY_SIZE(fabricIndexes)]; + updateData.privilege = privileges[i % (MATTER_ARRAY_SIZE(privileges) - 1)]; - updateData.AddSubject(nullptr, subjects[i % ArraySize(authModes)][i % ArraySize(subjects[0])]); - updateData.AddTarget(nullptr, targets[i % ArraySize(targets)]); + updateData.AddSubject(nullptr, subjects[i % MATTER_ARRAY_SIZE(authModes)][i % MATTER_ARRAY_SIZE(subjects[0])]); + updateData.AddTarget(nullptr, targets[i % MATTER_ARRAY_SIZE(targets)]); data[i] = updateData; @@ -2191,7 +2191,7 @@ TEST_F(TestAccessControl, TestUpdateEntry) EXPECT_EQ(accessControl.UpdateEntry(i, entry), CHIP_NO_ERROR); } - EXPECT_EQ(CompareAccessControl(accessControl, data, ArraySize(data)), CHIP_NO_ERROR); + EXPECT_EQ(CompareAccessControl(accessControl, data, MATTER_ARRAY_SIZE(data)), CHIP_NO_ERROR); } } diff --git a/src/access/tests/TestAccessRestrictionProvider.cpp b/src/access/tests/TestAccessRestrictionProvider.cpp index 723d023e48b2ff..d50d4e03acc9e8 100644 --- a/src/access/tests/TestAccessRestrictionProvider.cpp +++ b/src/access/tests/TestAccessRestrictionProvider.cpp @@ -85,7 +85,7 @@ constexpr AclEntryData aclEntryData[] = { .subject = kOperationalNodeId2, }, }; -constexpr size_t aclEntryDataCount = ArraySize(aclEntryData); +constexpr size_t aclEntryDataCount = MATTER_ARRAY_SIZE(aclEntryData); struct CheckData { @@ -348,14 +348,14 @@ TEST_F(TestAccessRestriction, AccessAttributeRestrictionTest) // test wildcarded entity id entries.push_back(entry); EXPECT_EQ(accessRestrictionProvider.SetEntries(1, entries), CHIP_NO_ERROR); - RunChecks(accessAttributeRestrictionTestData, ArraySize(accessAttributeRestrictionTestData)); + RunChecks(accessAttributeRestrictionTestData, MATTER_ARRAY_SIZE(accessAttributeRestrictionTestData)); // test specific entity id entries.clear(); entry.restrictions[0].id.SetValue(1); entries.push_back(entry); EXPECT_EQ(accessRestrictionProvider.SetEntries(1, entries), CHIP_NO_ERROR); - RunChecks(accessAttributeRestrictionTestData, ArraySize(accessAttributeRestrictionTestData)); + RunChecks(accessAttributeRestrictionTestData, MATTER_ARRAY_SIZE(accessAttributeRestrictionTestData)); } constexpr CheckData writeAttributeRestrictionTestData[] = { @@ -401,14 +401,14 @@ TEST_F(TestAccessRestriction, WriteAttributeRestrictionTest) // test wildcarded entity id entries.push_back(entry); EXPECT_EQ(accessRestrictionProvider.SetEntries(1, entries), CHIP_NO_ERROR); - RunChecks(writeAttributeRestrictionTestData, ArraySize(writeAttributeRestrictionTestData)); + RunChecks(writeAttributeRestrictionTestData, MATTER_ARRAY_SIZE(writeAttributeRestrictionTestData)); // test specific entity id entries.clear(); entry.restrictions[0].id.SetValue(1); entries.push_back(entry); EXPECT_EQ(accessRestrictionProvider.SetEntries(1, entries), CHIP_NO_ERROR); - RunChecks(writeAttributeRestrictionTestData, ArraySize(writeAttributeRestrictionTestData)); + RunChecks(writeAttributeRestrictionTestData, MATTER_ARRAY_SIZE(writeAttributeRestrictionTestData)); } constexpr CheckData commandAttributeRestrictionTestData[] = { @@ -454,14 +454,14 @@ TEST_F(TestAccessRestriction, CommandRestrictionTest) // test wildcarded entity id entries.push_back(entry); EXPECT_EQ(accessRestrictionProvider.SetEntries(1, entries), CHIP_NO_ERROR); - RunChecks(commandAttributeRestrictionTestData, ArraySize(commandAttributeRestrictionTestData)); + RunChecks(commandAttributeRestrictionTestData, MATTER_ARRAY_SIZE(commandAttributeRestrictionTestData)); // test specific entity id entries.clear(); entry.restrictions[0].id.SetValue(1); entries.push_back(entry); EXPECT_EQ(accessRestrictionProvider.SetEntries(1, entries), CHIP_NO_ERROR); - RunChecks(commandAttributeRestrictionTestData, ArraySize(commandAttributeRestrictionTestData)); + RunChecks(commandAttributeRestrictionTestData, MATTER_ARRAY_SIZE(commandAttributeRestrictionTestData)); } constexpr CheckData eventAttributeRestrictionTestData[] = { @@ -507,14 +507,14 @@ TEST_F(TestAccessRestriction, EventRestrictionTest) // test wildcarded entity id entries.push_back(entry); EXPECT_EQ(accessRestrictionProvider.SetEntries(1, entries), CHIP_NO_ERROR); - RunChecks(eventAttributeRestrictionTestData, ArraySize(eventAttributeRestrictionTestData)); + RunChecks(eventAttributeRestrictionTestData, MATTER_ARRAY_SIZE(eventAttributeRestrictionTestData)); // test specific entity id entries.clear(); entry.restrictions[0].id.SetValue(1); entries.push_back(entry); EXPECT_EQ(accessRestrictionProvider.SetEntries(1, entries), CHIP_NO_ERROR); - RunChecks(eventAttributeRestrictionTestData, ArraySize(eventAttributeRestrictionTestData)); + RunChecks(eventAttributeRestrictionTestData, MATTER_ARRAY_SIZE(eventAttributeRestrictionTestData)); } constexpr CheckData combinedRestrictionTestData[] = { @@ -612,7 +612,7 @@ TEST_F(TestAccessRestriction, CombinedRestrictionTest) entries2.push_back(entry2); EXPECT_EQ(accessRestrictionProvider.SetEntries(2, entries2), CHIP_NO_ERROR); - RunChecks(combinedRestrictionTestData, ArraySize(combinedRestrictionTestData)); + RunChecks(combinedRestrictionTestData, MATTER_ARRAY_SIZE(combinedRestrictionTestData)); } TEST_F(TestAccessRestriction, AttributeStorageSeperationTest) @@ -715,7 +715,7 @@ TEST_F(TestAccessRestriction, ListSelectiondDuringCommissioningTest) entries.push_back(entry2); EXPECT_EQ(accessRestrictionProvider.SetEntries(1, entries), CHIP_NO_ERROR); - RunChecks(listSelectionDuringCommissioningData, ArraySize(listSelectionDuringCommissioningData)); + RunChecks(listSelectionDuringCommissioningData, MATTER_ARRAY_SIZE(listSelectionDuringCommissioningData)); } } // namespace Access diff --git a/src/app/AttributePathExpandIterator.cpp b/src/app/AttributePathExpandIterator.cpp index 7f357164427b44..708ce612c73468 100644 --- a/src/app/AttributePathExpandIterator.cpp +++ b/src/app/AttributePathExpandIterator.cpp @@ -182,7 +182,7 @@ std::optional AttributePathExpandIterator::NextAttributeId() VerifyOrReturnValue(mPosition.mAttributePath->mValue.HasWildcardAttributeId(), std::nullopt); // Ensure (including ordering) that GlobalAttributesNotInMetadata is reported as needed - for (unsigned i = 0; i < ArraySize(GlobalAttributesNotInMetadata); i++) + for (unsigned i = 0; i < MATTER_ARRAY_SIZE(GlobalAttributesNotInMetadata); i++) { if (GlobalAttributesNotInMetadata[i] != mPosition.mOutputPath.mAttributeId) { @@ -190,7 +190,7 @@ std::optional AttributePathExpandIterator::NextAttributeId() } unsigned nextAttributeIndex = i + 1; - if (nextAttributeIndex < ArraySize(GlobalAttributesNotInMetadata)) + if (nextAttributeIndex < MATTER_ARRAY_SIZE(GlobalAttributesNotInMetadata)) { return GlobalAttributesNotInMetadata[nextAttributeIndex]; } @@ -206,7 +206,7 @@ std::optional AttributePathExpandIterator::NextAttributeId() } // Finished the data model, start with global attributes - static_assert(ArraySize(GlobalAttributesNotInMetadata) > 0); + static_assert(MATTER_ARRAY_SIZE(GlobalAttributesNotInMetadata) > 0); return GlobalAttributesNotInMetadata[0]; } diff --git a/src/app/clusters/color-control-server/color-control-server.cpp b/src/app/clusters/color-control-server/color-control-server.cpp index 98379b26a70a50..ee49bc266a8585 100644 --- a/src/app/clusters/color-control-server/color-control-server.cpp +++ b/src/app/clusters/color-control-server/color-control-server.cpp @@ -689,7 +689,7 @@ EmberEventControl * ColorControlServer::getEventControl(EndpointId endpoint) uint16_t index = getEndpointIndex(endpoint); EmberEventControl * event = nullptr; - if (index < ArraySize(eventControls)) + if (index < MATTER_ARRAY_SIZE(eventControls)) { event = &eventControls[index]; } @@ -817,7 +817,7 @@ ColorControlServer::ColorHueTransitionState * ColorControlServer::getColorHueTra { ColorHueTransitionState * state = nullptr; - if (index < ArraySize(colorHueTransitionStates)) + if (index < MATTER_ARRAY_SIZE(colorHueTransitionStates)) { state = &colorHueTransitionStates[index]; } @@ -845,7 +845,7 @@ ColorControlServer::Color16uTransitionState * ColorControlServer::getSaturationT { Color16uTransitionState * state = nullptr; - if (index < ArraySize(colorSatTransitionStates)) + if (index < MATTER_ARRAY_SIZE(colorSatTransitionStates)) { state = &colorSatTransitionStates[index]; } @@ -2071,7 +2071,7 @@ void ColorControlServer::updateHueSatCommand(EndpointId endpoint) ColorControlServer::Color16uTransitionState * ColorControlServer::getXTransitionStateByIndex(uint16_t index) { Color16uTransitionState * state = nullptr; - if (index < ArraySize(colorXtransitionStates)) + if (index < MATTER_ARRAY_SIZE(colorXtransitionStates)) { state = &colorXtransitionStates[index]; } @@ -2099,7 +2099,7 @@ ColorControlServer::Color16uTransitionState * ColorControlServer::getXTransition ColorControlServer::Color16uTransitionState * ColorControlServer::getYTransitionStateByIndex(uint16_t index) { Color16uTransitionState * state = nullptr; - if (index < ArraySize(colorYtransitionStates)) + if (index < MATTER_ARRAY_SIZE(colorYtransitionStates)) { state = &colorYtransitionStates[index]; } @@ -2447,7 +2447,7 @@ void ColorControlServer::updateXYCommand(EndpointId endpoint) ColorControlServer::Color16uTransitionState * ColorControlServer::getTempTransitionStateByIndex(uint16_t index) { Color16uTransitionState * state = nullptr; - if (index < ArraySize(colorTempTransitionStates)) + if (index < MATTER_ARRAY_SIZE(colorTempTransitionStates)) { state = &colorTempTransitionStates[index]; } 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 8744582c35becd..ba4d6e1c2e6aea 100644 --- a/src/app/clusters/diagnostic-logs-server/diagnostic-logs-server.cpp +++ b/src/app/clusters/diagnostic-logs-server/diagnostic-logs-server.cpp @@ -49,8 +49,9 @@ DiagnosticLogsProviderDelegate * gDiagnosticLogsProviderDelegateTable[kDiagnosti DiagnosticLogsProviderDelegate * GetDiagnosticLogsProviderDelegate(EndpointId endpoint) { - uint16_t ep = emberAfGetClusterServerEndpointIndex(endpoint, Id, MATTER_DM_DIAGNOSTIC_LOGS_CLUSTER_SERVER_ENDPOINT_COUNT); - auto delegate = (ep >= ArraySize(gDiagnosticLogsProviderDelegateTable) ? nullptr : gDiagnosticLogsProviderDelegateTable[ep]); + uint16_t ep = emberAfGetClusterServerEndpointIndex(endpoint, Id, MATTER_DM_DIAGNOSTIC_LOGS_CLUSTER_SERVER_ENDPOINT_COUNT); + auto delegate = + (ep >= MATTER_ARRAY_SIZE(gDiagnosticLogsProviderDelegateTable) ? nullptr : gDiagnosticLogsProviderDelegateTable[ep]); if (delegate == nullptr) { diff --git a/src/app/clusters/electrical-energy-measurement-server/electrical-energy-measurement-server.cpp b/src/app/clusters/electrical-energy-measurement-server/electrical-energy-measurement-server.cpp index a2bfbc97cc4c0a..79d466b8652aaf 100644 --- a/src/app/clusters/electrical-energy-measurement-server/electrical-energy-measurement-server.cpp +++ b/src/app/clusters/electrical-energy-measurement-server/electrical-energy-measurement-server.cpp @@ -153,7 +153,7 @@ MeasurementData * MeasurementDataForEndpoint(EndpointId endpointId) return nullptr; } - if (index >= ArraySize(gMeasurements)) + if (index >= MATTER_ARRAY_SIZE(gMeasurements)) { ChipLogError(NotSpecified, "Internal error: invalid/unexpected energy measurement index."); return nullptr; diff --git a/src/app/clusters/occupancy-sensor-server/occupancy-sensor-server.cpp b/src/app/clusters/occupancy-sensor-server/occupancy-sensor-server.cpp index 03eaaa46475d1c..baa8dd6993cb9c 100644 --- a/src/app/clusters/occupancy-sensor-server/occupancy-sensor-server.cpp +++ b/src/app/clusters/occupancy-sensor-server/occupancy-sensor-server.cpp @@ -136,7 +136,7 @@ Structs::HoldTimeLimitsStruct::Type * GetHoldTimeLimitsForEndpoint(EndpointId en return nullptr; } - if (index >= ArraySize(sHoldTimeLimitsStructs)) + if (index >= MATTER_ARRAY_SIZE(sHoldTimeLimitsStructs)) { ChipLogError(NotSpecified, "Internal error: invalid/unexpected hold time limits index."); return nullptr; @@ -171,7 +171,7 @@ uint16_t * GetHoldTimeForEndpoint(EndpointId endpoint) return nullptr; } - if (index >= ArraySize(sHoldTimeLimitsStructs)) + if (index >= MATTER_ARRAY_SIZE(sHoldTimeLimitsStructs)) { ChipLogError(NotSpecified, "Internal error: invalid/unexpected hold time index."); return nullptr; diff --git a/src/app/clusters/scenes-server/SceneHandlerImpl.cpp b/src/app/clusters/scenes-server/SceneHandlerImpl.cpp index fcaa3985734bb2..fed01713c5c4bd 100644 --- a/src/app/clusters/scenes-server/SceneHandlerImpl.cpp +++ b/src/app/clusters/scenes-server/SceneHandlerImpl.cpp @@ -253,7 +253,7 @@ DefaultSceneHandlerImpl::SerializeAdd(EndpointId endpoint, const ExtensionFieldS size_t pairTotal = 0; // Verify size of list ReturnErrorOnFailure(extensionFieldSet.attributeValueList.ComputeSize(&pairTotal)); - VerifyOrReturnError(pairTotal <= ArraySize(aVPairs), CHIP_ERROR_BUFFER_TOO_SMALL); + VerifyOrReturnError(pairTotal <= MATTER_ARRAY_SIZE(aVPairs), CHIP_ERROR_BUFFER_TOO_SMALL); uint8_t pairCount = 0; auto pair_iterator = extensionFieldSet.attributeValueList.begin(); @@ -280,7 +280,7 @@ CHIP_ERROR DefaultSceneHandlerImpl::Deserialize(EndpointId endpoint, ClusterId c // Verify size of list size_t pairTotal = 0; ReturnErrorOnFailure(attributeValueList.ComputeSize(&pairTotal)); - VerifyOrReturnError(pairTotal <= ArraySize(mAVPairs), CHIP_ERROR_BUFFER_TOO_SMALL); + VerifyOrReturnError(pairTotal <= MATTER_ARRAY_SIZE(mAVPairs), CHIP_ERROR_BUFFER_TOO_SMALL); uint8_t pairCount = 0; auto pair_iterator = attributeValueList.begin(); diff --git a/src/app/clusters/scenes-server/scenes-server.cpp b/src/app/clusters/scenes-server/scenes-server.cpp index e7e6821731d477..cd784948a12b29 100644 --- a/src/app/clusters/scenes-server/scenes-server.cpp +++ b/src/app/clusters/scenes-server/scenes-server.cpp @@ -233,7 +233,7 @@ CHIP_ERROR ScenesServer::FabricSceneInfo::SetSceneInfoStruct(EndpointId endpoint uint8_t sceneInfoStructIndex = 0; if (CHIP_ERROR_NOT_FOUND == FindSceneInfoStructIndex(fabric, endpointIndex, sceneInfoStructIndex)) { - VerifyOrReturnError(mSceneInfoStructsCount[endpointIndex] < ArraySize(mSceneInfoStructs[endpointIndex]), + VerifyOrReturnError(mSceneInfoStructsCount[endpointIndex] < MATTER_ARRAY_SIZE(mSceneInfoStructs[endpointIndex]), CHIP_ERROR_NO_MEMORY); sceneInfoStructIndex = mSceneInfoStructsCount[endpointIndex]; @@ -256,7 +256,7 @@ void ScenesServer::FabricSceneInfo::ClearSceneInfoStruct(EndpointId endpoint, Fa ReturnOnFailure(FindSceneInfoStructIndex(fabric, endpointIndex, sceneInfoStructIndex)); uint8_t nextIndex = static_cast(sceneInfoStructIndex + 1); - uint8_t moveNum = static_cast(ArraySize(mSceneInfoStructs[endpointIndex]) - nextIndex); + uint8_t moveNum = static_cast(MATTER_ARRAY_SIZE(mSceneInfoStructs[endpointIndex]) - nextIndex); // Compress the endpoint's SceneInfoStruct array if (moveNum) { @@ -289,7 +289,7 @@ CHIP_ERROR ScenesServer::FabricSceneInfo::FindFabricSceneInfoIndex(EndpointId en uint16_t index = emberAfGetClusterServerEndpointIndex(endpoint, ScenesManagement::Id, MATTER_DM_SCENES_CLUSTER_SERVER_ENDPOINT_COUNT); - if (index < ArraySize(mSceneInfoStructs)) + if (index < MATTER_ARRAY_SIZE(mSceneInfoStructs)) { endpointIndex = index; return CHIP_NO_ERROR; @@ -307,7 +307,7 @@ CHIP_ERROR ScenesServer::FabricSceneInfo::FindFabricSceneInfoIndex(EndpointId en /// @return CHIP_NO_ERROR or CHIP_ERROR_NOT_FOUND, CHIP_ERROR_INVALID_ARGUMENT if invalid fabric or endpointIndex are provided CHIP_ERROR ScenesServer::FabricSceneInfo::FindSceneInfoStructIndex(FabricIndex fabric, size_t endpointIndex, uint8_t & index) { - VerifyOrReturnError(endpointIndex < ArraySize(mSceneInfoStructs), CHIP_ERROR_INVALID_ARGUMENT); + VerifyOrReturnError(endpointIndex < MATTER_ARRAY_SIZE(mSceneInfoStructs), CHIP_ERROR_INVALID_ARGUMENT); VerifyOrReturnError(kUndefinedFabricIndex != fabric, CHIP_ERROR_INVALID_ARGUMENT); index = 0; 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 4ea9964b342a50..54a62166172a61 100644 --- a/src/app/clusters/test-cluster-server/test-cluster-server.cpp +++ b/src/app/clusters/test-cluster-server/test-cluster-server.cpp @@ -583,7 +583,7 @@ CHIP_ERROR TestAttrAccess::WriteListNullablesAndOptionalsStructAttribute(const C if (!value.nullableList.IsNull()) { ReturnErrorOnFailure(value.nullableList.Value().ComputeSize(&count)); - VerifyOrReturnError(count <= ArraySize(gSimpleEnums), CHIP_ERROR_INVALID_ARGUMENT); + VerifyOrReturnError(count <= MATTER_ARRAY_SIZE(gSimpleEnums), CHIP_ERROR_INVALID_ARGUMENT); auto iter2 = value.nullableList.Value().begin(); gSimpleEnumCount = 0; while (iter2.Next()) diff --git a/src/app/clusters/thermostat-server/thermostat-server-atomic.cpp b/src/app/clusters/thermostat-server/thermostat-server-atomic.cpp index 19a6ffa3387e12..6cb76fee8c6884 100644 --- a/src/app/clusters/thermostat-server/thermostat-server-atomic.cpp +++ b/src/app/clusters/thermostat-server/thermostat-server-atomic.cpp @@ -213,7 +213,7 @@ bool ThermostatAttrAccess::InAtomicWrite(EndpointId endpoint, Optional= ArraySize(mAtomicWriteSessions)) + if (ep >= MATTER_ARRAY_SIZE(mAtomicWriteSessions)) { return false; } @@ -264,7 +264,7 @@ bool ThermostatAttrAccess::InAtomicWrite( uint16_t ep = emberAfGetClusterServerEndpointIndex(endpoint, Thermostat::Id, MATTER_DM_THERMOSTAT_CLUSTER_SERVER_ENDPOINT_COUNT); - if (ep >= ArraySize(mAtomicWriteSessions)) + if (ep >= MATTER_ARRAY_SIZE(mAtomicWriteSessions)) { return false; } @@ -306,7 +306,7 @@ bool ThermostatAttrAccess::SetAtomicWrite( uint16_t ep = emberAfGetClusterServerEndpointIndex(endpoint, Thermostat::Id, MATTER_DM_THERMOSTAT_CLUSTER_SERVER_ENDPOINT_COUNT); - if (ep >= ArraySize(mAtomicWriteSessions)) + if (ep >= MATTER_ARRAY_SIZE(mAtomicWriteSessions)) { return false; } @@ -341,7 +341,7 @@ void ThermostatAttrAccess::ResetAtomicWrite(EndpointId endpoint) uint16_t ep = emberAfGetClusterServerEndpointIndex(endpoint, Thermostat::Id, MATTER_DM_THERMOSTAT_CLUSTER_SERVER_ENDPOINT_COUNT); - if (ep >= ArraySize(mAtomicWriteSessions)) + if (ep >= MATTER_ARRAY_SIZE(mAtomicWriteSessions)) { return; } @@ -358,7 +358,7 @@ ScopedNodeId ThermostatAttrAccess::GetAtomicWriteOriginatorScopedNodeId(const En uint16_t ep = emberAfGetClusterServerEndpointIndex(endpoint, Thermostat::Id, MATTER_DM_THERMOSTAT_CLUSTER_SERVER_ENDPOINT_COUNT); - if (ep < ArraySize(mAtomicWriteSessions)) + if (ep < MATTER_ARRAY_SIZE(mAtomicWriteSessions)) { originatorNodeId = mAtomicWriteSessions[ep].nodeId; } diff --git a/src/app/clusters/thermostat-server/thermostat-server.cpp b/src/app/clusters/thermostat-server/thermostat-server.cpp index a1f0d27779571f..669e994c80e250 100644 --- a/src/app/clusters/thermostat-server/thermostat-server.cpp +++ b/src/app/clusters/thermostat-server/thermostat-server.cpp @@ -510,7 +510,7 @@ Delegate * GetDelegate(EndpointId endpoint) { uint16_t ep = emberAfGetClusterServerEndpointIndex(endpoint, Thermostat::Id, MATTER_DM_THERMOSTAT_CLUSTER_SERVER_ENDPOINT_COUNT); - return (ep >= ArraySize(gDelegateTable) ? nullptr : gDelegateTable[ep]); + return (ep >= MATTER_ARRAY_SIZE(gDelegateTable) ? nullptr : gDelegateTable[ep]); } void SetDefaultDelegate(EndpointId endpoint, Delegate * delegate) @@ -518,7 +518,7 @@ void SetDefaultDelegate(EndpointId endpoint, Delegate * delegate) uint16_t ep = emberAfGetClusterServerEndpointIndex(endpoint, Thermostat::Id, MATTER_DM_THERMOSTAT_CLUSTER_SERVER_ENDPOINT_COUNT); // if endpoint is found, add the delegate in the delegate table - if (ep < ArraySize(gDelegateTable)) + if (ep < MATTER_ARRAY_SIZE(gDelegateTable)) { gDelegateTable[ep] = delegate; } @@ -744,7 +744,7 @@ CHIP_ERROR ThermostatAttrAccess::Write(const ConcreteDataAttributePath & aPath, void ThermostatAttrAccess::OnFabricRemoved(const FabricTable & fabricTable, FabricIndex fabricIndex) { - for (size_t i = 0; i < ArraySize(mAtomicWriteSessions); ++i) + for (size_t i = 0; i < MATTER_ARRAY_SIZE(mAtomicWriteSessions); ++i) { auto & atomicWriteState = mAtomicWriteSessions[i]; if (atomicWriteState.state == AtomicWriteState::Open && atomicWriteState.nodeId.GetFabricIndex() == fabricIndex) diff --git a/src/app/server/Dnssd.cpp b/src/app/server/Dnssd.cpp index 2dea0a4b4bd9aa..a2bad90d8507d2 100644 --- a/src/app/server/Dnssd.cpp +++ b/src/app/server/Dnssd.cpp @@ -306,7 +306,7 @@ CHIP_ERROR DnssdServer::Advertise(bool commissionableNode, chip::Dnssd::Commissi #if CHIP_ENABLE_ROTATING_DEVICE_ID && defined(CHIP_DEVICE_CONFIG_ROTATING_DEVICE_ID_UNIQUE_ID) char rotatingDeviceIdHexBuffer[RotatingDeviceId::kHexMaxLength]; - ReturnErrorOnFailure(GenerateRotatingDeviceId(rotatingDeviceIdHexBuffer, ArraySize(rotatingDeviceIdHexBuffer))); + ReturnErrorOnFailure(GenerateRotatingDeviceId(rotatingDeviceIdHexBuffer, MATTER_ARRAY_SIZE(rotatingDeviceIdHexBuffer))); advertiseParameters.SetRotatingDeviceId(std::make_optional(rotatingDeviceIdHexBuffer)); #endif diff --git a/src/app/tests/TestAclEvent.cpp b/src/app/tests/TestAclEvent.cpp index 5610d18ed6015c..a2c1e7bb52fc5b 100644 --- a/src/app/tests/TestAclEvent.cpp +++ b/src/app/tests/TestAclEvent.cpp @@ -189,7 +189,7 @@ class TestAclEvent : public Test::AppContext AppContext::SetUp(); ASSERT_EQ(mEventCounter.Init(0), CHIP_NO_ERROR); - chip::app::EventManagement::CreateEventManagement(&GetExchangeManager(), ArraySize(logStorageResources), + chip::app::EventManagement::CreateEventManagement(&GetExchangeManager(), MATTER_ARRAY_SIZE(logStorageResources), gCircularEventBuffer, logStorageResources, &mEventCounter); Access::GetAccessControl().Finish(); diff --git a/src/app/tests/TestAttributePathExpandIterator.cpp b/src/app/tests/TestAttributePathExpandIterator.cpp index 2b8de0623f775a..23917bf7fe30f9 100644 --- a/src/app/tests/TestAttributePathExpandIterator.cpp +++ b/src/app/tests/TestAttributePathExpandIterator.cpp @@ -126,11 +126,11 @@ TEST_F(TestAttributePathExpandIterator, TestAllWildcard) ChipLogDetail(AppServer, "Visited Attribute: 0x%04X / " ChipLogFormatMEI " / " ChipLogFormatMEI, path.mEndpointId, ChipLogValueMEI(path.mClusterId), ChipLogValueMEI(path.mAttributeId)); - EXPECT_LT(index, ArraySize(paths)); + EXPECT_LT(index, MATTER_ARRAY_SIZE(paths)); EXPECT_EQ(paths[index], path); index++; } - EXPECT_EQ(index, ArraySize(paths)); + EXPECT_EQ(index, MATTER_ARRAY_SIZE(paths)); } TEST_F(TestAttributePathExpandIterator, TestWildcardEndpoint) @@ -158,11 +158,11 @@ TEST_F(TestAttributePathExpandIterator, TestWildcardEndpoint) } ChipLogDetail(AppServer, "Visited Attribute: 0x%04X / " ChipLogFormatMEI " / " ChipLogFormatMEI, path.mEndpointId, ChipLogValueMEI(path.mClusterId), ChipLogValueMEI(path.mAttributeId)); - EXPECT_LT(index, ArraySize(paths)); + EXPECT_LT(index, MATTER_ARRAY_SIZE(paths)); EXPECT_EQ(paths[index], path); index++; } - EXPECT_EQ(index, ArraySize(paths)); + EXPECT_EQ(index, MATTER_ARRAY_SIZE(paths)); } TEST_F(TestAttributePathExpandIterator, TestWildcardCluster) @@ -193,11 +193,11 @@ TEST_F(TestAttributePathExpandIterator, TestWildcardCluster) } ChipLogDetail(AppServer, "Visited Attribute: 0x%04X / " ChipLogFormatMEI " / " ChipLogFormatMEI, path.mEndpointId, ChipLogValueMEI(path.mClusterId), ChipLogValueMEI(path.mAttributeId)); - EXPECT_LT(index, ArraySize(paths)); + EXPECT_LT(index, MATTER_ARRAY_SIZE(paths)); EXPECT_EQ(paths[index], path); index++; } - EXPECT_EQ(index, ArraySize(paths)); + EXPECT_EQ(index, MATTER_ARRAY_SIZE(paths)); } TEST_F(TestAttributePathExpandIterator, TestWildcardClusterGlobalAttributeNotInMetadata) @@ -229,11 +229,11 @@ TEST_F(TestAttributePathExpandIterator, TestWildcardClusterGlobalAttributeNotInM } ChipLogDetail(AppServer, "Visited Attribute: 0x%04X / " ChipLogFormatMEI " / " ChipLogFormatMEI, path.mEndpointId, ChipLogValueMEI(path.mClusterId), ChipLogValueMEI(path.mAttributeId)); - EXPECT_LT(index, ArraySize(paths)); + EXPECT_LT(index, MATTER_ARRAY_SIZE(paths)); EXPECT_EQ(paths[index], path); index++; } - EXPECT_EQ(index, ArraySize(paths)); + EXPECT_EQ(index, MATTER_ARRAY_SIZE(paths)); } TEST_F(TestAttributePathExpandIterator, TestWildcardAttribute) @@ -269,11 +269,11 @@ TEST_F(TestAttributePathExpandIterator, TestWildcardAttribute) } ChipLogDetail(AppServer, "Visited Attribute: 0x%04X / " ChipLogFormatMEI " / " ChipLogFormatMEI, path.mEndpointId, ChipLogValueMEI(path.mClusterId), ChipLogValueMEI(path.mAttributeId)); - EXPECT_LT(index, ArraySize(paths)); + EXPECT_LT(index, MATTER_ARRAY_SIZE(paths)); EXPECT_EQ(paths[index], path); index++; } - EXPECT_EQ(index, ArraySize(paths)); + EXPECT_EQ(index, MATTER_ARRAY_SIZE(paths)); } TEST_F(TestAttributePathExpandIterator, TestNoWildcard) @@ -302,11 +302,11 @@ TEST_F(TestAttributePathExpandIterator, TestNoWildcard) } ChipLogDetail(AppServer, "Visited Attribute: 0x%04X / " ChipLogFormatMEI " / " ChipLogFormatMEI, path.mEndpointId, ChipLogValueMEI(path.mClusterId), ChipLogValueMEI(path.mAttributeId)); - EXPECT_LT(index, ArraySize(paths)); + EXPECT_LT(index, MATTER_ARRAY_SIZE(paths)); EXPECT_EQ(paths[index], path); index++; } - EXPECT_EQ(index, ArraySize(paths)); + EXPECT_EQ(index, MATTER_ARRAY_SIZE(paths)); } TEST_F(TestAttributePathExpandIterator, TestFixedPathExpansion) @@ -484,11 +484,11 @@ TEST_F(TestAttributePathExpandIterator, TestMultipleClusInfo) { ChipLogDetail(AppServer, "Visited Attribute: 0x%04X / " ChipLogFormatMEI " / " ChipLogFormatMEI, path.mEndpointId, ChipLogValueMEI(path.mClusterId), ChipLogValueMEI(path.mAttributeId)); - EXPECT_LT(index, ArraySize(paths)); + EXPECT_LT(index, MATTER_ARRAY_SIZE(paths)); EXPECT_EQ(paths[index], path); index++; } - EXPECT_EQ(index, ArraySize(paths)); + EXPECT_EQ(index, MATTER_ARRAY_SIZE(paths)); } // identical test, however this checks that position re-use works @@ -508,11 +508,11 @@ TEST_F(TestAttributePathExpandIterator, TestMultipleClusInfo) } ChipLogDetail(AppServer, "Visited Attribute: 0x%04X / " ChipLogFormatMEI " / " ChipLogFormatMEI, path.mEndpointId, ChipLogValueMEI(path.mClusterId), ChipLogValueMEI(path.mAttributeId)); - EXPECT_LT(index, ArraySize(paths)); + EXPECT_LT(index, MATTER_ARRAY_SIZE(paths)); EXPECT_EQ(paths[index], path); index++; } - EXPECT_EQ(index, ArraySize(paths)); + EXPECT_EQ(index, MATTER_ARRAY_SIZE(paths)); } } diff --git a/src/app/tests/TestEventLogging.cpp b/src/app/tests/TestEventLogging.cpp index cbc42d9060e435..733509f26769bb 100644 --- a/src/app/tests/TestEventLogging.cpp +++ b/src/app/tests/TestEventLogging.cpp @@ -67,7 +67,7 @@ class TestEventLogging : public chip::Test::AppContext AppContext::SetUp(); ASSERT_EQ(mEventCounter.Init(0), CHIP_NO_ERROR); - chip::app::EventManagement::CreateEventManagement(&GetExchangeManager(), ArraySize(logStorageResources), + chip::app::EventManagement::CreateEventManagement(&GetExchangeManager(), MATTER_ARRAY_SIZE(logStorageResources), gCircularEventBuffer, logStorageResources, &mEventCounter); } diff --git a/src/app/tests/TestEventLoggingNoUTCTime.cpp b/src/app/tests/TestEventLoggingNoUTCTime.cpp index f3cfc0e8a30ddc..255b904414e73f 100644 --- a/src/app/tests/TestEventLoggingNoUTCTime.cpp +++ b/src/app/tests/TestEventLoggingNoUTCTime.cpp @@ -101,7 +101,7 @@ class TestEventLoggingNoUTCTime : public chip::Test::AppContext AppContext::SetUp(); ASSERT_EQ(mEventCounter.Init(0), CHIP_NO_ERROR); - chip::app::EventManagement::CreateEventManagement(&GetExchangeManager(), ArraySize(logStorageResources), + chip::app::EventManagement::CreateEventManagement(&GetExchangeManager(), MATTER_ARRAY_SIZE(logStorageResources), gCircularEventBuffer, logStorageResources, &mEventCounter); } diff --git a/src/app/tests/TestEventOverflow.cpp b/src/app/tests/TestEventOverflow.cpp index 4a3cc2d80c3613..2a1ce61fa5f56f 100644 --- a/src/app/tests/TestEventOverflow.cpp +++ b/src/app/tests/TestEventOverflow.cpp @@ -67,7 +67,7 @@ class TestEventOverflow : public chip::Test::AppContext VerifyOrReturn(!HasFailure()); ASSERT_EQ(mEventCounter.Init(0), CHIP_NO_ERROR); - chip::app::EventManagement::CreateEventManagement(&GetExchangeManager(), ArraySize(logStorageResources), + chip::app::EventManagement::CreateEventManagement(&GetExchangeManager(), MATTER_ARRAY_SIZE(logStorageResources), gCircularEventBuffer, logStorageResources, &mEventCounter); } diff --git a/src/app/tests/TestFabricScopedEventLogging.cpp b/src/app/tests/TestFabricScopedEventLogging.cpp index d825626688f90b..6e79f317b085be 100644 --- a/src/app/tests/TestFabricScopedEventLogging.cpp +++ b/src/app/tests/TestFabricScopedEventLogging.cpp @@ -68,7 +68,7 @@ class TestFabricScopedEventLogging : public chip::Test::AppContext AppContext::SetUp(); ASSERT_EQ(mEventCounter.Init(0), CHIP_NO_ERROR); - chip::app::EventManagement::CreateEventManagement(&GetExchangeManager(), ArraySize(logStorageResources), + chip::app::EventManagement::CreateEventManagement(&GetExchangeManager(), MATTER_ARRAY_SIZE(logStorageResources), gCircularEventBuffer, logStorageResources, &mEventCounter); } diff --git a/src/app/tests/TestReadInteraction.cpp b/src/app/tests/TestReadInteraction.cpp index 50b4b745299d02..0017b96a4c0bcc 100644 --- a/src/app/tests/TestReadInteraction.cpp +++ b/src/app/tests/TestReadInteraction.cpp @@ -505,7 +505,7 @@ class TestReadInteraction : public chip::Test::AppContext AppContext::SetUp(); ASSERT_EQ(mEventCounter.Init(0), CHIP_NO_ERROR); - chip::app::EventManagement::CreateEventManagement(&GetExchangeManager(), ArraySize(logStorageResources), + chip::app::EventManagement::CreateEventManagement(&GetExchangeManager(), MATTER_ARRAY_SIZE(logStorageResources), gCircularEventBuffer, logStorageResources, &mEventCounter); mOldProvider = InteractionModelEngine::GetInstance()->SetDataModelProvider(&TestImCustomDataModel::Instance()); chip::Test::SetMockNodeConfig(TestMockNodeConfig()); diff --git a/src/app/tests/integration/chip_im_responder.cpp b/src/app/tests/integration/chip_im_responder.cpp index 12996affd398ca..0757ea171c77a8 100644 --- a/src/app/tests/integration/chip_im_responder.cpp +++ b/src/app/tests/integration/chip_im_responder.cpp @@ -139,7 +139,7 @@ CHIP_ERROR InitializeEventLogging(chip::Messaging::ExchangeManager * apMgr) { &gCritEventBuffer[0], sizeof(gCritEventBuffer), chip::app::PriorityLevel::Critical }, }; - chip::app::EventManagement::CreateEventManagement(apMgr, ArraySize(logStorageResources), gCircularEventBuffer, + chip::app::EventManagement::CreateEventManagement(apMgr, MATTER_ARRAY_SIZE(logStorageResources), gCircularEventBuffer, logStorageResources, &gEventCounter); return CHIP_NO_ERROR; } diff --git a/src/app/util/attribute-storage.cpp b/src/app/util/attribute-storage.cpp index a17ffce6c3590b..415086483914cc 100644 --- a/src/app/util/attribute-storage.cpp +++ b/src/app/util/attribute-storage.cpp @@ -1414,7 +1414,7 @@ bool IsTreeCompositionForEndpoint(EndpointId endpoint) EndpointComposition GetCompositionForEndpointIndex(uint16_t endpointIndex) { - VerifyOrReturnValue(endpointIndex < ArraySize(emAfEndpoints), EndpointComposition::kInvalid); + VerifyOrReturnValue(endpointIndex < MATTER_ARRAY_SIZE(emAfEndpoints), EndpointComposition::kInvalid); if (emAfEndpoints[endpointIndex].bitmask.Has(EmberAfEndpointOptions::isFlatComposition)) { return EndpointComposition::kFullFamily; diff --git a/src/app/util/attribute-storage.h b/src/app/util/attribute-storage.h index 57769a2b6fb50a..8045681948a3b0 100644 --- a/src/app/util/attribute-storage.h +++ b/src/app/util/attribute-storage.h @@ -38,7 +38,7 @@ static constexpr uint16_t kEmberInvalidEndpointIndex = 0xFFFF; #endif #define DECLARE_DYNAMIC_ENDPOINT(endpointName, clusterList) \ - EmberAfEndpointType endpointName = { clusterList, ArraySize(clusterList), 0 } + EmberAfEndpointType endpointName = { clusterList, MATTER_ARRAY_SIZE(clusterList), 0 } #define DECLARE_DYNAMIC_CLUSTER_LIST_BEGIN(clusterListName) EmberAfCluster clusterListName[] = { @@ -46,7 +46,7 @@ static constexpr uint16_t kEmberInvalidEndpointIndex = 0xFFFF; // It can be assigned with the ZAP_CLUSTER_MASK(SERVER) or ZAP_CLUSTER_MASK(CLUSTER) values. #define DECLARE_DYNAMIC_CLUSTER(clusterId, clusterAttrs, role, incomingCommands, outgoingCommands) \ { \ - clusterId, clusterAttrs, ArraySize(clusterAttrs), 0, role, NULL, incomingCommands, outgoingCommands \ + clusterId, clusterAttrs, MATTER_ARRAY_SIZE(clusterAttrs), 0, role, NULL, incomingCommands, outgoingCommands \ } #define DECLARE_DYNAMIC_CLUSTER_LIST_END } diff --git a/src/app/util/privilege-storage.cpp b/src/app/util/privilege-storage.cpp index 2bf38a1802347f..28ac04dc2da050 100644 --- a/src/app/util/privilege-storage.cpp +++ b/src/app/util/privilege-storage.cpp @@ -37,7 +37,8 @@ namespace GeneratedAccessReadAttribute { constexpr ClusterId kCluster[] = GENERATED_ACCESS_READ_ATTRIBUTE__CLUSTER; constexpr AttributeId kAttribute[] = GENERATED_ACCESS_READ_ATTRIBUTE__ATTRIBUTE; constexpr chip::Access::Privilege kPrivilege[] = GENERATED_ACCESS_READ_ATTRIBUTE__PRIVILEGE; -static_assert(ArraySize(kCluster) == ArraySize(kAttribute) && ArraySize(kAttribute) == ArraySize(kPrivilege), +static_assert(MATTER_ARRAY_SIZE(kCluster) == MATTER_ARRAY_SIZE(kAttribute) && + MATTER_ARRAY_SIZE(kAttribute) == MATTER_ARRAY_SIZE(kPrivilege), "Generated parallel arrays must be same size"); } // namespace GeneratedAccessReadAttribute #endif @@ -47,7 +48,8 @@ namespace GeneratedAccessWriteAttribute { constexpr ClusterId kCluster[] = GENERATED_ACCESS_WRITE_ATTRIBUTE__CLUSTER; constexpr AttributeId kAttribute[] = GENERATED_ACCESS_WRITE_ATTRIBUTE__ATTRIBUTE; constexpr chip::Access::Privilege kPrivilege[] = GENERATED_ACCESS_WRITE_ATTRIBUTE__PRIVILEGE; -static_assert(ArraySize(kCluster) == ArraySize(kAttribute) && ArraySize(kAttribute) == ArraySize(kPrivilege), +static_assert(MATTER_ARRAY_SIZE(kCluster) == MATTER_ARRAY_SIZE(kAttribute) && + MATTER_ARRAY_SIZE(kAttribute) == MATTER_ARRAY_SIZE(kPrivilege), "Generated parallel arrays must be same size"); } // namespace GeneratedAccessWriteAttribute #endif @@ -57,7 +59,8 @@ namespace GeneratedAccessInvokeCommand { constexpr ClusterId kCluster[] = GENERATED_ACCESS_INVOKE_COMMAND__CLUSTER; constexpr CommandId kCommand[] = GENERATED_ACCESS_INVOKE_COMMAND__COMMAND; constexpr chip::Access::Privilege kPrivilege[] = GENERATED_ACCESS_INVOKE_COMMAND__PRIVILEGE; -static_assert(ArraySize(kCluster) == ArraySize(kCommand) && ArraySize(kCommand) == ArraySize(kPrivilege), +static_assert(MATTER_ARRAY_SIZE(kCluster) == MATTER_ARRAY_SIZE(kCommand) && + MATTER_ARRAY_SIZE(kCommand) == MATTER_ARRAY_SIZE(kPrivilege), "Generated parallel arrays must be same size"); } // namespace GeneratedAccessInvokeCommand #endif @@ -67,7 +70,8 @@ namespace GeneratedAccessReadEvent { constexpr ClusterId kCluster[] = GENERATED_ACCESS_READ_EVENT__CLUSTER; constexpr EventId kEvent[] = GENERATED_ACCESS_READ_EVENT__EVENT; constexpr chip::Access::Privilege kPrivilege[] = GENERATED_ACCESS_READ_EVENT__PRIVILEGE; -static_assert(ArraySize(kCluster) == ArraySize(kEvent) && ArraySize(kEvent) == ArraySize(kPrivilege), +static_assert(MATTER_ARRAY_SIZE(kCluster) == MATTER_ARRAY_SIZE(kEvent) && + MATTER_ARRAY_SIZE(kEvent) == MATTER_ARRAY_SIZE(kPrivilege), "Generated parallel arrays must be same size"); } // namespace GeneratedAccessReadEvent #endif @@ -78,7 +82,7 @@ chip::Access::Privilege MatterGetAccessPrivilegeForReadAttribute(ClusterId clust { #ifdef GENERATED_ACCESS_READ_ATTRIBUTE__CLUSTER using namespace GeneratedAccessReadAttribute; - for (size_t i = 0; i < ArraySize(kCluster); ++i) + for (size_t i = 0; i < MATTER_ARRAY_SIZE(kCluster); ++i) { if (kCluster[i] == cluster && kAttribute[i] == attribute) { @@ -93,7 +97,7 @@ chip::Access::Privilege MatterGetAccessPrivilegeForWriteAttribute(ClusterId clus { #ifdef GENERATED_ACCESS_WRITE_ATTRIBUTE__CLUSTER using namespace GeneratedAccessWriteAttribute; - for (size_t i = 0; i < ArraySize(kCluster); ++i) + for (size_t i = 0; i < MATTER_ARRAY_SIZE(kCluster); ++i) { if (kCluster[i] == cluster && kAttribute[i] == attribute) { @@ -108,7 +112,7 @@ chip::Access::Privilege MatterGetAccessPrivilegeForInvokeCommand(ClusterId clust { #ifdef GENERATED_ACCESS_INVOKE_COMMAND__CLUSTER using namespace GeneratedAccessInvokeCommand; - for (size_t i = 0; i < ArraySize(kCluster); ++i) + for (size_t i = 0; i < MATTER_ARRAY_SIZE(kCluster); ++i) { if (kCluster[i] == cluster && kCommand[i] == command) { @@ -123,7 +127,7 @@ chip::Access::Privilege MatterGetAccessPrivilegeForReadEvent(ClusterId cluster, { #ifdef GENERATED_ACCESS_READ_EVENT__CLUSTER using namespace GeneratedAccessReadEvent; - for (size_t i = 0; i < ArraySize(kCluster); ++i) + for (size_t i = 0; i < MATTER_ARRAY_SIZE(kCluster); ++i) { if (kCluster[i] == cluster && kEvent[i] == event) { diff --git a/src/controller/tests/TestEventCaching.cpp b/src/controller/tests/TestEventCaching.cpp index 5821b84b3fab75..d66e95303851db 100644 --- a/src/controller/tests/TestEventCaching.cpp +++ b/src/controller/tests/TestEventCaching.cpp @@ -74,7 +74,7 @@ class TestEventCaching : public Test::AppContext VerifyOrReturn(!HasFailure()); // Stop if parent had a failure. ASSERT_EQ(mEventCounter.Init(0), CHIP_NO_ERROR); - chip::app::EventManagement::CreateEventManagement(&GetExchangeManager(), ArraySize(logStorageResources), + chip::app::EventManagement::CreateEventManagement(&GetExchangeManager(), MATTER_ARRAY_SIZE(logStorageResources), gCircularEventBuffer, logStorageResources, &mEventCounter); } @@ -158,7 +158,7 @@ TEST_F(TestEventCaching, TestBasicCaching) InitDataModelHandler(); // Register our fake dynamic endpoint. - DataVersion dataVersionStorage[ArraySize(testEndpointClusters)]; + DataVersion dataVersionStorage[MATTER_ARRAY_SIZE(testEndpointClusters)]; emberAfSetDynamicEndpoint(0, kTestEndpointId, &testEndpoint, Span(dataVersionStorage)); chip::EventNumber firstEventNumber; diff --git a/src/controller/tests/TestEventChunking.cpp b/src/controller/tests/TestEventChunking.cpp index 80cd0707b63dfd..bd78814f372b49 100644 --- a/src/controller/tests/TestEventChunking.cpp +++ b/src/controller/tests/TestEventChunking.cpp @@ -86,7 +86,7 @@ class TestEventChunking : public chip::Test::AppContext // TODO: use ASSERT_EQ, once transition to pw_unit_test is complete VerifyOrDieWithMsg((err = mEventCounter.Init(0)) == CHIP_NO_ERROR, AppServer, "Init EventCounter failed: %" CHIP_ERROR_FORMAT, err.Format()); - chip::app::EventManagement::CreateEventManagement(&GetExchangeManager(), ArraySize(logStorageResources), + chip::app::EventManagement::CreateEventManagement(&GetExchangeManager(), MATTER_ARRAY_SIZE(logStorageResources), gCircularEventBuffer, logStorageResources, &mEventCounter); } @@ -292,7 +292,7 @@ TEST_F(TestEventChunking, TestEventChunking) InitDataModelHandler(); // Register our fake dynamic endpoint. - DataVersion dataVersionStorage[ArraySize(testEndpointClusters)]; + DataVersion dataVersionStorage[MATTER_ARRAY_SIZE(testEndpointClusters)]; emberAfSetDynamicEndpoint(0, kTestEndpointId, &testEndpoint, Span(dataVersionStorage)); chip::EventNumber firstEventNumber; @@ -360,7 +360,7 @@ TEST_F(TestEventChunking, TestMixedEventsAndAttributesChunking) InitDataModelHandler(); // Register our fake dynamic endpoint. - DataVersion dataVersionStorage[ArraySize(testEndpointClusters)]; + DataVersion dataVersionStorage[MATTER_ARRAY_SIZE(testEndpointClusters)]; emberAfSetDynamicEndpoint(0, kTestEndpointId, &testEndpoint, Span(dataVersionStorage)); chip::EventNumber firstEventNumber; @@ -407,7 +407,7 @@ TEST_F(TestEventChunking, TestMixedEventsAndAttributesChunking) // Always returns the same number of attributes read (5 + revision + GlobalAttributesNotInMetadata). // EXPECT_TRUE(readCallback.mOnReportEnd); - EXPECT_EQ(readCallback.mAttributeCount, 6 + ArraySize(GlobalAttributesNotInMetadata)); + EXPECT_EQ(readCallback.mAttributeCount, 6 + MATTER_ARRAY_SIZE(GlobalAttributesNotInMetadata)); EXPECT_EQ(readCallback.mEventCount, static_cast(lastEventNumber - firstEventNumber + 1)); EXPECT_EQ(GetExchangeManager().GetNumActiveExchanges(), 0u); @@ -438,7 +438,7 @@ TEST_F(TestEventChunking, TestMixedEventsAndLargeAttributesChunking) InitDataModelHandler(); // Register our fake dynamic endpoint. - DataVersion dataVersionStorage[ArraySize(testEndpointClusters)]; + DataVersion dataVersionStorage[MATTER_ARRAY_SIZE(testEndpointClusters)]; emberAfSetDynamicEndpoint(0, kTestEndpointId, &testEndpoint4, Span(dataVersionStorage)); chip::EventNumber firstEventNumber; diff --git a/src/controller/tests/TestEventNumberCaching.cpp b/src/controller/tests/TestEventNumberCaching.cpp index 666e6033f79334..5a19c7bb08a789 100644 --- a/src/controller/tests/TestEventNumberCaching.cpp +++ b/src/controller/tests/TestEventNumberCaching.cpp @@ -73,7 +73,7 @@ class TestEventNumberCaching : public chip::Test::AppContext // TODO: use ASSERT_EQ, once transition to pw_unit_test is complete VerifyOrDieWithMsg((err = mEventCounter.Init(0)) == CHIP_NO_ERROR, AppServer, "Init EventCounter failed: %" CHIP_ERROR_FORMAT, err.Format()); - chip::app::EventManagement::CreateEventManagement(&GetExchangeManager(), ArraySize(logStorageResources), + chip::app::EventManagement::CreateEventManagement(&GetExchangeManager(), MATTER_ARRAY_SIZE(logStorageResources), gCircularEventBuffer, logStorageResources, &mEventCounter); } @@ -151,7 +151,7 @@ TEST_F(TestEventNumberCaching, TestEventNumberCaching) InitDataModelHandler(); // Register our fake dynamic endpoint. - DataVersion dataVersionStorage[ArraySize(testEndpointClusters)]; + DataVersion dataVersionStorage[MATTER_ARRAY_SIZE(testEndpointClusters)]; emberAfSetDynamicEndpoint(0, kTestEndpointId, &testEndpoint, Span(dataVersionStorage)); chip::EventNumber firstEventNumber; diff --git a/src/controller/tests/TestReadChunking.cpp b/src/controller/tests/TestReadChunking.cpp index 3d2676e7f4c440..fb8eada9fcd8d3 100644 --- a/src/controller/tests/TestReadChunking.cpp +++ b/src/controller/tests/TestReadChunking.cpp @@ -328,7 +328,7 @@ class TestMutableAttrAccess void SetVal(uint8_t attribute, uint8_t newVal) { uint8_t index = static_cast(attribute - 1); - if (index < ArraySize(val) && val[index] != newVal) + if (index < MATTER_ARRAY_SIZE(val) && val[index] != newVal) { val[index] = newVal; SetDirty(attribute); @@ -343,7 +343,7 @@ class TestMutableAttrAccess CHIP_ERROR TestMutableAttrAccess::Read(const app::ConcreteReadAttributePath & aPath, app::AttributeValueEncoder & aEncoder) { uint8_t index = static_cast(aPath.mAttributeId - 1); - VerifyOrReturnError(aPath.mEndpointId == kTestEndpointId5 && index < ArraySize(val), CHIP_ERROR_NOT_FOUND); + VerifyOrReturnError(aPath.mEndpointId == kTestEndpointId5 && index < MATTER_ARRAY_SIZE(val), CHIP_ERROR_NOT_FOUND); return aEncoder.Encode(val[index]); } @@ -486,7 +486,7 @@ TEST_F(TestReadChunking, TestChunking) InitDataModelHandler(); // Register our fake dynamic endpoint. - DataVersion dataVersionStorage[ArraySize(testEndpointClusters)]; + DataVersion dataVersionStorage[MATTER_ARRAY_SIZE(testEndpointClusters)]; emberAfSetDynamicEndpoint(0, kTestEndpointId, &testEndpoint, Span(dataVersionStorage)); app::AttributePathParams attributePath(kTestEndpointId, app::Clusters::UnitTesting::Id); @@ -521,7 +521,7 @@ TEST_F(TestReadChunking, TestChunking) // // Always returns the same number of attributes read (5 + revision + GlobalAttributesNotInMetadata). // - EXPECT_EQ(readCallback.mAttributeCount, 6 + ArraySize(GlobalAttributesNotInMetadata)); + EXPECT_EQ(readCallback.mAttributeCount, 6 + MATTER_ARRAY_SIZE(GlobalAttributesNotInMetadata)); readCallback.mAttributeCount = 0; EXPECT_EQ(GetExchangeManager().GetNumActiveExchanges(), 0u); @@ -549,7 +549,7 @@ TEST_F(TestReadChunking, TestListChunking) InitDataModelHandler(); // Register our fake dynamic endpoint. - DataVersion dataVersionStorage[ArraySize(testEndpoint3Clusters)]; + DataVersion dataVersionStorage[MATTER_ARRAY_SIZE(testEndpoint3Clusters)]; emberAfSetDynamicEndpoint(0, kTestEndpointId3, &testEndpoint3, Span(dataVersionStorage)); app::AttributePathParams attributePath(kTestEndpointId3, app::Clusters::UnitTesting::Id, kTestListAttribute); @@ -562,7 +562,7 @@ TEST_F(TestReadChunking, TestListChunking) AttributePathParams pathList[] = { attributePath, attributePath }; readParams.mpAttributePathParamsList = pathList; - readParams.mAttributePathParamsListSize = ArraySize(pathList); + readParams.mAttributePathParamsListSize = MATTER_ARRAY_SIZE(pathList); constexpr size_t maxPacketSize = kMaxSecureSduLengthBytes; bool gotSuccessfulEncode = false; @@ -653,7 +653,7 @@ TEST_F(TestReadChunking, TestBadChunking) app::InteractionModelEngine::GetInstance()->GetReportingEngine().SetWriterReserved(0); // Register our fake dynamic endpoint. - DataVersion dataVersionStorage[ArraySize(testEndpoint3Clusters)]; + DataVersion dataVersionStorage[MATTER_ARRAY_SIZE(testEndpoint3Clusters)]; emberAfSetDynamicEndpoint(0, kTestEndpointId3, &testEndpoint3, Span(dataVersionStorage)); app::AttributePathParams attributePath(kTestEndpointId3, app::Clusters::UnitTesting::Id, kTestBadAttribute); @@ -703,7 +703,7 @@ TEST_F(TestReadChunking, TestDynamicEndpoint) InitDataModelHandler(); // Register our fake dynamic endpoint. - DataVersion dataVersionStorage[ArraySize(testEndpoint4Clusters)]; + DataVersion dataVersionStorage[MATTER_ARRAY_SIZE(testEndpoint4Clusters)]; app::AttributePathParams attributePath; app::ReadPrepareParams readParams(sessionHandle); @@ -734,7 +734,8 @@ TEST_F(TestReadChunking, TestDynamicEndpoint) // Ensure we have received the report, we do not care about the initial report here. // GlobalAttributesNotInMetadata attributes are not included in testClusterAttrsOnEndpoint4. - EXPECT_EQ(readCallback.mAttributeCount, ArraySize(testClusterAttrsOnEndpoint4) + ArraySize(GlobalAttributesNotInMetadata)); + EXPECT_EQ(readCallback.mAttributeCount, + MATTER_ARRAY_SIZE(testClusterAttrsOnEndpoint4) + MATTER_ARRAY_SIZE(GlobalAttributesNotInMetadata)); // We have received all report data. EXPECT_TRUE(readCallback.mOnReportEnd); @@ -759,7 +760,8 @@ TEST_F(TestReadChunking, TestDynamicEndpoint) // Ensure we have received the report, we do not care about the initial report here. // GlobalAttributesNotInMetadata attributes are not included in testClusterAttrsOnEndpoint4. - EXPECT_EQ(readCallback.mAttributeCount, ArraySize(testClusterAttrsOnEndpoint4) + ArraySize(GlobalAttributesNotInMetadata)); + EXPECT_EQ(readCallback.mAttributeCount, + MATTER_ARRAY_SIZE(testClusterAttrsOnEndpoint4) + MATTER_ARRAY_SIZE(GlobalAttributesNotInMetadata)); // We have received all report data. EXPECT_TRUE(readCallback.mOnReportEnd); @@ -899,8 +901,8 @@ TEST_F(TestReadChunking, TestSetDirtyBetweenChunks) app::InteractionModelEngine::GetInstance()->GetReportingEngine().SetWriterReserved(0); app::InteractionModelEngine::GetInstance()->GetReportingEngine().SetMaxAttributesPerChunk(2); - DataVersion dataVersionStorage1[ArraySize(testEndpointClusters)]; - DataVersion dataVersionStorage5[ArraySize(testEndpoint5Clusters)]; + DataVersion dataVersionStorage1[MATTER_ARRAY_SIZE(testEndpointClusters)]; + DataVersion dataVersionStorage5[MATTER_ARRAY_SIZE(testEndpoint5Clusters)]; gMutableAttrAccess.Reset(); diff --git a/src/controller/tests/TestServerCommandDispatch.cpp b/src/controller/tests/TestServerCommandDispatch.cpp index f4457c0013ef34..17acaa5887c14b 100644 --- a/src/controller/tests/TestServerCommandDispatch.cpp +++ b/src/controller/tests/TestServerCommandDispatch.cpp @@ -279,7 +279,7 @@ void TestServerCommandDispatch::TestDataResponseHelper(const EmberAfEndpointType // // All our endpoints have the same number of clusters, so just pick one. // - DataVersion dataVersionStorage[ArraySize(testEndpointClusters1)]; + DataVersion dataVersionStorage[MATTER_ARRAY_SIZE(testEndpointClusters1)]; emberAfSetDynamicEndpoint(0, kTestEndpointId, aEndpoint, Span(dataVersionStorage)); // Passing of stack variables by reference is only safe because of synchronous completion of the interaction. Otherwise, it's diff --git a/src/controller/tests/TestWriteChunking.cpp b/src/controller/tests/TestWriteChunking.cpp index 21df8c6326f2bd..72813e6c2f1b60 100644 --- a/src/controller/tests/TestWriteChunking.cpp +++ b/src/controller/tests/TestWriteChunking.cpp @@ -107,7 +107,7 @@ DECLARE_DYNAMIC_CLUSTER(Clusters::UnitTesting::Id, testClusterAttrsOnEndpoint, Z DECLARE_DYNAMIC_ENDPOINT(testEndpoint, testEndpointClusters); -DataVersion dataVersionStorage[ArraySize(testEndpointClusters)]; +DataVersion dataVersionStorage[MATTER_ARRAY_SIZE(testEndpointClusters)]; //clang-format on diff --git a/src/controller/tests/data_model/TestRead.cpp b/src/controller/tests/data_model/TestRead.cpp index d320def488ec47..f4999ab416bdba 100644 --- a/src/controller/tests/data_model/TestRead.cpp +++ b/src/controller/tests/data_model/TestRead.cpp @@ -948,8 +948,8 @@ TEST_F(TestRead, TestReadSubscribeAttributeResponseWithCache) readPrepareParams.mpEventPathParamsList = eventPathParams; // This size needs to be big enough that we can't fit our // DataVersionFilterIBs in the same packet. Max size is - // ArraySize(eventPathParams); - static_assert(75 <= ArraySize(eventPathParams)); + // MATTER_ARRAY_SIZE(eventPathParams); + static_assert(75 <= MATTER_ARRAY_SIZE(eventPathParams)); readPrepareParams.mEventPathParamsListSize = 75; err = readClient.SendRequest(readPrepareParams); @@ -1136,8 +1136,8 @@ TEST_F(TestRead, TestReadSubscribeAttributeResponseWithCache) readPrepareParams.mpEventPathParamsList = eventPathParams; // This size needs to be big enough that we can only fit our first - // DataVersionFilterIB. Max size is ArraySize(eventPathParams); - static_assert(73 <= ArraySize(eventPathParams)); + // DataVersionFilterIB. Max size is MATTER_ARRAY_SIZE(eventPathParams); + static_assert(73 <= MATTER_ARRAY_SIZE(eventPathParams)); readPrepareParams.mEventPathParamsListSize = 73; err = readClient.SendRequest(readPrepareParams); EXPECT_EQ(err, CHIP_NO_ERROR); @@ -1468,7 +1468,7 @@ TEST_F(TestRead, TestResubscribeAttributeTimeout) // Read full wildcard paths, repeat twice to ensure chunking. AttributePathParams attributePathParams[1]; readPrepareParams.mpAttributePathParamsList = attributePathParams; - readPrepareParams.mAttributePathParamsListSize = ArraySize(attributePathParams); + readPrepareParams.mAttributePathParamsListSize = MATTER_ARRAY_SIZE(attributePathParams); attributePathParams[0].mEndpointId = kTestEndpointId; attributePathParams[0].mClusterId = Clusters::UnitTesting::Id; attributePathParams[0].mAttributeId = Clusters::UnitTesting::Attributes::Boolean::Id; @@ -1550,7 +1550,7 @@ TEST_F(TestRead, TestSubscribeAttributeTimeout) AttributePathParams attributePathParams[1]; readPrepareParams.mpAttributePathParamsList = attributePathParams; - readPrepareParams.mAttributePathParamsListSize = ArraySize(attributePathParams); + readPrepareParams.mAttributePathParamsListSize = MATTER_ARRAY_SIZE(attributePathParams); attributePathParams[0].mEndpointId = kTestEndpointId; attributePathParams[0].mClusterId = Clusters::UnitTesting::Id; attributePathParams[0].mAttributeId = Clusters::UnitTesting::Attributes::Boolean::Id; @@ -2289,7 +2289,7 @@ TEST_F(TestRead, TestSubscribe_OnActiveModeNotification) // Read full wildcard paths, repeat twice to ensure chunking. AttributePathParams attributePathParams[1]; readPrepareParams.mpAttributePathParamsList = attributePathParams; - readPrepareParams.mAttributePathParamsListSize = ArraySize(attributePathParams); + readPrepareParams.mAttributePathParamsListSize = MATTER_ARRAY_SIZE(attributePathParams); attributePathParams[0].mEndpointId = kTestEndpointId; attributePathParams[0].mClusterId = Clusters::UnitTesting::Id; attributePathParams[0].mAttributeId = Clusters::UnitTesting::Attributes::Boolean::Id; @@ -2379,7 +2379,7 @@ TEST_F(TestRead, TestSubscribe_DynamicLITSubscription) // Read full wildcard paths, repeat twice to ensure chunking. AttributePathParams attributePathParams[1]; readPrepareParams.mpAttributePathParamsList = attributePathParams; - readPrepareParams.mAttributePathParamsListSize = ArraySize(attributePathParams); + readPrepareParams.mAttributePathParamsListSize = MATTER_ARRAY_SIZE(attributePathParams); attributePathParams[0].mEndpointId = kRootEndpointId; attributePathParams[0].mClusterId = Clusters::IcdManagement::Id; attributePathParams[0].mAttributeId = Clusters::IcdManagement::Attributes::OperatingMode::Id; @@ -2490,7 +2490,7 @@ TEST_F(TestRead, TestSubscribe_ImmediatelyResubscriptionForLIT) // Read full wildcard paths, repeat twice to ensure chunking. AttributePathParams attributePathParams[1]; readPrepareParams.mpAttributePathParamsList = attributePathParams; - readPrepareParams.mAttributePathParamsListSize = ArraySize(attributePathParams); + readPrepareParams.mAttributePathParamsListSize = MATTER_ARRAY_SIZE(attributePathParams); attributePathParams[0].mEndpointId = kTestEndpointId; attributePathParams[0].mClusterId = Clusters::UnitTesting::Id; attributePathParams[0].mAttributeId = Clusters::UnitTesting::Attributes::Boolean::Id; @@ -3078,7 +3078,7 @@ TEST_F(TestRead, TestSubscribeAttributeDeniedNotExistPath) AttributePathParams attributePathParams[1]; readPrepareParams.mpAttributePathParamsList = attributePathParams; - readPrepareParams.mAttributePathParamsListSize = ArraySize(attributePathParams); + readPrepareParams.mAttributePathParamsListSize = MATTER_ARRAY_SIZE(attributePathParams); attributePathParams[0].mEndpointId = kRootEndpointId; // this cluster does NOT exist on the root endpoint attributePathParams[0].mClusterId = Clusters::UnitTesting::Id; attributePathParams[0].mAttributeId = Clusters::UnitTesting::Attributes::ListStructOctetString::Id; @@ -4330,7 +4330,7 @@ TEST_F(TestRead, TestReadHandler_TooManyPaths) // Needs to be larger than our plausible path pool. AttributePathParams attributePathParams[sTooLargePathCount]; readPrepareParams.mpAttributePathParamsList = attributePathParams; - readPrepareParams.mAttributePathParamsListSize = ArraySize(attributePathParams); + readPrepareParams.mAttributePathParamsListSize = MATTER_ARRAY_SIZE(attributePathParams); { MockInteractionModelApp delegate; @@ -4382,7 +4382,7 @@ TEST_F(TestRead, TestReadHandler_TwoParallelReadsSecondTooManyPaths) // Read full wildcard paths, repeat twice to ensure chunking. AttributePathParams attributePathParams1[2]; readPrepareParams1.mpAttributePathParamsList = attributePathParams1; - readPrepareParams1.mAttributePathParamsListSize = ArraySize(attributePathParams1); + readPrepareParams1.mAttributePathParamsListSize = MATTER_ARRAY_SIZE(attributePathParams1); CHIP_ERROR err = readClient1.SendRequest(readPrepareParams1); EXPECT_EQ(err, CHIP_NO_ERROR); @@ -4391,7 +4391,7 @@ TEST_F(TestRead, TestReadHandler_TwoParallelReadsSecondTooManyPaths) // Read full wildcard paths, repeat twice to ensure chunking. AttributePathParams attributePathParams2[sTooLargePathCount]; readPrepareParams2.mpAttributePathParamsList = attributePathParams2; - readPrepareParams2.mAttributePathParamsListSize = ArraySize(attributePathParams2); + readPrepareParams2.mAttributePathParamsListSize = MATTER_ARRAY_SIZE(attributePathParams2); err = readClient2.SendRequest(readPrepareParams2); EXPECT_EQ(err, CHIP_NO_ERROR); diff --git a/src/credentials/FabricTable.cpp b/src/credentials/FabricTable.cpp index 1c4001cefecebd..7e8ee4fd2e4cda 100644 --- a/src/credentials/FabricTable.cpp +++ b/src/credentials/FabricTable.cpp @@ -1391,7 +1391,7 @@ CHIP_ERROR FabricTable::ReadFabricInfo(TLV::ContiguousBufferTLVReader & reader) CHIP_ERROR err; while ((err = reader.Next()) == CHIP_NO_ERROR) { - if (mFabricCount >= ArraySize(mStates)) + if (mFabricCount >= MATTER_ARRAY_SIZE(mStates)) { // We have nowhere to deserialize this fabric info into. return CHIP_ERROR_NO_MEMORY; diff --git a/src/credentials/GroupDataProviderImpl.cpp b/src/credentials/GroupDataProviderImpl.cpp index 22a935fdb70494..3b9be9482b2587 100644 --- a/src/credentials/GroupDataProviderImpl.cpp +++ b/src/credentials/GroupDataProviderImpl.cpp @@ -1787,7 +1787,7 @@ CHIP_ERROR GroupDataProviderImpl::GetIpkKeySet(FabricIndex fabric_index, KeySet out_keyset.num_keys_used = keyset.keys_count; out_keyset.policy = keyset.policy; - for (size_t key_idx = 0; key_idx < ArraySize(out_keyset.epoch_keys); ++key_idx) + for (size_t key_idx = 0; key_idx < MATTER_ARRAY_SIZE(out_keyset.epoch_keys); ++key_idx) { out_keyset.epoch_keys[key_idx].Clear(); if (key_idx < keyset.keys_count) diff --git a/src/credentials/tests/CHIPCert_test_vectors.cpp b/src/credentials/tests/CHIPCert_test_vectors.cpp index ca9bd9556550c6..c3d55b716ed31f 100644 --- a/src/credentials/tests/CHIPCert_test_vectors.cpp +++ b/src/credentials/tests/CHIPCert_test_vectors.cpp @@ -56,7 +56,7 @@ namespace TestCerts { #define TEST_CERT_ENUM_REF_ENTRY(NAME) TestCert::k##NAME, extern const TestCert gTestCerts[] = { ENUMERATE_TEST_CERTS(TEST_CERT_ENUM_REF_ENTRY) }; -extern const size_t gNumTestCerts = ArraySize(gTestCerts); +extern const size_t gNumTestCerts = MATTER_ARRAY_SIZE(gTestCerts); #define TEST_CERT_SELECT_NAME(NAME) \ case TestCert::k##NAME: \ diff --git a/src/credentials/tests/TestChipCert.cpp b/src/credentials/tests/TestChipCert.cpp index 94d53c7ae1619e..40fd734dbce666 100644 --- a/src/credentials/tests/TestChipCert.cpp +++ b/src/credentials/tests/TestChipCert.cpp @@ -1165,9 +1165,9 @@ TEST_F(TestChipCert, TestChipCert_CertUsage) { 2, sDS, sSAandCA, CHIP_NO_ERROR }, }; // clang-format on - size_t sNumUsageTestCases = ArraySize(sUsageTestCases); + size_t sNumUsageTestCases = MATTER_ARRAY_SIZE(sUsageTestCases); - err = certSet.Init(certDataArray, ArraySize(certDataArray)); + err = certSet.Init(certDataArray, MATTER_ARRAY_SIZE(certDataArray)); EXPECT_EQ(err, CHIP_NO_ERROR); err = LoadTestCertSet01(certSet); diff --git a/src/credentials/tests/TestDeviceAttestationConstruction.cpp b/src/credentials/tests/TestDeviceAttestationConstruction.cpp index 8fc949ca29c999..346afae9a2a3c7 100644 --- a/src/credentials/tests/TestDeviceAttestationConstruction.cpp +++ b/src/credentials/tests/TestDeviceAttestationConstruction.cpp @@ -280,7 +280,7 @@ TEST_F(TestDeviceAttestationConstruction, TestAttestationElements_Deconstruction EXPECT_TRUE(attestationNonceDeconstructed.data_equal(ByteSpan(attestationNonceTestVector))); EXPECT_EQ(timestampTestVector, timestampDeconstructed); EXPECT_TRUE(firmwareInfoDeconstructed.empty()); - EXPECT_EQ(ArraySize(vendorReservedArrayTestVector), vendorReserved.GetNumberOfElements()); + EXPECT_EQ(MATTER_ARRAY_SIZE(vendorReservedArrayTestVector), vendorReserved.GetNumberOfElements()); struct VendorReservedElement element; while (vendorReserved.GetNextVendorReservedElement(element) == CHIP_NO_ERROR) @@ -363,7 +363,7 @@ TEST_F(TestDeviceAttestationConstruction, TestVendorReservedData) DeviceAttestationVendorReservedConstructor vendorReserved(vendorReservedArray, 6); size_t i; uint8_t strings[6][50]; - for (i = 0; i < ArraySize(inputArray); i++) + for (i = 0; i < MATTER_ARRAY_SIZE(inputArray); i++) { snprintf(reinterpret_cast(strings[i]), sizeof(strings[i]), "Vendor Reserved Data #%d", (int) i); // for debugging use @@ -383,12 +383,12 @@ TEST_F(TestDeviceAttestationConstruction, TestVendorReservedData) EXPECT_TRUE(element); EXPECT_TRUE(element = vendorReserved.Next()); - for (i = 0; element && i < ArraySize(desiredOrder); element = vendorReserved.Next(), i++) + for (i = 0; element && i < MATTER_ARRAY_SIZE(desiredOrder); element = vendorReserved.Next(), i++) { EXPECT_TRUE(element->vendorId == desiredOrder[i]->vendorId && element->profileNum == desiredOrder[i]->profileNum && element->tagNum == desiredOrder[i]->tagNum); } - EXPECT_EQ(i, ArraySize(desiredOrder)); // check if previous loop matched for every array entry. + EXPECT_EQ(i, MATTER_ARRAY_SIZE(desiredOrder)); // check if previous loop matched for every array entry. // add another element, it should fail uint8_t testByteSpan[] = { 0x1, 0x2, 0x3 }; @@ -469,7 +469,7 @@ TEST_F(TestDeviceAttestationConstruction, TestAttestationElements_Deconstruction EXPECT_TRUE(attestationNonceDeconstructed.data_equal(ByteSpan(attestationNonceTestVector))); EXPECT_EQ(timestampTestVector, timestampDeconstructed); EXPECT_TRUE(firmwareInfoDeconstructed.data_equal(ByteSpan(firmwareInfoTestVector))); - EXPECT_EQ(ArraySize(vendorReservedArrayTestVector), vendorReserved.GetNumberOfElements()); + EXPECT_EQ(MATTER_ARRAY_SIZE(vendorReservedArrayTestVector), vendorReserved.GetNumberOfElements()); struct VendorReservedElement element; size_t elementsSeen = 0; @@ -492,7 +492,7 @@ TEST_F(TestDeviceAttestationConstruction, TestAttestationElements_Deconstruction break; } } - EXPECT_EQ(elementsSeen, ArraySize(vendorReservedArrayTestVector)); + EXPECT_EQ(elementsSeen, MATTER_ARRAY_SIZE(vendorReservedArrayTestVector)); } TEST_F(TestDeviceAttestationConstruction, TestAttestationElements_DeconstructionUnordered) diff --git a/src/crypto/tests/TestChipCryptoPAL.cpp b/src/crypto/tests/TestChipCryptoPAL.cpp index b9bf84493b4192..1713b3cfb85961 100644 --- a/src/crypto/tests/TestChipCryptoPAL.cpp +++ b/src/crypto/tests/TestChipCryptoPAL.cpp @@ -325,7 +325,7 @@ TEST_F(TestChipCryptoPAL, TestAES_CTR_128CryptTestVectors) TEST_F(TestChipCryptoPAL, TestAES_CCM_128EncryptTestVectors) { HeapChecker heapChecker; - int numOfTestVectors = ArraySize(ccm_128_test_vectors); + int numOfTestVectors = MATTER_ARRAY_SIZE(ccm_128_test_vectors); int numOfTestsRan = 0; for (int vectorIndex = 0; vectorIndex < numOfTestVectors; vectorIndex++) { @@ -369,7 +369,7 @@ TEST_F(TestChipCryptoPAL, TestAES_CCM_128EncryptTestVectors) TEST_F(TestChipCryptoPAL, TestAES_CCM_128DecryptTestVectors) { HeapChecker heapChecker; - int numOfTestVectors = ArraySize(ccm_128_test_vectors); + int numOfTestVectors = MATTER_ARRAY_SIZE(ccm_128_test_vectors); int numOfTestsRan = 0; for (int vectorIndex = 0; vectorIndex < numOfTestVectors; vectorIndex++) { @@ -404,7 +404,7 @@ TEST_F(TestChipCryptoPAL, TestAES_CCM_128DecryptTestVectors) TEST_F(TestChipCryptoPAL, TestAES_CCM_128EncryptInvalidNonceLen) { HeapChecker heapChecker; - int numOfTestVectors = ArraySize(ccm_128_test_vectors); + int numOfTestVectors = MATTER_ARRAY_SIZE(ccm_128_test_vectors); int numOfTestsRan = 0; for (int vectorIndex = 0; vectorIndex < numOfTestVectors; vectorIndex++) { @@ -433,7 +433,7 @@ TEST_F(TestChipCryptoPAL, TestAES_CCM_128EncryptInvalidNonceLen) TEST_F(TestChipCryptoPAL, TestAES_CCM_128EncryptInvalidTagLen) { HeapChecker heapChecker; - int numOfTestVectors = ArraySize(ccm_128_test_vectors); + int numOfTestVectors = MATTER_ARRAY_SIZE(ccm_128_test_vectors); int numOfTestsRan = 0; for (int vectorIndex = 0; vectorIndex < numOfTestVectors; vectorIndex++) { @@ -462,7 +462,7 @@ TEST_F(TestChipCryptoPAL, TestAES_CCM_128EncryptInvalidTagLen) TEST_F(TestChipCryptoPAL, TestAES_CCM_128DecryptInvalidNonceLen) { HeapChecker heapChecker; - int numOfTestVectors = ArraySize(ccm_128_test_vectors); + int numOfTestVectors = MATTER_ARRAY_SIZE(ccm_128_test_vectors); int numOfTestsRan = 0; for (int vectorIndex = 0; vectorIndex < numOfTestVectors; vectorIndex++) { @@ -563,7 +563,7 @@ TEST_F(TestChipCryptoPAL, TestAsn1Conversions) static_assert(sizeof(kDerSigConvDerCase4) == (sizeof(kDerSigConvRawCase4) + chip::Crypto::kMax_ECDSA_X9Dot62_Asn1_Overhead), "kDerSigConvDerCase4 must have worst case overhead"); - int numOfTestVectors = ArraySize(kDerSigConvTestVectors); + int numOfTestVectors = MATTER_ARRAY_SIZE(kDerSigConvTestVectors); for (int vectorIndex = 0; vectorIndex < numOfTestVectors; vectorIndex++) { const der_sig_conv_vector * vector = &kDerSigConvTestVectors[vectorIndex]; @@ -601,7 +601,7 @@ TEST_F(TestChipCryptoPAL, TestAsn1Conversions) TEST_F(TestChipCryptoPAL, TestRawIntegerToDerValidCases) { HeapChecker heapChecker; - int numOfTestCases = ArraySize(kRawIntegerToDerVectors); + int numOfTestCases = MATTER_ARRAY_SIZE(kRawIntegerToDerVectors); for (int testIdx = 0; testIdx < numOfTestCases; testIdx++) { @@ -810,7 +810,7 @@ TEST_F(TestChipCryptoPAL, TestReadDerLengthInvalidCases) TEST_F(TestChipCryptoPAL, TestHash_SHA256) { HeapChecker heapChecker; - unsigned int numOfTestCases = ArraySize(hash_sha256_test_vectors); + unsigned int numOfTestCases = MATTER_ARRAY_SIZE(hash_sha256_test_vectors); unsigned int numOfTestsExecuted = 0; for (numOfTestsExecuted = 0; numOfTestsExecuted < numOfTestCases; numOfTestsExecuted++) @@ -821,13 +821,13 @@ TEST_F(TestChipCryptoPAL, TestHash_SHA256) bool success = memcmp(v.hash, out_buffer, sizeof(out_buffer)) == 0; EXPECT_TRUE(success); } - EXPECT_EQ(numOfTestsExecuted, ArraySize(hash_sha256_test_vectors)); + EXPECT_EQ(numOfTestsExecuted, MATTER_ARRAY_SIZE(hash_sha256_test_vectors)); } TEST_F(TestChipCryptoPAL, TestHash_SHA256_Stream) { HeapChecker heapChecker; - unsigned int numOfTestCases = ArraySize(hash_sha256_test_vectors); + unsigned int numOfTestCases = MATTER_ARRAY_SIZE(hash_sha256_test_vectors); unsigned int numOfTestsExecuted = 0; CHIP_ERROR error = CHIP_NO_ERROR; @@ -867,7 +867,7 @@ TEST_F(TestChipCryptoPAL, TestHash_SHA256_Stream) EXPECT_TRUE(success); } - EXPECT_EQ(numOfTestsExecuted, ArraySize(hash_sha256_test_vectors)); + EXPECT_EQ(numOfTestsExecuted, MATTER_ARRAY_SIZE(hash_sha256_test_vectors)); // Test partial digests uint8_t source_buf[2 * kSHA256_Hash_Length]; @@ -955,7 +955,7 @@ TEST_F(TestChipCryptoPAL, TestHash_SHA256_Stream) TEST_F(TestChipCryptoPAL, TestHMAC_SHA256_RawKey) { HeapChecker heapChecker; - int numOfTestCases = ArraySize(hmac_sha256_test_vectors_raw_key); + int numOfTestCases = MATTER_ARRAY_SIZE(hmac_sha256_test_vectors_raw_key); int numOfTestsExecuted = 0; TestHMAC_sha mHMAC; @@ -977,7 +977,7 @@ TEST_F(TestChipCryptoPAL, TestHMAC_SHA256_RawKey) TEST_F(TestChipCryptoPAL, TestHMAC_SHA256_KeyHandle) { HeapChecker heapChecker; - int numOfTestCases = ArraySize(hmac_sha256_test_vectors_key_handle); + int numOfTestCases = MATTER_ARRAY_SIZE(hmac_sha256_test_vectors_key_handle); int numOfTestsExecuted = 0; TestHMAC_sha mHMAC; @@ -1009,7 +1009,7 @@ TEST_F(TestChipCryptoPAL, TestHMAC_SHA256_KeyHandle) TEST_F(TestChipCryptoPAL, TestHKDF_SHA256) { HeapChecker heapChecker; - int numOfTestCases = ArraySize(hkdf_sha256_test_vectors); + int numOfTestCases = MATTER_ARRAY_SIZE(hkdf_sha256_test_vectors); int numOfTestsExecuted = 0; TestHKDF_sha mHKDF; @@ -1299,7 +1299,7 @@ TEST_F(TestChipCryptoPAL, TestAddEntropySources) TEST_F(TestChipCryptoPAL, TestPBKDF2_SHA256_TestVectors) { HeapChecker heapChecker; - int numOfTestVectors = ArraySize(pbkdf2_sha256_test_vectors); + int numOfTestVectors = MATTER_ARRAY_SIZE(pbkdf2_sha256_test_vectors); int numOfTestsRan = 0; TestPBKDF2_sha256 pbkdf1; for (int vectorIndex = 0; vectorIndex < numOfTestVectors; vectorIndex++) @@ -1611,7 +1611,7 @@ TEST_F(TestChipCryptoPAL, TestSPAKE2P_spake2p_FEMul) HeapChecker heapChecker; uint8_t fe_out[kMAX_FE_Length]; - int numOfTestVectors = ArraySize(fe_mul_tvs); + int numOfTestVectors = MATTER_ARRAY_SIZE(fe_mul_tvs); int numOfTestsRan = 0; for (int vectorIndex = 0; vectorIndex < numOfTestVectors; vectorIndex++) { @@ -1646,7 +1646,7 @@ TEST_F(TestChipCryptoPAL, TestSPAKE2P_spake2p_FELoadWrite) HeapChecker heapChecker; uint8_t fe_out[kMAX_FE_Length]; - int numOfTestVectors = ArraySize(fe_rw_tvs); + int numOfTestVectors = MATTER_ARRAY_SIZE(fe_rw_tvs); int numOfTestsRan = 0; for (int vectorIndex = 0; vectorIndex < numOfTestVectors; vectorIndex++) { @@ -1676,7 +1676,7 @@ TEST_F(TestChipCryptoPAL, TestSPAKE2P_spake2p_Mac) uint8_t mac[kMAX_Hash_Length]; MutableByteSpan mac_span{ mac }; - int numOfTestVectors = ArraySize(hmac_tvs); + int numOfTestVectors = MATTER_ARRAY_SIZE(hmac_tvs); int numOfTestsRan = 0; for (int vectorIndex = 0; vectorIndex < numOfTestVectors; vectorIndex++) { @@ -1707,7 +1707,7 @@ TEST_F(TestChipCryptoPAL, TestSPAKE2P_spake2p_PointMul) uint8_t output[kMAX_Point_Length]; size_t out_len = sizeof(output); - int numOfTestVectors = ArraySize(point_mul_tvs); + int numOfTestVectors = MATTER_ARRAY_SIZE(point_mul_tvs); int numOfTestsRan = 0; for (int vectorIndex = 0; vectorIndex < numOfTestVectors; vectorIndex++) { @@ -1745,7 +1745,7 @@ TEST_F(TestChipCryptoPAL, TestSPAKE2P_spake2p_PointMulAdd) uint8_t output[kMAX_Point_Length]; size_t out_len = sizeof(output); - int numOfTestVectors = ArraySize(point_muladd_tvs); + int numOfTestVectors = MATTER_ARRAY_SIZE(point_muladd_tvs); int numOfTestsRan = 0; for (int vectorIndex = 0; vectorIndex < numOfTestVectors; vectorIndex++) { @@ -1789,7 +1789,7 @@ TEST_F(TestChipCryptoPAL, TestSPAKE2P_spake2p_PointLoadWrite) uint8_t output[kMAX_Point_Length]; size_t out_len = sizeof(output); - int numOfTestVectors = ArraySize(point_rw_tvs); + int numOfTestVectors = MATTER_ARRAY_SIZE(point_rw_tvs); int numOfTestsRan = 0; for (int vectorIndex = 0; vectorIndex < numOfTestVectors; vectorIndex++) { @@ -1818,7 +1818,7 @@ TEST_F(TestChipCryptoPAL, TestSPAKE2P_spake2p_PointLoadWrite) TEST_F(TestChipCryptoPAL, TestSPAKE2P_spake2p_PointIsValid) { HeapChecker heapChecker; - int numOfTestVectors = ArraySize(point_valid_tvs); + int numOfTestVectors = MATTER_ARRAY_SIZE(point_valid_tvs); int numOfTestsRan = 0; for (int vectorIndex = 0; vectorIndex < numOfTestVectors; vectorIndex++) { @@ -1882,7 +1882,7 @@ TEST_F(TestChipCryptoPAL, TestSPAKE2P_RFC) uint8_t Vverifier[kMAX_Hash_Length]; size_t Vverifier_len = sizeof(Vverifier); - int numOfTestVectors = ArraySize(rfc_tvs); + int numOfTestVectors = MATTER_ARRAY_SIZE(rfc_tvs); int numOfTestsRan = 0; // static_assert(sizeof(Spake2p_Context) < 1024, "Allocate more bytes for Spake2p Context"); // printf("Sizeof spake2pcontext %lu\n", sizeof(Spake2p_Context)); @@ -2878,14 +2878,14 @@ TEST_F(TestChipCryptoPAL, TestX509_ReplaceCertIfResignedCertFound) const TestCase kTestCases[] = { { sTestCert_PAI_FFF2_8001_Cert, nullptr, 5, sTestCert_PAI_FFF2_8001_Cert }, { sTestCert_PAI_FFF2_8001_Cert, TestCandidateCertsList3, 0, sTestCert_PAI_FFF2_8001_Cert }, - { sTestCert_PAI_FFF1_8000_Cert, TestCandidateCertsList1, ArraySize(TestCandidateCertsList1), sTestCert_PAI_FFF1_8000_Cert }, - { sTestCert_PAI_FFF2_8001_Cert, TestCandidateCertsList2, ArraySize(TestCandidateCertsList2), sTestCert_PAI_FFF2_8001_Cert }, - { sTestCert_PAI_FFF2_8001_Cert, TestCandidateCertsList3, ArraySize(TestCandidateCertsList3), sTestCert_PAI_FFF2_8001_Resigned_Cert }, - { sTestCert_PAI_FFF2_8001_Cert, TestCandidateCertsList4, ArraySize(TestCandidateCertsList4), sTestCert_PAI_FFF2_8001_Resigned_Cert }, - { sTestCert_PAI_FFF2_8001_Cert, TestCandidateCertsList5, ArraySize(TestCandidateCertsList5), sTestCert_PAI_FFF2_8001_Cert }, - { sTestCert_PAI_FFF2_8001_Cert, TestCandidateCertsList6, ArraySize(TestCandidateCertsList6), sTestCert_PAI_FFF2_8001_Cert }, - { sTestCert_PAI_FFF2_8001_Cert, TestCandidateCertsList7, ArraySize(TestCandidateCertsList7), sTestCert_PAI_FFF2_8001_Resigned_Cert }, - { sTestCert_PAI_FFF2_NoPID_Cert, TestCandidateCertsList7, ArraySize(TestCandidateCertsList7), sTestCert_PAI_FFF2_NoPID_Resigned_Cert }, + { sTestCert_PAI_FFF1_8000_Cert, TestCandidateCertsList1, MATTER_ARRAY_SIZE(TestCandidateCertsList1), sTestCert_PAI_FFF1_8000_Cert }, + { sTestCert_PAI_FFF2_8001_Cert, TestCandidateCertsList2, MATTER_ARRAY_SIZE(TestCandidateCertsList2), sTestCert_PAI_FFF2_8001_Cert }, + { sTestCert_PAI_FFF2_8001_Cert, TestCandidateCertsList3, MATTER_ARRAY_SIZE(TestCandidateCertsList3), sTestCert_PAI_FFF2_8001_Resigned_Cert }, + { sTestCert_PAI_FFF2_8001_Cert, TestCandidateCertsList4, MATTER_ARRAY_SIZE(TestCandidateCertsList4), sTestCert_PAI_FFF2_8001_Resigned_Cert }, + { sTestCert_PAI_FFF2_8001_Cert, TestCandidateCertsList5, MATTER_ARRAY_SIZE(TestCandidateCertsList5), sTestCert_PAI_FFF2_8001_Cert }, + { sTestCert_PAI_FFF2_8001_Cert, TestCandidateCertsList6, MATTER_ARRAY_SIZE(TestCandidateCertsList6), sTestCert_PAI_FFF2_8001_Cert }, + { sTestCert_PAI_FFF2_8001_Cert, TestCandidateCertsList7, MATTER_ARRAY_SIZE(TestCandidateCertsList7), sTestCert_PAI_FFF2_8001_Resigned_Cert }, + { sTestCert_PAI_FFF2_NoPID_Cert, TestCandidateCertsList7, MATTER_ARRAY_SIZE(TestCandidateCertsList7), sTestCert_PAI_FFF2_NoPID_Resigned_Cert }, }; // clang-format on @@ -2902,16 +2902,16 @@ TEST_F(TestChipCryptoPAL, TestX509_ReplaceCertIfResignedCertFound) // Error case: invalid input argument for referenceCertificate { ByteSpan outCert; - CHIP_ERROR result = - ReplaceCertIfResignedCertFound(ByteSpan(), TestCandidateCertsList7, ArraySize(TestCandidateCertsList7), outCert); + CHIP_ERROR result = ReplaceCertIfResignedCertFound(ByteSpan(), TestCandidateCertsList7, + MATTER_ARRAY_SIZE(TestCandidateCertsList7), outCert); EXPECT_EQ(result, CHIP_ERROR_INVALID_ARGUMENT); } // Error case: invalid input argument for one of the certificates in the candidateCertificates list { ByteSpan outCert; - CHIP_ERROR result = - ReplaceCertIfResignedCertFound(ByteSpan(), TestCandidateCertsList8, ArraySize(TestCandidateCertsList8), outCert); + CHIP_ERROR result = ReplaceCertIfResignedCertFound(ByteSpan(), TestCandidateCertsList8, + MATTER_ARRAY_SIZE(TestCandidateCertsList8), outCert); EXPECT_EQ(result, CHIP_ERROR_INVALID_ARGUMENT); } } diff --git a/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerCluster.mm b/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerCluster.mm index 2927efa181b32c..fe72c4395dbfaa 100644 --- a/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerCluster.mm +++ b/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerCluster.mm @@ -287,7 +287,7 @@ - (BOOL)associateWithController:(nullable MTRDeviceController *)controller } if (needsDescriptorAttributes) { - attributeCount += ArraySize(sDescriptorAttributesMetadata); + attributeCount += MATTER_ARRAY_SIZE(sDescriptorAttributesMetadata); } // And add one for ClusterRevision diff --git a/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerEndpoint.mm b/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerEndpoint.mm index e30061a0ed79f9..46d006e21fe1dc 100644 --- a/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerEndpoint.mm +++ b/src/darwin/Framework/CHIP/ServerEndpoint/MTRServerEndpoint.mm @@ -273,7 +273,7 @@ - (BOOL)finishAssociationWithController:(nullable MTRDeviceController *)controll metadata.clusterId = MTRClusterIDTypeDescriptorID; metadata.attributes = sDescriptorAttributesMetadata; - metadata.attributeCount = ArraySize(sDescriptorAttributesMetadata); + metadata.attributeCount = MATTER_ARRAY_SIZE(sDescriptorAttributesMetadata); metadata.clusterSize = 0; // All our attributes are external. diff --git a/src/data-model-providers/codegen/CodegenDataModelProvider.cpp b/src/data-model-providers/codegen/CodegenDataModelProvider.cpp index 7fd6d241704b0e..6913214ac803cc 100644 --- a/src/data-model-providers/codegen/CodegenDataModelProvider.cpp +++ b/src/data-model-providers/codegen/CodegenDataModelProvider.cpp @@ -274,7 +274,7 @@ CHIP_ERROR CodegenDataModelProvider::Attributes(const ConcreteClusterPath & path // // We have Attributes from ember + global attributes that are NOT in ember metadata. // We have to report them all - constexpr size_t kGlobalAttributeNotInMetadataCount = ArraySize(GlobalAttributesNotInMetadata); + constexpr size_t kGlobalAttributeNotInMetadataCount = MATTER_ARRAY_SIZE(GlobalAttributesNotInMetadata); ReturnErrorOnFailure(builder.EnsureAppendCapacity(cluster->attributeCount + kGlobalAttributeNotInMetadataCount)); diff --git a/src/include/platform/internal/GenericPlatformManagerImpl_FreeRTOS.ipp b/src/include/platform/internal/GenericPlatformManagerImpl_FreeRTOS.ipp index 1230a91517bc69..d88454f0e2ef62 100644 --- a/src/include/platform/internal/GenericPlatformManagerImpl_FreeRTOS.ipp +++ b/src/include/platform/internal/GenericPlatformManagerImpl_FreeRTOS.ipp @@ -253,8 +253,8 @@ template CHIP_ERROR GenericPlatformManagerImpl_FreeRTOS::_StartEventLoopTask(void) { #if defined(CHIP_CONFIG_FREERTOS_USE_STATIC_TASK) && CHIP_CONFIG_FREERTOS_USE_STATIC_TASK - mEventLoopTask = xTaskCreateStatic(EventLoopTaskMain, CHIP_DEVICE_CONFIG_CHIP_TASK_NAME, ArraySize(mEventLoopStack), this, - CHIP_DEVICE_CONFIG_CHIP_TASK_PRIORITY, mEventLoopStack, &mEventLoopTaskStruct); + mEventLoopTask = xTaskCreateStatic(EventLoopTaskMain, CHIP_DEVICE_CONFIG_CHIP_TASK_NAME, MATTER_ARRAY_SIZE(mEventLoopStack), + this, CHIP_DEVICE_CONFIG_CHIP_TASK_PRIORITY, mEventLoopStack, &mEventLoopTaskStruct); #else xTaskCreate(EventLoopTaskMain, CHIP_DEVICE_CONFIG_CHIP_TASK_NAME, CHIP_DEVICE_CONFIG_CHIP_TASK_STACK_SIZE / sizeof(StackType_t), this, CHIP_DEVICE_CONFIG_CHIP_TASK_PRIORITY, &mEventLoopTask); @@ -329,9 +329,9 @@ CHIP_ERROR GenericPlatformManagerImpl_FreeRTOS::_StartBackgroundEvent { #if defined(CHIP_DEVICE_CONFIG_ENABLE_BG_EVENT_PROCESSING) && CHIP_DEVICE_CONFIG_ENABLE_BG_EVENT_PROCESSING #if defined(CHIP_CONFIG_FREERTOS_USE_STATIC_TASK) && CHIP_CONFIG_FREERTOS_USE_STATIC_TASK - mBackgroundEventLoopTask = - xTaskCreateStatic(BackgroundEventLoopTaskMain, CHIP_DEVICE_CONFIG_BG_TASK_NAME, ArraySize(mBackgroundEventLoopStack), this, - CHIP_DEVICE_CONFIG_BG_TASK_PRIORITY, mBackgroundEventLoopStack, &mBackgroundEventLoopTaskStruct); + mBackgroundEventLoopTask = xTaskCreateStatic( + BackgroundEventLoopTaskMain, CHIP_DEVICE_CONFIG_BG_TASK_NAME, MATTER_ARRAY_SIZE(mBackgroundEventLoopStack), this, + CHIP_DEVICE_CONFIG_BG_TASK_PRIORITY, mBackgroundEventLoopStack, &mBackgroundEventLoopTaskStruct); #else xTaskCreate(BackgroundEventLoopTaskMain, CHIP_DEVICE_CONFIG_BG_TASK_NAME, CHIP_DEVICE_CONFIG_BG_TASK_STACK_SIZE / sizeof(StackType_t), this, CHIP_DEVICE_CONFIG_BG_TASK_PRIORITY, diff --git a/src/lib/dnssd/Discovery_ImplPlatform.cpp b/src/lib/dnssd/Discovery_ImplPlatform.cpp index e83a88915f2ea4..0ecf30640d90a5 100644 --- a/src/lib/dnssd/Discovery_ImplPlatform.cpp +++ b/src/lib/dnssd/Discovery_ImplPlatform.cpp @@ -353,7 +353,7 @@ void DiscoveryImplPlatform::HandleNodeIdResolve(void * context, DnssdService * r size_t addressesFound = 0; for (auto & ip : addresses) { - if (addressesFound == ArraySize(nodeData.resolutionData.ipAddress)) + if (addressesFound == MATTER_ARRAY_SIZE(nodeData.resolutionData.ipAddress)) { // Out of space. ChipLogProgress(Discovery, "Can't add more IPs to ResolvedNodeData"); @@ -396,7 +396,7 @@ void DnssdService::ToDiscoveredCommissionNodeData(const Span & size_t addressesFound = 0; for (auto & ip : addresses) { - if (addressesFound == ArraySize(discoveredData.ipAddress)) + if (addressesFound == MATTER_ARRAY_SIZE(discoveredData.ipAddress)) { // Out of space. ChipLogProgress(Discovery, "Can't add more IPs to DiscoveredNodeData"); diff --git a/src/lib/dnssd/IncrementalResolve.cpp b/src/lib/dnssd/IncrementalResolve.cpp index 867b1a8dcddb6c..1838e126d00e69 100644 --- a/src/lib/dnssd/IncrementalResolve.cpp +++ b/src/lib/dnssd/IncrementalResolve.cpp @@ -320,7 +320,7 @@ CHIP_ERROR IncrementalResolver::OnTxtRecord(const ResourceData & data, BytesRang CHIP_ERROR IncrementalResolver::OnIpAddress(Inet::InterfaceId interface, const Inet::IPAddress & addr) { - if (mCommonResolutionData.numIPs >= ArraySize(mCommonResolutionData.ipAddress)) + if (mCommonResolutionData.numIPs >= MATTER_ARRAY_SIZE(mCommonResolutionData.ipAddress)) { return CHIP_ERROR_NO_MEMORY; } diff --git a/src/lib/shell/MainLoopCYW30739.cpp b/src/lib/shell/MainLoopCYW30739.cpp index 920e33f666ee1d..554a6eb807dde0 100644 --- a/src/lib/shell/MainLoopCYW30739.cpp +++ b/src/lib/shell/MainLoopCYW30739.cpp @@ -157,7 +157,7 @@ void ProcessInput(intptr_t args) break; default: - if (sInputLength < ArraySize(sInputBuffer) - 1) + if (sInputLength < MATTER_ARRAY_SIZE(sInputBuffer) - 1) { sInputBuffer[sInputLength++] = input[i]; } diff --git a/src/lib/shell/MainLoopMW320.cpp b/src/lib/shell/MainLoopMW320.cpp index 8445587b40ccae..0e0e382e28f5f1 100644 --- a/src/lib/shell/MainLoopMW320.cpp +++ b/src/lib/shell/MainLoopMW320.cpp @@ -257,7 +257,7 @@ static void RegisterMetaCommands(void) std::atexit(AtExitShell); - Engine::Root().RegisterCommands(sCmds, ArraySize(sCmds)); + Engine::Root().RegisterCommands(sCmds, MATTER_ARRAY_SIZE(sCmds)); } // ---- diff --git a/src/lib/shell/commands/BLE.cpp b/src/lib/shell/commands/BLE.cpp index 9647f7fc5c6f3e..e61f8988e0f50c 100644 --- a/src/lib/shell/commands/BLE.cpp +++ b/src/lib/shell/commands/BLE.cpp @@ -86,7 +86,8 @@ void RegisterBLECommands() { &BLEAdvertiseHandler, "adv", "Manage BLE advertising. Usage: ble adv " }, }; - static constexpr Command bleCommand = { &SubShellCommand, "ble", "Bluetooth LE commands" }; + static constexpr Command bleCommand = { &SubShellCommand, "ble", + "Bluetooth LE commands" }; Engine::Root().RegisterCommands(&bleCommand, 1); } diff --git a/src/lib/shell/commands/Device.cpp b/src/lib/shell/commands/Device.cpp index de11f4d2e7a25d..94607d6599fd96 100644 --- a/src/lib/shell/commands/Device.cpp +++ b/src/lib/shell/commands/Device.cpp @@ -37,7 +37,7 @@ void RegisterDeviceCommands() { &FactoryResetHandler, "factoryreset", "Performs device factory reset" }, }; - static constexpr Command deviceComand = { &SubShellCommand, "device", + static constexpr Command deviceComand = { &SubShellCommand, "device", "Device management commands" }; Engine::Root().RegisterCommands(&deviceComand, 1); diff --git a/src/lib/shell/commands/Dns.cpp b/src/lib/shell/commands/Dns.cpp index 917f94f849d865..8ea918e0c022a5 100644 --- a/src/lib/shell/commands/Dns.cpp +++ b/src/lib/shell/commands/Dns.cpp @@ -297,10 +297,11 @@ void RegisterDnsCommands() static constexpr Command subCommands[] = { { &ResolveHandler, "resolve", "Resolve Matter operational service. Usage: dns resolve fabricid nodeid (e.g. dns resolve 5544332211 1)" }, - { &SubShellCommand, "browse", "Browse Matter DNS services" }, + { &SubShellCommand, "browse", "Browse Matter DNS services" }, }; - static constexpr Command dnsCommand = { &SubShellCommand, "dns", "DNS client commands" }; + static constexpr Command dnsCommand = { &SubShellCommand, "dns", + "DNS client commands" }; Engine::Root().RegisterCommands(&dnsCommand, 1); } diff --git a/src/lib/shell/commands/Meta.cpp b/src/lib/shell/commands/Meta.cpp index 7bf188de763e43..9a0f8a399542ce 100644 --- a/src/lib/shell/commands/Meta.cpp +++ b/src/lib/shell/commands/Meta.cpp @@ -71,7 +71,7 @@ void RegisterMetaCommands() std::atexit(AtExitShell); - Engine::Root().RegisterCommands(sCmds, ArraySize(sCmds)); + Engine::Root().RegisterCommands(sCmds, MATTER_ARRAY_SIZE(sCmds)); } } // namespace Shell diff --git a/src/lib/shell/commands/Ota.cpp b/src/lib/shell/commands/Ota.cpp index 2be0619151e2d0..484602312801df 100644 --- a/src/lib/shell/commands/Ota.cpp +++ b/src/lib/shell/commands/Ota.cpp @@ -102,7 +102,7 @@ void RegisterOtaCommands() { &StateHandler, "state", "Get current image update state" }, { &ProgressHandler, "progress", "Get current image update progress" } }; - static constexpr Command otaCommand = { &SubShellCommand, "ota", "OTA commands" }; + static constexpr Command otaCommand = { &SubShellCommand, "ota", "OTA commands" }; Engine::Root().RegisterCommands(&otaCommand, 1); } diff --git a/src/lib/shell/commands/Stat.cpp b/src/lib/shell/commands/Stat.cpp index cf1799c8a71db8..8b4c7446ea5f9e 100644 --- a/src/lib/shell/commands/Stat.cpp +++ b/src/lib/shell/commands/Stat.cpp @@ -96,7 +96,8 @@ void RegisterStatCommands() { &StatResetHandler, "reset", "Reset peak usage of system resources" }, }; - static constexpr Command statCommand = { &SubShellCommand, "stat", "Statistics commands" }; + static constexpr Command statCommand = { &SubShellCommand, "stat", + "Statistics commands" }; Engine::Root().RegisterCommands(&statCommand, 1); } diff --git a/src/lib/shell/commands/WiFi.cpp b/src/lib/shell/commands/WiFi.cpp index f2076a72decdba..98fdf27422873e 100644 --- a/src/lib/shell/commands/WiFi.cpp +++ b/src/lib/shell/commands/WiFi.cpp @@ -154,7 +154,8 @@ void RegisterWiFiCommands() { &WiFiDisconnectHandler, "disconnect", "Disconnect device from AP. Usage: wifi disconnect" }, }; - static constexpr Command wifiCommand = { &SubShellCommand, "wifi", "Wi-Fi commands" }; + static constexpr Command wifiCommand = { &SubShellCommand, "wifi", + "Wi-Fi commands" }; Engine::Root().RegisterCommands(&wifiCommand, 1); } diff --git a/src/lib/shell/tests/TestShellStreamerStdio.cpp b/src/lib/shell/tests/TestShellStreamerStdio.cpp index b71ebaf80ae50d..91ff5cb2d3b662 100644 --- a/src/lib/shell/tests/TestShellStreamerStdio.cpp +++ b/src/lib/shell/tests/TestShellStreamerStdio.cpp @@ -50,7 +50,7 @@ static const struct test_streamer_vector test_vector_streamer_out[] = { TEST(TestShellStreamerStdio, TestStreamer_Output) { - int numOfTestVectors = ArraySize(test_vector_streamer_out); + int numOfTestVectors = MATTER_ARRAY_SIZE(test_vector_streamer_out); int numOfTestsRan = 0; const struct test_streamer_vector * test_params; diff --git a/src/lib/shell/tests/TestShellTokenizeLine.cpp b/src/lib/shell/tests/TestShellTokenizeLine.cpp index 64bb301dc52141..ae1420192c1e24 100644 --- a/src/lib/shell/tests/TestShellTokenizeLine.cpp +++ b/src/lib/shell/tests/TestShellTokenizeLine.cpp @@ -101,7 +101,7 @@ static const struct test_shell_vector test_vector_shell_tokenizer[] = { TEST(TestShellTokenizeLine, TestShell_Tokenizer) { - int numOfTestVectors = ArraySize(test_vector_shell_tokenizer); + int numOfTestVectors = MATTER_ARRAY_SIZE(test_vector_shell_tokenizer); int numOfTestsRan = 0; const struct test_shell_vector * test_params; diff --git a/src/lib/support/CodeUtils.h b/src/lib/support/CodeUtils.h index d96112d88586e8..931ed813f31cbf 100644 --- a/src/lib/support/CodeUtils.h +++ b/src/lib/support/CodeUtils.h @@ -678,7 +678,7 @@ inline void chipDie(void) #endif /** - * @def ArraySize(aArray) + * @def MATTER_ARRAY_SIZE(aArray) * * @brief * Returns the size of an array in number of elements. @@ -687,16 +687,18 @@ inline void chipDie(void) * * @code * int numbers[10]; - * SortNumbers(numbers, ArraySize(numbers)); + * SortNumbers(numbers, MATTER_ARRAY_SIZE(numbers)); * @endcode * * @return The size of an array in number of elements. * - * @note Clever template-based solutions seem to fail when ArraySize is used + * @note Clever template-based solutions seem to fail when MATTER_ARRAY_SIZE is used * with a variable-length array argument, so we just do the C-compatible * thing in C++ as well. */ -#define ArraySize(a) (sizeof(a) / sizeof((a)[0])) +#ifndef MATTER_ARRAY_SIZE +#define MATTER_ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) +#endif /** * @brief Ensures that if `str` is NULL, a non-null `default_str_value` is provided diff --git a/src/lib/support/jsontlv/TlvJson.cpp b/src/lib/support/jsontlv/TlvJson.cpp index e38c71bf88111e..49e56422e914b4 100644 --- a/src/lib/support/jsontlv/TlvJson.cpp +++ b/src/lib/support/jsontlv/TlvJson.cpp @@ -68,7 +68,7 @@ struct KeyContext static constexpr uint16_t kMaxStringLen = 1280; constexpr char kBase64Header[] = "base64:"; -constexpr size_t kBase64HeaderLen = ArraySize(kBase64Header) - 1; +constexpr size_t kBase64HeaderLen = MATTER_ARRAY_SIZE(kBase64Header) - 1; namespace chip { diff --git a/src/lib/support/tests/TestBytesToHex.cpp b/src/lib/support/tests/TestBytesToHex.cpp index 7384958befd415..dd148bc6880c8d 100644 --- a/src/lib/support/tests/TestBytesToHex.cpp +++ b/src/lib/support/tests/TestBytesToHex.cpp @@ -390,14 +390,14 @@ TEST(TestBytesToHex, TestLogBufferAsHex) const TestCase kTestCases[] = { // Basic cases - { "", ByteSpan(buffer), kExpectedText1, ArraySize(kExpectedText1) }, - { nullptr, ByteSpan(buffer), kExpectedText1, ArraySize(kExpectedText1) }, - { "label", ByteSpan(buffer), kExpectedText2, ArraySize(kExpectedText2) }, + { "", ByteSpan(buffer), kExpectedText1, MATTER_ARRAY_SIZE(kExpectedText1) }, + { nullptr, ByteSpan(buffer), kExpectedText1, MATTER_ARRAY_SIZE(kExpectedText1) }, + { "label", ByteSpan(buffer), kExpectedText2, MATTER_ARRAY_SIZE(kExpectedText2) }, // Empty buffer leads to a single label - { "label", ByteSpan(), kExpectedText3, ArraySize(kExpectedText3) }, + { "label", ByteSpan(), kExpectedText3, MATTER_ARRAY_SIZE(kExpectedText3) }, // Less than full single line works - { "label", ByteSpan(&buffer[0], 3), kExpectedText4, ArraySize(kExpectedText4) }, + { "label", ByteSpan(&buffer[0], 3), kExpectedText4, MATTER_ARRAY_SIZE(kExpectedText4) }, }; for (auto testCase : kTestCases) diff --git a/src/platform/FreeRTOS/GenericThreadStackManagerImpl_FreeRTOS.hpp b/src/platform/FreeRTOS/GenericThreadStackManagerImpl_FreeRTOS.hpp index 9008258989375e..cb17a104302fcb 100644 --- a/src/platform/FreeRTOS/GenericThreadStackManagerImpl_FreeRTOS.hpp +++ b/src/platform/FreeRTOS/GenericThreadStackManagerImpl_FreeRTOS.hpp @@ -67,7 +67,7 @@ CHIP_ERROR GenericThreadStackManagerImpl_FreeRTOS::_StartThreadTask(v return CHIP_ERROR_INCORRECT_STATE; } #if defined(CHIP_CONFIG_FREERTOS_USE_STATIC_TASK) && CHIP_CONFIG_FREERTOS_USE_STATIC_TASK - mThreadTask = xTaskCreateStatic(ThreadTaskMain, CHIP_DEVICE_CONFIG_THREAD_TASK_NAME, ArraySize(mThreadStack), this, + mThreadTask = xTaskCreateStatic(ThreadTaskMain, CHIP_DEVICE_CONFIG_THREAD_TASK_NAME, MATTER_ARRAY_SIZE(mThreadStack), this, CHIP_DEVICE_CONFIG_THREAD_TASK_PRIORITY, mThreadStack, &mThreadTaskStruct); #else diff --git a/src/platform/Infineon/CYW30739/UnprovisionedOptigaFactoryDataProvider.cpp b/src/platform/Infineon/CYW30739/UnprovisionedOptigaFactoryDataProvider.cpp index 9d56181d6bd79b..ed1287971fdb62 100644 --- a/src/platform/Infineon/CYW30739/UnprovisionedOptigaFactoryDataProvider.cpp +++ b/src/platform/Infineon/CYW30739/UnprovisionedOptigaFactoryDataProvider.cpp @@ -67,7 +67,7 @@ CHIP_ERROR UnprovisionedOptigaFactoryDataProvider::ProvisionDataOnce() ChipLogProgress(DeviceLayer, "Provisioning Optiga data"); - for (size_t i = 0; i < ArraySize(configs); i++) + for (size_t i = 0; i < MATTER_ARRAY_SIZE(configs); i++) { ProvisionDataFromConfig(configs[i].key, configs[i].object_id, configs[i].object_type); } diff --git a/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.hpp b/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.hpp index 86aee98c4aaf1b..410766834a2629 100644 --- a/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.hpp +++ b/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.hpp @@ -1518,7 +1518,7 @@ CHIP_ERROR GenericThreadStackManagerImpl_OpenThread::_AddSrpService(c srpService->mService.mName = alloc.Clone(aName); srpService->mService.mPort = aPort; - VerifyOrExit(aSubTypes.size() < ArraySize(srpService->mSubTypes), error = CHIP_ERROR_BUFFER_TOO_SMALL); + VerifyOrExit(aSubTypes.size() < MATTER_ARRAY_SIZE(srpService->mSubTypes), error = CHIP_ERROR_BUFFER_TOO_SMALL); entryId = 0; for (const char * subType : aSubTypes) @@ -1530,7 +1530,7 @@ CHIP_ERROR GenericThreadStackManagerImpl_OpenThread::_AddSrpService(c srpService->mService.mSubTypeLabels = srpService->mSubTypes; // Initialize TXT entries - VerifyOrExit(aTxtEntries.size() <= ArraySize(srpService->mTxtEntries), error = CHIP_ERROR_BUFFER_TOO_SMALL); + VerifyOrExit(aTxtEntries.size() <= MATTER_ARRAY_SIZE(srpService->mTxtEntries), error = CHIP_ERROR_BUFFER_TOO_SMALL); entryId = 0; for (const chip::Dnssd::TextEntry & entry : aTxtEntries) @@ -1547,7 +1547,7 @@ CHIP_ERROR GenericThreadStackManagerImpl_OpenThread::_AddSrpService(c } using OtNumTxtEntries = decltype(srpService->mService.mNumTxtEntries); - static_assert(ArraySize(srpService->mTxtEntries) <= std::numeric_limits::max(), + static_assert(MATTER_ARRAY_SIZE(srpService->mTxtEntries) <= std::numeric_limits::max(), "Number of DNS TXT entries may not fit in otSrpClientService structure"); srpService->mService.mNumTxtEntries = static_cast(aTxtEntries.size()); srpService->mService.mTxtEntries = srpService->mTxtEntries; @@ -1943,7 +1943,7 @@ void GenericThreadStackManagerImpl_OpenThread::OnDnsBrowseResult(otEr { // Invoke callback for every service one by one instead of for the whole // list due to large memory size needed to allocate on stack. - static_assert(ArraySize(dnsResult->mMdnsService.mName) >= ArraySize(serviceName), + static_assert(MATTER_ARRAY_SIZE(dnsResult->mMdnsService.mName) >= MATTER_ARRAY_SIZE(serviceName), "The target buffer must be big enough"); Platform::CopyString(dnsResult->mMdnsService.mName, serviceName); DeviceLayer::PlatformMgr().ScheduleWork(DispatchBrowse, reinterpret_cast(dnsResult)); diff --git a/src/platform/nxp/common/DnssdImplBr.cpp b/src/platform/nxp/common/DnssdImplBr.cpp index e65ae2d5ef331b..7f6aa25fa6f7d7 100644 --- a/src/platform/nxp/common/DnssdImplBr.cpp +++ b/src/platform/nxp/common/DnssdImplBr.cpp @@ -579,7 +579,7 @@ CHIP_ERROR FromSrpCacheToMdnsData(const otSrpServerService * service, const otSr tmpName = otSrpServerServiceGetInstanceName(service); // Extract from the .... the part size_t substringSize = strchr(tmpName, '.') - tmpName; - if (substringSize >= ArraySize(mdnsService.mName)) + if (substringSize >= MATTER_ARRAY_SIZE(mdnsService.mName)) { return CHIP_ERROR_INVALID_ARGUMENT; } @@ -588,7 +588,7 @@ CHIP_ERROR FromSrpCacheToMdnsData(const otSrpServerService * service, const otSr // Extract from the .... the part. tmpName = tmpName + substringSize + 1; substringSize = strchr(tmpName, '.') - tmpName; - if (substringSize >= ArraySize(mdnsService.mType)) + if (substringSize >= MATTER_ARRAY_SIZE(mdnsService.mType)) { return CHIP_ERROR_INVALID_ARGUMENT; } @@ -618,7 +618,7 @@ CHIP_ERROR FromSrpCacheToMdnsData(const otSrpServerService * service, const otSr // Extract from the .. the part. tmpName = otSrpServerHostGetFullName(host); substringSize = strchr(tmpName, '.') - tmpName; - if (substringSize >= ArraySize(mdnsService.mHostName)) + if (substringSize >= MATTER_ARRAY_SIZE(mdnsService.mHostName)) { return CHIP_ERROR_INVALID_ARGUMENT; } @@ -677,11 +677,11 @@ static CHIP_ERROR FromServiceTypeToMdnsData(chip::Dnssd::DnssdService & mdnsServ // Extract from the . the part. substringSize = strchr(aServiceType, '.') - aServiceType; - if (substringSize >= ArraySize(mdnsService.mType)) + if (substringSize >= MATTER_ARRAY_SIZE(mdnsService.mType)) { return CHIP_ERROR_INVALID_ARGUMENT; } - Platform::CopyString(mdnsService.mType, ArraySize(mdnsService.mType), aServiceType); + Platform::CopyString(mdnsService.mType, MATTER_ARRAY_SIZE(mdnsService.mType), aServiceType); // Extract from the .. the . part. protocolSubstringStart = aServiceType + substringSize; @@ -694,11 +694,11 @@ static CHIP_ERROR FromServiceTypeToMdnsData(chip::Dnssd::DnssdService & mdnsServ // Jump over '.' in protocolSubstringStart and substract the string terminator from the size substringSize = strlen(++protocolSubstringStart) - 1; - if (substringSize >= ArraySize(protocol)) + if (substringSize >= MATTER_ARRAY_SIZE(protocol)) { return CHIP_ERROR_INVALID_ARGUMENT; } - Platform::CopyString(protocol, ArraySize(protocol), protocolSubstringStart); + Platform::CopyString(protocol, MATTER_ARRAY_SIZE(protocol), protocolSubstringStart); if (strncmp(protocol, "_udp", chip::Dnssd::kDnssdProtocolTextMaxSize) == 0) { diff --git a/src/protocols/bdx/BdxTransferProxyDiagnosticLog.cpp b/src/protocols/bdx/BdxTransferProxyDiagnosticLog.cpp index ba1a41376afbbe..3c152dd022d703 100644 --- a/src/protocols/bdx/BdxTransferProxyDiagnosticLog.cpp +++ b/src/protocols/bdx/BdxTransferProxyDiagnosticLog.cpp @@ -33,7 +33,7 @@ CHIP_ERROR BDXTransferProxyDiagnosticLog::Init(TransferSession * transferSession uint16_t fileDesignatorLength = 0; auto fileDesignator = transferSession->GetFileDesignator(fileDesignatorLength); - VerifyOrReturnError(fileDesignatorLength <= ArraySize(mFileDesignator), CHIP_ERROR_INVALID_STRING_LENGTH); + VerifyOrReturnError(fileDesignatorLength <= MATTER_ARRAY_SIZE(mFileDesignator), CHIP_ERROR_INVALID_STRING_LENGTH); mTransfer = transferSession; mFileDesignatorLen = static_cast(fileDesignatorLength); diff --git a/src/protocols/secure_channel/SimpleSessionResumptionStorage.cpp b/src/protocols/secure_channel/SimpleSessionResumptionStorage.cpp index 991003ccff4bf6..65c920bbd10a3e 100644 --- a/src/protocols/secure_channel/SimpleSessionResumptionStorage.cpp +++ b/src/protocols/secure_channel/SimpleSessionResumptionStorage.cpp @@ -99,7 +99,7 @@ CHIP_ERROR SimpleSessionResumptionStorage::LoadIndex(SessionIndex & index) CHIP_ERROR err; while ((err = reader.Next(TLV::kTLVType_Structure, TLV::AnonymousTag())) == CHIP_NO_ERROR) { - if (count >= ArraySize(index.mNodes)) + if (count >= MATTER_ARRAY_SIZE(index.mNodes)) { return CHIP_ERROR_NO_MEMORY; } diff --git a/src/protocols/secure_channel/tests/TestCheckinMsg.cpp b/src/protocols/secure_channel/tests/TestCheckinMsg.cpp index 23f3b2f2d68ca4..31643af55f2433 100644 --- a/src/protocols/secure_channel/tests/TestCheckinMsg.cpp +++ b/src/protocols/secure_channel/tests/TestCheckinMsg.cpp @@ -176,7 +176,7 @@ CHIP_ERROR ParseAndVerifyPayload(MutableByteSpan & applicationData, const CheckI */ TEST(TestCheckInMsg, TestCheckinMessageGenerate_ValidInputsSameSizeOutputAsPayload) { - int numOfTestCases = ArraySize(checkIn_message_test_vectors); + int numOfTestCases = MATTER_ARRAY_SIZE(checkIn_message_test_vectors); for (int numOfTestsExecuted = 0; numOfTestsExecuted < numOfTestCases; numOfTestsExecuted++) { CheckIn_Message_test_vector vector = checkIn_message_test_vectors[numOfTestsExecuted]; @@ -197,7 +197,7 @@ TEST(TestCheckInMsg, TestCheckinMessageGenerate_ValidInputsSameSizeOutputAsPaylo */ TEST(TestCheckInMsg, TestCheckinMessageGenerate_ValidInputsBiggerSizeOutput) { - int numOfTestCases = ArraySize(checkIn_message_test_vectors); + int numOfTestCases = MATTER_ARRAY_SIZE(checkIn_message_test_vectors); for (int numOfTestsExecuted = 0; numOfTestsExecuted < numOfTestCases; numOfTestsExecuted++) { CheckIn_Message_test_vector vector = checkIn_message_test_vectors[numOfTestsExecuted]; @@ -310,7 +310,7 @@ TEST(TestCheckInMsg, TestCheckInMessageGenerate_EmptyHmacKeyHandle) */ TEST(TestCheckInMsg, TestCheckinMessageParse_ValidInputsSameSizeMinAppData) { - int numOfTestCases = ArraySize(checkIn_message_test_vectors); + int numOfTestCases = MATTER_ARRAY_SIZE(checkIn_message_test_vectors); for (int numOfTestsExecuted = 0; numOfTestsExecuted < numOfTestCases; numOfTestsExecuted++) { CheckIn_Message_test_vector vector = checkIn_message_test_vectors[numOfTestsExecuted]; @@ -328,7 +328,7 @@ TEST(TestCheckInMsg, TestCheckinMessageParse_ValidInputsSameSizeMinAppData) */ TEST(TestCheckInMsg, TestCheckinMessageParse_ValidInputsBiggerSizeMinAppData) { - int numOfTestCases = ArraySize(checkIn_message_test_vectors); + int numOfTestCases = MATTER_ARRAY_SIZE(checkIn_message_test_vectors); for (int numOfTestsExecuted = 0; numOfTestsExecuted < numOfTestCases; numOfTestsExecuted++) { CheckIn_Message_test_vector vector = checkIn_message_test_vectors[numOfTestsExecuted]; @@ -446,7 +446,7 @@ TEST(TestCheckInMsg, TestCheckInMessageParse_EmptyHmacKeyHandle) */ TEST(TestCheckInMsg, TestCheckinMessageParse_CorruptedNonce) { - int numOfTestCases = ArraySize(checkIn_message_test_vectors); + int numOfTestCases = MATTER_ARRAY_SIZE(checkIn_message_test_vectors); for (int numOfTestsExecuted = 0; numOfTestsExecuted < numOfTestCases; numOfTestsExecuted++) { CheckIn_Message_test_vector vector = checkIn_message_test_vectors[numOfTestsExecuted]; @@ -479,7 +479,7 @@ TEST(TestCheckInMsg, TestCheckinMessageParse_InvalidNonce) */ TEST(TestCheckInMsg, TestCheckInMessagePayloadSize) { - int numOfTestCases = ArraySize(checkIn_message_test_vectors); + int numOfTestCases = MATTER_ARRAY_SIZE(checkIn_message_test_vectors); for (int numOfTestsExecuted = 0; numOfTestsExecuted < numOfTestCases; numOfTestsExecuted++) { CheckIn_Message_test_vector vector = checkIn_message_test_vectors[numOfTestsExecuted]; diff --git a/src/protocols/secure_channel/tests/TestDefaultSessionResumptionStorage.cpp b/src/protocols/secure_channel/tests/TestDefaultSessionResumptionStorage.cpp index 70b841aec80581..8893751a008392 100644 --- a/src/protocols/secure_channel/tests/TestDefaultSessionResumptionStorage.cpp +++ b/src/protocols/secure_channel/tests/TestDefaultSessionResumptionStorage.cpp @@ -39,7 +39,7 @@ TEST(TestDefaultSessionResumptionStorage, TestSave) } vectors[CHIP_CONFIG_CASE_SESSION_RESUME_CACHE_SIZE + 1]; // Populate test vectors. - for (size_t i = 0; i < ArraySize(vectors); ++i) + for (size_t i = 0; i < MATTER_ARRAY_SIZE(vectors); ++i) { EXPECT_EQ(chip::Crypto::DRBG_get_bytes(vectors[i].resumptionId.data(), vectors[i].resumptionId.size()), CHIP_NO_ERROR); *vectors[i].resumptionId.data() = @@ -65,7 +65,7 @@ TEST(TestDefaultSessionResumptionStorage, TestSave) // If more sophisticated LRU behavior is implemented, this test // case should be modified to match. { - size_t last = ArraySize(vectors) - 1; + size_t last = MATTER_ARRAY_SIZE(vectors) - 1; EXPECT_EQ( sessionStorage.Save(vectors[last].node, vectors[last].resumptionId, vectors[last].sharedSecret, vectors[last].cats), CHIP_NO_ERROR); @@ -119,9 +119,9 @@ TEST(TestDefaultSessionResumptionStorage, TestInPlaceSave) // Construct only a few unique node identities to simulate talking to a // couple peers. chip::ScopedNodeId nodes[3]; - static_assert(ArraySize(nodes) < CHIP_CONFIG_CASE_SESSION_RESUME_CACHE_SIZE, + static_assert(MATTER_ARRAY_SIZE(nodes) < CHIP_CONFIG_CASE_SESSION_RESUME_CACHE_SIZE, "must have fewer nodes than slots in session resumption storage"); - for (size_t i = 0; i < ArraySize(nodes); ++i) + for (size_t i = 0; i < MATTER_ARRAY_SIZE(nodes); ++i) { do { @@ -130,28 +130,28 @@ TEST(TestDefaultSessionResumptionStorage, TestInPlaceSave) } // Populate test vectors. - for (size_t i = 0; i < ArraySize(vectors); ++i) + for (size_t i = 0; i < MATTER_ARRAY_SIZE(vectors); ++i) { EXPECT_EQ(chip::Crypto::DRBG_get_bytes(vectors[i].resumptionId.data(), vectors[i].resumptionId.size()), CHIP_NO_ERROR); *vectors[i].resumptionId.data() = static_cast(i); // set first byte to our index to ensure uniqueness for the FindByResumptionId call vectors[i].sharedSecret.SetLength(vectors[i].sharedSecret.Capacity()); EXPECT_EQ(chip::Crypto::DRBG_get_bytes(vectors[i].sharedSecret.Bytes(), vectors[i].sharedSecret.Length()), CHIP_NO_ERROR); - vectors[i].node = nodes[i % ArraySize(nodes)]; + vectors[i].node = nodes[i % MATTER_ARRAY_SIZE(nodes)]; vectors[i].cats.values[0] = static_cast(rand()); vectors[i].cats.values[1] = static_cast(rand()); vectors[i].cats.values[2] = static_cast(rand()); } // Add one entry for each node. - for (size_t i = 0; i < ArraySize(nodes); ++i) + for (size_t i = 0; i < MATTER_ARRAY_SIZE(nodes); ++i) { EXPECT_EQ(sessionStorage.Save(vectors[i].node, vectors[i].resumptionId, vectors[i].sharedSecret, vectors[i].cats), CHIP_NO_ERROR); } // Read back and verify values. - for (size_t i = 0; i < ArraySize(nodes); ++i) + for (size_t i = 0; i < MATTER_ARRAY_SIZE(nodes); ++i) { chip::ScopedNodeId outNode; chip::SessionResumptionStorage::ResumptionIdStorage outResumptionId; @@ -183,7 +183,7 @@ TEST(TestDefaultSessionResumptionStorage, TestInPlaceSave) } // Read back and verify that only the last record for each node was retained. - for (size_t i = ArraySize(vectors) - ArraySize(nodes); i < ArraySize(vectors); ++i) + for (size_t i = MATTER_ARRAY_SIZE(vectors) - MATTER_ARRAY_SIZE(nodes); i < MATTER_ARRAY_SIZE(vectors); ++i) { chip::ScopedNodeId outNode; chip::SessionResumptionStorage::ResumptionIdStorage outResumptionId; @@ -264,7 +264,7 @@ TEST(TestDefaultSessionResumptionStorage, TestDelete) EXPECT_EQ(chip::Crypto::DRBG_get_bytes(sharedSecret.Bytes(), sharedSecret.Length()), CHIP_NO_ERROR); // Populate test vectors. - for (size_t i = 0; i < ArraySize(vectors); ++i) + for (size_t i = 0; i < MATTER_ARRAY_SIZE(vectors); ++i) { EXPECT_EQ(chip::Crypto::DRBG_get_bytes(vectors[i].resumptionId.data(), vectors[i].resumptionId.size()), CHIP_NO_ERROR); *vectors[i].resumptionId.data() = diff --git a/src/protocols/user_directed_commissioning/UDCClientState.h b/src/protocols/user_directed_commissioning/UDCClientState.h index 259f6eedf1c0dc..32b1cf0e17d6b9 100644 --- a/src/protocols/user_directed_commissioning/UDCClientState.h +++ b/src/protocols/user_directed_commissioning/UDCClientState.h @@ -109,7 +109,7 @@ class UDCClientState size_t GetRotatingIdLength() const { return mRotatingIdLen; } void SetRotatingId(const uint8_t * rotatingId, size_t rotatingIdLen) { - size_t maxSize = ArraySize(mRotatingId); + size_t maxSize = MATTER_ARRAY_SIZE(mRotatingId); mRotatingIdLen = (maxSize < rotatingIdLen) ? maxSize : rotatingIdLen; memcpy(mRotatingId, rotatingId, mRotatingIdLen); } diff --git a/src/protocols/user_directed_commissioning/UserDirectedCommissioning.h b/src/protocols/user_directed_commissioning/UserDirectedCommissioning.h index fb1aedc03e8d6e..f6a3f9a908ccac 100644 --- a/src/protocols/user_directed_commissioning/UserDirectedCommissioning.h +++ b/src/protocols/user_directed_commissioning/UserDirectedCommissioning.h @@ -96,7 +96,7 @@ class DLL_EXPORT IdentificationDeclaration size_t GetRotatingIdLength() const { return mRotatingIdLen; } void SetRotatingId(const uint8_t * rotatingId, size_t rotatingIdLen) { - size_t maxSize = ArraySize(mRotatingId); + size_t maxSize = MATTER_ARRAY_SIZE(mRotatingId); mRotatingIdLen = (maxSize < rotatingIdLen) ? maxSize : rotatingIdLen; memcpy(mRotatingId, rotatingId, mRotatingIdLen); } diff --git a/src/setup_payload/Base38.h b/src/setup_payload/Base38.h index f147250e9793f4..23b0a7685c7699 100644 --- a/src/setup_payload/Base38.h +++ b/src/setup_payload/Base38.h @@ -32,6 +32,6 @@ namespace chip { static const char kCodes[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '-', '.' }; static const uint8_t kBase38CharactersNeededInNBytesChunk[] = { 2, 4, 5 }; -static const uint8_t kRadix = ArraySize(kCodes); +static const uint8_t kRadix = MATTER_ARRAY_SIZE(kCodes); } // namespace chip diff --git a/src/setup_payload/tests/TestAdditionalDataPayload.cpp b/src/setup_payload/tests/TestAdditionalDataPayload.cpp index c0671994ff96b4..4c7d1abe585849 100644 --- a/src/setup_payload/tests/TestAdditionalDataPayload.cpp +++ b/src/setup_payload/tests/TestAdditionalDataPayload.cpp @@ -75,7 +75,8 @@ CHIP_ERROR GenerateAdditionalDataPayload(AdditionalDataPayloadGeneratorParams & return err; } char output[kAdditionalDataPayloadLength]; - err = chip::Encoding::BytesToUppercaseHexString(bufferHandle->Start(), bufferHandle->DataLength(), output, ArraySize(output)); + err = chip::Encoding::BytesToUppercaseHexString(bufferHandle->Start(), bufferHandle->DataLength(), output, + MATTER_ARRAY_SIZE(output)); if (err == CHIP_NO_ERROR) { @@ -162,7 +163,7 @@ TEST_F(TestAdditionalDataPayload, TestGeneratingRotatingDeviceIdAsString) additionalDataPayloadParams.rotatingDeviceIdLifetimeCounter = kLifetimeCounter; additionalDataPayloadParams.rotatingDeviceIdUniqueId = ByteSpan(kUniqueId); err = AdditionalDataPayloadGenerator().generateRotatingDeviceIdAsHexString( - additionalDataPayloadParams, rotatingDeviceIdHexBuffer, ArraySize(rotatingDeviceIdHexBuffer), + additionalDataPayloadParams, rotatingDeviceIdHexBuffer, MATTER_ARRAY_SIZE(rotatingDeviceIdHexBuffer), rotatingDeviceIdValueOutputSize); EXPECT_EQ(err, CHIP_NO_ERROR); EXPECT_STREQ(rotatingDeviceIdHexBuffer, kRotatingDeviceId); @@ -185,7 +186,7 @@ TEST_F(TestAdditionalDataPayload, TestGeneratingRotatingDeviceIdAsStringWithNull additionalDataPayloadParams.rotatingDeviceIdLifetimeCounter = 0; additionalDataPayloadParams.rotatingDeviceIdUniqueId = ByteSpan(); err = AdditionalDataPayloadGenerator().generateRotatingDeviceIdAsHexString( - additionalDataPayloadParams, rotatingDeviceIdHexBuffer, ArraySize(rotatingDeviceIdHexBuffer), + additionalDataPayloadParams, rotatingDeviceIdHexBuffer, MATTER_ARRAY_SIZE(rotatingDeviceIdHexBuffer), rotatingDeviceIdValueOutputSize); EXPECT_EQ(err, CHIP_ERROR_INVALID_ARGUMENT); } @@ -199,7 +200,7 @@ TEST_F(TestAdditionalDataPayload, TestGeneratingRotatingDeviceIdWithSmallBuffer) additionalDataPayloadParams.rotatingDeviceIdLifetimeCounter = kLifetimeCounter; additionalDataPayloadParams.rotatingDeviceIdUniqueId = ByteSpan(kUniqueId); err = AdditionalDataPayloadGenerator().generateRotatingDeviceIdAsHexString( - additionalDataPayloadParams, rotatingDeviceIdHexBuffer, ArraySize(rotatingDeviceIdHexBuffer), + additionalDataPayloadParams, rotatingDeviceIdHexBuffer, MATTER_ARRAY_SIZE(rotatingDeviceIdHexBuffer), rotatingDeviceIdValueOutputSize); EXPECT_EQ(err, CHIP_ERROR_BUFFER_TOO_SMALL); } diff --git a/src/setup_payload/tests/TestQRCode.cpp b/src/setup_payload/tests/TestQRCode.cpp index ce5048489113e6..2a429368d453f6 100644 --- a/src/setup_payload/tests/TestQRCode.cpp +++ b/src/setup_payload/tests/TestQRCode.cpp @@ -165,7 +165,7 @@ TEST(TestQRCode, TestBase38) memset(encodedSpan.data(), '?', encodedSpan.size()); subSpan = encodedSpan.SubSpan(0, 3); base38Encode(inputSpan.SubSpan(0, 1), subSpan); - size_t encodedLen = strnlen(encodedSpan.data(), ArraySize(encodedBuf)); + size_t encodedLen = strnlen(encodedSpan.data(), MATTER_ARRAY_SIZE(encodedBuf)); EXPECT_EQ(encodedLen, strlen("A0")); EXPECT_STREQ(encodedBuf, "A0"); diff --git a/src/tools/chip-cert/Cmd_GenCD.cpp b/src/tools/chip-cert/Cmd_GenCD.cpp index 6d4e61159b7dea..e2577ff0350baa 100644 --- a/src/tools/chip-cert/Cmd_GenCD.cpp +++ b/src/tools/chip-cert/Cmd_GenCD.cpp @@ -400,7 +400,7 @@ bool HandleOption(const char * progName, OptionSet * optSet, int id, const char } break; case 'p': - if (gCertElements.ProductIdsCount == ArraySize(gCertElements.ProductIds)) + if (gCertElements.ProductIdsCount == MATTER_ARRAY_SIZE(gCertElements.ProductIds)) { PrintArgError("%s: Too many Product Ids are specified: %s\n", progName, arg); return false; @@ -474,7 +474,7 @@ bool HandleOption(const char * progName, OptionSet * optSet, int id, const char gCertElements.DACOriginVIDandPIDPresent = true; break; case 'a': - if (gCertElements.AuthorizedPAAListCount >= ArraySize(gCertElements.AuthorizedPAAList)) + if (gCertElements.AuthorizedPAAListCount >= MATTER_ARRAY_SIZE(gCertElements.AuthorizedPAAList)) { PrintArgError("%s: Too many Authorized PAA Certificates are specified: %s\n", progName, arg); return false;