[ltt-dev] [PATCH 8/9] rculfhash: simplify get_count_order()

Lai Jiangshan laijs at cn.fujitsu.com
Mon Oct 10 21:23:58 EDT 2011


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

diff --git a/rculfhash.c b/rculfhash.c
index 7b880d7..eca3a4e 100644
--- a/rculfhash.c
+++ b/rculfhash.c
@@ -445,24 +445,22 @@ unsigned int fls_ulong(unsigned long x)
 #endif
 }
 
+/* find the minimum order that x <= (1UL << order) */
 int get_count_order_u32(uint32_t x)
 {
-	int order;
+	if (!x)
+		return -1;
 
-	order = fls_u32(x) - 1;
-	if (x & (x - 1))
-		order++;
-	return order;
+	return fls_u32(x - 1);
 }
 
+/* find the minimum order that x <= (1UL << order) */
 int get_count_order_ulong(unsigned long x)
 {
-	int order;
+	if (!x)
+		return -1;
 
-	order = fls_ulong(x) - 1;
-	if (x & (x - 1))
-		order++;
-	return order;
+	return fls_ulong(x - 1);
 }
 
 #ifdef POISON_FREE
-- 
1.7.4.4





More information about the lttng-dev mailing list