[ltt-dev] [PATCH 10/11] remove unneed code in _cds_lfht_del()

Lai Jiangshan laijs at cn.fujitsu.com
Fri Oct 14 11:04:40 EDT 2011


Signed-off-by: Lai Jiangshan <laijs at cn.fujitsu.com>
---
 rculfhash.c |   22 +++++-----------------
 1 files changed, 5 insertions(+), 17 deletions(-)

diff --git a/rculfhash.c b/rculfhash.c
index 2c3f914..5d0b35f 100644
--- a/rculfhash.c
+++ b/rculfhash.c
@@ -928,10 +928,9 @@ int _cds_lfht_del(struct cds_lfht *ht, unsigned long size,
 {
 	struct cds_lfht_node *dummy, *next, *old;
 	struct _cds_lfht_node *lookup;
-	int flagged = 0;
 
 	if (!node)	/* Return -ENOENT if asked to delete NULL node */
-		goto end;
+		return -ENOENT;
 
 	/* logically delete the node */
 	assert(!is_dummy(node));
@@ -942,7 +941,7 @@ int _cds_lfht_del(struct cds_lfht *ht, unsigned long size,
 
 		next = old;
 		if (unlikely(is_removed(next)))
-			goto end;
+			return -ENOENT;
 		if (dummy_removal)
 			assert(is_dummy(next));
 		else
@@ -951,9 +950,6 @@ int _cds_lfht_del(struct cds_lfht *ht, unsigned long size,
 		old = uatomic_cmpxchg(&node->p.next, next, new_next);
 	} while (old != next);
 
-	/* We performed the (logical) deletion. */
-	flagged = 1;
-
 	/*
 	 * Ensure that the node is not visible to readers anymore: lookup for
 	 * the node, and remove it (along with any other logically removed node)
@@ -962,17 +958,9 @@ int _cds_lfht_del(struct cds_lfht *ht, unsigned long size,
 	lookup = lookup_bucket(ht, size, bit_reverse_ulong(node->p.reverse_hash));
 	dummy = (struct cds_lfht_node *) lookup;
 	_cds_lfht_gc_bucket(dummy, node);
-end:
-	/*
-	 * Only the flagging action indicated that we (and no other)
-	 * removed the node from the hash.
-	 */
-	if (flagged) {
-		assert(is_removed(rcu_dereference(node->p.next)));
-		return 0;
-	} else {
-		return -ENOENT;
-	}
+
+	assert(is_removed(rcu_dereference(node->p.next)));
+	return 0;
 }
 
 static
-- 
1.7.4.4





More information about the lttng-dev mailing list