From: Colin McCabe Date: Wed, 11 May 2011 11:38:29 +0000 (-0400) Subject: userspace-rcu tests: zero array before using X-Git-Tag: v0.6.0~47 X-Git-Url: https://git.liburcu.org/?p=urcu.git;a=commitdiff_plain;h=92e8d9d64a97e2d098cefa223208b2d18118194e userspace-rcu tests: zero array before using 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 Signed-off-by: Mathieu Desnoyers --- diff --git a/tests/test_qsbr.c b/tests/test_qsbr.c index 1ef8c26..99da27c 100644 --- a/tests/test_qsbr.c +++ b/tests/test_qsbr.c @@ -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); diff --git a/tests/test_urcu.c b/tests/test_urcu.c index e6a6489..bbdb2d8 100644 --- a/tests/test_urcu.c +++ b/tests/test_urcu.c @@ -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); diff --git a/tests/test_urcu_assign.c b/tests/test_urcu_assign.c index 24a704b..a73fc23 100644 --- a/tests/test_urcu_assign.c +++ b/tests/test_urcu_assign.c @@ -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); diff --git a/tests/test_urcu_bp.c b/tests/test_urcu_bp.c index 7f20a6a..f475fa6 100644 --- a/tests/test_urcu_bp.c +++ b/tests/test_urcu_bp.c @@ -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);