]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
tools/nolibc/printf: Simplify __nolibc_printf()
authorDavid Laight <david.laight.linux@gmail.com>
Sun, 8 Mar 2026 11:37:31 +0000 (11:37 +0000)
committerThomas Weißschuh <linux@weissschuh.net>
Fri, 20 Mar 2026 16:46:10 +0000 (17:46 +0100)
commitb3d30efd052360c11abe1259a15dfcf2448b37be
tree8a35c58a65082654cbbaad40dcfd19e8c3c3618c
parenta2fa5a752ce67c11a9d6d6535165195073ce0c46
tools/nolibc/printf: Simplify __nolibc_printf()

Move the check for the length modifiers into the format processing
between the field width and conversion specifier.
This lets the loop be simplified and a 'fast scan' for a format start
used.

If an error is detected (eg an invalid conversion specifier) then
copy the invalid format to the output buffer.

Reduces code size by about 10% on x86-64.

Some versions of gcc bloat this version by generating a jump table.
All goes away in the later patches.

Signed-off-by: David Laight <david.laight.linux@gmail.com>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://patch.msgid.link/20260308113742.12649-7-david.laight.linux@gmail.com
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
tools/include/nolibc/stdio.h