From d67de87ecd15b531718b4e5642b264a5f9b6bbc4 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Thu, 20 Aug 2020 17:08:24 -0500 Subject: Simplify code to avoid using a boolean to free MPI types --- src/H5Dchunk.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index 92cdfda..52a921f 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -4954,11 +4954,10 @@ H5D__chunk_collective_fill(const H5D_t *dset, H5D_chunk_coll_info_t *chunk_info, int blocks, leftover, block_len; /* converted to int for MPI */ MPI_Aint *chunk_disp_array = NULL; int *block_lens = NULL; - MPI_Datatype mem_type, file_type; + MPI_Datatype mem_type = MPI_DATATYPE_NULL, file_type = MPI_DATATYPE_NULL; H5FD_mpio_xfer_t prev_xfer_mode; /* Previous data xfer mode */ hbool_t have_xfer_mode = FALSE; /* Whether the previous xffer mode has been retrieved */ hbool_t need_addr_sort = FALSE; - hbool_t created_mpi_datatypes = FALSE; /* Whether MPI datatypes were created */ int i; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ @@ -5046,9 +5045,6 @@ H5D__chunk_collective_fill(const H5D_t *dset, H5D_chunk_coll_info_t *chunk_info, HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hvector failed", mpi_code) if(MPI_SUCCESS != (mpi_code = MPI_Type_commit(&mem_type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code) - - /* Indicate that the MPI types were created */ - created_mpi_datatypes = TRUE; } /* end if */ else { /* Set up file & memory MPI types, to participate in collective write */ @@ -5086,12 +5082,12 @@ done: HDONE_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set transfer mode") /* free things */ - if(created_mpi_datatypes) { + if(MPI_DATATYPE_NULL != file_type) if(MPI_SUCCESS != (mpi_code = MPI_Type_free(&file_type))) HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code) + if(MPI_DATATYPE_NULL != mem_type) if(MPI_SUCCESS != (mpi_code = MPI_Type_free(&mem_type))) HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code) - } /* end if */ H5MM_xfree(chunk_disp_array); H5MM_xfree(block_lens); -- cgit v0.12