Skip to contentSkip to conversation

Replace conditional test with is_power_of_2().

PATCH New Robert P. J. Day 1 participant 1 message Apr 24, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Replace conditional test with is_power_of_2().

---

yes, i know the word "tachnique" is misspelled there. that's not
part of this patch so i'm not fixing it here.

kernel/kfifo.c +1 -1
index bc41ad0..04a1748 100644
@@ -74,7 +74,7 @@ struct kfifo *kfifo_alloc(unsigned int size, gfp_t gfp_mask, spinlock_t *lock)
 	 * round up to the next power of 2, since our 'let the indices
 	 * wrap' tachnique works only in this case.
 	 */
-	if (size & (size - 1)) {
+	if (!is_power_of_2(size)) {
 		BUG_ON(size > 0x80000000);
 		size = roundup_pow_of_two(size);
 	}

========================================================================
Robert P. J. Day Waterloo, Ontario, CANADA

Linux Consulting, Training and Annoying Kernel Pedantry.

Web page:                                          http://crashcourse.ca
Linked In:                             http://www.linkedin.com/in/rpjday
Twitter:                                       http://twitter.com/rpjday

========================================================================