From 280d62a559bc9d96259b4d784b942bee3c725573 Mon Sep 17 00:00:00 2001 From: Rahix Date: Thu, 16 May 2024 12:00:07 +0200 Subject: [PATCH] fw: iec: Fix warning about references to static mut References to static mut quickly lead to undefined behavior. Adjust the code such that no direct references to static mut variables are created. --- Firmware-IEC/src-rust/matiec/ext.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Firmware-IEC/src-rust/matiec/ext.rs b/Firmware-IEC/src-rust/matiec/ext.rs index 2ba022b..f262df7 100644 --- a/Firmware-IEC/src-rust/matiec/ext.rs +++ b/Firmware-IEC/src-rust/matiec/ext.rs @@ -22,13 +22,13 @@ macro_rules! io_tags_def { paste::paste! { $( #[export_name = concat!("__", stringify!($IO))] - static mut [<$IO _ADDR>]: *const $Ty = unsafe { &$IO }; + static mut [<$IO _ADDR>]: *const $Ty = unsafe { ::core::ptr::addr_of!($IO) }; pub static mut $IO: $Ty = 0; )* pub unsafe fn all_mut<'a>() -> [&'a mut $Ty; $N] { [ - $(&mut $IO,)* + $(&mut *::core::ptr::addr_of_mut!($IO),)* ] } }