From 650a6dec18306e566b46c3a7cd49cda2fd0b8c40 Mon Sep 17 00:00:00 2001 From: Mr NeilBrown Date: Fri, 16 Oct 2020 09:43:09 +1100 Subject: [PATCH] LU-6142 lustre: iput() can safely be passed NULL. 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 Change-Id: Idcd1a6746ecc67dcfcb0713d2762ca0bdb29de19 Reviewed-on: https://review.whamcloud.com/40291 Tested-by: jenkins Reviewed-by: Aurelien Degremont Tested-by: Maloo Reviewed-by: James Simmons Reviewed-by: Andreas Dilger --- lustre/llite/dir.c | 3 +-- lustre/llite/llite_lib.c | 3 +-- lustre/llite/statahead.c | 3 +-- lustre/lmv/lmv_obd.c | 6 ++---- lustre/osd-ldiskfs/osd_compat.c | 6 ++---- lustre/osd-ldiskfs/osd_handler.c | 3 +-- lustre/osd-ldiskfs/osd_scrub.c | 2 +- 7 files changed, 9 insertions(+), 17 deletions(-) diff --git a/lustre/llite/dir.c b/lustre/llite/dir.c index a4729db..6d083b6 100644 --- a/lustre/llite/dir.c +++ b/lustre/llite/dir.c @@ -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: diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index 335f0d8..3a778a6 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -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: diff --git a/lustre/llite/statahead.c b/lustre/llite/statahead.c index 6745d08..43db649 100644 --- a/lustre/llite/statahead.c +++ b/lustre/llite/statahead.c @@ -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); } diff --git a/lustre/lmv/lmv_obd.c b/lustre/lmv/lmv_obd.c index d84c408..5c95be1 100644 --- a/lustre/lmv/lmv_obd.c +++ b/lustre/lmv/lmv_obd.c @@ -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); diff --git a/lustre/osd-ldiskfs/osd_compat.c b/lustre/osd-ldiskfs/osd_compat.c index 56561b6..4e450a5 100644 --- a/lustre/osd-ldiskfs/osd_compat.c +++ b/lustre/osd-ldiskfs/osd_compat.c @@ -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) diff --git a/lustre/osd-ldiskfs/osd_handler.c b/lustre/osd-ldiskfs/osd_handler.c index 97fceb3..ac5e9d0 100644 --- a/lustre/osd-ldiskfs/osd_handler.c +++ b/lustre/osd-ldiskfs/osd_handler.c @@ -5869,8 +5869,7 @@ trigger: GOTO(out, rc); out: - if (inode) - iput(inode); + iput(inode); RETURN(rc); } diff --git a/lustre/osd-ldiskfs/osd_scrub.c b/lustre/osd-ldiskfs/osd_scrub.c index 9e64ae2..0352876 100644 --- a/lustre/osd-ldiskfs/osd_scrub.c +++ b/lustre/osd-ldiskfs/osd_scrub.c @@ -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) { -- 1.8.3.1