Skip to content

Commit d494686

Browse files
committed
Fix errors
Signed-off-by: Sumera Priyadarsini <[email protected]>
1 parent 2c477ec commit d494686

File tree

2 files changed

+18
-17
lines changed

2 files changed

+18
-17
lines changed

rust/kernel/file_operations.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ pub trait FileOperations: Send + Sync + Sized {
530530
const TO_USE: ToUse;
531531

532532
/// The pointer type that will be used to hold ourselves.
533-
type Wrapper: PointerWrapper<Self>;
533+
type Wrapper: PointerWrapper;
534534

535535
/// Cleans up after the last reference to the file goes away.
536536
///

rust/kernel/types.rs

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use core::{ops::Deref, pin::Pin};
99
use alloc::{boxed::Box, sync::Arc};
1010

1111
use crate::bindings;
12+
use crate::c_types;
1213
use crate::sync::{Ref, RefCounted};
1314

1415
/// Permissions.
@@ -82,56 +83,56 @@ macro_rules! cstr {
8283
/// file::private_data`.
8384
pub trait PointerWrapper {
8485
/// Returns the raw pointer.
85-
fn into_pointer(self) -> *const T;
86+
fn into_pointer(self) -> *const c_types::c_void;
8687

8788
/// Returns the instance back from the raw pointer.
8889
///
8990
/// # Safety
9091
///
9192
/// The passed pointer must come from a previous call to [`PointerWrapper::into_pointer()`].
92-
unsafe fn from_pointer(ptr: *const T) -> Self;
93+
unsafe fn from_pointer(ptr: *const c_types::c_void) -> Self;
9394
}
9495

9596
impl<T> PointerWrapper for Box<T> {
96-
fn into_pointer(self) -> *const T {
97-
Box::into_raw(self)
97+
fn into_pointer(self) -> *const c_types::c_void {
98+
Box::into_raw(self) as _
9899
}
99100

100-
unsafe fn from_pointer(ptr: *const T) -> Self {
101+
unsafe fn from_pointer(ptr: *const c_types::c_void) -> Self {
101102
Box::from_raw(ptr as _)
102103
}
103104
}
104105

105106
impl<T: RefCounted> PointerWrapper for Ref<T> {
106-
fn into_pointer(self) -> *const T {
107-
Ref::into_raw(self)
107+
fn into_pointer(self) -> *const c_types::c_void {
108+
Ref::into_raw(self) as _
108109
}
109110

110-
unsafe fn from_pointer(ptr: *const T) -> Self {
111+
unsafe fn from_pointer(ptr: *const c_types::c_void) -> Self {
111112
Ref::from_raw(ptr as _)
112113
}
113114
}
114115

115116
impl<T> PointerWrapper for Arc<T> {
116-
fn into_pointer(self) -> *const T {
117-
Arc::into_raw(self)
117+
fn into_pointer(self) -> *const c_types::c_void {
118+
Arc::into_raw(self) as _
118119
}
119120

120-
unsafe fn from_pointer(ptr: *const T) -> Self {
121-
Arc::from_raw(ptr)
121+
unsafe fn from_pointer(ptr: *const c_types::c_void) -> Self {
122+
Arc::from_raw(ptr as _)
122123
}
123124
}
124125

125-
impl<T, W: PointerWrapper + Deref> PointerWrapper for Pin<W> {
126-
fn into_pointer(self) -> *const T {
126+
impl<T: PointerWrapper + Deref> PointerWrapper for Pin<T> {
127+
fn into_pointer(self) -> *const c_types::c_void {
127128
// SAFETY: We continue to treat the pointer as pinned by returning just a pointer to it to
128129
// the caller.
129130
let inner = unsafe { Pin::into_inner_unchecked(self) };
130131
inner.into_pointer()
131132
}
132133

133-
unsafe fn from_pointer(p: *const T) -> Self {
134+
unsafe fn from_pointer(p: *const c_types::c_void) -> Self {
134135
// SAFETY: The object was originally pinned.
135-
Pin::new_unchecked(W::from_pointer(p))
136+
Pin::new_unchecked(T::from_pointer(p))
136137
}
137138
}

0 commit comments

Comments
 (0)