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

Tristan Matthews tmatth at videolan.org
Tue Jan 12 17:07:33 UTC 2021


On Tue, Jan 12, 2021 at 11:53 AM <remi at remlab.net> wrote:
>
> 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);

LGTM.

Best,
-t


More information about the vlc-devel mailing list