Skip to content

Commit 9e886cc

Browse files
Address review comments
1 parent efd2e07 commit 9e886cc

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

examples/all-clusters-app/all-clusters-common/src/occupancy-sensing-stub.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ using namespace chip::DeviceLayer;
2929
using chip::Protocols::InteractionModel::Status;
3030

3131
static std::unique_ptr<OccupancySensingAttrAccess>
32-
gAttrAccess[MATTER_DM_OCCUPANCY_SENSING_CLUSTER_SERVER_ENDPOINT_COUNT + CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT + 1];
32+
gAttrAccess[MATTER_DM_OCCUPANCY_SENSING_CLUSTER_SERVER_ENDPOINT_COUNT + CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT];
3333

3434
void emberAfOccupancySensingClusterInitCallback(EndpointId endpointId)
3535
{

src/app/clusters/mode-select-server/mode-select-server.cpp

+22-4
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ using BootReasonType = GeneralDiagnostics::BootReasonEnum;
4949

5050
static InteractionModel::Status verifyModeValue(const EndpointId endpointId, const uint8_t newMode);
5151

52-
ModeSelect::SupportedModesManager * sSupportedModesManager = nullptr;
52+
static ModeSelect::SupportedModesManager * sSupportedModesManager = nullptr;
5353

5454
const SupportedModesManager * ModeSelect::getSupportedModesManager()
5555
{
@@ -82,6 +82,12 @@ CHIP_ERROR ModeSelectAttrAccess::Read(const ConcreteReadAttributePath & aPath, A
8282

8383
if (ModeSelect::Attributes::SupportedModes::Id == aPath.mAttributeId)
8484
{
85+
if (gSupportedModeManager == nullptr)
86+
{
87+
ChipLogError(Zcl, "ModeSelect: SupportedModesManager is NULL");
88+
aEncoder.EncodeEmptyList();
89+
return CHIP_NO_ERROR;
90+
}
8591
const ModeSelect::SupportedModesManager::ModeOptionsProvider modeOptionsProvider =
8692
gSupportedModeManager->getModeOptionsProvider(aPath.mEndpointId);
8793
if (modeOptionsProvider.begin() == nullptr)
@@ -115,8 +121,14 @@ bool emberAfModeSelectClusterChangeToModeCallback(CommandHandler * commandHandle
115121
uint8_t newMode = commandData.newMode;
116122
// Check that the newMode matches one of the supported options
117123
const ModeSelect::Structs::ModeOptionStruct::Type * modeOptionPtr;
118-
Status checkSupportedModeStatus =
119-
ModeSelect::getSupportedModesManager()->getModeOptionByMode(endpointId, newMode, &modeOptionPtr);
124+
const ModeSelect::SupportedModesManager * gSupportedModeManager = ModeSelect::getSupportedModesManager();
125+
if (gSupportedModeManager == nullptr)
126+
{
127+
ChipLogError(Zcl, "ModeSelect: SupportedModesManager is NULL");
128+
commandHandler->AddStatus(commandPath, Status::Failure);
129+
return true;
130+
}
131+
Status checkSupportedModeStatus = gSupportedModeManager->getModeOptionByMode(endpointId, newMode, &modeOptionPtr);
120132
if (Status::Success != checkSupportedModeStatus)
121133
{
122134
ChipLogProgress(Zcl, "ModeSelect: Failed to find the option with mode %u", newMode);
@@ -276,5 +288,11 @@ static InteractionModel::Status verifyModeValue(const EndpointId endpointId, con
276288
return InteractionModel::Status::Success;
277289
}
278290
const ModeSelect::Structs::ModeOptionStruct::Type * modeOptionPtr;
279-
return ModeSelect::getSupportedModesManager()->getModeOptionByMode(endpointId, newMode, &modeOptionPtr);
291+
const ModeSelect::SupportedModesManager * gSupportedModeManager = ModeSelect::getSupportedModesManager();
292+
if (gSupportedModeManager == nullptr)
293+
{
294+
ChipLogError(Zcl, "ModeSelect: SupportedModesManager is NULL");
295+
return Status::Failure;
296+
}
297+
return gSupportedModeManager->getModeOptionByMode(endpointId, newMode, &modeOptionPtr);
280298
}

0 commit comments

Comments
 (0)