userspace-rcu tests: zero array before using
authorColin McCabe <cmccabe@alumni.cmu.edu>
Wed, 11 May 2011 11:38:29 +0000 (07:38 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 11 May 2011 11:38:29 +0000 (07:38 -0400)
It seems like we need the test arrays to start out zeroed.

Without this patch, I get errors like this when running the tests:
test_urcu: test_urcu.c:201: test_array_alloc:
Assertion `test_array[index].a == 0xDEADBEEF || test_array[index].a ==
0' failed.

Signed-off-by: Colin McCabe <cmccabe@alumni.cmu.edu>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
tests/test_qsbr.c
tests/test_urcu.c
tests/test_urcu_assign.c
tests/test_urcu_bp.c

index 1ef8c265895025a51021bf005b25eedeae546f98..99da27c6a97564c5c015ee34b08174cd99ccde28 100644 (file)
@@ -403,7 +403,7 @@ int main(int argc, char **argv)
        printf_verbose("thread %-6s, thread id : %lx, tid %lu\n",
                        "main", pthread_self(), (unsigned long)gettid());
 
-       test_array = malloc(sizeof(*test_array) * ARRAY_SIZE);
+       test_array = calloc(1, sizeof(*test_array) * ARRAY_SIZE);
        tid_reader = malloc(sizeof(*tid_reader) * nr_readers);
        tid_writer = malloc(sizeof(*tid_writer) * nr_writers);
        count_reader = malloc(sizeof(*count_reader) * nr_readers);
index e6a648981ed8b6b5a0abb679771d98d5e695dd9b..bbdb2d8f4ac33abe82aa23ce6a8844a2db179b89 100644 (file)
@@ -400,7 +400,7 @@ int main(int argc, char **argv)
        printf_verbose("thread %-6s, thread id : %lx, tid %lu\n",
                        "main", pthread_self(), (unsigned long)gettid());
 
-       test_array = malloc(sizeof(*test_array) * ARRAY_SIZE);
+       test_array = calloc(1, sizeof(*test_array) * ARRAY_SIZE);
        tid_reader = malloc(sizeof(*tid_reader) * nr_readers);
        tid_writer = malloc(sizeof(*tid_writer) * nr_writers);
        count_reader = malloc(sizeof(*count_reader) * nr_readers);
index 24a704b242583de6f6894b4d534426124d4f9aa9..a73fc23892aa37961de60c409d6b2dbae0d11d49 100644 (file)
@@ -399,7 +399,7 @@ int main(int argc, char **argv)
        printf_verbose("thread %-6s, thread id : %lx, tid %lu\n",
                        "main", pthread_self(), (unsigned long)gettid());
 
-       test_array = malloc(sizeof(*test_array) * ARRAY_SIZE);
+       test_array = calloc(1, sizeof(*test_array) * ARRAY_SIZE);
        tid_reader = malloc(sizeof(*tid_reader) * nr_readers);
        tid_writer = malloc(sizeof(*tid_writer) * nr_writers);
        count_reader = malloc(sizeof(*count_reader) * nr_readers);
index 7f20a6a060233c4795ae5ed01d0a9aef4891c748..f475fa6bd574ada9bf2013f805b9a222a5f76058 100644 (file)
@@ -396,7 +396,7 @@ int main(int argc, char **argv)
        printf_verbose("thread %-6s, thread id : %lx, tid %lu\n",
                        "main", pthread_self(), (unsigned long)gettid());
 
-       test_array = malloc(sizeof(*test_array) * ARRAY_SIZE);
+       test_array = calloc(1, sizeof(*test_array) * ARRAY_SIZE);
        tid_reader = malloc(sizeof(*tid_reader) * nr_readers);
        tid_writer = malloc(sizeof(*tid_writer) * nr_writers);
        count_reader = malloc(sizeof(*count_reader) * nr_readers);
This page took 0.026564 seconds and 4 git commands to generate.