Linux NILFS development
 help / color / mirror / Atom feed
* [PATCH] nilfs2: trivial coding style fix
@ 2009-12-04  9:23 Jiro SEKIBA
       [not found] ` <87vdgnxfcd.wl%jir-27yqGEOhnJbQT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Jiro SEKIBA @ 2009-12-04  9:23 UTC (permalink / raw)
  To: users-JrjvKiOkagjYtjvyW6yDsg; +Cc: Ryusuke Konishi

Hi,

This is a trivial style fix patch to mend errors/warnings
reported by "checkpatch.pl --file".

Signed-off-by: Jiro SEKIBA <jir-hfpbi5WX9J54Eiagz67IpQ@public.gmane.org>
---
 fs/nilfs2/bmap.c   |    3 ++-
 fs/nilfs2/cpfile.c |    5 +++--
 fs/nilfs2/direct.c |   14 ++++++++------
 3 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/fs/nilfs2/bmap.c b/fs/nilfs2/bmap.c
index 08834df..78ccbba 100644
--- a/fs/nilfs2/bmap.c
+++ b/fs/nilfs2/bmap.c
@@ -426,7 +426,8 @@ __u64 nilfs_bmap_data_get_key(const struct nilfs_bmap *bmap,
 	key = page_index(bh->b_page) << (PAGE_CACHE_SHIFT -
 					 bmap->b_inode->i_blkbits);
 	for (pbh = page_buffers(bh->b_page); pbh != bh;
-	     pbh = pbh->b_this_page, key++);
+	     pbh = pbh->b_this_page, key++)
+		;
 
 	return key;
 }
diff --git a/fs/nilfs2/cpfile.c b/fs/nilfs2/cpfile.c
index 3f5d5d0..a86d402 100644
--- a/fs/nilfs2/cpfile.c
+++ b/fs/nilfs2/cpfile.c
@@ -328,9 +328,10 @@ int nilfs_cpfile_delete_checkpoints(struct inode *cpfile,
 			tnicps += nicps;
 			nilfs_mdt_mark_buffer_dirty(cp_bh);
 			nilfs_mdt_mark_dirty(cpfile);
+			count = nilfs_cpfile_block_sub_valid_checkpoints(
+				  cpfile, cp_bh, kaddr, nicps);
 			if (!nilfs_cpfile_is_in_first(cpfile, cno) &&
-			    (count = nilfs_cpfile_block_sub_valid_checkpoints(
-				    cpfile, cp_bh, kaddr, nicps)) == 0) {
+			    count == 0) {
 				/* make hole */
 				kunmap_atomic(kaddr, KM_USER0);
 				brelse(cp_bh);
diff --git a/fs/nilfs2/direct.c b/fs/nilfs2/direct.c
index d369ac7..f817282 100644
--- a/fs/nilfs2/direct.c
+++ b/fs/nilfs2/direct.c
@@ -53,9 +53,10 @@ static int nilfs_direct_lookup(const struct nilfs_bmap *bmap,
 
 	direct = (struct nilfs_direct *)bmap;
 	if ((key > NILFS_DIRECT_KEY_MAX) ||
-	    (level != 1) ||	/* XXX: use macro for level 1 */
-	    ((ptr = nilfs_direct_get_ptr(direct, key)) ==
-	     NILFS_BMAP_INVALID_PTR))
+	    (level != 1))  /* XXX: use macro for level 1 */
+		return -ENOENT;
+	ptr = nilfs_direct_get_ptr(direct, key);
+	if (ptr == NILFS_BMAP_INVALID_PTR)
 		return -ENOENT;
 
 	if (ptrp != NULL)
@@ -73,9 +74,10 @@ static int nilfs_direct_lookup_contig(const struct nilfs_bmap *bmap,
 	sector_t blocknr;
 	int ret, cnt;
 
-	if (key > NILFS_DIRECT_KEY_MAX ||
-	    (ptr = nilfs_direct_get_ptr(direct, key)) ==
-	    NILFS_BMAP_INVALID_PTR)
+	if (key > NILFS_DIRECT_KEY_MAX)
+		return -ENOENT;
+	ptr = nilfs_direct_get_ptr(direct, key);
+	if (ptr == NILFS_BMAP_INVALID_PTR)
 		return -ENOENT;
 
 	if (NILFS_BMAP_USE_VBN(bmap)) {
-- 
1.5.6.5

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

* Re: [PATCH] nilfs2: trivial coding style fix
       [not found] ` <87vdgnxfcd.wl%jir-27yqGEOhnJbQT0dZR+AlfA@public.gmane.org>
