Tamir Duberstein
unread,Aug 13, 2025, 11:42:08 AMAug 13Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter, Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross, Danilo Krummrich, Greg Kroah-Hartman, Dave Ertman, Ira Weiny, Leon Romanovsky, Breno Leitao, Rafael J. Wysocki, Viresh Kumar, Luis Chamberlain, Russ Weight, Brendan Higgins, David Gow, Rae Moar, FUJITA Tomonori, Rob Herring, Saravana Kannan, Jocelyn Falempe, Javier Martinez Canillas, Arnd Bergmann, Len Brown, dri-...@lists.freedesktop.org, linux-...@vger.kernel.org, rust-fo...@vger.kernel.org, linu...@vger.kernel.org, linux-k...@vger.kernel.org, kuni...@googlegroups.com, net...@vger.kernel.org, devic...@vger.kernel.org, linux...@vger.kernel.org, Tamir Duberstein
Prepare for `core::ffi::CStr` taking the place of `kernel::str::CStr` by
avoid methods that only exist on the latter.
Also avoid `Deref<Target=BStr> for CStr` as that impl doesn't exist on
`core::ffi::CStr`.
Signed-off-by: Tamir Duberstein <
tam...@gmail.com>
Acked-by: Andreas Hindborg <
a.hin...@kernel.org>
---
rust/kernel/
configfs.rs | 4 ++--
samples/rust/
rust_configfs.rs | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/rust/kernel/
configfs.rs b/rust/kernel/
configfs.rs
index 2736b798cdc6..9fb5ef825e41 100644
--- a/rust/kernel/
configfs.rs
+++ b/rust/kernel/
configfs.rs
@@ -263,7 +263,7 @@ pub fn new(
try_pin_init!(Self {
group <- pin_init::init_zeroed().chain(|v: &mut Opaque<bindings::config_group>| {
let place = v.get();
- let name = name.as_bytes_with_nul().as_ptr();
+ let name = name.to_bytes_with_nul().as_ptr();
// SAFETY: It is safe to initialize a group once it has been zeroed.
unsafe {
bindings::config_group_init_type_name(place, name.cast(), item_type.as_ptr())
@@ -613,7 +613,7 @@ impl<const ID: u64, O, Data> Attribute<ID, O, Data>
pub const fn new(name: &'static CStr) -> Self {
Self {
attribute: Opaque::new(bindings::configfs_attribute {
- ca_name: name.as_char_ptr(),
+ ca_name: crate::str::as_char_ptr_in_const_context(name),
ca_owner: core::ptr::null_mut(),
ca_mode: 0o660,
show: Some(Self::show),
diff --git a/samples/rust/
rust_configfs.rs b/samples/rust/
rust_configfs.rs
index af04bfa35cb2..5005453f874d 100644
--- a/samples/rust/
rust_configfs.rs
+++ b/samples/rust/
rust_configfs.rs
@@ -94,7 +94,7 @@ impl configfs::AttributeOperations<0> for Configuration {
fn show(container: &Configuration, page: &mut [u8; PAGE_SIZE]) -> Result<usize> {
pr_info!("Show message\n");
- let data = container.message;
+ let data = container.message.to_bytes();
page[0..data.len()].copy_from_slice(data);
Ok(data.len())
}
--
2.50.1