git: d4f9e326393e - main - libc/stdio: Increase BUF in vfprintf.c and vfwprintf.c
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 29 Nov 2024 21:39:29 UTC
The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=d4f9e326393e3298062a58338e2c94ef6baff8b5 commit d4f9e326393e3298062a58338e2c94ef6baff8b5 Author: Ahmad Khalifa <ahmadkhalifa570@gmail.com> AuthorDate: 2024-08-31 03:42:04 +0000 Commit: Warner Losh <imp@FreeBSD.org> CommitDate: 2024-11-29 21:38:36 +0000 libc/stdio: Increase BUF in vfprintf.c and vfwprintf.c With the %b format specifier we need enough space to write a uintmax_t in binary. Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/1400 --- lib/libc/stdio/vfprintf.c | 8 ++------ lib/libc/stdio/vfwprintf.c | 8 ++------ sys/kern/subr_prf.c | 2 +- 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/lib/libc/stdio/vfprintf.c b/lib/libc/stdio/vfprintf.c index 785340ab2a24..2dc8d9022179 100644 --- a/lib/libc/stdio/vfprintf.c +++ b/lib/libc/stdio/vfprintf.c @@ -291,13 +291,9 @@ vfprintf(FILE * __restrict fp, const char * __restrict fmt0, va_list ap) /* * The size of the buffer we use as scratch space for integer * conversions, among other things. We need enough space to - * write a uintmax_t in octal (plus one byte). + * write a uintmax_t in binary. */ -#if UINTMAX_MAX <= UINT64_MAX -#define BUF 32 -#else -#error "BUF must be large enough to format a uintmax_t" -#endif +#define BUF (sizeof(uintmax_t) * CHAR_BIT) /* * Non-MT-safe version diff --git a/lib/libc/stdio/vfwprintf.c b/lib/libc/stdio/vfwprintf.c index d43b472f7730..0d77bd74567e 100644 --- a/lib/libc/stdio/vfwprintf.c +++ b/lib/libc/stdio/vfwprintf.c @@ -369,13 +369,9 @@ vfwprintf(FILE * __restrict fp, const wchar_t * __restrict fmt0, va_list ap) /* * The size of the buffer we use as scratch space for integer * conversions, among other things. We need enough space to - * write a uintmax_t in octal (plus one byte). + * write a uintmax_t in binary. */ -#if UINTMAX_MAX <= UINT64_MAX -#define BUF 32 -#else -#error "BUF must be large enough to format a uintmax_t" -#endif +#define BUF (sizeof(uintmax_t) * CHAR_BIT) /* * Non-MT-safe version diff --git a/sys/kern/subr_prf.c b/sys/kern/subr_prf.c index 5cfc92e9761a..131d5456d2f9 100644 --- a/sys/kern/subr_prf.c +++ b/sys/kern/subr_prf.c @@ -512,7 +512,7 @@ putchar(int c, void *arg) if ((flags & TOTTY) && tp != NULL && !KERNEL_PANICKED()) tty_putchar(tp, c); - if ((flags & TOCONS ) && cn_mute) { + if ((flags & TOCONS) && cn_mute) { flags &= ~TOCONS; ap->flags = flags; }