summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2022-02-14 09:26:16 +0300
committerIvan Maidanski <ivmai@mail.ru>2022-02-14 12:29:11 +0300
commitbdea34747d0a49899e034bcbede36afce464a6ab (patch)
tree7ac475ad5c25465eefa380c3328eb0df64a32ad4
parent691685d27474cafc9475650564d43362bb35245c (diff)
downloadlibatomic_ops-bdea34747d0a49899e034bcbede36afce464a6ab.tar.gz
Eliminate 'function is never used' cppcheck warning for AO_stack_init
* tests/test_stack.c [CPPCHECK] (the_list): Define w/o initialization. * tests/test_stack.c [CPPCHECK] (main): Call AO_stack_init().
-rw-r--r--tests/test_stack.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/tests/test_stack.c b/tests/test_stack.c
index 40d5795..09225ff 100644
--- a/tests/test_stack.c
+++ b/tests/test_stack.c
@@ -85,7 +85,11 @@ typedef struct le {
int data;
} list_element;
-AO_stack_t the_list = AO_STACK_INITIALIZER;
+#if defined(CPPCHECK)
+ AO_stack_t the_list; /* to test AO_stack_init() */
+#else
+ AO_stack_t the_list = AO_STACK_INITIALIZER;
+#endif
/* Add elements from 1 to n to the list (1 is pushed first). */
/* This is called from a single thread only. */
@@ -262,6 +266,9 @@ int main(int argc, char **argv)
# ifdef AO_USE_ALMOST_LOCK_FREE
printf("Use almost-lock-free implementation\n");
# endif
+# if defined(CPPCHECK)
+ AO_stack_init(&the_list);
+# endif
for (exper_n = 0; exper_n < N_EXPERIMENTS; ++exper_n)
for (nthreads = 1; nthreads <= max_nthreads; ++nthreads)
{