summaryrefslogtreecommitdiff
path: root/rust/kernel/prelude.rs
diff options
context:
space:
mode:
authorTamir Duberstein <tamird@gmail.com>2025-10-18 15:16:37 -0400
committerMiguel Ojeda <ojeda@kernel.org>2025-10-22 07:47:27 +0200
commit3b83f5d5e78ac5cddd811a5e431af73959864390 (patch)
tree79023bc67135a3514c25145d7278b8d090a85eec /rust/kernel/prelude.rs
parentc5cf01ba8dfe9c0f631ace6f64ec436303783000 (diff)
rust: replace `CStr` with `core::ffi::CStr`
`kernel::ffi::CStr` was introduced in commit d126d2380131 ("rust: str: add `CStr` type") in November 2022 as an upstreaming of earlier work that was done in May 2021[0]. That earlier work, having predated the inclusion of `CStr` in `core`, largely duplicated the implementation of `std::ffi::CStr`. `std::ffi::CStr` was moved to `core::ffi::CStr` in Rust 1.64 in September 2022. Hence replace `kernel::str::CStr` with `core::ffi::CStr` to reduce our custom code footprint, and retain needed custom functionality through an extension trait. Add `CStr` to `ffi` and the kernel prelude. Link: https://github.com/Rust-for-Linux/linux/commit/faa3cbcca03d0dec8f8e43f1d8d5c0860d98a23f [0] Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Acked-by: Danilo Krummrich <dakr@kernel.org> Reviewed-by: Benno Lossin <lossin@kernel.org> Signed-off-by: Tamir Duberstein <tamird@gmail.com> Link: https://patch.msgid.link/20251018-cstr-core-v18-16-9378a54385f8@gmail.com [ Removed assert that would now depend on the Rust version. - Miguel ] Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Diffstat (limited to 'rust/kernel/prelude.rs')
-rw-r--r--rust/kernel/prelude.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/rust/kernel/prelude.rs b/rust/kernel/prelude.rs
index 26424ad7e989..33fa8404c5c6 100644
--- a/rust/kernel/prelude.rs
+++ b/rust/kernel/prelude.rs
@@ -19,7 +19,7 @@ pub use core::{
pub use ::ffi::{
c_char, c_int, c_long, c_longlong, c_schar, c_short, c_uchar, c_uint, c_ulong, c_ulonglong,
- c_ushort, c_void,
+ c_ushort, c_void, CStr,
};
pub use crate::alloc::{flags::*, Box, KBox, KVBox, KVVec, KVec, VBox, VVec, Vec};
@@ -43,7 +43,7 @@ pub use super::static_assert;
pub use super::error::{code::*, Error, Result};
-pub use super::{str::CStr, ThisModule};
+pub use super::{str::CStrExt as _, ThisModule};
pub use super::init::InPlaceInit;