qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH 2/2] rfifolock: fix bogus coverity warning


From: Stefan Hajnoczi
Subject: [Qemu-devel] [PATCH 2/2] rfifolock: fix bogus coverity warning
Date: Fri, 14 Mar 2014 16:14:59 +0100

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 <address@hidden>
---
 util/rfifolock.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/util/rfifolock.c b/util/rfifolock.c
index afbf748..f42214d 100644
--- a/util/rfifolock.c
+++ b/util/rfifolock.c
@@ -17,12 +17,14 @@
 void rfifolock_init(RFifoLock *r, void (*cb)(void *), void *opaque)
 {
     qemu_mutex_init(&r->lock);
+    qemu_cond_init(&r->cond);
+    qemu_mutex_lock(&r->lock);
     r->head = 0;
     r->tail = 0;
-    qemu_cond_init(&r->cond);
     r->nesting = 0;
     r->cb = cb;
     r->cb_opaque = opaque;
+    qemu_mutex_unlock(&r->lock);
 }
 
 void rfifolock_destroy(RFifoLock *r)
-- 
1.8.5.3




reply via email to

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