Re: [PATCH v2 next 07/11] tools/nolibc/printf: Add support for conversion flags "#- +" and format "%X"

From: Thomas Weißschuh

Date: Wed Feb 18 2026 - 12:39:11 EST


On 2026-02-16 22:50:25+0000, David Laight wrote:
> On Mon, 16 Feb 2026 20:57:37 +0100
> Thomas Weißschuh <linux@xxxxxxxxxxxxxx> wrote:
>
> > On 2026-02-06 19:11:17+0000, david.laight.linux@xxxxxxxxx wrote:
> > > From: David Laight <david.laight.linux@xxxxxxxxx>
> > >
> > > Add support for all the normal flag chacacters except '0' (zero pad).
> > > '-' left alignment.
> > > '+' and ' ' Sign characters for non-negative numbers.
> > > '#' adds 0x to hex numbers.
> > > Partially support "%X", outputs lower case a..f the same as "%x".
> > >
> > > Move the "%s" code in with the numeric formats to save a va_arg() call.
> > >
> > > Prepend the sign (or "0x") after conversion to ascii and use the length
> > > returned by u64toh_r() and u64toa_r().
> > > Both needed for precision and zero-padding in the next patch.
> > >
> > > Signed-off-by: David Laight <david.laight.linux@xxxxxxxxx>
> > > ---
> > >
> > > Changes for v2:
> > > - Add support for left justifying fields (removed from patch 6).
> > > - Merge in the changes from the old patch 8.
> > > - Add support for "%#x" (formally part of patch 9).
> > >
> > > tools/include/nolibc/stdio.h | 97 ++++++++++++++++++++++++++----------
> > > 1 file changed, 71 insertions(+), 26 deletions(-)
> >
> > (...)
> >
> > > +non_numeric_conversion:
> > > + if (ch == 'm') {
> > > #ifdef NOLIBC_IGNORE_ERRNO
> > > outstr = "unknown error";
> > > + len = __builtin_strlen(outstr);
> >
> > Why the builtin and not the regular one?
>
> In that case the builtin one will generate a compile-time constant.

Then please also add a comment.

> But that code gets changed in later patches.
> The #if belongs in strerror().