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

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

Generated by: LCOV version 1.14