Skip to contentSkip to conversation

xfs: remove unnecessary check in xfile_create()

PATCH In review Yang Yingliang 2 participants 2 messages Aug 24, 2023 XFS filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs: remove unnecessary check in xfile_create()

shmem_file_setup() returns ERR_PTR() when it fails, so remove the unnecessary null pointer check.

---
 fs/xfs/scrub/xfile.c | 2 --
 1 file changed, 2 deletions(-)
fs/xfs/scrub/xfile.c +0 -2
index d98e8e77c684..71779d81cad7 100644
@@ -70,8 +70,6 @@ xfile_create(
 		return -ENOMEM;
 
 	xf->file = shmem_file_setup(description, isize, 0);
-	if (!xf->file)
-		goto out_xfile;
 	if (IS_ERR(xf->file)) {
 		error = PTR_ERR(xf->file);
 		goto out_xfile;
Signature · 1 line
2.25.1
#1 lore raw
Quoted 2 lines · Yang Yingliang

shmem_file_setup() returns ERR_PTR() when it fails, so remove the unnecessary null pointer check.

Technically correct, but what harm is there in leaving a null check in case the shmem_file_setup function ever /does/ start returning NULL?

--D

Quoted 21 lines
---
 fs/xfs/scrub/xfile.c | 2 --
 1 file changed, 2 deletions(-)
fs/xfs/scrub/xfile.c +0 -2
index d98e8e77c684..71779d81cad7 100644
@@ -70,8 +70,6 @@ xfile_create(
 		return -ENOMEM;
 
 	xf->file = shmem_file_setup(description, isize, 0);
-	if (!xf->file)
-		goto out_xfile;
 	if (IS_ERR(xf->file)) {
 		error = PTR_ERR(xf->file);
 		goto out_xfile;
Signature · 1 line
2.25.1