Skip to content

Commit 59cd783

Browse files
virtaddr: remove unused method copied_read
Signed-off-by: Andy-Python-Programmer <[email protected]>
1 parent 4cb69a2 commit 59cd783

File tree

1 file changed

+2
-14
lines changed
  • src/aero_kernel/src/mem/paging

1 file changed

+2
-14
lines changed

src/aero_kernel/src/mem/paging/addr.rs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -118,20 +118,8 @@ impl VirtAddr {
118118

119119
/// Returns if the address is valid to read `sizeof(T)` bytes at the address.
120120
fn validate_read<T: Sized>(&self) -> bool {
121-
(*self + core::mem::size_of::<T>()) <= crate::arch::task::userland_last_address()
122-
}
123-
124-
/// Validate reads `sizeof(T)` bytes from the virtual address and returns a copy
125-
/// of the value (`T`).
126-
///
127-
/// ## Example
128-
/// ```no_run
129-
/// let value: u64 = VirtAddr::new(0xcafebabe)
130-
/// .copied_read::<u64>()
131-
/// .ok_or(AeroSyscallError::EFAULT)?;
132-
/// ```
133-
pub fn copied_read<T: Copy + Sized>(&self) -> Option<T> {
134-
self.read_mut::<T>().map(|t| *t)
121+
(*self + core::mem::size_of::<T>()) <= crate::arch::task::userland_last_address() // in-range
122+
&& self.0 != 0 // non-null
135123
}
136124

137125
/// Aligns the virtual address downwards to the given alignment.

0 commit comments

Comments
 (0)