diff options
| author | Tamir Duberstein <tamird@kernel.org> | 2026-05-26 14:39:11 -0400 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2026-07-03 12:29:38 +0200 |
| commit | 9e32d2a9784736b3fc262f51ddda1141de753314 (patch) | |
| tree | f4f7c4732ff3da14d74f734994e62b2639b7c23b /drivers | |
| parent | e9217e9776812aa63ca428d04053f6239e4308a5 (diff) | |
rust: binder: enable `clippy::cast_lossless`
Before Rust 1.29.0, Clippy introduced the `cast_lossless` lint [1]:
> Rust's `as` keyword will perform many kinds of conversions, including
> silently lossy conversions. Conversion functions such as `i32::from`
> will only perform lossless conversions. Using the conversion functions
> prevents conversions from becoming silently lossy if the input types
> ever change, and makes it clear for people reading the code that the
> conversion is lossless.
While this does not 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 in the Binder Rust driver -- no functional
change intended.
Link: https://rust-lang.github.io/rust-clippy/master/index.html#cast_lossless [1]
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Assisted-by: Codex:gpt-5
Signed-off-by: Tamir Duberstein <tamird@kernel.org>
Link: https://patch.msgid.link/20260526-binder-strict-provenance-v2-5-a41d89c29bc5@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/android/binder/freeze.rs | 2 | ||||
| -rw-r--r-- | drivers/android/binder/process.rs | 6 | ||||
| -rw-r--r-- | drivers/android/binder/rust_binder_main.rs | 1 |
3 files changed, 4 insertions, 5 deletions
diff --git a/drivers/android/binder/freeze.rs b/drivers/android/binder/freeze.rs index 53b60035639a..2178258772e5 100644 --- a/drivers/android/binder/freeze.rs +++ b/drivers/android/binder/freeze.rs @@ -127,7 +127,7 @@ impl DeliverToRead for FreezeMessage { } let mut state_info = BinderFrozenStateInfo::default(); - state_info.is_frozen = is_frozen as u32; + state_info.is_frozen = u32::from(is_frozen); state_info.cookie = freeze.cookie.0; freeze.is_pending = true; freeze.last_is_frozen = Some(is_frozen); diff --git a/drivers/android/binder/process.rs b/drivers/android/binder/process.rs index 49ca1bcd21a1..99d1a7ade599 100644 --- a/drivers/android/binder/process.rs +++ b/drivers/android/binder/process.rs @@ -1526,9 +1526,9 @@ fn get_frozen_status(data: UserSlice) -> Result { found = true; let inner = proc.inner.lock(); let txns_pending = inner.txns_pending_locked(); - info.async_recv |= inner.async_recv as u32; - info.sync_recv |= inner.sync_recv as u32; - info.sync_recv |= (txns_pending as u32) << 1; + info.async_recv |= u32::from(inner.async_recv); + info.sync_recv |= u32::from(inner.sync_recv); + info.sync_recv |= u32::from(txns_pending) << 1; } }); } diff --git a/drivers/android/binder/rust_binder_main.rs b/drivers/android/binder/rust_binder_main.rs index 2c10a8cd3d88..432390aab25b 100644 --- a/drivers/android/binder/rust_binder_main.rs +++ b/drivers/android/binder/rust_binder_main.rs @@ -6,7 +6,6 @@ #![crate_name = "rust_binder"] #![recursion_limit = "256"] -#![allow(clippy::cast_lossless)] use kernel::{ bindings::{self, seq_file}, |
