From: Thomas Haller Date: Fri, 26 Jul 2019 08:57:26 +0000 (+0200) Subject: errno-util: return const string from strerror_safe() X-Git-Tag: v243-rc1~28 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6fd79cca68a170c88e87b5d95cd7a44953df94e2;p=thirdparty%2Fsystemd.git errno-util: return const string from strerror_safe() C's strerror() function does not return a "const char *" pointer for the string. That has historic reasons and C99 even comments that "[t]he array pointed to shall not be modified by the program". Make the strerror_safe() wrapper correct this and be more strict in this regard. --- diff --git a/src/basic/errno-util.h b/src/basic/errno-util.h index 34859d6d8a9..6053cde62dd 100644 --- a/src/basic/errno-util.h +++ b/src/basic/errno-util.h @@ -31,7 +31,7 @@ static inline int negative_errno(void) { return -errno; } -static inline char *strerror_safe(int error) { +static inline const char *strerror_safe(int error) { /* 'safe' here does NOT mean thread safety. */ return strerror(abs(error)); }