@ 2009-12-04 11:01   ` Ryusuke Konishi
       [not found]     ` <20091204.200102.43716794.ryusuke-sG5X7nlA6pw@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Ryusuke Konishi @ 2009-12-04 11:01 UTC (permalink / raw)
  To: jir-hfpbi5WX9J54Eiagz67IpQ
  Cc: konishi.ryusuke-Zyj7fXuS5i5L9jVzuh4AOg,
	users-JrjvKiOkagjYtjvyW6yDsg

Hi,
On Fri, 04 Dec 2009 18:23:30 +0900, Jiro SEKIBA <jir-hfpbi5WX9J54Eiagz67IpQ@public.gmane.org> wrote:
> Hi,
> 
> This is a trivial style fix patch to mend errors/warnings
> reported by "checkpatch.pl --file".
> 
> Signed-off-by: Jiro SEKIBA <jir-hfpbi5WX9J54Eiagz67IpQ@public.gmane.org>
> ---
>  fs/nilfs2/bmap.c   |    3 ++-
>  fs/nilfs2/cpfile.c |    5 +++--
>  fs/nilfs2/direct.c |   14 ++++++++------
>  3 files changed, 13 insertions(+), 9 deletions(-)

Ok, I'll comment inline below.
 
> diff --git a/fs/nilfs2/bmap.c b/fs/nilfs2/bmap.c
> index 08834df..78ccbba 100644
> --- a/fs/nilfs2/bmap.c
> +++ b/fs/nilfs2/bmap.c
> @@ -426,7 +426,8 @@ __u64 nilfs_bmap_data_get_key(const struct nilfs_bmap *bmap,
>  	key = page_index(bh->b_page) << (PAGE_CACHE_SHIFT -
>  					 bmap->b_inode->i_blkbits);
>  	for (pbh = page_buffers(bh->b_page); pbh != bh;
> -	     pbh = pbh->b_this_page, key++);
> +	     pbh = pbh->b_this_page, key++)
> +		;

How about moving the "key++" inside the loop?  The line break in the
middle of the for-sentence looks eliminable.

