[PATCH v6 13/18] rust: time: hrtimer: refactor to use `&raw const`
From: Antonio Hickey
Date: Thu Apr 17 2025 - 21:45:23 EST
Replacing all occurrences of `addr_of!(place)` with
`&raw const place`.
This will allow us to reduce macro complexity, and improve consistency
with existing reference syntax as `&raw const` is similar to `&` making
it fit more naturally with other existing code.
Suggested-by: Benno Lossin <benno.lossin@xxxxxxxxx>
Link: https://github.com/Rust-for-Linux/linux/issues/1148
Signed-off-by: Antonio Hickey <contact@xxxxxxxxxxxxxxxxx>
---
rust/kernel/time/hrtimer.rs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/rust/kernel/time/hrtimer.rs b/rust/kernel/time/hrtimer.rs
index ce53f8579d18..d91d2a655baf 100644
--- a/rust/kernel/time/hrtimer.rs
+++ b/rust/kernel/time/hrtimer.rs
@@ -132,7 +132,7 @@ unsafe fn raw_get(this: *const Self) -> *mut bindings::hrtimer {
// SAFETY: The field projection to `timer` does not go out of bounds,
// because the caller of this function promises that `this` points to an
// allocation of at least the size of `Self`.
- unsafe { Opaque::raw_get(core::ptr::addr_of!((*this).timer)) }
+ unsafe { Opaque::raw_get(&raw const (*this).timer) }
}
/// Cancel an initialized and potentially running timer.
@@ -494,7 +494,7 @@ unsafe fn raw_get_timer(
this: *const Self,
) -> *const $crate::time::hrtimer::HrTimer<$timer_type> {
// SAFETY: The caller promises that the pointer is not dangling.
- unsafe { ::core::ptr::addr_of!((*this).$field) }
+ unsafe { &raw const (*this).$field }
}
#[inline]
--
2.48.1