Matter SDK Coverage Report
Current view: top level - app/MessageDef - StructParser.cpp (source / functions) Coverage Total Hit
Test: SHA:b879ecb8e99e175eea0a293a888bda853da2b19c Lines: 91.3 % 23 21
Test Date: 2025-01-17 19:00:11 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        54247 : CHIP_ERROR StructParser::Init(const TLV::TLVReader & aReader)
      22              : {
      23        54247 :     mReader.Init(aReader);
      24        54247 :     VerifyOrReturnError(TLV::kTLVType_Structure == mReader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE);
      25        54247 :     ReturnErrorOnFailure(mReader.EnterContainer(mOuterContainerType));
      26        54247 :     return CheckSchemaOrdering();
      27              : }
      28              : 
      29        54247 : CHIP_ERROR StructParser::CheckSchemaOrdering() const
      30              : {
      31        54247 :     CHIP_ERROR err = CHIP_NO_ERROR;
      32        54247 :     TLV::TLVReader reader;
      33        54247 :     reader.Init(mReader);
      34        54247 :     uint32_t preTagNum = 0;
      35        54247 :     bool first         = true;
      36       174657 :     while (CHIP_NO_ERROR == (err = reader.Next()))
      37              :     {
      38       120410 :         if (!TLV::IsContextTag(reader.GetTag()))
      39              :         {
      40              :             // Just skip over non-context tags, for forward compat.
      41            0 :             continue;
      42              :         }
      43       120410 :         uint32_t tagNum = TLV::TagNumFromTag(reader.GetTag());
      44       120410 :         if (first || (preTagNum < tagNum))
      45              :         {
      46       120410 :             preTagNum = tagNum;
      47              :         }
      48              :         else
      49              :         {
      50            0 :             return CHIP_ERROR_INVALID_TLV_TAG;
      51              :         }
      52       120410 :         first = false;
      53              :     }
      54        54247 :     if (CHIP_END_OF_TLV == err)
      55              :     {
      56        54247 :         err = CHIP_NO_ERROR;
      57              :     }
      58        54247 :     ReturnErrorOnFailure(err);
      59        54247 :     return reader.ExitContainer(mOuterContainerType);
      60              : }
      61              : } // namespace app
      62              : } // namespace chip
        

Generated by: LCOV version 2.0-1