diff mbox

[3/3] fs/ext2/inode: Optimize the condition for iomap_begin

Message ID 20180701061848.7036-3-yehs2007@zoho.com (mailing list archive)
State New, archived
Headers show

Commit Message

Huaisheng Ye July 1, 2018, 6:18 a.m. UTC
From: Huaisheng Ye <yehs1@lenovo.com>

If ext2_get_blocks returns negative result, ext2_iomap_begin
will return for error case.
Adjust the judging condition of ret value will be useful for
code simplification.

Signed-off-by: Huaisheng Ye <yehs1@lenovo.com>
---
 fs/ext2/inode.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Jan Kara July 2, 2018, 7:57 a.m. UTC | #1
On Sun 01-07-18 14:18:48, Huaisheng Ye wrote:
> From: Huaisheng Ye <yehs1@lenovo.com>
> 
> If ext2_get_blocks returns negative result, ext2_iomap_begin
> will return for error case.
> Adjust the judging condition of ret value will be useful for
> code simplification.
> 
> Signed-off-by: Huaisheng Ye <yehs1@lenovo.com>

I'm sorry but how exactly is this simpler?

								Honza

> ---
>  fs/ext2/inode.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c
> index ca211bd..9b1004d 100644
> --- a/fs/ext2/inode.c
> +++ b/fs/ext2/inode.c
> @@ -819,15 +819,15 @@ static int ext2_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
>  	iomap->offset = (loff_t)first_block << blkbits;
>  	iomap->dax_dev = sbi->s_daxdev;
>  
> -	if (ret == 0) {
> -		iomap->type = IOMAP_HOLE;
> -		iomap->addr = IOMAP_NULL_ADDR;
> -		iomap->length = 1 << blkbits;
> -	} else {
> +	if (ret) {
>  		iomap->type = IOMAP_MAPPED;
>  		iomap->addr = (u64)bno << blkbits;
>  		iomap->length = (u64)ret << blkbits;
>  		iomap->flags |= IOMAP_F_MERGED;
> +	} else {
> +		iomap->type = IOMAP_HOLE;
> +		iomap->addr = IOMAP_NULL_ADDR;
> +		iomap->length = 1 << blkbits;
>  	}
>  
>  	if (new)
> -- 
> 1.8.3.1
> 
> 
>
diff mbox

Patch

diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c
index ca211bd..9b1004d 100644
--- a/fs/ext2/inode.c
+++ b/fs/ext2/inode.c
@@ -819,15 +819,15 @@  static int ext2_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
 	iomap->offset = (loff_t)first_block << blkbits;
 	iomap->dax_dev = sbi->s_daxdev;
 
-	if (ret == 0) {
-		iomap->type = IOMAP_HOLE;
-		iomap->addr = IOMAP_NULL_ADDR;
-		iomap->length = 1 << blkbits;
-	} else {
+	if (ret) {
 		iomap->type = IOMAP_MAPPED;
 		iomap->addr = (u64)bno << blkbits;
 		iomap->length = (u64)ret << blkbits;
 		iomap->flags |= IOMAP_F_MERGED;
+	} else {
+		iomap->type = IOMAP_HOLE;
+		iomap->addr = IOMAP_NULL_ADDR;
+		iomap->length = 1 << blkbits;
 	}
 
 	if (new)