qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
	Markus Armbruster <armbru@redhat.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	"Dr. David Alan Gilbert" <dgilbert@redhat.com>
Subject: [Qemu-devel] [PATCH 1/2] iothread: fix bogus coverity warning
Date: Fri, 14 Mar 2014 16:14:58 +0100	[thread overview]
Message-ID: <1394810099-21028-2-git-send-email-stefanha@redhat.com> (raw)
In-Reply-To: <1394810099-21028-1-git-send-email-stefanha@redhat.com>

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 --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.
      */
-- 
1.8.5.3

  reply	other threads:[~2014-03-14 15:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-14 15:14 [Qemu-devel] [PATCH 0/2] dataplane: fix bogus coverity warnings Stefan Hajnoczi
2014-03-14 15:14 ` Stefan Hajnoczi [this message]
2014-03-14 15:14 ` [Qemu-devel] [PATCH 2/2] rfifolock: fix bogus coverity warning Stefan Hajnoczi
2014-03-14 17:25 ` [Qemu-devel] [PATCH 0/2] dataplane: fix bogus coverity warnings Paolo Bonzini
2014-03-17 14:56   ` Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1394810099-21028-2-git-send-email-stefanha@redhat.com \
    --to=stefanha@redhat.com \
    --cc=armbru@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).