test_urcu_lfq: test for the proper pointer
authorLai Jiangshan <laijs@cn.fujitsu.com>
Sat, 13 Oct 2012 16:46:45 +0000 (12:46 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Sat, 13 Oct 2012 16:46:45 +0000 (12:46 -0400)
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 <laijs@cn.fujitsu.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
tests/test_urcu_lfq.c

index 39e0351abb27672f5d6677e436ebaeebc88567b3..1bbaf3cfd504a2abd0ead6e724f2b514c079dff5 100644 (file)
@@ -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)++;
                }
This page took 0.025468 seconds and 4 git commands to generate.