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 574d0e8..81efcae 100644 (file)
@@ -179,8 +179,11 @@ void *thr_reader(void *data)
        }
 
        for (;;) {
+               int v;
+
                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);
index cc5f47d..b10c9cd 100644 (file)
@@ -183,8 +183,11 @@ void *thr_reader(void *data)
        }
 
        for (;;) {
+               int v;
+
                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);
This page took 0.032482 seconds and 4 git commands to generate.