diff options
| author | Ivan Maidanski <ivmai@mail.ru> | 2014-06-13 16:35:55 +0400 |
|---|---|---|
| committer | Ivan Maidanski <ivmai@mail.ru> | 2014-06-13 16:35:55 +0400 |
| commit | ba6c3170412ef7f751ff63e2b656296265dcff93 (patch) | |
| tree | 0ab9e22c4cef9679585ea90288018166c6348d55 | |
| parent | b1e38be3cb8a957b014b64dd0e515fadbd198c9f (diff) | |
| download | libatomic_ops-ba6c3170412ef7f751ff63e2b656296265dcff93.tar.gz | |
Eliminate 'variable set but not used' Cppcheck warnings in test_stack
* tests/test_stack.c (run_one_test): Define "j" local variable only
if VERBOSE.
* tests/test_stack.c (main): Do not define "sum" local variable (and
don not compute the sum) if NO_TIMES.
| -rw-r--r-- | tests/test_stack.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/tests/test_stack.c b/tests/test_stack.c index 8170e5c..a3c5c30 100644 --- a/tests/test_stack.c +++ b/tests/test_stack.c @@ -175,9 +175,9 @@ volatile AO_t ops_performed = 0; list_element * t[MAX_NTHREADS + 1]; int index = (int)(size_t)arg; int i; - int j = 0; - # ifdef VERBOSE + int j = 0; + printf("starting thread %d\n", index); # endif while (fetch_and_add(&ops_performed, index + 1) + index + 1 < LIMIT) @@ -195,7 +195,9 @@ volatile AO_t ops_performed = 0; { AO_stack_push(&the_list, (AO_t *)t[i]); } - j += (index + 1); +# ifdef VERBOSE + j += index + 1; +# endif } # ifdef VERBOSE printf("finished thread %d: %d total ops\n", index, j); @@ -303,22 +305,23 @@ int main(int argc, char **argv) } for (nthreads = 1; nthreads <= max_nthreads; ++nthreads) { - unsigned long sum = 0; +# ifndef NO_TIMES + unsigned long sum = 0; +# endif printf("About %d pushes + %d pops in %d threads:", LIMIT, LIMIT, nthreads); - for (exper_n = 0; exper_n < N_EXPERIMENTS; ++exper_n) - { +# ifndef NO_TIMES + for (exper_n = 0; exper_n < N_EXPERIMENTS; ++exper_n) { # if defined(VERBOSE) printf(" [%lu]", times[nthreads][exper_n]); # endif sum += times[nthreads][exper_n]; } -# ifndef NO_TIMES - printf(" %lu msecs\n", (sum + N_EXPERIMENTS/2)/N_EXPERIMENTS); -# else - printf(" completed\n"); -# endif + printf(" %lu msecs\n", (sum + N_EXPERIMENTS/2)/N_EXPERIMENTS); +# else + printf(" completed\n"); +# endif } return 0; } |
