]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
rust: str: test: replace `alloc::format`
authorDanilo Krummrich <dakr@kernel.org>
Fri, 7 Mar 2025 22:49:52 +0000 (23:49 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 13 Mar 2025 12:01:47 +0000 (13:01 +0100)
commitec50a634be2b666b7cf9641da1e603553a7b1836
treefcdd42162dd85ba6089c8b4821d7dd18403fc105
parent575f8f47112a2089af008c3a379d536a3f8694b6
rust: str: test: replace `alloc::format`

commit eb6f92cd3f755c179204ea1f933b07cf992892fd upstream.

The current implementation of tests in str.rs use `format!` to format
strings for comparison, which, internally, creates a new `String`.

In order to prepare for getting rid of Rust's alloc crate, we have to
cut this dependency. Instead, implement `format!` for `CString`.

Note that for userspace tests, `Kmalloc`, which is backing `CString`'s
memory, is just a type alias to `Cmalloc`.

Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Reviewed-by: Benno Lossin <benno.lossin@proton.me>
Reviewed-by: Gary Guo <gary@garyguo.net>
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
Link: https://lore.kernel.org/r/20241004154149.93856-27-dakr@kernel.org
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
rust/kernel/str.rs