Skip to content

Commit 2740112

Browse files
Apply suggestions from code review
Co-authored-by: Boris Zbarsky <bzbarsky@apple.com>
1 parent 31ebe9d commit 2740112

File tree

1 file changed

+20
-22
lines changed

1 file changed

+20
-22
lines changed

src/app/clusters/thermostat-server/thermostat-server.cpp

+20-22
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,7 @@ CHIP_ERROR ThermostatAttrAccess::Write(const ConcreteDataAttributePath & aPath,
829829
VerifyOrDie(aPath.mClusterId == Thermostat::Id);
830830

831831
EndpointId endpoint = aPath.mEndpointId;
832-
const Access::SubjectDescriptor subjectDescriptor = aDecoder.GetSubjectDescriptor();
832+
auto & subjectDescriptor = aDecoder.GetSubjectDescriptor();
833833
ScopedNodeId scopedNodeId = ScopedNodeId();
834834

835835
// Get the node id if the authentication mode is CASE.
@@ -1306,7 +1306,7 @@ bool emberAfThermostatClusterSetActivePresetRequestCallback(
13061306
return true;
13071307
}
13081308

1309-
bool validAtomicAttributes(const chip::app::Clusters::Thermostat::Commands::AtomicRequest::DecodableType & commandData)
1309+
bool validAtomicAttributes(Commands::AtomicRequest::DecodableType & commandData)
13101310
{
13111311
auto attributeIdsIter = commandData.attributeRequests.begin();
13121312
bool requestedPresets, requestedSchedules;
@@ -1337,9 +1337,9 @@ bool validAtomicAttributes(const chip::app::Clusters::Thermostat::Commands::Atom
13371337
return true;
13381338
}
13391339

1340-
bool handleAtomicBegin(chip::app::CommandHandler * commandObj, const ScopedNodeId & sourceNodeId,
1341-
const chip::app::ConcreteCommandPath & commandPath,
1342-
const chip::app::Clusters::Thermostat::Commands::AtomicRequest::DecodableType & commandData)
1340+
bool handleAtomicBegin(CommandHandler * commandObj, const ScopedNodeId & sourceNodeId,
1341+
const ConcreteCommandPath & commandPath,
1342+
const Commands::AtomicRequest::DecodableType & commandData)
13431343
{
13441344
EndpointId endpoint = commandPath.mEndpointId;
13451345

@@ -1360,16 +1360,15 @@ bool handleAtomicBegin(chip::app::CommandHandler * commandObj, const ScopedNodeI
13601360
bool inAtomicWrite = gThermostatAttrAccess.InAtomicWrite(endpoint);
13611361
if (inAtomicWrite)
13621362
{
1363-
chip::app::Clusters::Thermostat::Commands::AtomicResponse::Type response;
1363+
Commands::AtomicResponse::Type response;
13641364
Globals::Structs::AtomicAttributeStatusStruct::Type attributeStatus[] = {
1365-
{ .attributeID = Presets::Id, .statusCode = static_cast<uint8_t>(imcode::Busy) },
1366-
{ .attributeID = Schedules::Id, .statusCode = static_cast<uint8_t>(imcode::Busy) }
1365+
{ .attributeID = Presets::Id, .statusCode = to_underlying(imcode::Busy) },
1366+
{ .attributeID = Schedules::Id, .statusCode = to_underlying(imcode::Busy) }
13671367
};
13681368

1369-
response.statusCode = static_cast<uint8_t>(imcode::Failure);
1369+
response.statusCode = to_underlying(imcode::Failure);
13701370
response.attributeStatus = attributeStatus;
13711371
commandObj->AddResponse(commandPath, response);
1372-
// commandObj->AddStatus(commandPath, imcode::Busy);
13731372
return true;
13741373
}
13751374

@@ -1379,23 +1378,23 @@ bool handleAtomicBegin(chip::app::CommandHandler * commandObj, const ScopedNodeI
13791378
ScheduleTimer(endpoint, timeout);
13801379
gThermostatAttrAccess.SetAtomicWrite(endpoint, true);
13811380
gThermostatAttrAccess.SetAtomicWriteScopedNodeId(endpoint, GetSourceScopedNodeId(commandObj));
1382-
chip::app::Clusters::Thermostat::Commands::AtomicResponse::Type response;
1381+
Commands::AtomicResponse::Type response;
13831382
Globals::Structs::AtomicAttributeStatusStruct::Type attributeStatus[] = {
1384-
{ .attributeID = Presets::Id, .statusCode = static_cast<uint8_t>(imcode::Success) },
1385-
{ .attributeID = Schedules::Id, .statusCode = static_cast<uint8_t>(imcode::Success) }
1383+
{ .attributeID = Presets::Id, .statusCode = to_underlying(imcode::Success) },
1384+
{ .attributeID = Schedules::Id, .statusCode = to_underlying(imcode::Success) }
13861385
};
13871386

1388-
response.statusCode = static_cast<uint8_t>(imcode::Failure);
1387+
response.statusCode = to_underlying(imcode::Failure);
13891388
response.attributeStatus = attributeStatus;
13901389
response.timeout.Emplace(timeout);
13911390
commandObj->AddResponse(commandPath, response);
13921391

13931392
return true;
13941393
}
13951394

1396-
bool handleAtomicCommit(chip::app::CommandHandler * commandObj, const ScopedNodeId & sourceNodeId,
1397-
const chip::app::ConcreteCommandPath & commandPath,
1398-
const chip::app::Clusters::Thermostat::Commands::AtomicRequest::DecodableType & commandData)
1395+
bool handleAtomicCommit(CommandHandler * commandObj, const ScopedNodeId & sourceNodeId,
1396+
const ConcreteCommandPath & commandPath,
1397+
const Commands::AtomicRequest::DecodableType & commandData)
13991398
{
14001399
if (!validAtomicAttributes(commandData))
14011400
{
@@ -1548,7 +1547,7 @@ bool handleAtomicCommit(chip::app::CommandHandler * commandObj, const ScopedNode
15481547
return SendResponseAndCleanUp(delegate, endpoint, commandObj, commandPath, imcode::ConstraintError);
15491548
}
15501549

1551-
// If the preset type for the preset scenario does not support name and a name is specified, return CONSTRAINT_ERROR.
1550+
// If the preset type for the preset scenario does not support names and a name is specified, return CONSTRAINT_ERROR.
15521551
if (!PresetTypeSupportsNames(delegate, presetScenario) && pendingPreset.GetName().HasValue())
15531552
{
15541553
return SendResponseAndCleanUp(delegate, endpoint, commandObj, commandPath, imcode::ConstraintError);
@@ -1599,9 +1598,9 @@ bool handleAtomicCommit(chip::app::CommandHandler * commandObj, const ScopedNode
15991598
return SendResponseAndCleanUp(delegate, endpoint, commandObj, commandPath, imcode::Success);
16001599
}
16011600

1602-
bool handleAtomicRollback(chip::app::CommandHandler * commandObj, const ScopedNodeId & sourceNodeId,
1603-
const chip::app::ConcreteCommandPath & commandPath,
1604-
const chip::app::Clusters::Thermostat::Commands::AtomicRequest::DecodableType & commandData)
1601+
bool handleAtomicRollback(CommandHandler * commandObj, const ScopedNodeId & sourceNodeId,
1602+
const ConcreteCommandPath & commandPath,
1603+
const Commands::AtomicRequest::DecodableType & commandData)
16051604
{
16061605
if (!validAtomicAttributes(commandData))
16071606
{
@@ -1637,7 +1636,6 @@ bool emberAfThermostatClusterAtomicRequestCallback(
16371636
const chip::app::Clusters::Thermostat::Commands::AtomicRequest::DecodableType & commandData)
16381637
{
16391638
auto & requestType = commandData.requestType;
1640-
// auto & timeout = commandData.timeout;
16411639

16421640
ScopedNodeId sourceNodeId = GetSourceScopedNodeId(commandObj);
16431641

0 commit comments

Comments
 (0)