LCOV - code coverage report
Current view: top level - drivers/net/ntnic/ntlog - ntlog.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 15 0.0 %
Date: 2025-01-02 22:41:34 Functions: 0 3 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 6 0.0 %

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :  * SPDX-License-Identifier: BSD-3-Clause
       3                 :            :  * Copyright(c) 2023 Napatech A/S
       4                 :            :  */
       5                 :            : 
       6                 :            : #include "ntlog.h"
       7                 :            : 
       8                 :            : #include <stdarg.h>
       9                 :            : #include <stddef.h>
      10                 :            : #include <string.h>
      11                 :            : #include <stdlib.h>
      12                 :            : #include <stdbool.h>
      13                 :            : 
      14                 :            : #include <rte_log.h>
      15                 :            : #include <rte_string_fns.h>
      16                 :            : 
      17                 :            : #define NTLOG_HELPER_STR_SIZE_MAX (1024)
      18                 :            : 
      19                 :          0 : char *ntlog_helper_str_alloc(const char *sinit)
      20                 :            : {
      21                 :          0 :         char *s = malloc(NTLOG_HELPER_STR_SIZE_MAX);
      22                 :            : 
      23         [ #  # ]:          0 :         if (!s)
      24                 :            :                 return NULL;
      25                 :            : 
      26         [ #  # ]:          0 :         if (sinit)
      27                 :            :                 snprintf(s, NTLOG_HELPER_STR_SIZE_MAX, "%s", sinit);
      28                 :            : 
      29                 :            :         else
      30                 :          0 :                 s[0] = '\0';
      31                 :            : 
      32                 :            :         return s;
      33                 :            : }
      34                 :            : 
      35                 :            : __rte_format_printf(2, 0)
      36                 :          0 : void ntlog_helper_str_add(char *s, const char *format, ...)
      37                 :            : {
      38         [ #  # ]:          0 :         if (!s)
      39                 :          0 :                 return;
      40                 :            : 
      41                 :            :         va_list args;
      42                 :          0 :         va_start(args, format);
      43                 :          0 :         int len = strlen(s);
      44                 :          0 :         vsnprintf(&s[len], (NTLOG_HELPER_STR_SIZE_MAX - 1 - len), format, args);
      45                 :          0 :         va_end(args);
      46                 :            : }
      47                 :            : 
      48                 :          0 : void ntlog_helper_str_free(char *s)
      49                 :            : {
      50                 :          0 :         free(s);
      51                 :          0 : }

Generated by: LCOV version 1.14