Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the remaining instances of KernelResult<()>. #152

Merged
merged 1 commit into from
Mar 30, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions rust/kernel/user_ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ impl UserSlicePtr {
/// mapped, writable memory (in which case some data from before the
/// fault may be written), or `data` is larger than the user slice
/// (in which case no data is written).
pub fn write_all(self, data: &[u8]) -> KernelResult<()> {
pub fn write_all(self, data: &[u8]) -> KernelResult {
self.writer().write_slice(data)
}

Expand Down Expand Up @@ -180,7 +180,7 @@ impl UserSlicePtrReader {
/// Returns `EFAULT` if the byte slice is bigger than the remaining size
/// of the user slice or if the address does not currently point to mapped,
/// readable memory.
pub fn read_slice(&mut self, data: &mut [u8]) -> KernelResult<()> {
pub fn read_slice(&mut self, data: &mut [u8]) -> KernelResult {
// SAFETY: The output buffer is valid as it's coming from a live reference.
unsafe { self.read_raw(data.as_mut_ptr(), data.len()) }
}
Expand All @@ -190,7 +190,7 @@ impl UserSlicePtrReader {
/// # Safety
///
/// The output buffer must be valid.
pub unsafe fn read_raw(&mut self, out: *mut u8, len: usize) -> KernelResult<()> {
pub unsafe fn read_raw(&mut self, out: *mut u8, len: usize) -> KernelResult {
if len > self.1 || len > u32::MAX as usize {
return Err(error::Error::EFAULT);
}
Expand Down Expand Up @@ -239,7 +239,7 @@ impl UserSlicePtrWriter {
/// Returns `EFAULT` if the byte slice is bigger than the remaining size
/// of the user slice or if the address does not currently point to mapped,
/// writable memory.
pub fn write_slice(&mut self, data: &[u8]) -> KernelResult<()> {
pub fn write_slice(&mut self, data: &[u8]) -> KernelResult {
// SAFETY: The input buffer is valid as it's coming from a live reference.
unsafe { self.write_raw(data.as_ptr(), data.len()) }
}
Expand All @@ -249,7 +249,7 @@ impl UserSlicePtrWriter {
/// # Safety
///
/// The input buffer must be valid.
unsafe fn write_raw(&mut self, data: *const u8, len: usize) -> KernelResult<()> {
unsafe fn write_raw(&mut self, data: *const u8, len: usize) -> KernelResult {
if len > self.1 || len > u32::MAX as usize {
return Err(error::Error::EFAULT);
}
Expand Down