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

From: Willy Tarreau

Date: Sun Feb 08 2026 - 11:06:23 EST


Another point I didn't notice, which confused me while reading next
patch:

On Fri, Feb 06, 2026 at 07:11:17PM +0000, david.laight.linux@xxxxxxxxx wrote:
> + if (_NOLIBC_PF_FLAGS_CONTAIN(ch_flag, 'c', 'd', 'i', 'u', 'x', 'p', 's')) {
> unsigned long long v;
> long long signed_v;
> - char *out = tmpbuf;
> + char *out = tmpbuf + 32;
> + int sign = 0;
(...)
> + if (_NOLIBC_PF_FLAGS_CONTAIN(ch_flag, 'p', '#' - 1)) {
> + /* "%p" and "%#x" need "0x" prepending. */
> + sign = 'x' | '0' << 8;
(...)
> + /* Add 0, 1 or 2 ("0x") sign characters left of any zero padding */
> + for (; sign; sign >>= 8) {
> + len++;
> + *--out = sign;
> + }

That's fine, but please mention in front of "sign" declaration something
like "/* may contain more than one char, starting with LSB */".

Willy