Skip to content

Commit

Permalink
fw: iec: Fix warning about references to static mut
Browse files Browse the repository at this point in the history
References to static mut quickly lead to undefined behavior.  Adjust the
code such that no direct references to static mut variables are created.
  • Loading branch information
Rahix committed May 16, 2024
1 parent 95655ce commit 280d62a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Firmware-IEC/src-rust/matiec/ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),)*
]
}
}
Expand Down

0 comments on commit 280d62a

Please sign in to comment.