From: Tamir Duberstein Date: Sat, 18 Oct 2025 19:16:31 +0000 (-0400) Subject: rust: opp: use `CStr::as_char_ptr` X-Git-Tag: v6.19-rc1~175^2~23 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=965a39a9627bfaee5a4f7471097439da19008338;p=thirdparty%2Fkernel%2Flinux.git rust: opp: use `CStr::as_char_ptr` Replace the use of `as_ptr` which works through `::deref()` in preparation for replacing `kernel::str::CStr` with `core::ffi::CStr` as the latter does not implement `Deref`. Signed-off-by: Tamir Duberstein Acked-by: Viresh Kumar Link: https://patch.msgid.link/20251018-cstr-core-v18-10-9378a54385f8@gmail.com Signed-off-by: Miguel Ojeda --- diff --git a/rust/kernel/opp.rs b/rust/kernel/opp.rs index 2c763fa9276d0..9d6c58178a6f4 100644 --- a/rust/kernel/opp.rs +++ b/rust/kernel/opp.rs @@ -13,7 +13,7 @@ use crate::{ cpumask::{Cpumask, CpumaskVar}, device::Device, error::{code::*, from_err_ptr, from_result, to_result, Result, VTABLE_DEFAULT_ERROR}, - ffi::c_ulong, + ffi::{c_char, c_ulong}, prelude::*, str::CString, sync::aref::{ARef, AlwaysRefCounted}, @@ -88,12 +88,12 @@ use core::{marker::PhantomData, ptr}; use macros::vtable; /// Creates a null-terminated slice of pointers to [`Cstring`]s. -fn to_c_str_array(names: &[CString]) -> Result> { +fn to_c_str_array(names: &[CString]) -> Result> { // Allocated a null-terminated vector of pointers. let mut list = KVec::with_capacity(names.len() + 1, GFP_KERNEL)?; for name in names.iter() { - list.push(name.as_ptr().cast(), GFP_KERNEL)?; + list.push(name.as_char_ptr(), GFP_KERNEL)?; } list.push(ptr::null(), GFP_KERNEL)?;