>From 21ed6e8365e371b9088df727d0449133df58e9bc Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Fri, 17 Mar 2023 22:33:24 +0100 Subject: [PATCH 1/2] vasnprintf, vasnwprintf: Simplify code. * lib/vasnprintf.c (MAX_ROOM_NEEDED): Remove dead code: The directives 'o', 'x', 'X' always take an unsigned integer argument. --- ChangeLog | 6 ++++++ lib/vasnprintf.c | 10 +++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8318d7f6fc..62dd39e17f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2023-03-17 Bruno Haible + + vasnprintf, vasnwprintf: Simplify code. + * lib/vasnprintf.c (MAX_ROOM_NEEDED): Remove dead code: The directives + 'o', 'x', 'X' always take an unsigned integer argument. + 2023-03-17 Bruno Haible vasnwprintf: Fix test failure on OpenBSD. diff --git a/lib/vasnprintf.c b/lib/vasnprintf.c index 74a6712926..a49eb1dcd7 100644 --- a/lib/vasnprintf.c +++ b/lib/vasnprintf.c @@ -1654,13 +1654,13 @@ MAX_ROOM_NEEDED (const arguments *ap, size_t arg_index, FCHAR_T conversion, break; case 'o': - if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT) + if (type == TYPE_ULONGLONGINT) tmp_length = (unsigned int) (sizeof (unsigned long long) * CHAR_BIT * 0.333334 /* binary -> octal */ ) + 1; /* turn floor into ceil */ - else if (type == TYPE_LONGINT || type == TYPE_ULONGINT) + else if (type == TYPE_ULONGINT) tmp_length = (unsigned int) (sizeof (unsigned long) * CHAR_BIT * 0.333334 /* binary -> octal */ @@ -1679,13 +1679,13 @@ MAX_ROOM_NEEDED (const arguments *ap, size_t arg_index, FCHAR_T conversion, break; case 'x': case 'X': - if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT) + if (type == TYPE_ULONGLONGINT) tmp_length = (unsigned int) (sizeof (unsigned long long) * CHAR_BIT * 0.25 /* binary -> hexadecimal */ ) + 1; /* turn floor into ceil */ - else if (type == TYPE_LONGINT || type == TYPE_ULONGINT) + else if (type == TYPE_ULONGINT) tmp_length = (unsigned int) (sizeof (unsigned long) * CHAR_BIT * 0.25 /* binary -> hexadecimal */ @@ -1699,7 +1699,7 @@ MAX_ROOM_NEEDED (const arguments *ap, size_t arg_index, FCHAR_T conversion, + 1; /* turn floor into ceil */ if (tmp_length < precision) tmp_length = precision; - /* Add 2, to account for a leading sign or alternate form. */ + /* Add 2, to account for a prefix from the alternate form. */ tmp_length = xsum (tmp_length, 2); break; -- 2.34.1