[ltt-dev] [PATCH 09/11] remove unneed code in _cds_lfht_replace()

Lai Jiangshan laijs at cn.fujitsu.com
Fri Oct 14 11:04:39 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 694cb99..2c3f914 100644
--- a/rculfhash.c
+++ b/rculfhash.c
@@ -785,10 +785,9 @@ int _cds_lfht_replace(struct cds_lfht *ht, unsigned long size,
 {
 	struct cds_lfht_node *dummy, *ret_next;
 	struct _cds_lfht_node *lookup;
-	int flagged = 0;
 
 	if (!old_node)	/* Return -ENOENT if asked to replace NULL node */
-		goto end;
+		return -ENOENT;
 
 	assert(!is_removed(old_node));
 	assert(!is_dummy(old_node));
@@ -802,7 +801,7 @@ int _cds_lfht_replace(struct cds_lfht *ht, unsigned long size,
 			 * Too late, the old node has been removed under us
 			 * between lookup and replace. Fail.
 			 */
-			goto end;
+			return -ENOENT;
 		}
 		assert(!is_dummy(old_next));
 		assert(new_node != clear_flag(old_next));
@@ -824,9 +823,6 @@ int _cds_lfht_replace(struct cds_lfht *ht, unsigned long size,
 		old_next = ret_next;
 	}
 
-	/* We performed the replacement. */
-	flagged = 1;
-
 	/*
 	 * Ensure that the old node is not visible to readers anymore:
 	 * lookup for the node, and remove it (along with any other
@@ -835,17 +831,9 @@ int _cds_lfht_replace(struct cds_lfht *ht, unsigned long size,
 	lookup = lookup_bucket(ht, size, bit_reverse_ulong(old_node->p.reverse_hash));
 	dummy = (struct cds_lfht_node *) lookup;
 	_cds_lfht_gc_bucket(dummy, new_node);
-end:
-	/*
-	 * Only the flagging action indicated that we (and no other)
-	 * replaced the node from the hash table.
-	 */
-	if (flagged) {
-		assert(is_removed(rcu_dereference(old_node->p.next)));
-		return 0;
-	} else {
-		return -ENOENT;
-	}
+
+	assert(is_removed(rcu_dereference(old_node->p.next)));
+	return 0;
 }
 
 static
-- 
1.7.4.4





More information about the lttng-dev mailing list