staging: lustre: llite: Remove IS_ERR test
PATCH v2 1/1 staging: lustre: llite: Remove IS_ERR test
Remove IS_ERR tests as ll_iget() function can return a ERR_PTR.
This patch also removes checkpatch warnings:
Comparison to NULL could be written "!root"
Comparison to NULL could be written "!inode"
Additionally, reinitialising root and inode to NULL has been removed since they have already been tested for the same.
Lastly, in the first case, the goto has been removed since iput(root) will return nothing for a NULL pointer.
---
Changes in v2:
-Remove IS_ERR test instead of replacing it with
IS_ERR_OR_NULL
drivers/staging/lustre/lustre/llite/llite_lib.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
drivers/staging/lustre/lustre/llite/llite_lib.c +4 -7
@@ -493,7 +493,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,md_free_lustre_md (sbi->ll_md_exp, &lmd);ptlrpc_req_finished (request); -if (root ==NULL ||IS_ERR (root)) { +if (!root) {if (lmd.lsm)obd_free_memmd (sbi->ll_dt_exp, &lmd.lsm);#ifdef CONFIG_FS_POSIX_ACL
@@ -502,10 +502,8 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, lmd.posix_acl = NULL; }#endif - err =IS_ERR (root) ?PTR_ERR (root) : -EBADF ; - root =NULL ; + err = -EBADF ;CERROR ("lustre_lite: bad iget4 for root\n" ); - goto out_root; } err =ll_close_thread_start (&sbi->ll_lcq);
@@ -1965,15 +1963,14 @@ int ll_prep_inode(struct inode **inode, struct ptlrpc_request *req, *inode =ll_iget (sb,cl_fid_build_ino (&md.body->fid1, sbi->ll_flags &LL_SBI_32BIT_API ), &md); -if (*inode ==NULL ||IS_ERR (*inode)) { +if (!inode) {#ifdef CONFIG_FS_POSIX_ACL if (md.posix_acl) {posix_acl_release (md.posix_acl); md.posix_acl =NULL ; }#endif - rc =IS_ERR (*inode) ?PTR_ERR (*inode) : -ENOMEM ; - *inode =NULL ; + rc = -ENOMEM ;CERROR ("new_inode -fatal: rc %d\n" , rc); goto out; }
Signature · 1 line
1.9.1
Quoted 1 line · On Monday 15 February 2016 22:59:10 Amitoj Kaur Chawla wrote:
Remove
IS_ERRtests asll_iget()function can return aERR_PTR.
I think you mean "can not return ERR_PTR", right?
Quoted 10 lines
This patch also removes checkpatch warnings:
Comparison to NULL could be written "!root"
Comparison to NULL could be written "!inode"Additionally, reinitialising root and inode to NULL has been removed since they have already been tested for the same.
Lastly, in the first case, the goto has been removed since iput(root) will return nothing for a NULL pointer.
I don't understand the removal of the goto. Doesn't it break the error handling if we continue without a root inode?
Otherwise looks good. I have checked that the return code handling is correct and it becomes much more intuitive this way.
Arnd
Quoted 9 lines · Amitoj Kaur Chawla
Remove
IS_ERRtests asll_iget()function can return aERR_PTR.This patch also removes checkpatch warnings:
Comparison to NULL could be written "!root"
Comparison to NULL could be written "!inode"Additionally, reinitialising root and inode to NULL has been removed since they have already been tested for the same.
Quoted 8 lines
Lastly, in the first case, the goto has been removed since iput(root) will return nothing for a NULL pointer.
Signed-off-by Amitoj Kaur Chawla <[email protected]>---
Changes in v2:
-RemoveIS_ERRtest instead of replacing it with
IS_ERR_OR_NULL
I think I missed the reviews in the v1 of your patch.
ll_iget() returns inode or NULL, inode can be ERR_PTR(rc), so usually we should be checking for the error with IS_ERR_OR_NULL(). Why is IS_ERR() been removed? what am i missing here?
regards
sudip