Thread (7 messages) 7 messages, 3 authors, 2025-03-16

Re: [PATCH v3 2/3] rust: replace `addr_of[_mut]!` with `&raw [mut]`

From: Boqun Feng <hidden>
Date: 2025-03-15 12:42:14
Also in: linux-block, linux-kselftest, linux-pci, lkml, rust-for-linux

On Sat, Mar 15, 2025 at 09:47:51AM +0000, Benno Lossin wrote:
On Sat Mar 15, 2025 at 1:23 AM CET, Boqun Feng wrote:
quoted
On Fri, Mar 14, 2025 at 11:41:55PM +0000, Antonio Hickey wrote:
[...]
quoted
@@ -541,7 +541,7 @@ macro_rules! stack_try_pin_init {
 ///
 /// ```rust
 /// # use kernel::{macros::{Zeroable, pin_data}, pin_init};
-/// # use core::{ptr::addr_of_mut, marker::PhantomPinned};
+/// # use core::marker::PhantomPinned;
 /// #[pin_data]
 /// #[derive(Zeroable)]
 /// struct Buf {
@@ -554,7 +554,7 @@ macro_rules! stack_try_pin_init {
 /// pin_init!(&this in Buf {
 ///     buf: [0; 64],
 ///     // SAFETY: TODO.
-///     ptr: unsafe { addr_of_mut!((*this.as_ptr()).buf).cast() },
+///     ptr: unsafe { &raw mut (*this.as_ptr()).buf.cast() },
This should be:


///     ptr: unsafe { &raw mut ((*this.as_ptr()).buf).cast() },

, right?
I'd say it has to be `ptr: unsafe { (&raw mut ((*this.as_ptr()).buf)).cast() }
Right, I missed a pair of parenthesis ;-) Thanks!

Regards,
Boqun
---
Cheers,
Benno
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help