Matter SDK Coverage Report
Current view: top level - app/MessageDef - StructParser.cpp (source / functions) Coverage Total Hit
Test: SHA:09f6fdf93a7e847a42518c076e487f336877a722 Lines: 91.3 % 23 21
Test Date: 2025-06-07 07:10:33 Functions: 100.0 % 2 2

            Line data    Source code
       1              : /**
       2              :  *
       3              :  *    Copyright (c) 2021 Project CHIP Authors
       4              :  *    Licensed under the Apache License, Version 2.0 (the "License");
       5              :  *    you may not use this file except in compliance with the License.
       6              :  *    You may obtain a copy of the License at
       7              :  *
       8              :  *        http://www.apache.org/licenses/LICENSE-2.0
       9              :  *
      10              :  *    Unless required by applicable law or agreed to in writing, software
      11              :  *    distributed under the License is distributed on an "AS IS" BASIS,
      12              :  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      13              :  *    See the License for the specific language governing permissions and
      14              :  *    limitations under the License.
      15              :  */
      16              : 
      17              : #include "StructParser.h"
      18              : 
      19              : namespace chip {
      20              : namespace app {
      21        74954 : CHIP_ERROR StructParser::Init(const TLV::TLVReader & aReader)
      22              : {
      23        74954 :     mReader.Init(aReader);
      24        74954 :     VerifyOrReturnError(TLV::kTLVType_Structure == mReader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE);
      25        74954 :     ReturnErrorOnFailure(mReader.EnterContainer(mOuterContainerType));
      26        74954 :     return CheckSchemaOrdering();
      27              : }
      28              : 
      29        74954 : CHIP_ERROR StructParser::CheckSchemaOrdering() const
      30              : {
      31        74954 :     CHIP_ERROR err = CHIP_NO_ERROR;
      32        74954 :     TLV::TLVReader reader;
      33        74954 :     reader.Init(mReader);
      34        74954 :     uint32_t preTagNum = 0;
      35        74954 :     bool first         = true;
      36       239481 :     while (CHIP_NO_ERROR == (err = reader.Next()))
      37              :     {
      38       164527 :         if (!TLV::IsContextTag(reader.GetTag()))
      39              :         {
      40              :             // Just skip over non-context tags, for forward compat.
      41            0 :             continue;
      42              :         }
      43       164527 :         uint32_t tagNum = TLV::TagNumFromTag(reader.GetTag());
      44       164527 :         if (first || (preTagNum < tagNum))
      45              :         {
      46       164527 :             preTagNum = tagNum;
      47              :         }
      48              :         else
      49              :         {
      50            0 :             return CHIP_ERROR_INVALID_TLV_TAG;
      51              :         }
      52       164527 :         first = false;
      53              :     }
      54        74954 :     if (CHIP_END_OF_TLV == err)
      55              :     {
      56        74954 :         err = CHIP_NO_ERROR;
      57              :     }
      58        74954 :     ReturnErrorOnFailure(err);
      59        74954 :     return reader.ExitContainer(mOuterContainerType);
      60              : }
      61              : } // namespace app
      62              : } // namespace chip
        

Generated by: LCOV version 2.0-1