diff mbox

[1/2] iothread: fix bogus coverity warning

Message ID 1394810099-21028-2-git-send-email-stefanha@redhat.com
State New
Headers show

Commit Message

Stefan Hajnoczi March 14, 2014, 3:14 p.m. UTC
Coverity warns about initializing variables that will later be accessed
under a mutex.  There is no problem with the code itself but let's avoid
accumulating Coverity warnings.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 iothread.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/iothread.c b/iothread.c
index cb5986b..9e25af9 100644
--- a/iothread.c
+++ b/iothread.c
@@ -75,11 +75,14 @@  static void iothread_complete(UserCreatable *obj, Error **errp)
 
     iothread->stopping = false;
     iothread->ctx = aio_context_new();
-    iothread->thread_id = -1;
 
     qemu_mutex_init(&iothread->init_done_lock);
     qemu_cond_init(&iothread->init_done_cond);
 
+    qemu_mutex_lock(&iothread->init_done_lock);
+    iothread->thread_id = -1;
+    qemu_mutex_unlock(&iothread->init_done_lock);
+
     /* This assumes we are called from a thread with useful CPU affinity for us
      * to inherit.
      */