diff options
author | Alex Richardson <alexrichardson@google.com> | 2021-12-09 14:31:38 +0000 |
---|---|---|
committer | Travis Geiselbrecht <travisg@gmail.com> | 2023-04-23 17:23:31 -0700 |
commit | 7c7612225aeb8c7d95a2fd0c117537b1ffab5d16 (patch) | |
tree | e7e8e351755dffaa98185a160228a5194a00799a | |
parent | 7b12b201fde1b2abd526aeea138fb932b79c631b (diff) | |
download | lk-7c7612225aeb8c7d95a2fd0c117537b1ffab5d16.tar.gz |
[libc] Fix -Wincompatible-library-redeclaration for strerror
Return a char * instead of a const char * to silence this Clang warning.
-rw-r--r-- | lib/libc/include/string.h | 2 | ||||
-rw-r--r-- | lib/libc/string/strerror.c | 7 |
2 files changed, 5 insertions, 4 deletions
diff --git a/lib/libc/include/string.h b/lib/libc/include/string.h index adccf85d..2d3dc9d1 100644 --- a/lib/libc/include/string.h +++ b/lib/libc/include/string.h @@ -22,7 +22,7 @@ char *strcat(char *, char const *); char *strchr(char const *, int) __PURE; int strcmp(char const *, char const *) __PURE; char *strcpy(char *, char const *); -char const *strerror(int) __CONST; +char *strerror(int) __CONST; size_t strlen(char const *) __PURE; char *strncat(char *, char const *, size_t); int strncmp(char const *, char const *, size_t) __PURE; diff --git a/lib/libc/string/strerror.c b/lib/libc/string/strerror.c index f5f24306..e887fa9d 100644 --- a/lib/libc/string/strerror.c +++ b/lib/libc/string/strerror.c @@ -9,12 +9,13 @@ #include <string.h> #include <sys/types.h> -char const * +char * strerror(int errnum) { + /* The C standard requires a non-const return type for backwards compat. */ if (errnum < 0) { - return "General Error"; + return (char *)"General Error"; } else { - return "No Error"; + return (char *)"No Error"; } } |