]> git.ipfire.org Git - thirdparty/linux.git/commit
vsprintf: associate the format state with the format pointer
authorLinus Torvalds <torvalds@linux-foundation.org>
Mon, 16 Dec 2024 23:44:10 +0000 (15:44 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Mon, 23 Dec 2024 19:18:35 +0000 (11:18 -0800)
commit938df695e98db7e0df540cce3b12da8c382955b4
tree9abb7e8864b11240d4a8c37d2806c28a46708b49
parent9e0e6d8a3268e805e061ae8b22f14e37b157102a
vsprintf: associate the format state with the format pointer

The vsnprintf() code is written as a state machine as it walks the
format pointer, but for various historical reasons the state is oddly
named and was encoded as the 'type' field in the 'struct printf_spec'.

That naming came from the fact that the states used to not just encode
the state of the state machine, but also the various integer types that
would then be printed out.

Let's make the state machine more obvious, and actually call it 'state',
and associate it with the format pointer itself, rather than the
'printf_spec' that contains the currently decoded formatting specs.

This also removes the bit packing from printf_spec, which makes it much
easier on the compiler.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
lib/vsprintf.c