dataplane: fix bogus coverity warnings
cover dataplane: fix bogus coverity warnings
Coverity detects when variable are accessed under a mutex most of the time. It warns when they are not accessed under the mutex. I initialized variables before the mutex and threads that access them even exist - Coverity doesn't like that. Fix the code.
Stefan Hajnoczi (2):
iothread: fix bogus coverity warning
rfifolock: fix bogus coverity warning
iothread.c | 5 ++++- util/rfifolock.c | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-)
Signature · 1 line
1.8.5.3
PATCH 1/2 iothread: fix bogus coverity warning
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.
--- iothread.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
iothread.c +4 -1
@@ -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. */
Signature · 1 line
1.8.5.3
PATCH 2/2 rfifolock: fix bogus coverity warning
In reply to Stefan HajnocziCoverity 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.
--- util/rfifolock.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
util/rfifolock.c +3 -1
@@ -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)
Signature · 1 line
1.8.5.3
Il 14/03/2014 16:14, Stefan Hajnoczi ha scritto:
Quoted 5 lines
Coverity detects when variable are accessed under a mutex most of the time. It warns when they are not accessed under the mutex. I initialized variables before the mutex and threads that access them even exist - Coverity doesn't like that. Fix the code.
Quoted 8 lines
Stefan Hajnoczi (2):
iothread: fix bogus coverity warning
rfifolock: fix bogus coverity warningiothread.c | 5 ++++- util/rfifolock.c | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-)
Nah, I think Coverity is wrong. It should detect initialization of the mutex, and treat surrounding code as single-threaded. I silenced the defects in the report, like others before.
Paolo
Quoted 10 lines · Paolo Bonzini
Il 14/03/2014 16:14, Stefan Hajnoczi ha scritto:
Quoted 9 lines
Coverity detects when variable are accessed under a mutex most of the time. It warns when they are not accessed under the mutex. I initialized variables before the mutex and threads that access them even exist - Coverity doesn't like that. Fix the code.
Stefan Hajnoczi (2):
iothread: fix bogus coverity warning
rfifolock: fix bogus coverity warning
Quoted 8 lines
Quoted 4 lines
iothread.c| 5 ++++-util/rfifolock.c| 4 +++-2 files changed, 7 insertions(+), 2 deletions(-)Nah, I think Coverity is wrong. It should detect initialization of the mutex, and treat surrounding code as single-threaded. I silenced the defects in the report, like others before.
Okay, let's drop these patches.
Stefan