Skip to content

Commit

Permalink
Fix: test: side-effect in assertion
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
compudj committed Sep 21, 2015
1 parent 999991c commit 19d0e7e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion tests/benchmark/test_mutex.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 4 additions & 1 deletion tests/benchmark/test_perthreadlock.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 19d0e7e

Please sign in to comment.