From 19d0e7ef8f7998fb256017ba2da414d78b3cb91b Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Mon, 21 Sep 2015 11:55:17 -0400 Subject: [PATCH] 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 --- tests/benchmark/test_mutex.c | 5 ++++- tests/benchmark/test_perthreadlock.c | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) 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); -- 2.34.1