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>
Fri, 11 Feb 2022 19:43:13 +0000 (20:43 +0100)
commit07bb023cbccfe600643c844ee219a3c3c7dcd986
tree8a82de18e7d44087e62ef248dba75124e4a4e1d5
parent933a9669ef0c9163d488fb06a5530c01883d507e
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