All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ocfs2: remove redundant NULL check in rename path
@ 2025-06-17  1:25 Long Li
  2025-06-17  2:05 ` Su Yue
  2025-06-17  3:48 ` Joseph Qi
  0 siblings, 2 replies; 3+ messages in thread
From: Long Li @ 2025-06-17  1:25 UTC (permalink / raw)
  To: mark, jlbec, joseph.qi; +Cc: ocfs2-devel, leo.lilong, yangerkun, lonuxli.64

The code checks newfe_bh for NULL after it has already been dereferenced
to access b_data. This NULL check is unnecessary for two reasons:

1. If ocfs2_inode_lock() succeeds (returns >= 0), newfe_bh is guaranteed
   to be valid.
2. We've already dereferenced newfe_bh to access b_data, so it must be
   non-NULL at this point.

Remove the redundant NULL check in the trace_ocfs2_rename_over_existing()
call to improve code clarity.

Signed-off-by: Long Li <leo.lilong@huawei.com>
---
 fs/ocfs2/namei.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
index 99278c8f0e24..26bc59c3a813 100644
--- a/fs/ocfs2/namei.c
+++ b/fs/ocfs2/namei.c
@@ -1452,8 +1452,8 @@ static int ocfs2_rename(struct mnt_idmap *idmap,
 		newfe = (struct ocfs2_dinode *) newfe_bh->b_data;
 
 		trace_ocfs2_rename_over_existing(
-		     (unsigned long long)newfe_blkno, newfe_bh, newfe_bh ?
-		     (unsigned long long)newfe_bh->b_blocknr : 0ULL);
+		     (unsigned long long)newfe_blkno, newfe_bh,
+		     (unsigned long long)newfe_bh->b_blocknr);
 
 		if (S_ISDIR(new_inode->i_mode) || (new_inode->i_nlink == 1)) {
 			status = ocfs2_prepare_orphan_dir(osb, &orphan_dir,
-- 
2.39.2


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

* Re: [PATCH] ocfs2: remove redundant NULL check in rename path
  2025-06-17  1:25 [PATCH] ocfs2: remove redundant NULL check in rename path Long Li
@ 2025-06-17  2:05 ` Su Yue
  2025-06-17  3:48 ` Joseph Qi
  1 sibling, 0 replies; 3+ messages in thread
From: Su Yue @ 2025-06-17  2:05 UTC (permalink / raw)
  To: Long Li; +Cc: mark, jlbec, joseph.qi, ocfs2-devel, yangerkun, lonuxli.64

On Tue 17 Jun 2025 at 09:25, Long Li <leo.lilong@huawei.com> 
wrote:

> The code checks newfe_bh for NULL after it has already been 
> dereferenced
> to access b_data. This NULL check is unnecessary for two 
> reasons:
>
> 1. If ocfs2_inode_lock() succeeds (returns >= 0), newfe_bh is 
> guaranteed
>    to be valid.
> 2. We've already dereferenced newfe_bh to access b_data, so it 
> must be
>    non-NULL at this point.
>
> Remove the redundant NULL check in the 
> trace_ocfs2_rename_over_existing()
> call to improve code clarity.
>
> Signed-off-by: Long Li <leo.lilong@huawei.com>
>

Reviewed-by: Su Yue <glass.su@suse.com>
> ---
>  fs/ocfs2/namei.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
> index 99278c8f0e24..26bc59c3a813 100644
> --- a/fs/ocfs2/namei.c
> +++ b/fs/ocfs2/namei.c
> @@ -1452,8 +1452,8 @@ static int ocfs2_rename(struct mnt_idmap 
> *idmap,
>  		newfe = (struct ocfs2_dinode *) newfe_bh->b_data;
>
>  		trace_ocfs2_rename_over_existing(
> -		     (unsigned long long)newfe_blkno, newfe_bh, newfe_bh ?
> -		     (unsigned long long)newfe_bh->b_blocknr : 0ULL);
> +		     (unsigned long long)newfe_blkno, newfe_bh,
> +		     (unsigned long long)newfe_bh->b_blocknr);
>
>  		if (S_ISDIR(new_inode->i_mode) || (new_inode->i_nlink == 
>  1)) {
>  			status = ocfs2_prepare_orphan_dir(osb, &orphan_dir,

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

* Re: [PATCH] ocfs2: remove redundant NULL check in rename path
  2025-06-17  1:25 [PATCH] ocfs2: remove redundant NULL check in rename path Long Li
  2025-06-17  2:05 ` Su Yue
@ 2025-06-17  3:48 ` Joseph Qi
  1 sibling, 0 replies; 3+ messages in thread
From: Joseph Qi @ 2025-06-17  3:48 UTC (permalink / raw)
  To: Long Li, mark, jlbec, akpm; +Cc: ocfs2-devel, yangerkun, lonuxli.64



On 2025/6/17 09:25, Long Li wrote:
> The code checks newfe_bh for NULL after it has already been dereferenced
> to access b_data. This NULL check is unnecessary for two reasons:
> 
> 1. If ocfs2_inode_lock() succeeds (returns >= 0), newfe_bh is guaranteed
>    to be valid.
> 2. We've already dereferenced newfe_bh to access b_data, so it must be
>    non-NULL at this point.
> 
> Remove the redundant NULL check in the trace_ocfs2_rename_over_existing()
> call to improve code clarity.
> 

Looks reasonable.
Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com>

> Signed-off-by: Long Li <leo.lilong@huawei.com>
> ---
>  fs/ocfs2/namei.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
> index 99278c8f0e24..26bc59c3a813 100644
> --- a/fs/ocfs2/namei.c
> +++ b/fs/ocfs2/namei.c
> @@ -1452,8 +1452,8 @@ static int ocfs2_rename(struct mnt_idmap *idmap,
>  		newfe = (struct ocfs2_dinode *) newfe_bh->b_data;
>  
>  		trace_ocfs2_rename_over_existing(
> -		     (unsigned long long)newfe_blkno, newfe_bh, newfe_bh ?
> -		     (unsigned long long)newfe_bh->b_blocknr : 0ULL);
> +		     (unsigned long long)newfe_blkno, newfe_bh,
> +		     (unsigned long long)newfe_bh->b_blocknr);
>  
>  		if (S_ISDIR(new_inode->i_mode) || (new_inode->i_nlink == 1)) {
>  			status = ocfs2_prepare_orphan_dir(osb, &orphan_dir,


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

end of thread, other threads:[~2025-06-17  3:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-17  1:25 [PATCH] ocfs2: remove redundant NULL check in rename path Long Li
2025-06-17  2:05 ` Su Yue
2025-06-17  3:48 ` Joseph Qi

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.