libc printf_render_errno(): do not use strerror()

Reviewed by:	imp
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D44916
This commit is contained in:
Konstantin Belousov
2024-04-23 20:15:22 +03:00
parent bac9d7e8f2
commit aa66995b4c
+4 -3
View File
@@ -27,6 +27,7 @@
*/
#include <namespace.h>
#include <limits.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@@ -53,13 +54,13 @@ __printf_render_errno(struct __printf_io *io, const struct printf_info *pi
{
int ret, error;
char buf[64];
const char *p;
char errnomsg[NL_TEXTMAX];
ret = 0;
error = *((const int *)arg[0]);
if (error >= 0 && error < __hidden_sys_nerr) {
p = strerror(error);
return (__printf_out(io, pi, p, strlen(p)));
strerror_r(error, errnomsg, sizeof(errnomsg));
return (__printf_out(io, pi, errnomsg, strlen(errnomsg)));
}
sprintf(buf, "errno=%d/0x%x", error, error);
ret += __printf_out(io, pi, buf, strlen(buf));