errno-list: errno_from_name() is pure but not const
Follow-up for 0c15577abe
This commit is contained in:
+22
-22
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user