All of lore.kernel.org
 help / color / mirror / Atom feed
From: Su Yue <l@damenly.org>
To: Long Li <leo.lilong@huawei.com>
Cc: <mark@fasheh.com>,  <jlbec@evilplan.org>,
	<joseph.qi@linux.alibaba.com>,  <ocfs2-devel@lists.linux.dev>,
	<yangerkun@huawei.com>,  <lonuxli.64@gmail.com>
Subject: Re: [PATCH] ocfs2: remove redundant NULL check in rename path
Date: Tue, 17 Jun 2025 10:05:11 +0800	[thread overview]
Message-ID: <qzzjxgvc.fsf@damenly.org> (raw)
In-Reply-To: <20250617012534.3458669-1-leo.lilong@huawei.com> (Long Li's message of "Tue, 17 Jun 2025 09:25:34 +0800")

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,

  reply	other threads:[~2025-06-17  2:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-17  1:25 [PATCH] ocfs2: remove redundant NULL check in rename path Long Li
2025-06-17  2:05 ` Su Yue [this message]
2025-06-17  3:48 ` Joseph Qi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=qzzjxgvc.fsf@damenly.org \
    --to=l@damenly.org \
    --cc=jlbec@evilplan.org \
    --cc=joseph.qi@linux.alibaba.com \
    --cc=leo.lilong@huawei.com \
    --cc=lonuxli.64@gmail.com \
    --cc=mark@fasheh.com \
    --cc=ocfs2-devel@lists.linux.dev \
    --cc=yangerkun@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.