linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] EXT4:  Use is_power_of_2() routine for clarity.
@ 2009-04-24 13:06 Robert P. J. Day
  2009-04-24 15:03 ` Eric Sandeen
  0 siblings, 1 reply; 4+ messages in thread
From: Robert P. J. Day @ 2009-04-24 13:06 UTC (permalink / raw)
  To: linux-ext4; +Cc: Andrew Morton


Signed-off-by: Robert P. J. Day <rpjday@crashcourse.ca>

---

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 2958f4e..479d5ef 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -1479,7 +1479,7 @@ set_qf_format:
 				return 0;
 			if (option < 0 || option > (1 << 30))
 				return 0;
-			if (option & (option - 1)) {
+			if (!is_power_of_2(option)) {
 				printk(KERN_ERR "EXT4-fs: inode_readahead_blks"
 				       " must be a power of 2\n");
 				return 0;
@@ -2092,7 +2092,7 @@ static ssize_t inode_readahead_blks_store(struct ext4_attr *a,
 		return -EINVAL;

 	/* inode_readahead_blks must be a power of 2 */
-	if (t & (t-1))
+	if (!is_power_of_2(t))
 		return -EINVAL;

 	sbi->s_inode_readahead_blks = t;

========================================================================
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
========================================================================

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] EXT4:  Use is_power_of_2() routine for clarity.
  2009-04-24 13:06 [PATCH] EXT4: Use is_power_of_2() routine for clarity Robert P. J. Day
@ 2009-04-24 15:03 ` Eric Sandeen
  2009-04-24 17:34   ` Theodore Tso
  0 siblings, 1 reply; 4+ messages in thread
From: Eric Sandeen @ 2009-04-24 15:03 UTC (permalink / raw)
  To: Robert P. J. Day; +Cc: linux-ext4, Andrew Morton

Robert P. J. Day wrote:
> Signed-off-by: Robert P. J. Day <rpjday@crashcourse.ca>

Looks fine, thanks.

Reviewed-by: Eric Sandeen <sandeen@redhat.com>

> ---
> 
> diff --git a/fs/ext4/super.c b/fs/ext4/super.c
> index 2958f4e..479d5ef 100644
> --- a/fs/ext4/super.c
> +++ b/fs/ext4/super.c
> @@ -1479,7 +1479,7 @@ set_qf_format:
>  				return 0;
>  			if (option < 0 || option > (1 << 30))
>  				return 0;
> -			if (option & (option - 1)) {
> +			if (!is_power_of_2(option)) {
>  				printk(KERN_ERR "EXT4-fs: inode_readahead_blks"
>  				       " must be a power of 2\n");
>  				return 0;
> @@ -2092,7 +2092,7 @@ static ssize_t inode_readahead_blks_store(struct ext4_attr *a,
>  		return -EINVAL;
> 
>  	/* inode_readahead_blks must be a power of 2 */
> -	if (t & (t-1))
> +	if (!is_power_of_2(t))
>  		return -EINVAL;
> 
>  	sbi->s_inode_readahead_blks = t;
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] EXT4:  Use is_power_of_2() routine for clarity.
  2009-04-24 15:03 ` Eric Sandeen
@ 2009-04-24 17:34   ` Theodore Tso
  2009-04-25  4:00     ` [PATCH] ext4: Use is_power_of_2() " Theodore Ts'o
  0 siblings, 1 reply; 4+ messages in thread
From: Theodore Tso @ 2009-04-24 17:34 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: Robert P. J. Day, linux-ext4, Andrew Morton

On Fri, Apr 24, 2009 at 10:03:31AM -0500, Eric Sandeen wrote:
> > @@ -2092,7 +2092,7 @@ static ssize_t inode_readahead_blks_store(struct ext4_attr *a,
> >  		return -EINVAL;
> > 
> >  	/* inode_readahead_blks must be a power of 2 */
> > -	if (t & (t-1))
> > +	if (!is_power_of_2(t))
> >  		return -EINVAL;

Might as well remove the comment; it's not needed if we're going to be
using is_power_of_2().

						- Ted

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] ext4: Use is_power_of_2() for clarity
  2009-04-24 17:34   ` Theodore Tso
@ 2009-04-25  4:00     ` Theodore Ts'o
  0 siblings, 0 replies; 4+ messages in thread
From: Theodore Ts'o @ 2009-04-25  4:00 UTC (permalink / raw)
  To: Ext4 Developers List; +Cc: Andrew Morton, Theodore Ts'o, Robert P. J. Day

Signed-off-by: Robert P. J. Day <rpjday@crashcourse.ca>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
---
 fs/ext4/super.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index f19d8b8..e20ff9c 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -1482,7 +1482,7 @@ set_qf_format:
 				return 0;
 			if (option < 0 || option > (1 << 30))
 				return 0;
-			if (option & (option - 1)) {
+			if (!is_power_of_2(option)) {
 				printk(KERN_ERR "EXT4-fs: inode_readahead_blks"
 				       " must be a power of 2\n");
 				return 0;
@@ -2100,8 +2100,7 @@ static ssize_t inode_readahead_blks_store(struct ext4_attr *a,
 	if (parse_strtoul(buf, 0x40000000, &t))
 		return -EINVAL;
 
-	/* inode_readahead_blks must be a power of 2 */
-	if (t & (t-1))
+	if (!is_power_of_2(t))
 		return -EINVAL;
 
 	sbi->s_inode_readahead_blks = t;
-- 
1.5.6.3


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-04-25  4:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-24 13:06 [PATCH] EXT4: Use is_power_of_2() routine for clarity Robert P. J. Day
2009-04-24 15:03 ` Eric Sandeen
2009-04-24 17:34   ` Theodore Tso
2009-04-25  4:00     ` [PATCH] ext4: Use is_power_of_2() " Theodore Ts'o

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).