diff options
author | Tamir Duberstein <tamird@gmail.com> | 2025-06-15 16:55:10 -0400 |
---|---|---|
committer | Miguel Ojeda <ojeda@kernel.org> | 2025-06-22 23:09:32 +0200 |
commit | dc35ddcf97e99b18559d0855071030e664aae44d (patch) | |
tree | 6bbda26cdd492b49ffb02923532157bf040ae88b /rust/kernel/uaccess.rs | |
parent | b7c8d7a8d251ab63fba3cc964f1928a216c28081 (diff) |
rust: enable `clippy::ref_as_ptr` lint
In Rust 1.78.0, Clippy introduced the `ref_as_ptr` lint [1]:
> Using `as` casts may result in silently changing mutability or type.
While this doesn't eliminate unchecked `as` conversions, it makes such
conversions easier to scrutinize. It also has the slight benefit of
removing a degree of freedom on which to bikeshed. Thus apply the
changes and enable the lint -- no functional change intended.
Link: https://rust-lang.github.io/rust-clippy/master/index.html#ref_as_ptr [1]
Suggested-by: Benno Lossin <benno.lossin@proton.me>
Link: https://lore.kernel.org/all/D8PGG7NTWB6U.3SS3A5LN4XWMN@proton.me/
Reviewed-by: Benno Lossin <benno.lossin@proton.me>
Reviewed-by: Boqun Feng <boqun.feng@gmail.com>
Signed-off-by: Tamir Duberstein <tamird@gmail.com>
Acked-by: Danilo Krummrich <dakr@kernel.org>
Link: https://lore.kernel.org/r/20250615-ptr-as-ptr-v12-6-f43b024581e8@gmail.com
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Diffstat (limited to 'rust/kernel/uaccess.rs')
-rw-r--r-- | rust/kernel/uaccess.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/rust/kernel/uaccess.rs b/rust/kernel/uaccess.rs index 6d70edd8086a..4ef13cf13a78 100644 --- a/rust/kernel/uaccess.rs +++ b/rust/kernel/uaccess.rs @@ -240,7 +240,7 @@ impl UserSliceReader { pub fn read_slice(&mut self, out: &mut [u8]) -> Result { // SAFETY: The types are compatible and `read_raw` doesn't write uninitialized bytes to // `out`. - let out = unsafe { &mut *(out as *mut [u8] as *mut [MaybeUninit<u8>]) }; + let out = unsafe { &mut *(core::ptr::from_mut(out) as *mut [MaybeUninit<u8>]) }; self.read_raw(out) } @@ -355,7 +355,7 @@ impl UserSliceWriter { let res = unsafe { bindings::_copy_to_user( self.ptr as *mut c_void, - (value as *const T).cast::<c_void>(), + core::ptr::from_ref(value).cast::<c_void>(), len, ) }; |