ocfs2: remove redundant NULL check in rename path
PATCH 1/1 ocfs2: remove redundant NULL check in rename path
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.
--- fs/ocfs2/namei.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/ocfs2/namei.c +2 -2
@@ -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,
Signature · 1 line
2.39.2
Quoted 8 lines · Long Li
The code checks
newfe_bhfor NULL after it has already been dereferenced to accessb_data. This NULL check is unnecessary for two reasons:1. If
ocfs2_inode_lock()succeeds (returns >= 0),newfe_bhis guaranteed to be valid.
2. We've already dereferencednewfe_bhto accessb_data, so it must be non-NULL at this point.
Quoted 5 lines
Remove the redundant NULL check in the
trace_ocfs2_rename_over_existing()call to improve code clarity.Signed-off-by Long Li <[email protected]>
Quoted 21 lines
--- fs/ocfs2/namei.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)fs/ocfs2/namei.c +2
-2@@ -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,
Quoted 11 lines · Long Li
The code checks
newfe_bhfor NULL after it has already been dereferenced to accessb_data. This NULL check is unnecessary for two reasons:1. If
ocfs2_inode_lock()succeeds (returns >= 0),newfe_bhis guaranteed to be valid.
2. We've already dereferencednewfe_bhto accessb_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.
Quoted 20 lines
Signed-off-by Long Li <[email protected]>--- fs/ocfs2/namei.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)fs/ocfs2/namei.c +2
-2@@ -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,