LCOV - code coverage report
Current view: top level - src/common - memcpy_s.c (source / functions) Hit Total Coverage
Test: lcov.info Lines: 10 12 83.3 %
Date: 2024-09-16 20:15:30 Functions: 2 2 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 6 10 60.0 %

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :    Copyright (c) 2021 Fraunhofer AISEC. See the COPYRIGHT
       3                 :            :    file at the top-level directory of this distribution.
       4                 :            : 
       5                 :            :    Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
       6                 :            :    http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
       7                 :            :    <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
       8                 :            :    option. This file may not be copied, modified, or distributed
       9                 :            :    except according to those terms.
      10                 :            : */
      11                 :            : 
      12                 :            : #include <stdint.h>
      13                 :            : #include <string.h>
      14                 :            : 
      15                 :            : #include "common/oscore_edhoc_error.h"
      16                 :            : #include "common/memcpy_s.h"
      17                 :            : 
      18                 :       1195 : enum err check_buffer_size(uint32_t is_size, uint32_t required_size)
      19                 :            : {
      20         [ -  + ]:       1195 :         if (is_size < required_size) {
      21                 :          0 :                 return buffer_to_small;
      22                 :            :         } else {
      23                 :       1195 :                 return ok;
      24                 :            :         }
      25                 :            : }
      26                 :            : 
      27                 :        531 : enum err _memcpy_s(uint8_t *dest, uint32_t dest_len, const uint8_t *source,
      28                 :            :                    uint32_t source_len)
      29                 :            : {
      30         [ +  + ]:        531 :         if (source_len == 0) {
      31                 :         39 :                 return ok;
      32                 :            :         }
      33   [ +  -  -  + ]:        492 :         if ((NULL == dest) || (NULL == source)) {
      34                 :          0 :                 return wrong_parameter;
      35                 :            :         }
      36                 :            : 
      37         [ -  + ]:        492 :         TRY(check_buffer_size(dest_len, source_len));
      38                 :        492 :         memcpy(dest, source, source_len);
      39                 :        492 :         return ok;
      40                 :            : }

Generated by: LCOV version 1.14