diff mbox series

ext4: Delete unnecessary checks before brelse()

Message ID 0d713702-072f-a89c-20ec-ca70aa83a432@web.de
State Awaiting Upstream
Headers show
Series ext4: Delete unnecessary checks before brelse() | expand

Commit Message

Markus Elfring June 13, 2020, 6:07 p.m. UTC
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 13 Jun 2020 19:12:24 +0200

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.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/ext4/extents.c | 6 ++----
 fs/ext4/xattr.c   | 3 +--
 2 files changed, 3 insertions(+), 6 deletions(-)

--
2.27.0

Comments

Ritesh Harjani July 8, 2020, 11:15 a.m. UTC | #1
On 6/13/20 11:37 PM, Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 13 Jun 2020 19:12:24 +0200
> 
> 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.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Sure, LGTM. Feel free to add
Reviewed-by: Ritesh Harjani <riteshh@linux.ibm.com>


> ---
>   fs/ext4/extents.c | 6 ++----
>   fs/ext4/xattr.c   | 3 +--
>   2 files changed, 3 insertions(+), 6 deletions(-)
> 
> diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
> index 221f240eae60..315276d50aa8 100644
> --- a/fs/ext4/extents.c
> +++ b/fs/ext4/extents.c
> @@ -693,10 +693,8 @@ void ext4_ext_drop_refs(struct ext4_ext_path *path)
>   		return;
>   	depth = path->p_depth;
>   	for (i = 0; i <= depth; i++, path++) {
> -		if (path->p_bh) {
> -			brelse(path->p_bh);
> -			path->p_bh = NULL;
> -		}
> +		brelse(path->p_bh);
> +		path->p_bh = NULL;
>   	}
>   }
> 
> diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
> index 9b29a40738ac..eb997ce21be3 100644
> --- a/fs/ext4/xattr.c
> +++ b/fs/ext4/xattr.c
> @@ -1354,8 +1354,7 @@ static int ext4_xattr_inode_write(handle_t *handle, struct inode *ea_inode,
> 
>   	block = 0;
>   	while (wsize < bufsize) {
> -		if (bh != NULL)
> -			brelse(bh);
> +		brelse(bh);
>   		csize = (bufsize - wsize) > blocksize ? blocksize :
>   								bufsize - wsize;
>   		bh = ext4_getblk(handle, ea_inode, block, 0);
> --
> 2.27.0
>
Theodore Ts'o Aug. 6, 2020, 4:09 a.m. UTC | #2
On Sat, Jun 13, 2020 at 08:07:56PM +0200, Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 13 Jun 2020 19:12:24 +0200
> 
> 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.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied, thanks.

						- Ted
diff mbox series

Patch

diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 221f240eae60..315276d50aa8 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -693,10 +693,8 @@  void ext4_ext_drop_refs(struct ext4_ext_path *path)
 		return;
 	depth = path->p_depth;
 	for (i = 0; i <= depth; i++, path++) {
-		if (path->p_bh) {
-			brelse(path->p_bh);
-			path->p_bh = NULL;
-		}
+		brelse(path->p_bh);
+		path->p_bh = NULL;
 	}
 }

diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
index 9b29a40738ac..eb997ce21be3 100644
--- a/fs/ext4/xattr.c
+++ b/fs/ext4/xattr.c
@@ -1354,8 +1354,7 @@  static int ext4_xattr_inode_write(handle_t *handle, struct inode *ea_inode,

 	block = 0;
 	while (wsize < bufsize) {
-		if (bh != NULL)
-			brelse(bh);
+		brelse(bh);
 		csize = (bufsize - wsize) > blocksize ? blocksize :
 								bufsize - wsize;
 		bh = ext4_getblk(handle, ea_inode, block, 0);