LCOV - code coverage report
Current view: top level - lib/eal/common - rte_bitset.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 7 7 100.0 %
Date: 2025-05-01 17:49:45 Functions: 1 1 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 8 8 100.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(c) 2023 Ericsson AB
       3                 :            :  */
       4                 :            : 
       5                 :            : #include <errno.h>
       6                 :            : #include <stdbool.h>
       7                 :            : #include <stdint.h>
       8                 :            : #include <sys/types.h>
       9                 :            : 
      10                 :            : #include <eal_export.h>
      11                 :            : #include "rte_bitset.h"
      12                 :            : 
      13                 :            : RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_bitset_to_str, 24.11)
      14                 :            : ssize_t
      15                 :          4 : rte_bitset_to_str(const uint64_t *bitset, size_t num_bits, char *buf, size_t capacity)
      16                 :            : {
      17                 :            :         size_t i;
      18                 :            : 
      19         [ +  + ]:          4 :         if (capacity < (num_bits + 1))
      20                 :            :                 return -EINVAL;
      21                 :            : 
      22         [ +  + ]:        105 :         for (i = 0; i < num_bits; i++) {
      23                 :            :                 bool value;
      24                 :            : 
      25         [ +  + ]:        102 :                 value = rte_bitset_test(bitset, num_bits - 1 - i);
      26         [ +  + ]:        201 :                 buf[i] = value ? '1' : '0';
      27                 :            :         }
      28                 :            : 
      29                 :          3 :         buf[num_bits] = '\0';
      30                 :            : 
      31                 :          3 :         return num_bits + 1;
      32                 :            : }

Generated by: LCOV version 1.14