From de37968c8c3be7dab31754728d859102dd5258b1 Mon Sep 17 00:00:00 2001 From: Timothy Day Date: Wed, 14 Aug 2024 00:58:01 -0400 Subject: [PATCH] LU-18141 osd: 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 Test-Parameters: trivial fstype=zfs Signed-off-by: Timothy Day Change-Id: I62d78961192f00faf83f9f3fee3c4bf5b8006863 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/56044 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: jsimmons Reviewed-by: Arshad Hussain Reviewed-by: Oleg Drokin --- lustre/osd-ldiskfs/osd_compat.c | 3 +-- lustre/osd-ldiskfs/osd_handler.c | 3 +-- lustre/osd-zfs/osd_oi.c | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/lustre/osd-ldiskfs/osd_compat.c b/lustre/osd-ldiskfs/osd_compat.c index 154a717..9723830 100644 --- a/lustre/osd-ldiskfs/osd_compat.c +++ b/lustre/osd-ldiskfs/osd_compat.c @@ -1027,8 +1027,7 @@ struct osd_obj_seq *osd_seq_load(struct osd_thread_info *info, cleanup: mutex_unlock(&map->om_dir_init_mutex); if (rc != 0) { - if (osd_seq != NULL) - OBD_FREE_PTR(osd_seq); + OBD_FREE_PTR(osd_seq); RETURN(ERR_PTR(rc)); } diff --git a/lustre/osd-ldiskfs/osd_handler.c b/lustre/osd-ldiskfs/osd_handler.c index 78d5167..b19439d 100644 --- a/lustre/osd-ldiskfs/osd_handler.c +++ b/lustre/osd-ldiskfs/osd_handler.c @@ -8146,8 +8146,7 @@ static void osd_key_fini(const struct lu_context *ctx, info->oti_ins_cache = NULL; info->oti_ins_cache_size = 0; } - if (info->oti_lookup_cache) - OBD_FREE_PTR(info->oti_lookup_cache); + OBD_FREE_PTR(info->oti_lookup_cache); OBD_FREE_PTR(info); } diff --git a/lustre/osd-zfs/osd_oi.c b/lustre/osd-zfs/osd_oi.c index 6396dbb..9e4fa8b 100644 --- a/lustre/osd-zfs/osd_oi.c +++ b/lustre/osd-zfs/osd_oi.c @@ -462,8 +462,7 @@ out: if (osd_seq != NULL && osd_seq->os_compat_dirs != NULL) OBD_FREE_PTR_ARRAY(osd_seq->os_compat_dirs, osd_seq->os_subdir_count); - if (osd_seq != NULL) - OBD_FREE_PTR(osd_seq); + OBD_FREE_PTR(osd_seq); osd_seq = ERR_PTR(rc); } RETURN(osd_seq); -- 1.8.3.1