All of lore.kernel.org
 help / color / mirror / Atom feed
From: Antonio Hickey <contact@antoniohickey.com>
To: "Brendan Higgins" <brendan.higgins@linux.dev>,
	"David Gow" <davidgow@google.com>, "Rae Moar" <rmoar@google.com>,
	"Miguel Ojeda" <ojeda@kernel.org>,
	"Alex Gaynor" <alex.gaynor@gmail.com>,
	"Boqun Feng" <boqun.feng@gmail.com>,
	"Gary Guo" <gary@garyguo.net>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Benno Lossin" <benno.lossin@proton.me>,
	"Andreas Hindborg" <a.hindborg@kernel.org>,
	"Alice Ryhl" <aliceryhl@google.com>,
	"Trevor Gross" <tmgross@umich.edu>,
	"Danilo Krummrich" <dakr@kernel.org>
Cc: Antonio Hickey <contact@antoniohickey.com>,
	linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com,
	rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v6 05/18] rust: kunit: refactor to use `&raw [const|mut]`
Date: Thu, 17 Apr 2025 21:41:26 -0400	[thread overview]
Message-ID: <20250418014143.888022-6-contact@antoniohickey.com> (raw)
In-Reply-To: <20250418014143.888022-1-contact@antoniohickey.com>

Replacing all occurrences of `addr_of!(place)` and `addr_of_mut!(place)`
with `&raw const place` and `&raw mut place` respectively.

This will allow us to reduce macro complexity, and improve consistency
with existing reference syntax as `&raw const`, `&raw mut` are similar
to `&`, `&mut` making it fit more naturally with other existing code.

Suggested-by: Benno Lossin <benno.lossin@proton.me>
Link: https://github.com/Rust-for-Linux/linux/issues/1148
Signed-off-by: Antonio Hickey <contact@antoniohickey.com>
---
 rust/kernel/kunit.rs | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/rust/kernel/kunit.rs b/rust/kernel/kunit.rs
index 1604fb6a5b1b..9f8165b15a37 100644
--- a/rust/kernel/kunit.rs
+++ b/rust/kernel/kunit.rs
@@ -130,9 +130,9 @@ unsafe impl Sync for UnaryAssert {}
             unsafe {
                 $crate::bindings::__kunit_do_failed_assertion(
                     kunit_test,
-                    core::ptr::addr_of!(LOCATION.0),
+                    &raw const LOCATION.0,
                     $crate::bindings::kunit_assert_type_KUNIT_ASSERTION,
-                    core::ptr::addr_of!(ASSERTION.0.assert),
+                    &raw const ASSERTION.0.assert,
                     Some($crate::bindings::kunit_unary_assert_format),
                     core::ptr::null(),
                 );
@@ -261,7 +261,7 @@ macro_rules! kunit_unsafe_test_suite {
                     // (as documented) must be valid for the lifetime of
                     // the suite (i.e., static).
                     test_cases: unsafe {
-                        ::core::ptr::addr_of_mut!($test_cases)
+                        (&raw mut $test_cases)
                             .cast::<::kernel::bindings::kunit_case>()
                     },
                     suite_init: None,
@@ -283,7 +283,7 @@ macro_rules! kunit_unsafe_test_suite {
             #[cfg_attr(not(target_os = "macos"), link_section = ".kunit_test_suites")]
             static mut KUNIT_TEST_SUITE_ENTRY: *const ::kernel::bindings::kunit_suite =
                 // SAFETY: `KUNIT_TEST_SUITE` is static.
-                unsafe { ::core::ptr::addr_of_mut!(KUNIT_TEST_SUITE) };
+                unsafe { &raw mut KUNIT_TEST_SUITE };
         };
     };
 }
-- 
2.48.1


  parent reply	other threads:[~2025-04-18  1:42 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-18  1:41 [PATCH v6 00/18] refactor to utilize `&raw [const|mut]` Antonio Hickey
2025-04-18  1:41 ` [PATCH v6 01/18] rust: init: refactor to use `&raw mut` Antonio Hickey
2025-04-21 20:20   ` Benno Lossin
2025-04-18  1:41 ` [PATCH v6 02/18] rust: list: refactor to use `&raw [const|mut]` Antonio Hickey
2025-04-18  1:41 ` [PATCH v6 03/18] rust: task: remove use of `addr_of!` macro Antonio Hickey
2025-04-18  1:41 ` [PATCH v6 04/18] rust: faux: refactor to use `&raw mut` Antonio Hickey
2025-04-18  1:41 ` Antonio Hickey [this message]
2025-04-18  1:41 ` [PATCH v6 06/18] rust: workqueue: refactor to use `&raw [const|mut]` Antonio Hickey
2025-04-18  1:41 ` [PATCH v6 07/18] rust: workqueue: replace `raw_get` with pointer cast Antonio Hickey
2025-04-18  1:41 ` [PATCH v6 08/18] rust: rbtree: refactor to use `&raw mut` Antonio Hickey
2025-04-18  1:41 ` [PATCH v6 09/18] rust: net: phy: " Antonio Hickey
2025-04-18  1:41 ` [PATCH v6 10/18] rust: sync: arc: refactor to use `&raw const` Antonio Hickey
2025-04-18  1:41 ` [PATCH v6 11/18] rust: jump_label: " Antonio Hickey
2025-04-18  1:41 ` [PATCH v6 12/18] rust: fs: file: " Antonio Hickey
2025-04-18  1:41 ` [PATCH v6 13/18] rust: time: hrtimer: " Antonio Hickey
2025-04-18  1:41 ` [PATCH v6 14/18] rust: pci: refactor to use `&raw mut` Antonio Hickey
2025-04-18  1:41 ` [PATCH v6 15/18] rust: platform: " Antonio Hickey
2025-04-18  1:41 ` [PATCH v6 16/18] rust: dma: refactor to use `&raw [const|mut]` Antonio Hickey
2025-04-18  1:41 ` [PATCH v6 17/18] rust: pin-init: refactor to use `&raw mut` Antonio Hickey
2025-04-18  1:41 ` [PATCH v6 18/18] rust: clippy: disallow `addr_of[_mut]!` macros Antonio Hickey
2025-04-18 13:45 ` [PATCH v6 00/18] refactor to utilize `&raw [const|mut]` Miguel Ojeda
2025-09-08 11:23 ` Miguel Ojeda

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250418014143.888022-6-contact@antoniohickey.com \
    --to=contact@antoniohickey.com \
    --cc=a.hindborg@kernel.org \
    --cc=alex.gaynor@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=benno.lossin@proton.me \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=brendan.higgins@linux.dev \
    --cc=dakr@kernel.org \
    --cc=davidgow@google.com \
    --cc=gary@garyguo.net \
    --cc=kunit-dev@googlegroups.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=ojeda@kernel.org \
    --cc=rmoar@google.com \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tmgross@umich.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.