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>
This commit is contained in:
Tamir Duberstein
2026-05-26 14:39:11 -04:00
committed by Greg Kroah-Hartman
parent e9217e9776
commit 9e32d2a978
3 changed files with 4 additions and 5 deletions

View File

@@ -127,7 +127,7 @@ fn do_work(
}
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);

View File

@@ -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;
}
});
}

View File

@@ -6,7 +6,6 @@
#![crate_name = "rust_binder"]
#![recursion_limit = "256"]
#![allow(clippy::cast_lossless)]
use kernel::{
bindings::{self, seq_file},