[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260207234305.508019e5@pumpkin>
Date: Sat, 7 Feb 2026 23:43:05 +0000
From: David Laight <david.laight.linux@...il.com>
To: Willy Tarreau <w@....eu>
Cc: Thomas Weißschuh <linux@...ssschuh.net>,
linux-kernel@...r.kernel.org, Cheng Li <lechain@...il.com>
Subject: Re: [PATCH v2 next 04/11] tools/nolibc/printf: Output pad
characters in 16 byte chunks
On Sat, 7 Feb 2026 20:38:36 +0100
Willy Tarreau <w@....eu> wrote:
> On Fri, Feb 06, 2026 at 07:11:14PM +0000, david.laight.linux@...il.com wrote:
> > From: David Laight <david.laight.linux@...il.com>
> >
> > Simple to do and saves calls to the callback function.
>
> +20 bytes here but OK for me.
I think some of those come back when I change all the variables to 'int'.
Some, but not all, is because width is 32bit but len is 64bit.
The final change that did:
width -= len;
...
while (width > 0)
saved a surprising amount provided the ... contained some code.
Breath on the code (or compiler version) and you easily get +/-60 bytes.
David
>
> > Signed-off-by: David Laight <david.laight.linux@...il.com>
>
> Acked-by: Willy Tarreau <w@....eu>
>
> > ---
> >
> > Changes for v2:
> > Formally patch 3, unchanged.
> >
> > tools/include/nolibc/stdio.h | 8 +++++---
> > 1 file changed, 5 insertions(+), 3 deletions(-)
> >
> > diff --git a/tools/include/nolibc/stdio.h b/tools/include/nolibc/stdio.h
> > index 552f09d51d82..c044a6b3babe 100644
> > --- a/tools/include/nolibc/stdio.h
> > +++ b/tools/include/nolibc/stdio.h
> > @@ -355,10 +355,12 @@ int __nolibc_printf(__nolibc_printf_cb cb, void *state, const char *fmt, va_list
> > outstr = fmt;
> > len = ofs - 1;
> > flush_str:
> > - while (width-- > len) {
> > - if (cb(state, " ", 1) != 0)
> > + while (width > len) {
> > + unsigned int pad_len = ((width - len - 1) & 15) + 1;
> > + width -= pad_len;
> > + written += pad_len;
> > + if (cb(state, " ", pad_len) != 0)
> > return -1;
> > - written += 1;
> > }
> > if (cb(state, outstr, len) != 0)
> > return -1;
>
> Willy
Powered by blists - more mailing lists