summaryrefslogtreecommitdiffstats
path: root/lib/libc/string/strerror.c
diff options
context:
space:
mode:
authorespie <espie@openbsd.org>2004-05-03 05:07:34 +0000
committerespie <espie@openbsd.org>2004-05-03 05:07:34 +0000
commit232b982ab46ea31ecbfd773dded4d52b5c506d17 (patch)
treea3be37b60adb5df676f43dfaba58a7c934a9ba6b /lib/libc/string/strerror.c
parentlittle KNF issue (diff)
downloadwireguard-openbsd-232b982ab46ea31ecbfd773dded4d52b5c506d17.tar.xz
wireguard-openbsd-232b982ab46ea31ecbfd773dded4d52b5c506d17.zip
build the error message in strerror_r.c directly, avoiding one copy there.
handle a few subtle details caught by the regression tests: correct termination, non copying if buffer length == 0, errno setting. let all former users of __strerror go through strerror_r. Work by Todd Miller and I. Okay millert@.
Diffstat (limited to 'lib/libc/string/strerror.c')
-rw-r--r--lib/libc/string/strerror.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/lib/libc/string/strerror.c b/lib/libc/string/strerror.c
index 6496f50afdd..edb6af73864 100644
--- a/lib/libc/string/strerror.c
+++ b/lib/libc/string/strerror.c
@@ -28,23 +28,17 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char *rcsid = "$OpenBSD: strerror.c,v 1.5 2003/06/11 21:08:16 deraadt Exp $";
+static char *rcsid = "$OpenBSD: strerror.c,v 1.6 2004/05/03 05:07:34 espie Exp $";
#endif /* LIBC_SCCS and not lint */
#include <string.h>
#include <limits.h>
-/*
- * Since perror() is not allowed to change the contents of strerror()'s
- * static buffer, both functions supply their own buffers to the
- * internal function __strerror().
- */
-
-extern char *__strerror(int, char *);
-
char *
strerror(int num)
{
static char buf[NL_TEXTMAX];
- return __strerror(num, buf);
+
+ (void)strerror_r(num, buf, sizeof(buf));
+ return (buf);
}