All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Knutsson <ricknu-0@student.ltu.se>
To: kernel-janitors@vger.kernel.org
Subject: Re: [KJ] [PATCH] is_power_of_2 in kernel/kfifo
Date: Wed, 21 Feb 2007 15:32:13 +0000	[thread overview]
Message-ID: <45DC65FD.4030109@student.ltu.se> (raw)
In-Reply-To: <1172063918.6127.83.camel@wriver-t81fb058.linuxcoe>

Vignesh Babu BM wrote:
> Replacing (n & (n-1)) in the context of power of 2 checks
> with is_power_of_2
>
> Signed-off-by: vignesh babu <vignesh.babu@wipro.com>
> --- 
> diff --git a/kernel/kfifo.c b/kernel/kfifo.c
> index 5d1d907..eeb5e7e 100644
> --- a/kernel/kfifo.c
> +++ b/kernel/kfifo.c
> @@ -24,6 +24,7 @@
>  #include <linux/slab.h>
>  #include <linux/err.h>
>  #include <linux/kfifo.h>
> +#include <linux/log2.h>
>  
>  /**
>   * kfifo_init - allocates a new FIFO using a preallocated buffer
> @@ -41,7 +42,7 @@ struct kfifo *kfifo_init(unsigned char *buffer, unsigned int size,
>  	struct kfifo *fifo;
>  
>  	/* size must be a power of 2 */
> -	BUG_ON(size & (size - 1));
> +	BUG_ON(!is_power_of_2(size));
>  
>  	fifo = kmalloc(sizeof(struct kfifo), gfp_mask);
>  	if (!fifo)
>   
Could you also remove the comment? (since it is now obvious by the code)

Richard Knutsson

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

  reply	other threads:[~2007-02-21 15:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-21 13:30 [KJ] [PATCH] is_power_of_2 in kernel/kfifo Vignesh Babu BM
2007-02-21 15:32 ` Richard Knutsson [this message]
2007-02-21 20:37 ` Stelian Pop

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=45DC65FD.4030109@student.ltu.se \
    --to=ricknu-0@student.ltu.se \
    --cc=kernel-janitors@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.