From: Mathieu Desnoyers Date: Mon, 21 Sep 2015 15:55:17 +0000 (-0400) Subject: Fix: test: side-effect in assertion X-Git-Tag: v0.9.0~32 X-Git-Url: https://git.liburcu.org/?p=urcu.git;a=commitdiff_plain;h=19d0e7ef8f7998fb256017ba2da414d78b3cb91b Fix: test: side-effect in assertion 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 --- diff --git a/tests/benchmark/test_mutex.c b/tests/benchmark/test_mutex.c index 574d0e8..81efcae 100644 --- a/tests/benchmark/test_mutex.c +++ b/tests/benchmark/test_mutex.c @@ -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); diff --git a/tests/benchmark/test_perthreadlock.c b/tests/benchmark/test_perthreadlock.c index cc5f47d..b10c9cd 100644 --- a/tests/benchmark/test_perthreadlock.c +++ b/tests/benchmark/test_perthreadlock.c @@ -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);