diff --git a/src/app/util/ember-compatibility-functions.cpp b/src/app/util/ember-compatibility-functions.cpp index 1b2e6ba1f9f72c..67d344eb05bdb8 100644 --- a/src/app/util/ember-compatibility-functions.cpp +++ b/src/app/util/ember-compatibility-functions.cpp @@ -455,14 +455,8 @@ CHIP_ERROR ReadSingleClusterData(const SubjectDescriptor & aSubjectDescriptor, b uint8_t dataLength = gEmberAttributeIOBufferSpan[0]; if (dataLength == 0xFF) { - if (isNullable) - { - ReturnErrorOnFailure(writer->PutNull(tag)); - } - else - { - return CHIP_ERROR_INCORRECT_STATE; - } + VerifyOrReturnError(isNullable, CHIP_ERROR_INCORRECT_STATE); + ReturnErrorOnFailure(writer->PutNull(tag)); } else { @@ -477,14 +471,8 @@ CHIP_ERROR ReadSingleClusterData(const SubjectDescriptor & aSubjectDescriptor, b memcpy(&dataLength, gEmberAttributeIOBufferSpan.data(), sizeof(dataLength)); if (dataLength == 0xFFFF) { - if (isNullable) - { - ReturnErrorOnFailure(writer->PutNull(tag)); - } - else - { - return CHIP_ERROR_INCORRECT_STATE; - } + VerifyOrReturnError(isNullable, CHIP_ERROR_INCORRECT_STATE); + ReturnErrorOnFailure(writer->PutNull(tag)); } else { @@ -498,14 +486,8 @@ CHIP_ERROR ReadSingleClusterData(const SubjectDescriptor & aSubjectDescriptor, b uint8_t dataLength = gEmberAttributeIOBufferSpan[0]; if (dataLength == 0xFF) { - if (isNullable) - { - ReturnErrorOnFailure(writer->PutNull(tag)); - } - else - { - return CHIP_ERROR_INCORRECT_STATE; - } + VerifyOrReturnError(isNullable, CHIP_ERROR_INCORRECT_STATE); + ReturnErrorOnFailure(writer->PutNull(tag)); } else { @@ -519,14 +501,8 @@ CHIP_ERROR ReadSingleClusterData(const SubjectDescriptor & aSubjectDescriptor, b memcpy(&dataLength, gEmberAttributeIOBufferSpan.data(), sizeof(dataLength)); if (dataLength == 0xFFFF) { - if (isNullable) - { - ReturnErrorOnFailure(writer->PutNull(tag)); - } - else - { - return CHIP_ERROR_INCORRECT_STATE; - } + VerifyOrReturnError(isNullable, CHIP_ERROR_INCORRECT_STATE); + ReturnErrorOnFailure(writer->PutNull(tag)); } else {