rust: uaccess: take advantage of the prelude and `Result`'s defaults
Miguel Ojeda
maintainerPATCH 1/1 rust: uaccess: take advantage of the prelude and `Result`'s defaults
The kernel prelude brings Result and the error codes; and the prelude itself is already available in the examples automatically.
In addition, Result already defaults to T = ().
Thus simplify.
---
A quick thing I noticed looking at something else...
rust/kernel/uaccess.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
rust/kernel/uaccess.rs +1 -3
@@ -46,10 +46,9 @@/// /// ```no_run /// use kernel::ffi::c_void; -/// use kernel::error::Result; /// use kernel::uaccess::{UserPtr, UserSlice}; /// -/// fn bytes_add_one(uptr: UserPtr, len: usize) -> Result<()> { +/// fn bytes_add_one(uptr: UserPtr, len: usize) -> Result { /// let (read, mut write) = UserSlice::new(uptr, len).reader_writer(); /// /// let mut buf = KVec::new();
@@ -68,7 +67,6 @@/// /// ```no_run /// use kernel::ffi::c_void; -/// use kernel::error::{code::EINVAL, Result}; /// use kernel::uaccess::{UserPtr, UserSlice}; /// /// /// Returns whether the data in this region is valid.
base-commit: b4432656b36e5cc1d50a1f2dc15357543add530e --
2.49.0
Quoted 8 lines · Miguel Ojeda
The
kernelprelude bringsResultand the error codes; and the prelude itself is already available in the examples automatically.In addition,
Resultalready defaults toT = ().Thus simplify.
Signed-off-by Miguel Ojeda <[email protected]>
Miguel Ojeda
AppliedQuoted 9 lines · Miguel Ojeda
The
kernelprelude bringsResultand the error codes; and the prelude itself is already available in the examples automatically.In addition,
Resultalready defaults toT = ().Thus simplify.
Signed-off-by Miguel Ojeda <[email protected]>
Applied to rust-next -- thanks!
Cheers,
Miguel