Fix: test: side-effect in assertion
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 21 Sep 2015 15:55:17 +0000 (11:55 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 21 Sep 2015 15:55:17 +0000 (11:55 -0400)
Coverity detected:

CID 1021642 (#1 of 2): Side effect in assertion
(ASSERT_SIDE_EFFECT)assert_side_effect: Argument test_array of assert()
has a side effect because the variable is volatile. The containing
function might work differently in a non-debug build.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
tests/benchmark/test_mutex.c
tests/benchmark/test_perthreadlock.c

index 574d0e8cfce8efb3363c32c8acdae103113b27df..81efcaeb33d77949b3bf7abec625082d18a43819 100644 (file)
@@ -179,8 +179,11 @@ void *thr_reader(void *data)
        }
 
        for (;;) {
        }
 
        for (;;) {
+               int v;
+
                pthread_mutex_lock(&lock);
                pthread_mutex_lock(&lock);
-               assert(test_array.a == 8);
+               v = test_array.a;
+               assert(v == 8);
                if (caa_unlikely(rduration))
                        loop_sleep(rduration);
                pthread_mutex_unlock(&lock);
                if (caa_unlikely(rduration))
                        loop_sleep(rduration);
                pthread_mutex_unlock(&lock);
index cc5f47dfa7345f530572e11e9b077154cbeed3ad..b10c9cd9a15def438f04b0177388689c6f9b4fd9 100644 (file)
@@ -183,8 +183,11 @@ void *thr_reader(void *data)
        }
 
        for (;;) {
        }
 
        for (;;) {
+               int v;
+
                pthread_mutex_lock(&per_thread_lock[tidx].lock);
                pthread_mutex_lock(&per_thread_lock[tidx].lock);
-               assert(test_array.a == 8);
+               v = test_array.a;
+               assert(v == 8);
                if (caa_unlikely(rduration))
                        loop_sleep(rduration);
                pthread_mutex_unlock(&per_thread_lock[tidx].lock);
                if (caa_unlikely(rduration))
                        loop_sleep(rduration);
                pthread_mutex_unlock(&per_thread_lock[tidx].lock);
This page took 0.025573 seconds and 4 git commands to generate.