From d0c711ff147ee8ee643f98eb3960aaac1748ba66 Mon Sep 17 00:00:00 2001 From: Timothy Day Date: Wed, 14 Aug 2024 00:55:07 -0400 Subject: [PATCH] LU-18141 quota: don't check for NULL before free'ing The common free'ing macros already check for NULL, so we don't need to explicitly check this beforehand. The patch has been generated with the coccinelle script below. @@ expression E; @@ - if (E != NULL) ( OBD_FREE_PTR(E); | OBD_FREE(E, ...); | LIBCFS_FREE(E, ...); | CFS_FREE_PTR(E); | CFS_FREE_PTR_ARRAY(E, ...); ) Test-Parameters: trivial Signed-off-by: Timothy Day Change-Id: Ia32742483baa5fe5a4a26cc7a40cea107b211241 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/56034 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: jsimmons Reviewed-by: Arshad Hussain Reviewed-by: Oleg Drokin --- lustre/quota/qmt_dev.c | 3 +-- lustre/quota/qmt_lock.c | 5 ++--- lustre/quota/qsd_config.c | 3 +-- lustre/quota/qsd_handler.c | 3 +-- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/lustre/quota/qmt_dev.c b/lustre/quota/qmt_dev.c index 3126355..b165438 100644 --- a/lustre/quota/qmt_dev.c +++ b/lustre/quota/qmt_dev.c @@ -186,8 +186,7 @@ static int qmt_connect_to_osd(const struct lu_env *env, struct qmt_device *qmt, ld->ld_site = qmt->qmt_child_exp->exp_obd->obd_lu_dev->ld_site; EXIT; out: - if (data) - OBD_FREE_PTR(data); + OBD_FREE_PTR(data); return rc; } diff --git a/lustre/quota/qmt_lock.c b/lustre/quota/qmt_lock.c index 8d708a6..8110e27 100644 --- a/lustre/quota/qmt_lock.c +++ b/lustre/quota/qmt_lock.c @@ -809,9 +809,8 @@ static int qmt_glimpse_lock(const struct lu_env *env, struct qmt_device *qmt, OBD_FREE_PTR(work); } out: - if (descs) - OBD_FREE(descs, - sizeof(struct ldlm_gl_lquota_desc) * locks_count); + OBD_FREE(descs, + sizeof(struct ldlm_gl_lquota_desc) * locks_count); RETURN(rc); } diff --git a/lustre/quota/qsd_config.c b/lustre/quota/qsd_config.c index 6b18cb7..3cc9d49 100644 --- a/lustre/quota/qsd_config.c +++ b/lustre/quota/qsd_config.c @@ -114,8 +114,7 @@ struct qsd_fsinfo *qsd_get_fsinfo(char *name, bool create) out: spin_unlock(&qfs_list_lock); - if (new) - OBD_FREE_PTR(new); + OBD_FREE_PTR(new); RETURN(qfs); } diff --git a/lustre/quota/qsd_handler.c b/lustre/quota/qsd_handler.c index 6388ecf..4af098d 100644 --- a/lustre/quota/qsd_handler.c +++ b/lustre/quota/qsd_handler.c @@ -442,8 +442,7 @@ out_noadjust: } lqe_putref(lqe); - if (lvb) - OBD_FREE_PTR(lvb); + OBD_FREE_PTR(lvb); EXIT; } -- 1.8.3.1