From 6b8274fbd86b95d09a15c0e967791b76b282d358 Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Sun, 20 Mar 2022 17:58:42 +0800 Subject: [PATCH] libc: Change the return type of strerror from "const char *" to "char *" to follow up the spec here: https://pubs.opengroup.org/onlinepubs/9699919799/functions/strerror.html Signed-off-by: Xiang Xiao --- include/string.h | 2 +- libs/libc/libc.csv | 2 +- libs/libc/string/lib_strerror.c | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/string.h b/include/string.h index c42bb82f0d..d202d08bff 100644 --- a/include/string.h +++ b/include/string.h @@ -53,7 +53,7 @@ extern "C" FAR char *strdup(FAR const char *s); FAR char *strndup(FAR const char *s, size_t size); -FAR const char *strerror(int); +FAR char *strerror(int); int strerror_r(int, FAR char *, size_t); size_t strlen(FAR const char *); size_t strnlen(FAR const char *, size_t); diff --git a/libs/libc/libc.csv b/libs/libc/libc.csv index b0236c2b54..5054e927c1 100644 --- a/libs/libc/libc.csv +++ b/libs/libc/libc.csv @@ -225,7 +225,7 @@ "strcpy","string.h","","FAR char *","FAR char *","FAR const char *" "strcspn","string.h","","size_t","FAR const char *","FAR const char *" "strdup","string.h","","FAR char *","FAR const char *" -"strerror","string.h","","FAR const char *","int" +"strerror","string.h","","FAR char *","int" "strerror_r","string.h","","int","int","FAR char *","size_t" "strftime","time.h","","size_t","FAR char *","size_t","FAR const char *","FAR const struct tm *" "strlen","string.h","","size_t","FAR const char *" diff --git a/libs/libc/string/lib_strerror.c b/libs/libc/string/lib_strerror.c index 82625df28c..bf1ee824fe 100644 --- a/libs/libc/string/lib_strerror.c +++ b/libs/libc/string/lib_strerror.c @@ -38,8 +38,8 @@ struct errno_strmap_s { - uint8_t errnum; - const char *str; + uint8_t errnum; + FAR char *str; }; /**************************************************************************** @@ -341,7 +341,7 @@ static const struct errno_strmap_s g_errnomap[] = * Name: strerror ****************************************************************************/ -FAR const char *strerror(int errnum) +FAR char *strerror(int errnum) { #ifdef CONFIG_LIBC_STRERROR int ndxlow = 0;