[vlc-devel] [PATCH] mutex: remove write-only variable

remi at remlab.net remi at remlab.net
Tue Jan 12 16:53:18 UTC 2021


From: RĂ©mi Denis-Courmont <remi at remlab.net>

---
 src/misc/threads.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/src/misc/threads.c b/src/misc/threads.c
index a44edb0727..46c569fff0 100644
--- a/src/misc/threads.c
+++ b/src/misc/threads.c
@@ -157,8 +157,6 @@ bool vlc_mutex_held(const vlc_mutex_t *mtx)
 
 void vlc_mutex_lock(vlc_mutex_t *mtx)
 {
-    unsigned value;
-
     /* This is the Drepper (non-recursive) mutex algorithm
      * from his "Futexes are tricky" paper. The mutex can value be:
      * - 0: the mutex is free
@@ -170,8 +168,7 @@ void vlc_mutex_lock(vlc_mutex_t *mtx)
 
     int canc = vlc_savecancel(); /* locking is never a cancellation point */
 
-    while ((value = atomic_exchange_explicit(&mtx->value, 2,
-                                             memory_order_acquire)) != 0)
+    while (atomic_exchange_explicit(&mtx->value, 2, memory_order_acquire))
         vlc_atomic_wait(&mtx->value, 2);
 
     vlc_restorecancel(canc);
-- 
2.30.0



More information about the vlc-devel mailing list