Re: [PATCH v4 05/11] rust: xarray: simplify `Guard::load`
From: Tamir Duberstein
Date: Fri Jun 05 2026 - 11:21:40 EST
On Thu, 04 Jun 2026 21:58:11 +0200, Andreas Hindborg <a.hindborg@xxxxxxxxxx> wrote:
> Simplify the implementation by removing the closure-based API from
> `Guard::load` in favor of returning `Option<NonNull<c_void>>` directly.
This is simpler, but the closure-based API was here for a reason (to
avoid passing around untyped pointers). This patch is estabilishing the
style for subsequent patches, but doesn't honestly describe that it is
doing so.
>
>
> diff --git a/rust/kernel/xarray.rs b/rust/kernel/xarray.rs
> index 05e6dc1ffe69..7da57c778669 100644
> --- a/rust/kernel/xarray.rs
> +++ b/rust/kernel/xarray.rs
> @@ -212,28 +212,23 @@ fn from(value: StoreError<T>) -> Self {
> [ ... skip 26 lines ... ]
> - self.load(index, |ptr| {
> - // SAFETY: `ptr` came from `T::into_foreign`.
> - unsafe { T::borrow_mut(ptr.as_ptr()) }
> - })
> + let ptr = self.load(index)?;
> +
Inconsistent whitespace.
--
Tamir Duberstein <tamird@xxxxxxxxxx>