Skip to contentSkip to conversation

is_power_of_2-net/core/neighbour.c

PATCH New vignesh babu 1 participant 1 message Jun 14, 2007

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 is_power_of_2-net/core/neighbour.c

Replacing (n & (n-1)) in the context of power of 2 checks with is_power_of_2

---

net/core/neighbour.c +2 -1
index 6f3bb73..e663999 100644
@@ -33,6 +33,7 @@
 #include <linux/rtnetlink.h>
 #include <linux/random.h>
 #include <linux/string.h>
+#include <linux/log2.h>
 
 #define NEIGH_DEBUG 1
 
@@ -311,7 +312,7 @@ static void neigh_hash_grow(struct neigh_table *tbl, unsigned long new_entries)
 
 	NEIGH_CACHE_STAT_INC(tbl, hash_grows);
 
-	BUG_ON(new_entries & (new_entries - 1));
+	BUG_ON(!is_power_of_2(new_entries));
 	new_hash = neigh_hash_alloc(new_entries);
 	if (!new_hash)
 		return;
Signature · 3 lines
Vignesh Babu BM 
_____________________________________________________________ 
"Why is it that every time I'm with you, makes me believe in magic?"