All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ext4: remove redundant judgment
@ 2022-04-06  9:05 cgel.zte
  2022-04-07 15:01 ` Theodore Ts'o
  0 siblings, 1 reply; 2+ messages in thread
From: cgel.zte @ 2022-04-06  9:05 UTC (permalink / raw)
  To: tytso; +Cc: adilger.kernel, linux-ext4, linux-kernel, Lv Ruyi, Zeal Robot

From: Lv Ruyi <lv.ruyi@zte.com.cn>

iput() has already handled null and non-null parameter. so there is no
need to use if().

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Lv Ruyi <lv.ruyi@zte.com.cn>
---
 fs/ext4/fast_commit.c | 3 +--
 fs/ext4/namei.c       | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/fs/ext4/fast_commit.c b/fs/ext4/fast_commit.c
index 3d72565ec6e8..e85d351a1a31 100644
--- a/fs/ext4/fast_commit.c
+++ b/fs/ext4/fast_commit.c
@@ -1659,8 +1659,7 @@ static int ext4_fc_replay_create(struct super_block *sb, struct ext4_fc_tl *tl,
 	set_nlink(inode, 1);
 	ext4_mark_inode_dirty(NULL, inode);
 out:
-	if (inode)
-		iput(inode);
+	iput(inode);
 	return ret;
 }
 
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index e37da8d5cd0c..2fd3b24a21cd 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -3363,8 +3363,7 @@ static int ext4_symlink(struct user_namespace *mnt_userns, struct inode *dir,
 	err = ext4_add_nondir(handle, dentry, &inode);
 	if (handle)
 		ext4_journal_stop(handle);
-	if (inode)
-		iput(inode);
+	iput(inode);
 	goto out_free_encrypted_link;
 
 err_drop_inode:
-- 
2.25.1


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

* Re: [PATCH] ext4: remove redundant judgment
  2022-04-06  9:05 [PATCH] ext4: remove redundant judgment cgel.zte
@ 2022-04-07 15:01 ` Theodore Ts'o
  0 siblings, 0 replies; 2+ messages in thread
From: Theodore Ts'o @ 2022-04-07 15:01 UTC (permalink / raw)
  To: cgel.zte; +Cc: adilger.kernel, linux-ext4, linux-kernel, Lv Ruyi, Zeal Robot

On Wed, Apr 06, 2022 at 09:05:01AM +0000, cgel.zte@gmail.com wrote:
> From: Lv Ruyi <lv.ruyi@zte.com.cn>
> 
> iput() has already handled null and non-null parameter. so there is no
> need to use if().
> 
> Reported-by: Zeal Robot <zealci@zte.com.cn>
> Signed-off-by: Lv Ruyi <lv.ruyi@zte.com.cn>

I'd use the word "conditional" instead of "judgment", so I'd suggest rewording it as:

>ext4: remove unnecessary conditional
>
>
>iput() already tests to see if it is called with a NULL argument, so
>there is no need to check if the inode is NULL before calling iput().

I've noticed that you've submitted this for other subsystems, so I'd
thought I'd mention it before just applying the patch and quietly
adjusting the commit description for clarity.

					- Ted

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

end of thread, other threads:[~2022-04-07 15:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-06  9:05 [PATCH] ext4: remove redundant judgment cgel.zte
2022-04-07 15:01 ` Theodore Ts'o

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.