diff options
Diffstat (limited to 'lib/libc/stdio/xprintf_errno.c')
-rw-r--r-- | lib/libc/stdio/xprintf_errno.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/lib/libc/stdio/xprintf_errno.c b/lib/libc/stdio/xprintf_errno.c index 7312ac6e0694..f1e5421f60c8 100644 --- a/lib/libc/stdio/xprintf_errno.c +++ b/lib/libc/stdio/xprintf_errno.c @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2005 Poul-Henning Kamp * All rights reserved. @@ -24,11 +24,10 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD$ */ #include <namespace.h> +#include <limits.h> #include <stdio.h> #include <string.h> #include <stdlib.h> @@ -40,7 +39,8 @@ #include "printf.h" int -__printf_arginfo_errno(const struct printf_info *pi __unused, size_t n, int *argt) +__printf_arginfo_errno(const struct printf_info *pi __unused, size_t n, + int *argt) { assert(n >= 1); @@ -49,17 +49,18 @@ __printf_arginfo_errno(const struct printf_info *pi __unused, size_t n, int *arg } int -__printf_render_errno(struct __printf_io *io, const struct printf_info *pi __unused, const void *const *arg) +__printf_render_errno(struct __printf_io *io, const struct printf_info *pi + __unused, const void *const *arg) { 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)); |