Re: [PATCH v4 05/11] rust: xarray: simplify `Guard::load`
From: Andreas Hindborg
Date: Tue Jun 09 2026 - 04:57:26 EST
Tamir Duberstein <tamird@xxxxxxxxxx> writes:
> 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.
I'll be sure to mention this in the commit message for next spin.
>
>>
>>
>> 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.
Thanks!
Best regards,
Andreas Hindborg