[ltt-dev] [PATCH] userspace-rcu tests: zero array before using

Mathieu Desnoyers mathieu.desnoyers at efficios.com
Wed May 11 07:37:31 EDT 2011


* Colin McCabe (cmccabe at alumni.cmu.edu) wrote:
> [PATCH] 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.

You're right. Patch merged. Thanks!

Mathieu

> 
> Signed-off-by: Colin McCabe <cmccabe at alumni.cmu.edu>
> ---
>  tests/test_qsbr.c        |    2 +-
>  tests/test_urcu.c        |    2 +-
>  tests/test_urcu_assign.c |    2 +-
>  tests/test_urcu_bp.c     |    2 +-
>  4 files changed, 4 insertions(+), 4 deletions(-)
> 
> 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);
> -- 
> 1.7.4.4

-- 
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com




More information about the lttng-dev mailing list