From 2056e23fc954b91a81a01cb977eae47caef3875c Mon Sep 17 00:00:00 2001 From: David Young Date: Tue, 14 Jul 2020 15:09:18 -0500 Subject: Avoid some casts, change some parameters from H5FD_t to H5FD_vfd_swmr_t when that's what both the callers and callees expect. NFCI. --- src/H5FDvfd_swmr.c | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/src/H5FDvfd_swmr.c b/src/H5FDvfd_swmr.c index 0914162..974ec56 100644 --- a/src/H5FDvfd_swmr.c +++ b/src/H5FDvfd_swmr.c @@ -86,11 +86,11 @@ static herr_t H5FD_vfd_swmr_lock(H5FD_t *_file, hbool_t rw); static herr_t H5FD_vfd_swmr_unlock(H5FD_t *_file); /* VFD SWMR */ -static htri_t H5FD__vfd_swmr_header_deserialize(H5FD_t *_file, - H5FD_vfd_swmr_md_header *md_header); -static htri_t H5FD__vfd_swmr_index_deserialize(const H5FD_t *_file, +static htri_t H5FD__vfd_swmr_header_deserialize(H5FD_vfd_swmr_t *, + H5FD_vfd_swmr_md_header *); +static htri_t H5FD__vfd_swmr_index_deserialize(const H5FD_vfd_swmr_t *file, H5FD_vfd_swmr_md_index *md_index, const H5FD_vfd_swmr_md_header *md_header); -static herr_t H5FD__vfd_swmr_load_hdr_and_idx(H5FD_t *_file, hbool_t open); +static herr_t H5FD__vfd_swmr_load_hdr_and_idx(H5FD_vfd_swmr_t *, hbool_t); HLOG_OUTLET_SHORT_DEFN(index_motion, swmr); HLOG_OUTLET_SHORT_DEFN(swmr_stats, swmr); @@ -286,7 +286,7 @@ H5FD__swmr_reader_open(H5FD_vfd_swmr_t *file, H5F_vfd_swmr_config_t *vfd_swmr_co /* Retry on loading and decoding the header and index in the * metadata file */ - if(H5FD__vfd_swmr_load_hdr_and_idx((H5FD_t *)file, TRUE) < 0) + if(H5FD__vfd_swmr_load_hdr_and_idx(file, TRUE) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "unable to load/decode the md file header/index"); @@ -995,10 +995,8 @@ done: * */ static herr_t -H5FD__vfd_swmr_load_hdr_and_idx(H5FD_t *_file, hbool_t open) +H5FD__vfd_swmr_load_hdr_and_idx(H5FD_vfd_swmr_t *file, hbool_t open) { - H5FD_vfd_swmr_t *file = /* VFD SWMR file struct */ - (H5FD_vfd_swmr_t *)_file; bool do_try; h5_retry_t retry; H5FD_vfd_swmr_md_header md_header; /* Metadata file header, take 1 */ @@ -1018,7 +1016,7 @@ H5FD__vfd_swmr_load_hdr_and_idx(H5FD_t *_file, hbool_t open) /* Load and decode the header. Go around again on a temporary * failure (FALSE). Bail on an irrecoverable failure (FAIL). */ - rc = H5FD__vfd_swmr_header_deserialize(_file, &md_header); + rc = H5FD__vfd_swmr_header_deserialize(file, &md_header); /* Temporary failure, try again. */ if (rc == FALSE) @@ -1052,7 +1050,7 @@ H5FD__vfd_swmr_load_hdr_and_idx(H5FD_t *_file, hbool_t open) /* Load and decode the index. Go around again on a temporary * failure (FALSE). Bail on an irrecoverable failure (FAIL). */ - rc = H5FD__vfd_swmr_index_deserialize(_file, &md_index, &md_header); + rc = H5FD__vfd_swmr_index_deserialize(file, &md_index, &md_header); if (rc == FALSE) continue; @@ -1065,7 +1063,7 @@ H5FD__vfd_swmr_load_hdr_and_idx(H5FD_t *_file, hbool_t open) * then we should have a consistent picture of the index. */ if (md_header.tick_num == md_index.tick_num && - (rc = H5FD__vfd_swmr_header_deserialize(_file, + (rc = H5FD__vfd_swmr_header_deserialize(file, &md_header_two)) == TRUE && md_header.tick_num == md_header_two.tick_num && md_header.index_length == md_header_two.index_length && @@ -1131,11 +1129,9 @@ done: *------------------------------------------------------------------------- */ static htri_t -H5FD__vfd_swmr_header_deserialize(H5FD_t *_file, +H5FD__vfd_swmr_header_deserialize(H5FD_vfd_swmr_t *file, H5FD_vfd_swmr_md_header *md_header) { - H5FD_vfd_swmr_t *file = /* VFD SWMR file struct */ - (H5FD_vfd_swmr_t *)_file; uint8_t image[H5FD_MD_HEADER_SIZE]; /* Buffer for element data */ uint32_t stored_chksum; /* Stored metadata checksum */ uint32_t computed_chksum; /* Computed metadata checksum */ @@ -1235,10 +1231,9 @@ done: * */ static htri_t -H5FD__vfd_swmr_index_deserialize(const H5FD_t *_file, +H5FD__vfd_swmr_index_deserialize(const H5FD_vfd_swmr_t *file, H5FD_vfd_swmr_md_index *md_index, const H5FD_vfd_swmr_md_header *md_header) { - const H5FD_vfd_swmr_t *file = (const H5FD_vfd_swmr_t *)_file; uint8_t *image; /* Buffer */ uint8_t *p = NULL; /* Pointer to buffer */ uint32_t stored_chksum; /* Stored metadata checksum value */ @@ -1419,7 +1414,7 @@ H5FD_vfd_swmr_get_tick_and_idx(H5FD_t *_file, hbool_t reload_hdr_and_index, /* Load and decode the header and index as indicated */ if (reload_hdr_and_index && - H5FD__vfd_swmr_load_hdr_and_idx(_file, FALSE) < 0) { + H5FD__vfd_swmr_load_hdr_and_idx(file, FALSE) < 0) { HGOTO_ERROR(H5E_VFL, H5E_CANTLOAD, FAIL, "unable to load/decode md header and index") } -- cgit v0.12