From 2b8dda74aa22b7dc7307bcdfda09b0efe356aa9f Mon Sep 17 00:00:00 2001 From: zachs18 <8355914+zachs18@users.noreply.github.com> Date: Tue, 25 Oct 2022 13:16:03 -0500 Subject: [PATCH] Remove unnecessary `mut` from `static mut LOCK_OWNER: AtomicU8` in critical section impl. `LOCK_OWNER` is only accessed using the atomic APIs, which take `&self`, so it does not need to be `static mut`, `static` is fine. (I haven't seen any miscompilations of this, but I'm unsure if Rust is allowed to assume `static mut`s are not aliased and apply optimizations based on that. If so, this would prevent that.) --- rp2040-hal/src/critical_section_impl.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rp2040-hal/src/critical_section_impl.rs b/rp2040-hal/src/critical_section_impl.rs index a4c259f..f3f573f 100644 --- a/rp2040-hal/src/critical_section_impl.rs +++ b/rp2040-hal/src/critical_section_impl.rs @@ -14,7 +14,7 @@ const LOCK_UNOWNED: u8 = 0; /// Indicates which core owns the lock so that we can call critical_section recursively. /// /// 0 = no one has the lock, 1 = core0 has the lock, 2 = core1 has the lock -static mut LOCK_OWNER: AtomicU8 = AtomicU8::new(LOCK_UNOWNED); +static LOCK_OWNER: AtomicU8 = AtomicU8::new(LOCK_UNOWNED); /// Marker value to indicate that we already owned the lock when we started the `critical_section`. ///