qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 1/4] monitor: use QEMU_LOCK_GUARD a bit more


From: Markus Armbruster
Subject: Re: [PATCH 1/4] monitor: use QEMU_LOCK_GUARD a bit more
Date: Thu, 25 May 2023 17:06:32 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)

Paolo Bonzini <pbonzini@redhat.com> writes:

> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  monitor/monitor.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/monitor/monitor.c b/monitor/monitor.c
> index 602535696c59..4b11bca2a21d 100644
> --- a/monitor/monitor.c
> +++ b/monitor/monitor.c
> @@ -161,10 +161,9 @@ static gboolean monitor_unblocked(void *do_not_use, 
> GIOCondition cond,
>  {
>      Monitor *mon = opaque;
>  
> -    qemu_mutex_lock(&mon->mon_lock);
> +    QEMU_LOCK_GUARD(&mon->mon_lock);
>      mon->out_watch = 0;
>      monitor_flush_locked(mon);
> -    qemu_mutex_unlock(&mon->mon_lock);
>      return FALSE;
>  }
>  
> @@ -203,9 +202,8 @@ static void monitor_flush_locked(Monitor *mon)
>  
>  void monitor_flush(Monitor *mon)
>  {
> -    qemu_mutex_lock(&mon->mon_lock);
> +    QEMU_LOCK_GUARD(&mon->mon_lock);
>      monitor_flush_locked(mon);
> -    qemu_mutex_unlock(&mon->mon_lock);
>  }
>  
>  /* flush at every end of line */

I wouldn't bother to make this change when the protected region is this
short and doesn't branch, but since you did, why not take it.

Reviewed-by: Markus Armbruster <armbru@redhat.com>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]