Whamcloud - gitweb
LU-6142 lustre: iput() can safely be passed NULL. 91/40291/3
authorMr NeilBrown <neilb@suse.de>
Thu, 15 Oct 2020 22:43:09 +0000 (09:43 +1100)
committerOleg Drokin <green@whamcloud.com>
Sat, 6 Mar 2021 02:34:44 +0000 (02:34 +0000)
iput() is a no-op when passed a NULL pointer, so there is no
need to test for NULL before calling it - doing so clutters
the code.

Signed-off-by: Mr NeilBrown <neilb@suse.de>
Change-Id: Idcd1a6746ecc67dcfcb0713d2762ca0bdb29de19
Reviewed-on: https://review.whamcloud.com/40291
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Aurelien Degremont <degremoa@amazon.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
lustre/llite/dir.c
lustre/llite/llite_lib.c
lustre/llite/statahead.c
lustre/lmv/lmv_obd.c
lustre/osd-ldiskfs/osd_compat.c
lustre/osd-ldiskfs/osd_handler.c
lustre/osd-ldiskfs/osd_scrub.c

index a4729db..6d083b6 100644 (file)
@@ -542,8 +542,7 @@ static int ll_dir_setdirstripe(struct dentry *dparent, struct lmv_user_md *lump,
        }
 
 out_inode:
-       if (inode != NULL)
-               iput(inode);
+       iput(inode);
 out_request:
        ptlrpc_req_finished(request);
 out_op_data:
index 335f0d8..3a778a6 100644 (file)
@@ -749,8 +749,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt)
 
        RETURN(err);
 out_root:
-       if (root)
-               iput(root);
+       iput(root);
 out_lock_cn_cb:
        obd_fid_fini(sbi->ll_dt_exp->exp_obd);
 out_dt:
index 6745d08..43db649 100644 (file)
@@ -274,8 +274,7 @@ sa_kill(struct ll_statahead_info *sai, struct sa_entry *entry)
        list_del_init(&entry->se_list);
        spin_unlock(&lli->lli_sa_lock);
 
-       if (entry->se_inode)
-               iput(entry->se_inode);
+       iput(entry->se_inode);
 
        sa_free(sai, entry);
 }
index d84c408..5c95be1 100644 (file)
@@ -3194,10 +3194,8 @@ static int lmv_unpackmd(struct obd_export *exp, struct lmv_stripe_md **lsmp,
                }
 
                if (lmv_dir_striped(lsm)) {
-                       for (i = 0; i < lsm->lsm_md_stripe_count; i++) {
-                               if (lsm->lsm_md_oinfo[i].lmo_root)
-                                       iput(lsm->lsm_md_oinfo[i].lmo_root);
-                       }
+                       for (i = 0; i < lsm->lsm_md_stripe_count; i++)
+                               iput(lsm->lsm_md_oinfo[i].lmo_root);
                        lsm_size = lmv_stripe_md_size(lsm->lsm_md_stripe_count);
                } else {
                        lsm_size = lmv_stripe_md_size(0);
index 56561b6..4e450a5 100644 (file)
@@ -610,10 +610,8 @@ static int osd_index_backup_dir_init(const struct lu_env *env,
 
 static void osd_index_backup_dir_fini(struct osd_device *dev)
 {
-       if (dev->od_index_backup_inode) {
-               iput(dev->od_index_backup_inode);
-               dev->od_index_backup_inode = NULL;
-       }
+       iput(dev->od_index_backup_inode);
+       dev->od_index_backup_inode = NULL;
 }
 
 int osd_obj_map_init(const struct lu_env *env, struct osd_device *dev)
index 97fceb3..ac5e9d0 100644 (file)
@@ -5869,8 +5869,7 @@ trigger:
        GOTO(out, rc);
 
 out:
-       if (inode)
-               iput(inode);
+       iput(inode);
 
        RETURN(rc);
 }
index 9e64ae2..0352876 100644 (file)
@@ -429,7 +429,7 @@ out:
                                OI_KNOWN_ON_OST : 0, NULL);
        up_write(&scrub->os_rwsem);
 
-       if (inode != NULL && !IS_ERR(inode))
+       if (!IS_ERR(inode))
                iput(inode);
 
        if (oii != NULL) {