Repurpose the checkSchemaValidity to PrettyPrint only (#21987)
--Remove the necessary elemnt check in im pretty print
--Rename CheckSchemaValidity to PrettyPrint
--Don't process the returned error for prettyPrint in IM client/server
code
diff --git a/src/app/MessageDef/InvokeResponseMessage.cpp b/src/app/MessageDef/InvokeResponseMessage.cpp
index 50de3ef..619c179 100644
--- a/src/app/MessageDef/InvokeResponseMessage.cpp
+++ b/src/app/MessageDef/InvokeResponseMessage.cpp
@@ -25,11 +25,10 @@
namespace chip {
namespace app {
-#if CHIP_CONFIG_IM_ENABLE_SCHEMA_CHECK
-CHIP_ERROR InvokeResponseMessage::Parser::CheckSchemaValidity() const
+#if CHIP_CONFIG_IM_PRETTY_PRINT
+CHIP_ERROR InvokeResponseMessage::Parser::PrettyPrint() const
{
- CHIP_ERROR err = CHIP_NO_ERROR;
- int tagPresenceMask = 0;
+ CHIP_ERROR err = CHIP_NO_ERROR;
TLV::TLVReader reader;
PRETTY_PRINT("InvokeResponseMessage =");
@@ -48,30 +47,23 @@
switch (tagNum)
{
case to_underlying(Tag::kSuppressResponse):
- // check if this tag has appeared before
- VerifyOrReturnError(!(tagPresenceMask & (1 << to_underlying(Tag::kSuppressResponse))), CHIP_ERROR_INVALID_TLV_TAG);
- tagPresenceMask |= (1 << to_underlying(Tag::kSuppressResponse));
#if CHIP_DETAIL_LOGGING
- {
- bool suppressResponse;
- ReturnErrorOnFailure(reader.Get(suppressResponse));
- PRETTY_PRINT("\tsuppressResponse = %s, ", suppressResponse ? "true" : "false");
- }
+ {
+ bool suppressResponse;
+ ReturnErrorOnFailure(reader.Get(suppressResponse));
+ PRETTY_PRINT("\tsuppressResponse = %s, ", suppressResponse ? "true" : "false");
+ }
#endif // CHIP_DETAIL_LOGGING
- break;
- case to_underlying(Tag::kInvokeResponses):
- // check if this tag has appeared before
- VerifyOrReturnError(!(tagPresenceMask & (1 << to_underlying(Tag::kInvokeResponses))), CHIP_ERROR_INVALID_TLV_TAG);
- tagPresenceMask |= (1 << to_underlying(Tag::kInvokeResponses));
- {
- InvokeResponseIBs::Parser invokeResponses;
- ReturnErrorOnFailure(invokeResponses.Init(reader));
+ break;
+ case to_underlying(Tag::kInvokeResponses): {
+ InvokeResponseIBs::Parser invokeResponses;
+ ReturnErrorOnFailure(invokeResponses.Init(reader));
- PRETTY_PRINT_INCDEPTH();
- ReturnErrorOnFailure(invokeResponses.CheckSchemaValidity());
- PRETTY_PRINT_DECDEPTH();
- }
- break;
+ PRETTY_PRINT_INCDEPTH();
+ ReturnErrorOnFailure(invokeResponses.PrettyPrint());
+ PRETTY_PRINT_DECDEPTH();
+ }
+ break;
case kInteractionModelRevisionTag:
ReturnErrorOnFailure(MessageParser::CheckInteractionModelRevision(reader));
break;
@@ -86,15 +78,13 @@
if (CHIP_END_OF_TLV == err)
{
- const int requiredFields = (1 << to_underlying(Tag::kSuppressResponse)) | (1 << to_underlying(Tag::kInvokeResponses));
- err =
- (tagPresenceMask & requiredFields) == requiredFields ? CHIP_NO_ERROR : CHIP_ERROR_IM_MALFORMED_INVOKE_RESPONSE_MESSAGE;
+ err = CHIP_NO_ERROR;
}
ReturnErrorOnFailure(err);
return reader.ExitContainer(mOuterContainerType);
}
-#endif // CHIP_CONFIG_IM_ENABLE_SCHEMA_CHECK
+#endif // CHIP_CONFIG_IM_PRETTY_PRINT
CHIP_ERROR InvokeResponseMessage::Parser::GetSuppressResponse(bool * const apSuppressResponse) const
{