From: Lai Jiangshan Date: Sat, 13 Oct 2012 16:46:45 +0000 (-0400) Subject: test_urcu_lfq: test for the proper pointer X-Git-Tag: v0.8.0~189 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=747b5930591527b65ad737ba609a59106ec2e89b;p=urcu.git test_urcu_lfq: test for the proper pointer We should use "if (qnode)" instead of "if (node)" in case of the struct cds_lfq_node_rcu is not the first field of struct node. Signed-off-by: Lai Jiangshan Signed-off-by: Mathieu Desnoyers --- diff --git a/tests/test_urcu_lfq.c b/tests/test_urcu_lfq.c index 39e0351..1bbaf3c 100644 --- a/tests/test_urcu_lfq.c +++ b/tests/test_urcu_lfq.c @@ -243,14 +243,15 @@ void *thr_dequeuer(void *_count) for (;;) { struct cds_lfq_node_rcu *qnode; - struct test *node; rcu_read_lock(); qnode = cds_lfq_dequeue_rcu(&q); - node = caa_container_of(qnode, struct test, list); rcu_read_unlock(); - if (node) { + if (qnode) { + struct test *node; + + node = caa_container_of(qnode, struct test, list); call_rcu(&node->rcu, free_node_cb); URCU_TLS(nr_successful_dequeues)++; }