]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
tools/nolibc/printf: Special case 0 and add support for %#x
authorDavid Laight <david.laight.linux@gmail.com>
Sun, 8 Mar 2026 11:37:38 +0000 (11:37 +0000)
committerThomas Weißschuh <linux@weissschuh.net>
Fri, 20 Mar 2026 16:57:08 +0000 (17:57 +0100)
commit5eae5f1a01aff6f9773547265167d7a680c6fbc3
tree6c9be8f6c67b1cd48dd2eb1548984fa22937ae88
parenta30d20588fb8507540d267505a8876bc37bb3ec7
tools/nolibc/printf: Special case 0 and add support for %#x

The output for %#x is almost the same as that for %p, both output in
hexadecimal with a leading "0x".
However for zero %#x should just output "0" (the same as decimal and ocal).
For %p match glibc and output "(nil)" rather than "0x0" or "0".

Add tests for "%#x", "% d", "%+d" and passing NULL to "%p".

Signed-off-by: David Laight <david.laight.linux@gmail.com>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://patch.msgid.link/20260308113742.12649-14-david.laight.linux@gmail.com
[Thomas: fix up testcases for musl libc]
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
tools/include/nolibc/stdio.h
tools/testing/selftests/nolibc/nolibc-test.c