lockable: replaced locks with lock guard macros where appropriate

- ran regexp "qemu_mutex_lock\(.*\).*\n.*if" to find targets
- replaced result with QEMU_LOCK_GUARD if all unlocks at function end
- replaced result with WITH_QEMU_LOCK_GUARD if unlock not at end

Signed-off-by: Daniel Brodsky <dnbrdsky@gmail.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Message-id: 20200404042108.389635-3-dnbrdsky@gmail.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
Daniel Brodsky 2020-04-03 21:21:08 -07:00 committed by Stefan Hajnoczi
parent 56f21718b8
commit 6e8a355de6
15 changed files with 83 additions and 106 deletions

View file

@ -25,6 +25,7 @@
#include "qemu/cutils.h"
#include "trace/control.h"
#include "qemu/thread.h"
#include "qemu/lockable.h"
static char *logfilename;
static QemuMutex qemu_logfile_mutex;
@ -94,7 +95,7 @@ void qemu_set_log(int log_flags)
if (qemu_loglevel && (!is_daemonized() || logfilename)) {
need_to_open_file = true;
}
qemu_mutex_lock(&qemu_logfile_mutex);
QEMU_LOCK_GUARD(&qemu_logfile_mutex);
if (qemu_logfile && !need_to_open_file) {
logfile = qemu_logfile;
atomic_rcu_set(&qemu_logfile, NULL);
@ -136,7 +137,6 @@ void qemu_set_log(int log_flags)
}
atomic_rcu_set(&qemu_logfile, logfile);
}
qemu_mutex_unlock(&qemu_logfile_mutex);
}
void qemu_log_needs_buffers(void)