From: Timothy Day Date: Wed, 14 Aug 2024 04:58:01 +0000 (-0400) Subject: LU-18141 osd: don't check for NULL before free'ing X-Git-Tag: 2.15.90~15 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=refs%2Fchanges%2F44%2F56044%2F2;p=fs%2Flustre-release.git 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 --- 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);