linux-kselftest.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH 3/3] rust: replace `addr_of[_mut]!` with `&raw [mut]`
@ 2025-03-13 12:20 Benno Lossin
  0 siblings, 0 replies; 3+ messages in thread
From: Benno Lossin @ 2025-03-13 12:20 UTC (permalink / raw)
  To: Antonio Hickey, Andreas Hindborg, Boqun Feng, Miguel Ojeda,
	Alex Gaynor, Gary Guo, Björn Roy Baron, Alice Ryhl,
	Trevor Gross, Danilo Krummrich, Greg Kroah-Hartman,
	Rafael J. Wysocki, Brendan Higgins, David Gow, Rae Moar,
	FUJITA Tomonori, Bjorn Helgaas
  Cc: Benno Lossin, linux-block, rust-for-linux, linux-kernel,
	linux-kselftest, kunit-dev, netdev, linux-pci

On Thu Mar 13, 2025 at 6:33 AM CET, Antonio Hickey wrote:
> Replacing all occurrences of `addr_of!(place)` with `&raw place`, and
> all occurrences of `addr_of_mut!(place)` with `&raw mut place`.
>
> Utilizing the new feature will allow us to reduce macro complexity, and
> improve consistency with existing reference syntax as `&raw`, `&raw mut`
> is very similar to `&`, `&mut` making it fit more naturally with other
> existing code.
>
> Depends on: Patch 1/3 0001-rust-enable-raw_ref_op-feature.patch

This information shouldn't be in the commit message. You can put it
below the `---` (that won't end up in the commit message). But since you
sent this as part of a series, you don't need to mention it.

> Suggested-by: Benno Lossin <y86-dev@protonmail.com>
> Link: https://github.com/Rust-for-Linux/linux/issues/1148
> Signed-off-by: Antonio Hickey <contact@antoniohickey.com>
> ---
>  rust/kernel/block/mq/request.rs        |  4 ++--
>  rust/kernel/faux.rs                    |  4 ++--
>  rust/kernel/fs/file.rs                 |  2 +-
>  rust/kernel/init.rs                    |  8 ++++----
>  rust/kernel/init/macros.rs             | 28 +++++++++++++-------------
>  rust/kernel/jump_label.rs              |  4 ++--
>  rust/kernel/kunit.rs                   |  4 ++--
>  rust/kernel/list.rs                    |  2 +-
>  rust/kernel/list/impl_list_item_mod.rs |  6 +++---
>  rust/kernel/net/phy.rs                 |  4 ++--
>  rust/kernel/pci.rs                     |  4 ++--
>  rust/kernel/platform.rs                |  4 +---
>  rust/kernel/rbtree.rs                  | 22 ++++++++++----------
>  rust/kernel/sync/arc.rs                |  2 +-
>  rust/kernel/task.rs                    |  4 ++--
>  rust/kernel/workqueue.rs               |  8 ++++----
>  16 files changed, 54 insertions(+), 56 deletions(-)

[...]

> diff --git a/rust/kernel/jump_label.rs b/rust/kernel/jump_label.rs
> index 4e974c768dbd..05d4564714c7 100644
> --- a/rust/kernel/jump_label.rs
> +++ b/rust/kernel/jump_label.rs
> @@ -20,8 +20,8 @@
>  #[macro_export]
>  macro_rules! static_branch_unlikely {
>      ($key:path, $keytyp:ty, $field:ident) => {{
> -        let _key: *const $keytyp = ::core::ptr::addr_of!($key);
> -        let _key: *const $crate::bindings::static_key_false = ::core::ptr::addr_of!((*_key).$field);
> +        let _key: *const $keytyp = &raw $key;

This should be `&raw const $key`. I wrote that wrongly in the issue.

> +        let _key: *const $crate::bindings::static_key_false = &raw (*_key).$field;

Same here.

>          let _key: *const $crate::bindings::static_key = _key.cast();
>  
>          #[cfg(not(CONFIG_JUMP_LABEL))]
> diff --git a/rust/kernel/kunit.rs b/rust/kernel/kunit.rs
> index 824da0e9738a..18357dd782ed 100644
> --- a/rust/kernel/kunit.rs
> +++ b/rust/kernel/kunit.rs
> @@ -128,9 +128,9 @@ unsafe impl Sync for UnaryAssert {}
>              unsafe {
>                  $crate::bindings::__kunit_do_failed_assertion(
>                      kunit_test,
> -                    core::ptr::addr_of!(LOCATION.0),
> +                    &raw LOCATION.0,

And here.

>                      $crate::bindings::kunit_assert_type_KUNIT_ASSERTION,
> -                    core::ptr::addr_of!(ASSERTION.0.assert),
> +                    &raw ASSERTION.0.assert,

Lastly here as well.

---
Cheers,
Benno


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-03-14  7:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20250313053340.405979-1-contact@antoniohickey.com>
2025-03-13  5:33 ` [PATCH 3/3] rust: replace `addr_of[_mut]!` with `&raw [mut]` Antonio Hickey
2025-03-14  7:10   ` kernel test robot
2025-03-13 12:20 Benno Lossin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).