[vlc-commits] mutex: remove write-only variable

Rémi Denis-Courmont git at videolan.org
Wed Jan 13 17:55:12 UTC 2021


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Jan 12 18:52:57 2021 +0200| [222367a03fd40043aa767fa8e55b8dbc1cec12ee] | committer: Rémi Denis-Courmont

mutex: remove write-only variable

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=222367a03fd40043aa767fa8e55b8dbc1cec12ee
---

 src/misc/threads.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/src/misc/threads.c b/src/misc/threads.c
index 196e0dc1d0..15311b5214 100644
--- a/src/misc/threads.c
+++ b/src/misc/threads.c
@@ -157,10 +157,8 @@ 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:
+     * from his "Futexes are tricky" paper. The mutex value can be:
      * - 0: the mutex is free
      * - 1: the mutex is locked and uncontended
      * - 2: the mutex is contended (i.e., unlock needs to wake up a waiter)
@@ -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);



More information about the vlc-commits mailing list