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.)
This commit is contained in:
zachs18 2022-10-25 13:16:03 -05:00 committed by GitHub
parent 3a0b33cfc8
commit 2b8dda74aa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -14,7 +14,7 @@ const LOCK_UNOWNED: u8 = 0;
/// Indicates which core owns the lock so that we can call critical_section recursively. /// 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 /// 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`. /// Marker value to indicate that we already owned the lock when we started the `critical_section`.
/// ///