Re: [PATCH 1/2] rust: dma: make use of start_ptr() and start_ptr_mut()

From: Alice Ryhl
Date: Tue Nov 04 2025 - 03:46:09 EST


On Mon, Nov 03, 2025 at 08:06:49PM +0100, Danilo Krummrich wrote:
> Using start_ptr() and start_ptr_mut() has the advantage that we inherit
> the requirements the a mutable or immutable reference from those
> methods.
>
> Hence, use them instead of self.cpu_addr.
>
> Signed-off-by: Danilo Krummrich <dakr@xxxxxxxxxx>

> // and we've just checked that the range and index is within bounds.
> // - `offset` can't overflow since it is smaller than `self.count` and we've checked
> // that `self.count` won't overflow early in the constructor.
> - Ok(unsafe { self.cpu_addr.add(offset) })
> + Ok(unsafe { self.start_ptr().cast_mut().add(offset) })

I guess this shows that the mutable/immutable requirements we inherit
aren't actually what we need?

Alice