Skip to content

Commit 1f79a52

Browse files
committed
Re-arrange code for read only and timed
1 parent 76b7e7d commit 1f79a52

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/app/codegen-data-model/CodegenDataModel_Write.cpp

+6-8
Original file line numberDiff line numberDiff line change
@@ -304,16 +304,14 @@ CHIP_ERROR CodegenDataModel::WriteAttribute(const InteractionModel::WriteAttribu
304304
return CHIP_IM_GLOBAL_STATUS(UnsupportedWrite);
305305
}
306306

307-
if ((*attributeMetadata)->IsReadOnly() && !request.operationFlags.Has(InteractionModel::OperationFlags::kInternal))
307+
// Internal is allowed to bypass timed writes and read-only.
308+
if (!request.operationFlags.Has(InteractionModel::OperationFlags::kInternal))
308309
{
309-
// Internal is allowed to try to bypass read-only updates, however otherwise we deny read-only
310-
// updates
311-
return CHIP_IM_GLOBAL_STATUS(UnsupportedWrite);
312-
}
310+
VerifyOrReturnError(!(*attributeMetadata)->IsReadOnly(), CHIP_IM_GLOBAL_STATUS(UnsupportedWrite));
313311

314-
if ((*attributeMetadata)->MustUseTimedWrite() && !request.writeFlags.Has(InteractionModel::WriteFlags::kTimed))
315-
{
316-
return CHIP_IM_GLOBAL_STATUS(NeedsTimedInteraction);
312+
VerifyOrReturnError(!(*attributeMetadata)->MustUseTimedWrite() ||
313+
request.writeFlags.Has(InteractionModel::WriteFlags::kTimed),
314+
CHIP_IM_GLOBAL_STATUS(NeedsTimedInteraction));
317315
}
318316

319317
if (request.path.mDataVersion.HasValue())

0 commit comments

Comments
 (0)