[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20250418014143.888022-6-contact@antoniohickey.com>
Date: Thu, 17 Apr 2025 21:41:26 -0400
From: Antonio Hickey <contact@...oniohickey.com>
To: Brendan Higgins <brendan.higgins@...ux.dev>,
David Gow <davidgow@...gle.com>,
Rae Moar <rmoar@...gle.com>,
Miguel Ojeda <ojeda@...nel.org>,
Alex Gaynor <alex.gaynor@...il.com>,
Boqun Feng <boqun.feng@...il.com>,
Gary Guo <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Benno Lossin <benno.lossin@...ton.me>,
Andreas Hindborg <a.hindborg@...nel.org>,
Alice Ryhl <aliceryhl@...gle.com>,
Trevor Gross <tmgross@...ch.edu>,
Danilo Krummrich <dakr@...nel.org>
Cc: Antonio Hickey <contact@...oniohickey.com>,
linux-kselftest@...r.kernel.org,
kunit-dev@...glegroups.com,
rust-for-linux@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH v6 05/18] rust: kunit: refactor to use `&raw [const|mut]`
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@...ton.me>
Link: https://github.com/Rust-for-Linux/linux/issues/1148
Signed-off-by: Antonio Hickey <contact@...oniohickey.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
Powered by blists - more mailing lists