LCOV - code coverage report
Current view: top level - basic - af-list.c (source / functions) Hit Total Coverage
Test: main_coverage.info Lines: 14 14 100.0 %
Date: 2019-08-22 15:41:25 Functions: 3 3 100.0 %

          Line data    Source code
       1             : /* SPDX-License-Identifier: LGPL-2.1+ */
       2             : 
       3             : #include <errno.h>
       4             : #include <string.h>
       5             : #include <sys/socket.h>
       6             : 
       7             : #include "af-list.h"
       8             : #include "macro.h"
       9             : 
      10             : static const struct af_name* lookup_af(register const char *str, register GPERF_LEN_TYPE len);
      11             : 
      12             : #include "af-from-name.h"
      13             : #include "af-to-name.h"
      14             : 
      15          61 : const char *af_to_name(int id) {
      16             : 
      17          61 :         if (id <= 0)
      18           1 :                 return NULL;
      19             : 
      20          60 :         if ((size_t) id >= ELEMENTSOF(af_names))
      21           1 :                 return NULL;
      22             : 
      23          59 :         return af_names[id];
      24             : }
      25             : 
      26          50 : int af_from_name(const char *name) {
      27             :         const struct af_name *sc;
      28             : 
      29          50 :         assert(name);
      30             : 
      31          50 :         sc = lookup_af(name, strlen(name));
      32          50 :         if (!sc)
      33           2 :                 return -EINVAL;
      34             : 
      35          48 :         return sc->id;
      36             : }
      37             : 
      38           1 : int af_max(void) {
      39           1 :         return ELEMENTSOF(af_names);
      40             : }

Generated by: LCOV version 1.14