mirror of
https://github.com/torvalds/linux.git
synced 2026-11-06 21:58:01 +01:00
rust_binder: simplify Result<()> uses
`kernel::error::Result<T = (), E = Error>` is a type alias for `core::result::Result<T, E>` with `()` as the default type argument for T. Explicitly specifying `Result<()>` is redundant. This change makes all usages of `Result` consistent across the driver. Link: https://github.com/Rust-for-Linux/linux/issues/1128 Suggested-by: Miguel Ojeda <ojeda@kernel.org> Signed-off-by: Nicolás Antinori <nico.antinori.7@gmail.com> Acked-by: Alice Ryhl <aliceryhl@google.com> Link: https://github.com/rust-lang/rust-clippy/issues/14848 Link: https://github.com/rust-lang/rust-clippy/pull/16123 Link: https://patch.msgid.link/20260831222857.1402608-1-nico.antinori.7@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
f344930a16
commit
d640ecc58a
|
|
@ -503,7 +503,7 @@ pub(crate) fn read_from(reader: &mut UserSliceReader) -> Result<BinderObject> {
|
|||
/// The closure should write the bytes for the object into the provided slice.
|
||||
pub(crate) fn read_from_inner<R>(reader: R) -> Result<BinderObject>
|
||||
where
|
||||
R: FnOnce(&mut [u8; size_of::<BinderObject>()]) -> Result<()>,
|
||||
R: FnOnce(&mut [u8; size_of::<BinderObject>()]) -> Result,
|
||||
{
|
||||
let mut obj = MaybeUninit::<BinderObject>::zeroed();
|
||||
|
||||
|
|
|
|||
|
|
@ -155,7 +155,7 @@ fn should_sync_wakeup(&self) -> bool {
|
|||
}
|
||||
|
||||
#[inline(never)]
|
||||
fn debug_print(&self, m: &SeqFile, prefix: &str, _tprefix: &str) -> Result<()> {
|
||||
fn debug_print(&self, m: &SeqFile, prefix: &str, _tprefix: &str) -> Result {
|
||||
seq_print!(m, "{}has frozen binder\n", prefix);
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -177,10 +177,7 @@ pub(crate) fn on_process_cleanup(&self, proc: &Process) -> KVVec<Arc<Process>> {
|
|||
}
|
||||
|
||||
impl Process {
|
||||
pub(crate) fn request_freeze_notif(
|
||||
self: &Arc<Self>,
|
||||
reader: &mut UserSliceReader,
|
||||
) -> Result<()> {
|
||||
pub(crate) fn request_freeze_notif(self: &Arc<Self>, reader: &mut UserSliceReader) -> Result {
|
||||
let hc = reader.read::<BinderHandleCookie>()?;
|
||||
let handle = hc.handle;
|
||||
let cookie = FreezeCookie(hc.cookie);
|
||||
|
|
@ -272,7 +269,7 @@ pub(crate) fn request_freeze_notif(
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) fn freeze_notif_done(self: &Arc<Self>, reader: &mut UserSliceReader) -> Result<()> {
|
||||
pub(crate) fn freeze_notif_done(self: &Arc<Self>, reader: &mut UserSliceReader) -> Result {
|
||||
let cookie = FreezeCookie(reader.read()?);
|
||||
let alloc = FreezeMessage::new(GFP_KERNEL)?;
|
||||
let mut node_refs_guard = self.node_refs.lock();
|
||||
|
|
@ -313,7 +310,7 @@ pub(crate) fn freeze_notif_done(self: &Arc<Self>, reader: &mut UserSliceReader)
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) fn clear_freeze_notif(self: &Arc<Self>, reader: &mut UserSliceReader) -> Result<()> {
|
||||
pub(crate) fn clear_freeze_notif(self: &Arc<Self>, reader: &mut UserSliceReader) -> Result {
|
||||
let hc = reader.read::<BinderHandleCookie>()?;
|
||||
let handle = hc.handle;
|
||||
let cookie = FreezeCookie(hc.cookie);
|
||||
|
|
|
|||
|
|
@ -255,11 +255,7 @@ pub(crate) fn has_oneway_transaction(&self, owner_inner: &mut ProcessInner) -> b
|
|||
}
|
||||
|
||||
#[inline(never)]
|
||||
pub(crate) fn full_debug_print(
|
||||
&self,
|
||||
m: &SeqFile,
|
||||
owner_inner: &mut ProcessInner,
|
||||
) -> Result<()> {
|
||||
pub(crate) fn full_debug_print(&self, m: &SeqFile, owner_inner: &mut ProcessInner) -> Result {
|
||||
let inner = self.inner.access_mut(owner_inner);
|
||||
seq_print!(
|
||||
m,
|
||||
|
|
@ -745,7 +741,7 @@ fn should_sync_wakeup(&self) -> bool {
|
|||
}
|
||||
|
||||
#[inline(never)]
|
||||
fn debug_print(&self, m: &SeqFile, prefix: &str, _tprefix: &str) -> Result<()> {
|
||||
fn debug_print(&self, m: &SeqFile, prefix: &str, _tprefix: &str) -> Result {
|
||||
seq_print!(
|
||||
m,
|
||||
"{}node work {}: u{:016x} c{:016x}\n",
|
||||
|
|
@ -1140,7 +1136,7 @@ fn should_sync_wakeup(&self) -> bool {
|
|||
}
|
||||
|
||||
#[inline(never)]
|
||||
fn debug_print(&self, m: &SeqFile, prefix: &str, _tprefix: &str) -> Result<()> {
|
||||
fn debug_print(&self, m: &SeqFile, prefix: &str, _tprefix: &str) -> Result {
|
||||
let inner = self.inner.lock();
|
||||
|
||||
let dead_binder = inner.dead && !inner.notification_done;
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ fn should_sync_wakeup(&self) -> bool {
|
|||
}
|
||||
|
||||
#[inline(never)]
|
||||
fn debug_print(&self, m: &SeqFile, prefix: &str, _tprefix: &str) -> Result<()> {
|
||||
fn debug_print(&self, m: &SeqFile, prefix: &str, _tprefix: &str) -> Result {
|
||||
seq_print!(
|
||||
m,
|
||||
"{}node work {}: u{:016x} c{:016x}\n",
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ impl Shrinker {
|
|||
}
|
||||
|
||||
/// Register this shrinker with the kernel.
|
||||
pub(crate) fn register(&'static self, name: &CStr) -> Result<()> {
|
||||
pub(crate) fn register(&'static self, name: &CStr) -> Result {
|
||||
// SAFETY: These fields are not yet used, so it's okay to zero them.
|
||||
unsafe {
|
||||
self.inner.get().write(ptr::null_mut());
|
||||
|
|
@ -352,7 +352,7 @@ pub(crate) fn register_with_vma(&self, vma: &virt::VmaNew) -> Result<usize> {
|
|||
/// Make sure that the given pages are allocated and mapped.
|
||||
///
|
||||
/// Must not be called from an atomic context.
|
||||
pub(crate) fn use_range(&self, start: usize, end: usize) -> Result<()> {
|
||||
pub(crate) fn use_range(&self, start: usize, end: usize) -> Result {
|
||||
if start >= end {
|
||||
return Ok(());
|
||||
}
|
||||
|
|
@ -398,7 +398,7 @@ pub(crate) fn use_range(&self, start: usize, end: usize) -> Result<()> {
|
|||
///
|
||||
/// Assumes that `i` is in bounds.
|
||||
#[cold]
|
||||
unsafe fn use_page_slow(&self, i: usize) -> Result<()> {
|
||||
unsafe fn use_page_slow(&self, i: usize) -> Result {
|
||||
let new_page = Page::alloc_page(GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO)?;
|
||||
|
||||
let mm_mutex = self.mm_lock.lock();
|
||||
|
|
|
|||
|
|
@ -548,7 +548,7 @@ pub(crate) fn pid_in_current_ns(&self) -> kernel::task::Pid {
|
|||
}
|
||||
|
||||
#[inline(never)]
|
||||
pub(crate) fn debug_print_stats(&self, m: &SeqFile, ctx: &Context) -> Result<()> {
|
||||
pub(crate) fn debug_print_stats(&self, m: &SeqFile, ctx: &Context) -> Result {
|
||||
seq_print!(m, "proc {}\n", self.pid_in_current_ns());
|
||||
seq_print!(m, "context {}\n", &*ctx.name);
|
||||
|
||||
|
|
@ -596,7 +596,7 @@ pub(crate) fn debug_print_stats(&self, m: &SeqFile, ctx: &Context) -> Result<()>
|
|||
}
|
||||
|
||||
#[inline(never)]
|
||||
pub(crate) fn debug_print(&self, m: &SeqFile, ctx: &Context, print_all: bool) -> Result<()> {
|
||||
pub(crate) fn debug_print(&self, m: &SeqFile, ctx: &Context, print_all: bool) -> Result {
|
||||
seq_print!(m, "proc {}\n", self.pid_in_current_ns());
|
||||
seq_print!(m, "context {}\n", &*ctx.name);
|
||||
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ pub(crate) fn is_full(&self) -> bool {
|
|||
self.ranges.len() == self.ranges.capacity()
|
||||
}
|
||||
|
||||
pub(crate) fn debug_print(&self, m: &SeqFile) -> Result<()> {
|
||||
pub(crate) fn debug_print(&self, m: &SeqFile) -> Result {
|
||||
for range in &self.ranges {
|
||||
seq_print!(
|
||||
m,
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ pub(crate) fn count_buffers(&self) -> usize {
|
|||
}
|
||||
}
|
||||
|
||||
pub(crate) fn debug_print(&self, m: &SeqFile) -> Result<()> {
|
||||
pub(crate) fn debug_print(&self, m: &SeqFile) -> Result {
|
||||
match &self.inner {
|
||||
Impl::Empty(_size) => Ok(()),
|
||||
Impl::Array(array) => array.debug_print(m),
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ pub(crate) fn count_buffers(&self) -> usize {
|
|||
.count()
|
||||
}
|
||||
|
||||
pub(crate) fn debug_print(&self, m: &SeqFile) -> Result<()> {
|
||||
pub(crate) fn debug_print(&self, m: &SeqFile) -> Result {
|
||||
for desc in self.tree.values() {
|
||||
let state = match &desc.state {
|
||||
Some(state) => &state.0,
|
||||
|
|
|
|||
|
|
@ -158,7 +158,7 @@ fn do_work(
|
|||
/// Generally only set to true for non-oneway transactions.
|
||||
fn should_sync_wakeup(&self) -> bool;
|
||||
|
||||
fn debug_print(&self, m: &SeqFile, prefix: &str, transaction_prefix: &str) -> Result<()>;
|
||||
fn debug_print(&self, m: &SeqFile, prefix: &str, transaction_prefix: &str) -> Result;
|
||||
}
|
||||
|
||||
// Wrapper around a `DeliverToRead` with linked list links.
|
||||
|
|
@ -274,7 +274,7 @@ fn should_sync_wakeup(&self) -> bool {
|
|||
false
|
||||
}
|
||||
|
||||
fn debug_print(&self, m: &SeqFile, prefix: &str, _tprefix: &str) -> Result<()> {
|
||||
fn debug_print(&self, m: &SeqFile, prefix: &str, _tprefix: &str) -> Result {
|
||||
seq_print!(m, "{}", prefix);
|
||||
if self.skip.load(Relaxed) {
|
||||
seq_print!(m, "(skipped) ");
|
||||
|
|
@ -545,7 +545,7 @@ unsafe impl<T> Sync for AssertSync<T> {}
|
|||
0
|
||||
}
|
||||
|
||||
fn rust_binder_transactions_show_impl(m: &SeqFile) -> Result<()> {
|
||||
fn rust_binder_transactions_show_impl(m: &SeqFile) -> Result {
|
||||
seq_print!(m, "binder transactions:\n");
|
||||
let contexts = context::get_all_contexts()?;
|
||||
for ctx in contexts {
|
||||
|
|
@ -558,7 +558,7 @@ fn rust_binder_transactions_show_impl(m: &SeqFile) -> Result<()> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn rust_binder_stats_show_impl(m: &SeqFile) -> Result<()> {
|
||||
fn rust_binder_stats_show_impl(m: &SeqFile) -> Result {
|
||||
seq_print!(m, "binder stats:\n");
|
||||
stats::GLOBAL_STATS.debug_print("", m);
|
||||
let contexts = context::get_all_contexts()?;
|
||||
|
|
@ -572,7 +572,7 @@ fn rust_binder_stats_show_impl(m: &SeqFile) -> Result<()> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn rust_binder_state_show_impl(m: &SeqFile) -> Result<()> {
|
||||
fn rust_binder_state_show_impl(m: &SeqFile) -> Result {
|
||||
seq_print!(m, "binder state:\n");
|
||||
let contexts = context::get_all_contexts()?;
|
||||
for ctx in contexts {
|
||||
|
|
@ -585,7 +585,7 @@ fn rust_binder_state_show_impl(m: &SeqFile) -> Result<()> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn rust_binder_proc_show_impl(m: &SeqFile, pid: Pid) -> Result<()> {
|
||||
fn rust_binder_proc_show_impl(m: &SeqFile, pid: Pid) -> Result {
|
||||
seq_print!(m, "binder proc state:\n");
|
||||
let contexts = context::get_all_contexts()?;
|
||||
for ctx in contexts {
|
||||
|
|
|
|||
|
|
@ -481,7 +481,7 @@ pub(crate) fn new(id: i32, process: Arc<Process>) -> Result<Arc<Self>> {
|
|||
}
|
||||
|
||||
#[inline(never)]
|
||||
pub(crate) fn debug_print(self: &Arc<Self>, m: &SeqFile, print_all: bool) -> Result<()> {
|
||||
pub(crate) fn debug_print(self: &Arc<Self>, m: &SeqFile, print_all: bool) -> Result {
|
||||
let inner = self.inner.lock();
|
||||
|
||||
if print_all || inner.current_transaction.is_some() || !inner.work_list.is_empty() {
|
||||
|
|
@ -1280,7 +1280,7 @@ fn read_transaction_info(
|
|||
cmd: u32,
|
||||
reader: &mut UserSliceReader,
|
||||
info: &mut TransactionInfo,
|
||||
) -> Result<()> {
|
||||
) -> Result {
|
||||
let td = match cmd {
|
||||
BC_TRANSACTION | BC_REPLY => {
|
||||
reader.read::<BinderTransactionData>()?.with_buffers_size(0)
|
||||
|
|
@ -1311,7 +1311,7 @@ fn read_transaction_info(
|
|||
}
|
||||
|
||||
#[inline(never)]
|
||||
fn transaction(self: &Arc<Self>, cmd: u32, reader: &mut UserSliceReader) -> Result<()> {
|
||||
fn transaction(self: &Arc<Self>, cmd: u32, reader: &mut UserSliceReader) -> Result {
|
||||
let mut info = TransactionInfo::zeroed();
|
||||
self.read_transaction_info(cmd, reader, &mut info)?;
|
||||
|
||||
|
|
@ -1776,7 +1776,7 @@ fn should_sync_wakeup(&self) -> bool {
|
|||
false
|
||||
}
|
||||
|
||||
fn debug_print(&self, m: &SeqFile, prefix: &str, _tprefix: &str) -> Result<()> {
|
||||
fn debug_print(&self, m: &SeqFile, prefix: &str, _tprefix: &str) -> Result {
|
||||
seq_print!(
|
||||
m,
|
||||
"{}transaction error: {}\n",
|
||||
|
|
|
|||
|
|
@ -577,7 +577,7 @@ fn should_sync_wakeup(&self) -> bool {
|
|||
!self.flags.is_oneway()
|
||||
}
|
||||
|
||||
fn debug_print(&self, m: &SeqFile, _prefix: &str, tprefix: &str) -> Result<()> {
|
||||
fn debug_print(&self, m: &SeqFile, _prefix: &str, tprefix: &str) -> Result {
|
||||
self.debug_print_inner(m, tprefix);
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user