From mboxrd@z Thu Jan 1 00:00:00 1970 From: mathieu.desnoyers@efficios.com (Mathieu Desnoyers) Date: Sat, 13 Oct 2012 12:48:58 -0400 Subject: [lttng-dev] [PATCH 3/4] test: test for the proper pointer In-Reply-To: <1350144514-4132-3-git-send-email-laijs@cn.fujitsu.com> References: <1350144514-4132-1-git-send-email-laijs@cn.fujitsu.com> <1350144514-4132-3-git-send-email-laijs@cn.fujitsu.com> Message-ID: <20121013164858.GG29985@Krystal> * Lai Jiangshan (laijs at cn.fujitsu.com) wrote: > 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. merged, thanks! Mathieu > > Signed-off-by: Lai Jiangshan > --- > tests/test_urcu_lfq.c | 7 ++++--- > 1 files changed, 4 insertions(+), 3 deletions(-) > > diff --git a/tests/test_urcu_lfq.c b/tests/test_urcu_lfq.c > index 66ddd41..0fcbf55 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)++; > } > -- > 1.7.7.6 > -- Mathieu Desnoyers Operating System Efficiency R&D Consultant EfficiOS Inc. http://www.efficios.com