2022-08-22 10:03:23

by CGEL

[permalink] [raw]
Subject: [PATCH linux-next] qnx4: delete the unnecessary checks before brelse()

From: ye xingchen <[email protected]>

The brelse() function tests whether its argument is NULL
and then returns immediately.
Thus remove the tests which are not needed around the shown calls.

Reported-by: Zeal Robot <[email protected]>
Signed-off-by: ye xingchen <[email protected]>
---
fs/qnx4/inode.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/qnx4/inode.c b/fs/qnx4/inode.c
index 391ea402920d..9dab8f65ba75 100644
--- a/fs/qnx4/inode.c
+++ b/fs/qnx4/inode.c
@@ -118,8 +118,7 @@ unsigned long qnx4_block_map( struct inode *inode, long iblock )
bh = NULL;
}
}
- if ( bh )
- brelse( bh );
+ brelse(bh);
}

QNX4DEBUG((KERN_INFO "qnx4: mapping block %ld of inode %ld = %ld\n",iblock,inode->i_ino,block));
--
2.25.1


2022-08-22 10:06:15

by Anders Larsen

[permalink] [raw]
Subject: Re: [PATCH linux-next] qnx4: delete the unnecessary checks before brelse()

On Monday, 2022-08-22 11:11 [email protected] wrote:
> From: ye xingchen <[email protected]>
>
> The brelse() function tests whether its argument is NULL
> and then returns immediately.
> Thus remove the tests which are not needed around the shown calls.
>
> Reported-by: Zeal Robot <[email protected]>
> Signed-off-by: ye xingchen <[email protected]>
> ---
> fs/qnx4/inode.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/fs/qnx4/inode.c b/fs/qnx4/inode.c
> index 391ea402920d..9dab8f65ba75 100644
> --- a/fs/qnx4/inode.c
> +++ b/fs/qnx4/inode.c
> @@ -118,8 +118,7 @@ unsigned long qnx4_block_map( struct inode *inode, long iblock )
> bh = NULL;
> }
> }
> - if ( bh )
> - brelse( bh );
> + brelse(bh);

When you remove the if() you must decrease the indentation of the following line!

> }
>
> QNX4DEBUG((KERN_INFO "qnx4: mapping block %ld of inode %ld = %ld\n",iblock,inode->i_ino,block));

Other than that,

Acked-by: Anders Larsen <[email protected]>