Skip to content

Commit 965a39a

Browse files
tamirdojeda
authored andcommitted
rust: opp: use CStr::as_char_ptr
Replace the use of `as_ptr` which works through `<CStr as Deref<Target=&[u8]>::deref()` in preparation for replacing `kernel::str::CStr` with `core::ffi::CStr` as the latter does not implement `Deref<Target=&[u8]>`. Signed-off-by: Tamir Duberstein <[email protected]> Acked-by: Viresh Kumar <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Miguel Ojeda <[email protected]>
1 parent 5b60cde commit 965a39a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

rust/kernel/opp.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use crate::{
1313
cpumask::{Cpumask, CpumaskVar},
1414
device::Device,
1515
error::{code::*, from_err_ptr, from_result, to_result, Result, VTABLE_DEFAULT_ERROR},
16-
ffi::c_ulong,
16+
ffi::{c_char, c_ulong},
1717
prelude::*,
1818
str::CString,
1919
sync::aref::{ARef, AlwaysRefCounted},
@@ -88,12 +88,12 @@ use core::{marker::PhantomData, ptr};
8888
use macros::vtable;
8989

9090
/// Creates a null-terminated slice of pointers to [`Cstring`]s.
91-
fn to_c_str_array(names: &[CString]) -> Result<KVec<*const u8>> {
91+
fn to_c_str_array(names: &[CString]) -> Result<KVec<*const c_char>> {
9292
// Allocated a null-terminated vector of pointers.
9393
let mut list = KVec::with_capacity(names.len() + 1, GFP_KERNEL)?;
9494

9595
for name in names.iter() {
96-
list.push(name.as_ptr().cast(), GFP_KERNEL)?;
96+
list.push(name.as_char_ptr(), GFP_KERNEL)?;
9797
}
9898

9999
list.push(ptr::null(), GFP_KERNEL)?;

0 commit comments

Comments
 (0)