>  	return key;
>  }
> diff --git a/fs/nilfs2/cpfile.c b/fs/nilfs2/cpfile.c
> index 3f5d5d0..a86d402 100644
> --- a/fs/nilfs2/cpfile.c
> +++ b/fs/nilfs2/cpfile.c
> @@ -328,9 +328,10 @@ int nilfs_cpfile_delete_checkpoints(struct inode *cpfile,
>  			tnicps += nicps;
>  			nilfs_mdt_mark_buffer_dirty(cp_bh);
>  			nilfs_mdt_mark_dirty(cpfile);
> +			count = nilfs_cpfile_block_sub_valid_checkpoints(
> +				  cpfile, cp_bh, kaddr, nicps);
>  			if (!nilfs_cpfile_is_in_first(cpfile, cno) &&
> -			    (count = nilfs_cpfile_block_sub_valid_checkpoints(
> -				    cpfile, cp_bh, kaddr, nicps)) == 0) {
> +			    count == 0) {

This conversion is not equivalent because
nilfs_cpfile_block_sub_valid_checkpoints() has a side effect.

>  				/* make hole */
>  				kunmap_atomic(kaddr, KM_USER0);
>  				brelse(cp_bh);
> diff --git a/fs/nilfs2/direct.c b/fs/nilfs2/direct.c
> index d369ac7..f817282 100644
> --- a/fs/nilfs2/direct.c
> +++ b/fs/nilfs2/direct.c
> @@ -53,9 +53,10 @@ static int nilfs_direct_lookup(const struct nilfs_bmap *bmap,
>  
>  	direct = (struct nilfs_direct *)bmap;
>  	if ((key > NILFS_DIRECT_KEY_MAX) ||
> -	    (level != 1) ||	/* XXX: use macro for level 1 */
> -	    ((ptr = nilfs_direct_get_ptr(direct, key)) ==
> -	     NILFS_BMAP_INVALID_PTR))
> +	    (level != 1))  /* XXX: use macro for level 1 */
> +		return -ENOENT;
> +	ptr = nilfs_direct_get_ptr(direct, key);
> +	if (ptr == NILFS_BMAP_INVALID_PTR)
>  		return -ENOENT;

Looks good, but it's still redundant.  How about removing unnecessary
parentheses in this occasion?

The first conditional statement can be simplified to:

	if (key > NILFS_DIRECT_KEY_MAX || level != 1)

  
>  	if (ptrp != NULL)
> @@ -73,9 +74,10 @@ static int nilfs_direct_lookup_contig(const struct nilfs_bmap *bmap,
>  	sector_t blocknr;
>  	int ret, cnt;
>  
> -	if (key > NILFS_DIRECT_KEY_MAX ||
> -	    (ptr = nilfs_direct_get_ptr(direct, key)) ==
> -	    NILFS_BMAP_INVALID_PTR)
> +	if (key > NILFS_DIRECT_KEY_MAX)
> +		return -ENOENT;
> +	ptr = nilfs_direct_get_ptr(direct, key);
> +	if (ptr == NILFS_BMAP_INVALID_PTR)
>  		return -ENOENT;

Looks good to me.
  
>  	if (NILFS_BMAP_USE_VBN(bmap)) {
> -- 
> 1.5.6.5

Thanks,
Ryusuke Konishi

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

* Re: [PATCH] nilfs2: trivial coding style fix
       [not found]     ` <20091204.200102.43716794.ryusuke-sG5X7nlA6pw@public.gmane.org>
@ 2009-12-04 12:02       ` Jiro SEKIBA
  2009-12-04 12:03       ` Jiro SEKIBA
  1 sibling, 0 replies; 6+ messages in thread
From: Jiro SEKIBA @ 2009-12-04 12:02 UTC (permalink / raw)
  To: NILFS Users mailing list

Hi,

Thank you for the reveiew.
I'll revise the patch!

thanks

regards,

At Fri, 04 Dec 2009 20:01:02 +0900 (JST),
Ryusuke Konishi wrote:
> 
> Hi,
> On Fri, 04 Dec 2009 18:23:30 +0900, Jiro SEKIBA <jir-hfpbi5WX9J54Eiagz67IpQ@public.gmane.org> wrote:
> > Hi,
> > 
> > This is a trivial style fix patch to mend errors/warnings
> > reported by "checkpatch.pl --file".
> > 
> > Signed-off-by: Jiro SEKIBA <jir-hfpbi5WX9J54Eiagz67IpQ@public.gmane.org>
> > ---
> >  fs/nilfs2/bmap.c   |    3 ++-
> >  fs/nilfs2/cpfile.c |    5 +++--
> >  fs/nilfs2/direct.c |   14 ++++++++------
> >  3 files changed, 13 insertions(+), 9 deletions(-)
> 
> Ok, I'll comment inline below.
>  
> > diff --git a/fs/nilfs2/bmap.c b/fs/nilfs2/bmap.c
> > index 08834df..78ccbba 100644
> > --- a/fs/nilfs2/bmap.c
> > +++ b/fs/nilfs2/bmap.c
> > @@ -426,7 +426,8 @@ __u64 nilfs_bmap_data_get_key(const struct nilfs_bmap *bmap,
> >  	key = page_index(bh->b_page) << (PAGE_CACHE_SHIFT -
> >  					 bmap->b_inode->i_blkbits);
> >  	for (pbh = page_buffers(bh->b_page); pbh != bh;
> > -	     pbh = pbh->b_this_page, key++);
> > +	     pbh = pbh->b_this_page, key++)
> > +		;
> 
> How about moving the "key++" inside the loop?  The line break in the
> middle of the for-sentence looks eliminable.
> 
> >  	return key;
> >  }
> > diff --git a/fs/nilfs2/cpfile.c b/fs/nilfs2/cpfile.c
> > index 3f5d5d0..a86d402 100644
> > --- a/fs/nilfs2/cpfile.c
> > +++ b/fs/nilfs2/cpfile.c
> > @@ -328,9 +328,10 @@ int nilfs_cpfile_delete_checkpoints(struct inode *cpfile,
> >  			tnicps += nicps;
> >  			nilfs_mdt_mark_buffer_dirty(cp_bh);
> >  			nilfs_mdt_mark_dirty(cpfile);
> > +			count = nilfs_cpfile_block_sub_valid_checkpoints(
> > +				  cpfile, cp_bh, kaddr, nicps);
> >  			if (!nilfs_cpfile_is_in_first(cpfile, cno) &&
> > -			    (count = nilfs_cpfile_block_sub_valid_checkpoints(
> > -				    cpfile, cp_bh, kaddr, nicps)) == 0) {
> > +			    count == 0) {
> 
> This conversion is not equivalent because
> nilfs_cpfile_block_sub_valid_checkpoints() has a side effect.
> 
> >  				/* make hole */
> >  				kunmap_atomic(kaddr, KM_USER0);
> >  				brelse(cp_bh);
> > diff --git a/fs/nilfs2/direct.c b/fs/nilfs2/direct.c
> > index d369ac7..f817282 100644
> > --- a/fs/nilfs2/direct.c
> > +++ b/fs/nilfs2/direct.c
> > @@ -53,9 +53,10 @@ static int nilfs_direct_lookup(const struct nilfs_bmap *bmap,
> >  
> >  	direct = (struct nilfs_direct *)bmap;
> >  	if ((key > NILFS_DIRECT_KEY_MAX) ||
> > -	    (level != 1) ||	/* XXX: use macro for level 1 */
> > -	    ((ptr = nilfs_direct_get_ptr(direct, key)) ==
> > -	     NILFS_BMAP_INVALID_PTR))
> > +	    (level != 1))  /* XXX: use macro for level 1 */
> > +		return -ENOENT;
> > +	ptr = nilfs_direct_get_ptr(direct, key);
> > +	if (ptr == NILFS_BMAP_INVALID_PTR)
> >  		return -ENOENT;
> 
> Looks good, but it's still redundant.  How about removing unnecessary
> parentheses in this occasion?
> 
> The first conditional statement can be simplified to:
> 
> 	if (key > NILFS_DIRECT_KEY_MAX || level != 1)
> 
>   
> >  	if (ptrp != NULL)
> > @@ -73,9 +74,10 @@ static int nilfs_direct_lookup_contig(const struct nilfs_bmap *bmap,
> >  	sector_t blocknr;
> >  	int ret, cnt;
> >  
> > -	if (key > NILFS_DIRECT_KEY_MAX ||
> > -	    (ptr = nilfs_direct_get_ptr(direct, key)) ==
> > -	    NILFS_BMAP_INVALID_PTR)
> > +	if (key > NILFS_DIRECT_KEY_MAX)
> > +		return -ENOENT;
> > +	ptr = nilfs_direct_get_ptr(direct, key);
> > +	if (ptr == NILFS_BMAP_INVALID_PTR)
> >  		return -ENOENT;
> 
> Looks good to me.
>   
> >  	if (NILFS_BMAP_USE_VBN(bmap)) {
> > -- 
> > 1.5.6.5
> 
> Thanks,
> Ryusuke Konishi
> _______________________________________________
> users mailing list
> users-JrjvKiOkagjYtjvyW6yDsg@public.gmane.org
> https://www.nilfs.org/mailman/listinfo/users
> 
> 
> 

-- 
Jiro SEKIBA <jir-hfpbi5WX9J54Eiagz67IpQ@public.gmane.org>

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

* [PATCH] nilfs2: trivial coding style fix
       [not found]     ` <20091204.200102.43716794.ryusuke-sG5X7nlA6pw@public.gmane.org>
  2009-12-04 12:02       ` Jiro SEKIBA
@ 2009-12-04 12:03       ` Jiro SEKIBA
       [not found]         ` <873a3rymi5.wl%jir-27yqGEOhnJbQT0dZR+AlfA@public.gmane.org>
  1 sibling, 1 reply; 6+ messages in thread
From: Jiro SEKIBA @ 2009-12-04 12:03 UTC (permalink / raw)
  To: NILFS Users mailing list

Hi,

This is a revised version of trivial style fix patch
to mend errors/warnings reported by "checkpatch.pl --file".

Signed-off-by: Jiro SEKIBA <jir-hfpbi5WX9J54Eiagz67IpQ@public.gmane.org>
---
 fs/nilfs2/bmap.c   |    3 ++-
 fs/nilfs2/cpfile.c |   31 ++++++++++++++++++-------------
 fs/nilfs2/direct.c |   17 +++++++++--------
 3 files changed, 29 insertions(+), 22 deletions(-)

diff --git a/fs/nilfs2/bmap.c b/fs/nilfs2/bmap.c
index f4a14ea..88db45a 100644
--- a/fs/nilfs2/bmap.c
+++ b/fs/nilfs2/bmap.c
@@ -418,7 +418,8 @@ __u64 nilfs_bmap_data_get_key(const struct nilfs_bmap *bmap,
 	key = page_index(bh->b_page) << (PAGE_CACHE_SHIFT -
 					 bmap->b_inode->i_blkbits);
 	for (pbh = page_buffers(bh->b_page); pbh != bh;
-	     pbh = pbh->b_this_page, key++);
+	     pbh = pbh->b_this_page)
+		key++;
 
 	return key;
 }
diff --git a/fs/nilfs2/cpfile.c b/fs/nilfs2/cpfile.c
index d5ad54e..1873781 100644
--- a/fs/nilfs2/cpfile.c
+++ b/fs/nilfs2/cpfile.c
@@ -328,19 +328,24 @@ int nilfs_cpfile_delete_checkpoints(struct inode *cpfile,
 			tnicps += nicps;
 			nilfs_mdt_mark_buffer_dirty(cp_bh);
 			nilfs_mdt_mark_dirty(cpfile);
-			if (!nilfs_cpfile_is_in_first(cpfile, cno) &&
-			    (count = nilfs_cpfile_block_sub_valid_checkpoints(
-				    cpfile, cp_bh, kaddr, nicps)) == 0) {
-				/* make hole */
-				kunmap_atomic(kaddr, KM_USER0);
-				brelse(cp_bh);
-				ret = nilfs_cpfile_delete_checkpoint_block(
-					cpfile, cno);
-				if (ret == 0)
-					continue;
-				printk(KERN_ERR "%s: cannot delete block\n",
-				       __func__);
-				break;
+			if (!nilfs_cpfile_is_in_first(cpfile, cno)) {
+				count =
+				  nilfs_cpfile_block_sub_valid_checkpoints(
+						cpfile, cp_bh, kaddr, nicps);
+				if (count == 0) {
+					/* make hole */
+					kunmap_atomic(kaddr, KM_USER0);
+					brelse(cp_bh);
+					ret =
+					  nilfs_cpfile_delete_checkpoint_block(
+								   cpfile, cno);
+					if (ret == 0)
+						continue;
+					printk(KERN_ERR
+					       "%s: cannot delete block\n",
+					       __func__);
+					break;
+				}
 			}
 		}
 
diff --git a/fs/nilfs2/direct.c b/fs/nilfs2/direct.c
index d369ac7..31d51fc 100644
--- a/fs/nilfs2/direct.c
+++ b/fs/nilfs2/direct.c
@@ -51,11 +51,11 @@ static int nilfs_direct_lookup(const struct nilfs_bmap *bmap,
 	struct nilfs_direct *direct;
 	__u64 ptr;
 
-	direct = (struct nilfs_direct *)bmap;
-	if ((key > NILFS_DIRECT_KEY_MAX) ||
-	    (level != 1) ||	/* XXX: use macro for level 1 */
-	    ((ptr = nilfs_direct_get_ptr(direct, key)) ==
-	     NILFS_BMAP_INVALID_PTR))
+	direct = (struct nilfs_direct *)bmap;  /* XXX: use macro for level 1 */
+	if ((key > NILFS_DIRECT_KEY_MAX) || (level != 1))
+		return -ENOENT;
+	ptr = nilfs_direct_get_ptr(direct, key);
+	if (ptr == NILFS_BMAP_INVALID_PTR)
 		return -ENOENT;
 
 	if (ptrp != NULL)
@@ -73,9 +73,10 @@ static int nilfs_direct_lookup_contig(const struct nilfs_bmap *bmap,
 	sector_t blocknr;
 	int ret, cnt;
 
-	if (key > NILFS_DIRECT_KEY_MAX ||
-	    (ptr = nilfs_direct_get_ptr(direct, key)) ==
-	    NILFS_BMAP_INVALID_PTR)
+	if (key > NILFS_DIRECT_KEY_MAX)
+		return -ENOENT;
+	ptr = nilfs_direct_get_ptr(direct, key);
+	if (ptr == NILFS_BMAP_INVALID_PTR)
 		return -ENOENT;
 
 	if (NILFS_BMAP_USE_VBN(bmap)) {
-- 
1.5.6.5

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

* Re: [PATCH] nilfs2: trivial coding style fix
       [not found]         ` <873a3rymi5.wl%jir-27yqGEOhnJbQT0dZR+AlfA@public.gmane.org>
@ 2009-12-06  6:43           ` Jiro SEKIBA
       [not found]             ` <874oo4lhzn.wl%jir-27yqGEOhnJbQT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Jiro SEKIBA @ 2009-12-06  6:43 UTC (permalink / raw)
  To: NILFS Users mailing list

Hi, 

I re-read the comment and realized that there are some room
to simplify the sytyle.  This is a re-revised version.

This is a trivial style fix patch to mend errors/warnings
reported by "checkpatch.pl --file".

Signed-off-by: Jiro SEKIBA <jir-hfpbi5WX9J54Eiagz67IpQ@public.gmane.org>
---
 fs/nilfs2/bmap.c   |    4 ++--
 fs/nilfs2/cpfile.c |   31 ++++++++++++++++++-------------
 fs/nilfs2/direct.c |   17 +++++++++--------
 3 files changed, 29 insertions(+), 23 deletions(-)

diff --git a/fs/nilfs2/bmap.c b/fs/nilfs2/bmap.c
index f4a14ea..effdbdb 100644
--- a/fs/nilfs2/bmap.c
+++ b/fs/nilfs2/bmap.c
@@ -417,8 +417,8 @@ __u64 nilfs_bmap_data_get_key(const struct nilfs_bmap *bmap,
 
 	key = page_index(bh->b_page) << (PAGE_CACHE_SHIFT -
 					 bmap->b_inode->i_blkbits);
-	for (pbh = page_buffers(bh->b_page); pbh != bh;
-	     pbh = pbh->b_this_page, key++);
+	for (pbh = page_buffers(bh->b_page); pbh != bh; pbh = pbh->b_this_page)
+		key++;
 
 	return key;
 }
diff --git a/fs/nilfs2/cpfile.c b/fs/nilfs2/cpfile.c
index d5ad54e..1873781 100644
--- a/fs/nilfs2/cpfile.c
+++ b/fs/nilfs2/cpfile.c
@@ -328,19 +328,24 @@ int nilfs_cpfile_delete_checkpoints(struct inode *cpfile,
 			tnicps += nicps;
 			nilfs_mdt_mark_buffer_dirty(cp_bh);
 			nilfs_mdt_mark_dirty(cpfile);
-			if (!nilfs_cpfile_is_in_first(cpfile, cno) &&
-			    (count = nilfs_cpfile_block_sub_valid_checkpoints(
-				    cpfile, cp_bh, kaddr, nicps)) == 0) {
-				/* make hole */
-				kunmap_atomic(kaddr, KM_USER0);
-				brelse(cp_bh);
-				ret = nilfs_cpfile_delete_checkpoint_block(
-					cpfile, cno);
-				if (ret == 0)
-					continue;
-				printk(KERN_ERR "%s: cannot delete block\n",
-				       __func__);
-				break;
+			if (!nilfs_cpfile_is_in_first(cpfile, cno)) {
+				count =
+				  nilfs_cpfile_block_sub_valid_checkpoints(
+						cpfile, cp_bh, kaddr, nicps);
+				if (count == 0) {
+					/* make hole */
+					kunmap_atomic(kaddr, KM_USER0);
+					brelse(cp_bh);
+					ret =
+					  nilfs_cpfile_delete_checkpoint_block(
+								   cpfile, cno);
+					if (ret == 0)
+						continue;
+					printk(KERN_ERR
+					       "%s: cannot delete block\n",
+					       __func__);
+					break;
+				}
 			}
 		}
 
diff --git a/fs/nilfs2/direct.c b/fs/nilfs2/direct.c
index d369ac7..236753d 100644
--- a/fs/nilfs2/direct.c
+++ b/fs/nilfs2/direct.c
@@ -51,11 +51,11 @@ static int nilfs_direct_lookup(const struct nilfs_bmap *bmap,
 	struct nilfs_direct *direct;
 	__u64 ptr;
 
-	direct = (struct nilfs_direct *)bmap;
-	if ((key > NILFS_DIRECT_KEY_MAX) ||
-	    (level != 1) ||	/* XXX: use macro for level 1 */
-	    ((ptr = nilfs_direct_get_ptr(direct, key)) ==
-	     NILFS_BMAP_INVALID_PTR))
+	direct = (struct nilfs_direct *)bmap;  /* XXX: use macro for level 1 */
+	if (key > NILFS_DIRECT_KEY_MAX || level != 1)
+		return -ENOENT;
+	ptr = nilfs_direct_get_ptr(direct, key);
+	if (ptr == NILFS_BMAP_INVALID_PTR)
 		return -ENOENT;
 
 	if (ptrp != NULL)
@@ -73,9 +73,10 @@ static int nilfs_direct_lookup_contig(const struct nilfs_bmap *bmap,
 	sector_t blocknr;
 	int ret, cnt;
 
-	if (key > NILFS_DIRECT_KEY_MAX ||
-	    (ptr = nilfs_direct_get_ptr(direct, key)) ==
-	    NILFS_BMAP_INVALID_PTR)
+	if (key > NILFS_DIRECT_KEY_MAX)
+		return -ENOENT;
+	ptr = nilfs_direct_get_ptr(direct, key);
+	if (ptr == NILFS_BMAP_INVALID_PTR)
 		return -ENOENT;
 
 	if (NILFS_BMAP_USE_VBN(bmap)) {
-- 
1.5.6.5

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

* Re: [PATCH] nilfs2: trivial coding style fix
       [not found]             ` <874oo4lhzn.wl%jir-27yqGEOhnJbQT0dZR+AlfA@public.gmane.org>
@ 2009-12-07 10:32               ` Ryusuke Konishi
  0 siblings, 0 replies; 6+ messages in thread
From: Ryusuke Konishi @ 2009-12-07 10:32 UTC (permalink / raw)
  To: users-JrjvKiOkagjYtjvyW6yDsg, jir-27yqGEOhnJbQT0dZR+AlfA
  Cc: konishi.ryusuke-Zyj7fXuS5i5L9jVzuh4AOg

Hi,
On Sun, 06 Dec 2009 15:43:56 +0900, Jiro SEKIBA <jir-27yqGEOhnJbQT0dZR+AlfA@public.gmane.org> wrote:
> Hi, 
> 
> I re-read the comment and realized that there are some room
> to simplify the sytyle.  This is a re-revised version.
> 
> This is a trivial style fix patch to mend errors/warnings
> reported by "checkpatch.pl --file".
> 
> Signed-off-by: Jiro SEKIBA <jir-hfpbi5WX9J54Eiagz67IpQ@public.gmane.org>
> ---
>  fs/nilfs2/bmap.c   |    4 ++--
>  fs/nilfs2/cpfile.c |   31 ++++++++++++++++++-------------
>  fs/nilfs2/direct.c |   17 +++++++++--------
>  3 files changed, 29 insertions(+), 23 deletions(-)

Looks good.  I'll queue it up.

Thanks,
Ryusuke Konishi

> diff --git a/fs/nilfs2/bmap.c b/fs/nilfs2/bmap.c
> index f4a14ea..effdbdb 100644
> --- a/fs/nilfs2/bmap.c
> +++ b/fs/nilfs2/bmap.c
> @@ -417,8 +417,8 @@ __u64 nilfs_bmap_data_get_key(const struct nilfs_bmap *bmap,
>  
>  	key = page_index(bh->b_page) << (PAGE_CACHE_SHIFT -
>  					 bmap->b_inode->i_blkbits);
> -	for (pbh = page_buffers(bh->b_page); pbh != bh;
> -	     pbh = pbh->b_this_page, key++);
> +	for (pbh = page_buffers(bh->b_page); pbh != bh; pbh = pbh->b_this_page)
> +		key++;
>  
>  	return key;
>  }
> diff --git a/fs/nilfs2/cpfile.c b/fs/nilfs2/cpfile.c
> index d5ad54e..1873781 100644
> --- a/fs/nilfs2/cpfile.c
> +++ b/fs/nilfs2/cpfile.c
> @@ -328,19 +328,24 @@ int nilfs_cpfile_delete_checkpoints(struct inode *cpfile,
>  			tnicps += nicps;
>  			nilfs_mdt_mark_buffer_dirty(cp_bh);
>  			nilfs_mdt_mark_dirty(cpfile);
> -			if (!nilfs_cpfile_is_in_first(cpfile, cno) &&
> -			    (count = nilfs_cpfile_block_sub_valid_checkpoints(
> -				    cpfile, cp_bh, kaddr, nicps)) == 0) {
> -				/* make hole */
> -				kunmap_atomic(kaddr, KM_USER0);
> -				brelse(cp_bh);
> -				ret = nilfs_cpfile_delete_checkpoint_block(
> -					cpfile, cno);
> -				if (ret == 0)
> -					continue;
> -				printk(KERN_ERR "%s: cannot delete block\n",
> -				       __func__);
> -				break;
> +			if (!nilfs_cpfile_is_in_first(cpfile, cno)) {
> +				count =
> +				  nilfs_cpfile_block_sub_valid_checkpoints(
> +						cpfile, cp_bh, kaddr, nicps);
> +				if (count == 0) {
> +					/* make hole */
> +					kunmap_atomic(kaddr, KM_USER0);
> +					brelse(cp_bh);
> +					ret =
> +					  nilfs_cpfile_delete_checkpoint_block(
> +								   cpfile, cno);
> +					if (ret == 0)
> +						continue;
> +					printk(KERN_ERR
> +					       "%s: cannot delete block\n",
> +					       __func__);
> +					break;
> +				}
>  			}
>  		}
>  
> diff --git a/fs/nilfs2/direct.c b/fs/nilfs2/direct.c
> index d369ac7..236753d 100644
> --- a/fs/nilfs2/direct.c
> +++ b/fs/nilfs2/direct.c
> @@ -51,11 +51,11 @@ static int nilfs_direct_lookup(const struct nilfs_bmap *bmap,
>  	struct nilfs_direct *direct;
>  	__u64 ptr;
>  
> -	direct = (struct nilfs_direct *)bmap;
> -	if ((key > NILFS_DIRECT_KEY_MAX) ||
> -	    (level != 1) ||	/* XXX: use macro for level 1 */
> -	    ((ptr = nilfs_direct_get_ptr(direct, key)) ==
> -	     NILFS_BMAP_INVALID_PTR))
> +	direct = (struct nilfs_direct *)bmap;  /* XXX: use macro for level 1 */
> +	if (key > NILFS_DIRECT_KEY_MAX || level != 1)
> +		return -ENOENT;
> +	ptr = nilfs_direct_get_ptr(direct, key);
> +	if (ptr == NILFS_BMAP_INVALID_PTR)
>  		return -ENOENT;
>  
>  	if (ptrp != NULL)
> @@ -73,9 +73,10 @@ static int nilfs_direct_lookup_contig(const struct nilfs_bmap *bmap,
>  	sector_t blocknr;
>  	int ret, cnt;
>  
> -	if (key > NILFS_DIRECT_KEY_MAX ||
> -	    (ptr = nilfs_direct_get_ptr(direct, key)) ==
> -	    NILFS_BMAP_INVALID_PTR)
> +	if (key > NILFS_DIRECT_KEY_MAX)
> +		return -ENOENT;
> +	ptr = nilfs_direct_get_ptr(direct, key);
> +	if (ptr == NILFS_BMAP_INVALID_PTR)
>  		return -ENOENT;
>  
>  	if (NILFS_BMAP_USE_VBN(bmap)) {
> -- 
> 1.5.6.5

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

end of thread, other threads:[~2009-12-07 10:32 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-04  9:23 [PATCH] nilfs2: trivial coding style fix Jiro SEKIBA
     [not found] ` <87vdgnxfcd.wl%jir-27yqGEOhnJbQT0dZR+AlfA@public.gmane.org>
2009-12-04 11:01   ` Ryusuke Konishi
     [not found]     ` <20091204.200102.43716794.ryusuke-sG5X7nlA6pw@public.gmane.org>
2009-12-04 12:02       ` Jiro SEKIBA
2009-12-04 12:03       ` Jiro SEKIBA
     [not found]         ` <873a3rymi5.wl%jir-27yqGEOhnJbQT0dZR+AlfA@public.gmane.org>
2009-12-06  6:43           ` Jiro SEKIBA
     [not found]             ` <874oo4lhzn.wl%jir-27yqGEOhnJbQT0dZR+AlfA@public.gmane.org>
2009-12-07 10:32               ` Ryusuke Konishi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox