diff --git a/src/basic/errno-list.c b/src/basic/errno-list.c index b39e15a768..5bfd8aa076 100644 --- a/src/basic/errno-list.c +++ b/src/basic/errno-list.c @@ -9,28 +9,6 @@ static const struct errno_name* lookup_errno(register const char *str, #include "errno-from-name.inc" -#if HAVE_STRERRORNAME_NP -const char* errno_to_name(int id) { - if (id == 0) /* To stay in line with our own impl */ - return NULL; - - return strerrorname_np(ABS(id)); -} -#else -#include "errno-to-name.inc" - -const char* errno_to_name(int id) { - - if (id < 0) - id = -id; - - if ((size_t) id >= ELEMENTSOF(errno_names)) - return NULL; - - return errno_names[id]; -} -#endif - int errno_from_name(const char *name) { const struct errno_name *sc; @@ -43,3 +21,25 @@ int errno_from_name(const char *name) { assert(sc->id > 0); return sc->id; } + +#if HAVE_STRERRORNAME_NP +const char* errno_to_name(int id) { + if (id == 0) /* To stay in line with our own impl */ + return NULL; + + return strerrorname_np(ABS(id)); +} +#else +# include "errno-to-name.inc" + +const char* errno_to_name(int id) { + + if (id < 0) + id = -id; + + if ((size_t) id >= ELEMENTSOF(errno_names)) + return NULL; + + return errno_names[id]; +} +#endif diff --git a/src/basic/errno-list.h b/src/basic/errno-list.h index ce9516068d..9040211b17 100644 --- a/src/basic/errno-list.h +++ b/src/basic/errno-list.h @@ -4,8 +4,7 @@ #include "forward.h" const char* errno_to_name(int id); - -int errno_from_name(const char *name) _const_; +int errno_from_name(const char *name) _pure_; static inline bool errno_is_valid(int n) { return n > 0 && n <= ERRNO_MAX; diff --git a/src/basic/errno-util.h b/src/basic/errno-util.h index fa53744f61..ea54378d78 100644 --- a/src/basic/errno-util.h +++ b/src/basic/errno-util.h @@ -52,7 +52,6 @@ static inline int negative_errno(void) { * It will suppress bogus gcc warnings in case it assumes 'errno' might * be 0 and thus the caller's error-handling might not be triggered. */ assert_return(errno > 0, -EINVAL); - return -errno; }