From: Mathieu Desnoyers Date: Mon, 5 Sep 2011 00:10:41 +0000 (-0400) Subject: lfq baseline: check for empty list X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=42eb9ea1d4ea572cfc4749ce2794955d228491a8;p=urcu.git lfq baseline: check for empty list Signed-off-by: Mathieu Desnoyers --- diff --git a/tests/test_lfq_baseline.c b/tests/test_lfq_baseline.c index 4f0eba2..c35d894 100644 --- a/tests/test_lfq_baseline.c +++ b/tests/test_lfq_baseline.c @@ -242,9 +242,12 @@ void *thr_dequeuer(void *_count) struct test *node; test_mutex_lock(); - node = cds_list_first_entry(&q, struct test, node); - if (node) + if (!cds_list_empty(&q)) { + node = cds_list_first_entry(&q, struct test, node); cds_list_del(&node->node); + } else { + node = NULL; + } test_mutex_unlock(); if (node) { @@ -273,7 +276,11 @@ void test_end(unsigned long long *nr_dequeues) struct test *node; do { - node = cds_list_first_entry(&q, struct test, node); + if (!cds_list_empty(&q)) { + node = cds_list_first_entry(&q, struct test, node); + } else { + node = NULL; + } if (node) { cds_list_del(&node->node); free(node); /* no more concurrent access */