vsprintf: add new `%pA` format specifier
authorGary Guo <gary@garyguo.net>
Sat, 3 Jul 2021 15:38:57 +0000 (17:38 +0200)
committerMiguel Ojeda <ojeda@kernel.org>
Mon, 17 Jan 2022 02:23:45 +0000 (03:23 +0100)
commitefd390f10e306255f9a0eabf8d29d726d5ecd79c
tree14730dff85618f8216766928fc68b6a61fd54551
parentdf51f5e6315ed2fe3cccd5941c7a7d380e0e5ab9
vsprintf: add new `%pA` format specifier

This patch adds a format specifier `%pA` to `vsprintf` which formats
a pointer as `core::fmt::Arguments`. Doing so allows us to directly
format to the internal buffer of `printf`, so we do not have to use
a temporary buffer on the stack to pre-assemble the message on
the Rust side.

This specifier is intended only to be used from Rust and not for C, so
`checkpatch.pl` is intentionally unchanged to catch any misuse.

Co-developed-by: Alex Gaynor <alex.gaynor@gmail.com>
Signed-off-by: Alex Gaynor <alex.gaynor@gmail.com>
Co-developed-by: Wedson Almeida Filho <wedsonaf@google.com>
Signed-off-by: Wedson Almeida Filho <wedsonaf@google.com>
Signed-off-by: Gary Guo <gary@garyguo.net>
Co-developed-by: Miguel Ojeda <ojeda@kernel.org>
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
lib/rust.h [new file with mode: 0644]
lib/vsprintf.c