From 3b70c29103cce7b03b6f0fe465e1197a3b212179 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Sat, 21 May 2022 11:15:28 +0200 Subject: [PATCH] Fix typo in futex RwLock::write_contended. I wrote `state` where I should've used `s`. This removes the unnecessary `s` variable to prevent that mistake. Fortunately, this typo didn't affect the correctness of the lock, as the second half of the condition (!has_writers_waiting) is enough for correctness, which explains why this mistake didn't show up during testing. --- library/std/src/sys/unix/locks/futex_rwlock.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/library/std/src/sys/unix/locks/futex_rwlock.rs b/library/std/src/sys/unix/locks/futex_rwlock.rs index 57f6d58840d..5ff1aba7974 100644 --- a/library/std/src/sys/unix/locks/futex_rwlock.rs +++ b/library/std/src/sys/unix/locks/futex_rwlock.rs @@ -208,9 +208,8 @@ impl RwLock { // Don't go to sleep if the lock has become available, // or if the writers waiting bit is no longer set. - let s = self.state.load(Relaxed); - if is_unlocked(state) || !has_writers_waiting(s) { - state = s; + state = self.state.load(Relaxed); + if is_unlocked(state) || !has_writers_waiting(state) { continue; }