From 42eb9ea1d4ea572cfc4749ce2794955d228491a8 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Sun, 4 Sep 2011 20:10:41 -0400 Subject: [PATCH] lfq baseline: check for empty list Signed-off-by: Mathieu Desnoyers --- tests/test_lfq_baseline.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) 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 */ -- 2.34.1