Skip to contentSkip to conversation

is_power_of_2 in net/core/neighbour.c

kj vignesh babu 2 participants 2 messages Aug 13, 2007 – Aug 25, 2007

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

Replacing n & (n - 1) for power of 2 check by is_power_of_2(n)

---

net/core/neighbour.c +2 -1
index ca2a153..f7de8f2 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?"
maintainer
#1 lore raw

From: vignesh babu <[email protected]>
Date: Mon, 13 Aug 2007 18:33:47 +0530

Quoted 3 lines

Replacing n & (n - 1) for power of 2 check by is_power_of_2(n)

Patch applied, thanks.
_______________________________________________
REMINDER: this mailing list moved to vger.kernel.org and current one will be discontinued soon. To resubscribe, send email to [email protected] with
&quot;subscribe kernel-janitors&quot; in message body and follow instructions.

Kernel-janitors mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/kernel-janitors