From a53f47b72f64ce67ecc13381643fc1a00bfc6872 Mon Sep 17 00:00:00 2001 From: Dana Robinson <43805+derobins@users.noreply.github.com> Date: Mon, 25 Apr 2022 23:24:11 -0700 Subject: Onion VFD: Misc cleanup (#1693) * Removes unused definitions from module headers (#1624) * Fix these Doxygen warnings #1581 (#1589) * Fixes a typo in H5.c (#1639) * free MPI_Group/MPI_Comm/MPI_Datatype objects (#1638) * free MPI_Group/MPI_Comm/MPI_Datatype objects * fix clang-format style * Adds build and license shields to README.md (#1641) * First stab at a Github status bar * Adds a .tokeignore file for counting lines of code accurately * Yanks lines of code calculation since it wildly overcounts * not depend on doIO to free an MPI_Comm object (#1642) * free MPI datatypes previously created (#1637) * Retrieve MPI-IO hints used by MPI library after file open (#1636) H5Pget_fapl_mpio() should return an MPI info object containing all the MPI-IO hints used by the MPI library underneath, after the file is opened. Some hints, such as cb_nodes (number of I/O aggregators), are useful for HDF5 applications and I/O libraries built on top of HDF5. * OESS-168: Remove clang warnings. (#1309) * OESS-168: Remove clang warnings. * OESS-168: Address @lrknox review. * OESS-168: Remove clang warnings. (#1376) * Remove H5_NO_ALIGNMENT_RESTRICTIONS (#1426) * Do not conditionally compile code that uses a pointer dereference and assignment to copy a potentially unaligned variable to aligned automatic storage, or vice versa. Instead, always use naked `memcpy(3)`s. Disassembling the generated code reveals that the `memcpy(3)`s optimize (`-O3`) to a single `mov` instruction for x86_64, which is not strict about alignment. This change reduces the size of code and scripts by 143 lines, eases our way to cross-compilation, and avoids invoking undefined behavior. * Committing clang-format changes * Per discussion, use HD and add comments. Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Cleans up some HL library code that inappropriately returns htri_t values cast to herr_t (#1651) * Cleans up some HL library code that inappropriately returns htri_t values cast to herr_t * Committing clang-format changes * Formatted source Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Mirror vfd test fixes (#1629) * Use the FAPL that was created earlier in the test (and delete an unused variable). This allows 'make check-vfd' to pass with --enable-mirror-vfd. * Check for testing directory before creating, to avoid warning from bash. Clean out .libs directory before re-using it (after a failed test), to remove any files generated by libtool. * Committing clang-format changes * Increment error count on failed file open and skip tests for VFDs that need modified filenames. * Skip the mirror VFD for 'make check-vfd' - the mirror VFD requires networking configuration parameters and can't be provided for an automated test that is configured with an environment variable. Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Removes HDF Group paths, adds shellcheck fixes (#1656) For more information: https://www.shellcheck.net/wiki/SC2086 -- Double quote to prevent globbing ... https://www.shellcheck.net/wiki/SC2230 -- which is non-standard. Use builti... https://www.shellcheck.net/wiki/SC2006 -- Use $(...) notation instead of le... * HDFFV-11306 Fixed (#1657) * HDFFV-11306, * Fixed it so both h5open_f and h5close_f can be called multiple times. * Fixed an issue with open objects remaining after h5close_f was called. * Added additional tests. * comments clean-up * Develop clang format java (#1653) * added HDFFV-11306 entry (#1662) * Adds the -q flag to all swmr test programs, quieting noisy output (#1665) * Adds paths-ignore to the Github pull request workflow (#1663) * Changes Github action `hdf5 dev CI` to `PR hdf5 dev CI` (#1666) So the PR action name is not the same as the one in main.yml * Replace H5detect's build-time detection of C99 integer properties with a (#1400) * Replace H5detect's build-time detection of C99 integer properties with a table-driven routine, `H5T__init_native_int()`, that is run at library initialization time. * Improve handling of copying of dynamic libraries and clean them up after (#1681) test finishes. * Warnings fixes (#1680) * Clean stack size warnings in sio_engine (#1687) * Fixes stack size warnings in tcoords.c (#1688) * Minor things noticed while bringing VFD SWMR in line with develop (#1691) * Removed dead code, weird formatting, and other badness * Fixed remaining stack size warnings in onion VFD * Committing clang-format changes Co-authored-by: Allen Byrne <50328838+byrnHDF@users.noreply.github.com> Co-authored-by: Wei-keng Liao Co-authored-by: H. Joe Lee Co-authored-by: David Young Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Quincey Koziol Co-authored-by: Scot Breitenfeld Co-authored-by: jhendersonHDF --- src/H5AC.c | 2 +- src/H5C.c | 20 +- src/H5Cmpio.c | 6 +- src/H5Dchunk.c | 7 +- src/H5Dcontig.c | 12 +- src/H5Dmpio.c | 10 +- src/H5FD.c | 8 +- src/H5FDmpio.c | 2 +- src/H5FDsec2.c | 10 +- src/H5Oflush.c | 1 - src/H5Oint.c | 2 +- src/H5Pfapl.c | 2 +- src/H5Tref.c | 4 +- test/cache_image.c | 2 +- test/dt_arith.c | 6 +- test/onion.c | 830 +++++++++++++++++++--------------------- test/tcoords.c | 62 ++- test/vfd.c | 187 ++++----- testpar/t_bigio.c | 4 +- testpar/t_filters_parallel.c | 6 +- testpar/t_vfd.c | 53 ++- tools/src/h5diff/ph5diff_main.c | 2 +- tools/src/h5perf/sio_engine.c | 55 ++- 23 files changed, 652 insertions(+), 641 deletions(-) diff --git a/src/H5AC.c b/src/H5AC.c index 60f0230..31caf90 100644 --- a/src/H5AC.c +++ b/src/H5AC.c @@ -2432,7 +2432,7 @@ done: /*------------------------------------------------------------------------------ * Function: H5AC_expunge_tag_type_metadata() * - * Purpose: Wrapper for cache level function which expunge entries with + * Purpose: Wrapper for cache level function which expunges entries with * a specific tag and type id. * * Return: SUCCEED on success, FAIL otherwise. diff --git a/src/H5C.c b/src/H5C.c index fa20165..77f3069 100644 --- a/src/H5C.c +++ b/src/H5C.c @@ -61,16 +61,16 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Cpkg.h" /* Cache */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* Files */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ +#include "H5private.h" /* Generic Functions */ +#include "H5Cpkg.h" /* Cache */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* Files */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ /****************/ /* Local Macros */ diff --git a/src/H5Cmpio.c b/src/H5Cmpio.c index ba6ff56..a0cc6bb 100644 --- a/src/H5Cmpio.c +++ b/src/H5Cmpio.c @@ -898,7 +898,11 @@ H5C_clear_coll_entries(H5C_t *cache_ptr, hbool_t partial) H5C_cache_entry_t *entry_ptr = NULL; herr_t ret_value = SUCCEED; +#if H5C_DO_SANITY_CHECKS FUNC_ENTER_NOAPI_NOINIT +#else + FUNC_ENTER_NOAPI_NOINIT_NOERR +#endif entry_ptr = cache_ptr->coll_tail_ptr; clear_cnt = (partial ? cache_ptr->coll_list_len / 2 : cache_ptr->coll_list_len); @@ -919,7 +923,7 @@ H5C_clear_coll_entries(H5C_t *cache_ptr, hbool_t partial) entry_ptr = prev_ptr; } /* end while */ -#ifdef H5C_DO_SANITY_CHECKS +#if H5C_DO_SANITY_CHECKS done: #endif /* H5C_DO_SANITY_CHECKS */ FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index 9167085..eac48a9 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -8124,8 +8124,8 @@ H5D__chunk_iter(const H5D_t *dset, H5D_chunk_iter_op_t op, void *op_data) /* Compose chunked index info struct */ idx_info.f = dset->oloc.file; idx_info.pline = &dset->shared->dcpl_cache.pline; - idx_info.layout = &dset->shared->layout.u.chunk; - idx_info.storage = &dset->shared->layout.storage.u.chunk; + idx_info.layout = &layout->u.chunk; + idx_info.storage = &layout->storage.u.chunk; /* If the dataset is not written, return without errors */ if (H5F_addr_defined(idx_info.storage->idx_addr)) { @@ -8136,8 +8136,7 @@ H5D__chunk_iter(const H5D_t *dset, H5D_chunk_iter_op_t op, void *op_data) ud.op_data = op_data; /* Iterate over the allocated chunks calling the iterator callback */ - if ((ret_value = - (dset->shared->layout.storage.u.chunk.ops->iterate)(&idx_info, H5D__chunk_iter_cb, &ud)) < 0) + if ((ret_value = (layout->storage.u.chunk.ops->iterate)(&idx_info, H5D__chunk_iter_cb, &ud)) < 0) HERROR(H5E_DATASET, H5E_CANTNEXT, "chunk iteration failed"); } /* end if H5F_addr_defined */ diff --git a/src/H5Dcontig.c b/src/H5Dcontig.c index e02d91a..b03ad47 100644 --- a/src/H5Dcontig.c +++ b/src/H5Dcontig.c @@ -605,23 +605,25 @@ done: static htri_t H5D__contig_may_use_select_io(const H5D_io_info_t *io_info, H5D_io_op_type_t op_type) { - const H5D_t *dataset = io_info->dset; /* Local pointer to dataset info */ - htri_t ret_value = FAIL; /* Return value */ + const H5D_t *dataset = NULL; /* Local pointer to dataset info */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(io_info); - HDassert(dataset); + HDassert(io_info->dset); HDassert(op_type == H5D_IO_OP_READ || op_type == H5D_IO_OP_WRITE); + dataset = io_info->dset; + /* Don't use selection I/O if it's globally disabled, if there is a type * conversion, or if it's not a contiguous dataset, or if the sieve buffer * exists (write) or is dirty (read) */ if (!H5_use_selection_io_g || io_info->io_ops.single_read != H5D__select_read || io_info->layout_ops.readvv != H5D__contig_readvv || - (op_type == H5D_IO_OP_READ && io_info->dset->shared->cache.contig.sieve_dirty) || - (op_type == H5D_IO_OP_WRITE && io_info->dset->shared->cache.contig.sieve_buf)) + (op_type == H5D_IO_OP_READ && dataset->shared->cache.contig.sieve_dirty) || + (op_type == H5D_IO_OP_WRITE && dataset->shared->cache.contig.sieve_buf)) ret_value = FALSE; else { hbool_t page_buf_enabled; diff --git a/src/H5Dmpio.c b/src/H5Dmpio.c index cb6f5c3..a7908fe 100644 --- a/src/H5Dmpio.c +++ b/src/H5Dmpio.c @@ -3467,8 +3467,9 @@ done: static herr_t H5D__mpio_redistribute_shared_chunks_int(H5D_filtered_collective_io_info_t *chunk_list, size_t *num_chunks_assigned_map, hbool_t all_ranks_involved, - const H5D_io_info_t *io_info, const H5D_chunk_map_t *fm, - int mpi_rank, int mpi_size) + const H5D_io_info_t * io_info, + const H5D_chunk_map_t H5_ATTR_NDEBUG_UNUSED *fm, int mpi_rank, + int mpi_size) { MPI_Datatype struct_type; MPI_Datatype packed_type; @@ -3797,7 +3798,8 @@ done: static herr_t H5D__mpio_share_chunk_modification_data(H5D_filtered_collective_io_info_t *chunk_list, size_t *chunk_list_num_entries, H5D_io_info_t *io_info, - const H5D_type_info_t *type_info, int mpi_rank, int mpi_size, + const H5D_type_info_t *type_info, int mpi_rank, + int H5_ATTR_NDEBUG_UNUSED mpi_size, H5D_filtered_collective_io_info_t **chunk_hash_table, unsigned char ***chunk_msg_bufs, int *chunk_msg_bufs_len) { @@ -4547,7 +4549,7 @@ H5D__mpio_collective_filtered_chunk_update(H5D_filtered_collective_io_info_t *ch H5D_filtered_collective_io_info_t *chunk_hash_table, unsigned char **chunk_msg_bufs, int chunk_msg_bufs_len, const H5D_io_info_t *io_info, const H5D_type_info_t *type_info, - int mpi_rank, int mpi_size) + int H5_ATTR_NDEBUG_UNUSED mpi_rank, int mpi_size) { H5D_fill_buf_info_t fb_info; H5D_chunk_info_t * chunk_info = NULL; diff --git a/src/H5FD.c b/src/H5FD.c index 3597050..6584843 100644 --- a/src/H5FD.c +++ b/src/H5FD.c @@ -2193,7 +2193,7 @@ H5FD_ctl(H5FD_t *file, uint64_t op_code, uint64_t flags, const void *input, void else if (flags & H5FD_CTL__FAIL_IF_UNKNOWN_FLAG) { HGOTO_ERROR(H5E_VFL, H5E_FCNTL, FAIL, - "VFD ctl request failed (no ctl and fail if unknown flag is set)") + "VFD ctl request failed (no ctl callback and fail if unknown flag is set)") } done: @@ -2261,8 +2261,10 @@ H5FDget_vfd_handle(H5FD_t *file, hid_t fapl_id, void **file_handle /*out*/) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get file handle for file driver") done: - if (FAIL == ret_value) - *file_handle = NULL; + if (FAIL == ret_value) { + if (file_handle) + *file_handle = NULL; + } FUNC_LEAVE_API(ret_value) } /* end H5FDget_vfd_handle() */ diff --git a/src/H5FDmpio.c b/src/H5FDmpio.c index fe9a3c2..1be4779 100644 --- a/src/H5FDmpio.c +++ b/src/H5FDmpio.c @@ -1914,7 +1914,7 @@ H5FD__mpio_vector_build_types(uint32_t count, H5FD_mem_t types[], haddr_t addrs[ if (!sub_types) { HDassert(!sub_types_created); - if (NULL == (sub_types = (int *)HDmalloc((size_t)count * sizeof(MPI_Datatype)))) + if (NULL == (sub_types = HDmalloc((size_t)count * sizeof(MPI_Datatype)))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "can't alloc sub types array") if (NULL == (sub_types_created = (uint8_t *)HDcalloc((size_t)count, 1))) { H5MM_free(sub_types); diff --git a/src/H5FDsec2.c b/src/H5FDsec2.c index 01c1179..aabee0f 100644 --- a/src/H5FDsec2.c +++ b/src/H5FDsec2.c @@ -1075,17 +1075,13 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD__sec2_ctl(H5FD_t *_file, uint64_t op_code, uint64_t flags, const void H5_ATTR_UNUSED *input, - void H5_ATTR_UNUSED **output) +H5FD__sec2_ctl(H5FD_t H5_ATTR_UNUSED *_file, uint64_t op_code, uint64_t flags, + const void H5_ATTR_UNUSED *input, void H5_ATTR_UNUSED **output) { - H5FD_sec2_t *file = (H5FD_sec2_t *)_file; - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE - /* Sanity checks */ - HDassert(file); - switch (op_code) { /* Unknown op code */ default: diff --git a/src/H5Oflush.c b/src/H5Oflush.c index 5d5c5da..d7c7c02 100644 --- a/src/H5Oflush.c +++ b/src/H5Oflush.c @@ -37,7 +37,6 @@ #include "H5CXprivate.h" /* API Contexts */ #include "H5Dprivate.h" /* Datasets */ #include "H5Eprivate.h" /* Errors */ -#include "H5ESprivate.h" /* Event Sets */ #include "H5Fprivate.h" /* Files */ #include "H5Gprivate.h" /* Groups */ #include "H5Iprivate.h" /* IDs */ diff --git a/src/H5Oint.c b/src/H5Oint.c index 93501a2..70661ad 100644 --- a/src/H5Oint.c +++ b/src/H5Oint.c @@ -3014,7 +3014,7 @@ H5O_get_proxy(const H5O_t *oh) *------------------------------------------------------------------------- */ herr_t -H5O__free(H5O_t *oh, hbool_t force) +H5O__free(H5O_t *oh, hbool_t H5_ATTR_NDEBUG_UNUSED force) { unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c index a3ce2f7..d8221a3 100644 --- a/src/H5Pfapl.c +++ b/src/H5Pfapl.c @@ -1636,7 +1636,7 @@ H5Pget_driver_config_str(hid_t fapl_id, char *config_buf, size_t buf_size) size_t config_str_len = HDstrlen(config_str); if (config_buf) { - HDstrncpy(config_buf, config_str, MIN(config_str_len + 1, buf_size)); + HDstrncpy(config_buf, config_str, buf_size); if (config_str_len >= buf_size) config_buf[buf_size - 1] = '\0'; } diff --git a/src/H5Tref.c b/src/H5Tref.c index 967f48d..b6b26ce 100644 --- a/src/H5Tref.c +++ b/src/H5Tref.c @@ -638,8 +638,8 @@ done: */ static herr_t H5T__ref_mem_write(H5VL_object_t *src_file, const void *src_buf, size_t src_size, H5R_type_t src_type, - H5VL_object_t H5_ATTR_UNUSED *dst_file, void *dst_buf, size_t dst_size, - void H5_ATTR_UNUSED *bg_buf) + H5VL_object_t H5_ATTR_UNUSED *dst_file, void *dst_buf, + size_t H5_ATTR_NDEBUG_UNUSED dst_size, void H5_ATTR_UNUSED *bg_buf) { H5F_t * src_f = NULL; hid_t file_id = H5I_INVALID_HID; diff --git a/test/cache_image.c b/test/cache_image.c index 419eb58..9a4b6b7 100644 --- a/test/cache_image.c +++ b/test/cache_image.c @@ -7510,7 +7510,7 @@ get_free_sections_test(hbool_t single_file_vfd) *------------------------------------------------------------------------- */ static unsigned -evict_on_close_test(hbool_t single_file_vfd) +evict_on_close_test(hbool_t H5_ATTR_PARALLEL_UNUSED single_file_vfd) { #ifndef H5_HAVE_PARALLEL const char *fcn_name = "evict_on_close_test()"; diff --git a/test/dt_arith.c b/test/dt_arith.c index 993048a..d73dc4e 100644 --- a/test/dt_arith.c +++ b/test/dt_arith.c @@ -2694,18 +2694,18 @@ my_isnan(dtype_t type, void *val) if (FLT_FLOAT == type) { float x = 0.0; HDmemcpy(&x, val, sizeof(float)); - retval = (x != x); + retval = !H5_FLT_ABS_EQUAL(x, x); } else if (FLT_DOUBLE == type) { double x = 0.0; HDmemcpy(&x, val, sizeof(double)); - retval = (x != x); + retval = !H5_DBL_ABS_EQUAL(x, x); #if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE } else if (FLT_LDOUBLE == type) { long double x = 0.0L; HDmemcpy(&x, val, sizeof(long double)); - retval = (x != x); + retval = !H5_LDBL_ABS_EQUAL(x, x); #endif } else { diff --git a/test/onion.c b/test/onion.c index 4d3a86c..a8c0491 100644 --- a/test/onion.c +++ b/test/onion.c @@ -42,8 +42,6 @@ #define ONION_TEST_REV_REV_WRITES_MAX 8 #define ONE_DIM_SIZE 1024 -#define WIP 1 /* development toggle */ - /* Structure to collect the onion filepaths in one place. */ struct onion_filepaths { char *canon; @@ -83,11 +81,6 @@ static int do_onion_open_and_writes(const char *filename, H5FD_onion_fapl_info_ struct revise_revision *about); static void onion_filepaths_destroy(struct onion_filepaths *); static struct onion_filepaths *onion_filepaths_init(const char *, H5FD_onion_fapl_info_t *); -#if 0 -static int is_onion_data_page_aligned( - const H5FD_onion_history_header_t *); -static uint32_t up_size_to_page_boundary(uint64_t, uint32_t); -#endif /* set at runtime in main() */ static unsigned int flags_create_s = 0; @@ -160,22 +153,6 @@ onion_filepaths_destroy(struct onion_filepaths *s) HDfree(s); } -#if 0 -static int -is_onion_data_page_aligned(const H5FD_onion_history_header_t *header) -{ - return header->flags & H5FD__ONION_HEADER_FLAG_PAGE_ALIGNMENT; -} - -static uint32_t -up_size_to_page_boundary(uint64_t size_in, uint32_t page_size) -{ - uint32_t _i = 0; /* number of pages occupied */ - for (_i = 1; (page_size * _i) < size_in; _i++); - return page_size * _i; -} -#endif - /*----------------------------------------------------------------------------- * Function: test_archival_index() * @@ -217,83 +194,105 @@ test_archival_index(void) * Failing validity checks */ + /* Invalid version should fail */ aix.version++; if (H5FD_onion_archival_index_is_valid(&aix)) - TEST_ERROR /* invalid version should fail */ - aix.version = 0; + TEST_ERROR + + /* Invalid version should fail */ + aix.version = 0; if (H5FD_onion_archival_index_is_valid(&aix)) - TEST_ERROR /* invalid version should fail */ - aix.version = H5FD__ONION_ARCHIVAL_INDEX_VERSION_CURR; + TEST_ERROR + aix.version = H5FD__ONION_ARCHIVAL_INDEX_VERSION_CURR; + /* NULL list should fail */ aix.list = NULL; if (H5FD_onion_archival_index_is_valid(&aix)) - TEST_ERROR /* list cannot be NULL */ + TEST_ERROR - aix.list = sorted_incomplete; + /* List not full should fail */ + aix.list = sorted_incomplete; if (H5FD_onion_archival_index_is_valid(&aix)) - TEST_ERROR /* list must be full */ + TEST_ERROR - aix.list = unsorted; + /* Unsorted list should fail */ + aix.list = unsorted; if (H5FD_onion_archival_index_is_valid(&aix)) - TEST_ERROR /* list must be sorted */ + TEST_ERROR - aix.list = sorted_duplicates; + /* List with duplicates should fail */ + aix.list = sorted_duplicates; if (H5FD_onion_archival_index_is_valid(&aix)) - TEST_ERROR /* list cannot have duplicates */ + TEST_ERROR - /* - * Passing validity checks - */ + /* + * Passing validity checks + */ - aix.list = sorted; + /* Sorted list should pass */ + aix.list = sorted; if (!H5FD_onion_archival_index_is_valid(&aix)) - TEST_ERROR /* everything in order should report valid */ + TEST_ERROR - aix.list = sorted_partial; + /* Extra elements ignored (should pass) */ + aix.list = sorted_partial; aix.n_entries = 4; if (!H5FD_onion_archival_index_is_valid(&aix)) - TEST_ERROR /* elements after n_entries are ignored */ + TEST_ERROR - /* - * Archival index search routine - */ + /* + * Archival index search routine + */ - aix.list = sorted; + aix.list = sorted; aix.n_entries = 8; + /* Check that address not in array returns zero */ if (H5FD_onion_archival_index_find(&aix, 3, &entry_out_p) != 0) - TEST_ERROR /* address not in array -> returns 0 */ - if (entry_out_p != NULL) TEST_ERROR /* pointer should remain unset */ + TEST_ERROR + /* Pointer should remain unset */ + if (entry_out_p != NULL) + TEST_ERROR - if (H5FD_onion_archival_index_find(&aix, 4, &entry_out_p) != 1) - TEST_ERROR /* address found -> should return 1 */ - if (NULL == entry_out_p) TEST_ERROR /* pointer should be set */ - if (558 != entry_out_p->phys_addr) TEST_ERROR /* incorrect address recorded */ + /* Address found should return 1 */ + if (H5FD_onion_archival_index_find(&aix, 4, &entry_out_p) != 1) + TEST_ERROR + /* Pointer should be set */ + if (NULL == entry_out_p) + TEST_ERROR + /* Incorrect address recorded */ + if (558 != entry_out_p->phys_addr) + TEST_ERROR - /* - * Test search edge cases - */ + /* + * Test search edge cases + */ - aix.list = sorted_incomplete; + aix.list = sorted_incomplete; aix.n_entries = 4; + /* Address not in array should return 0 */ if (H5FD_onion_archival_index_find(&aix, 1, &entry_out_p) != 0) - TEST_ERROR /* address not in array -> returns 0 */ + TEST_ERROR - if (H5FD_onion_archival_index_find(&aix, 101, &entry_out_p) != 0) - TEST_ERROR /* address not in array -> returns 0 */ + /* Address not in array should return 0 */ + if (H5FD_onion_archival_index_find(&aix, 101, &entry_out_p) != 0) + TEST_ERROR - /* - * Empty archival index - */ + /* + * Empty archival index + */ - entry_out_p = NULL; + entry_out_p = NULL; aix.n_entries = 0; /* actually populated list is irrelevant */ + /* Address not in array should return 0 */ if (H5FD_onion_archival_index_find(&aix, 3, &entry_out_p) != 0) - TEST_ERROR /* address not in array -> returns 0 */ - if (entry_out_p != NULL) TEST_ERROR /* pointer should remain unset */ + TEST_ERROR + /* Pointer should remain unset */ + if (entry_out_p != NULL) + TEST_ERROR - PASSED(); + PASSED(); return 0; error: @@ -337,19 +336,26 @@ test_revision_index(void) /* Test successful insertion and lookup */ + /* Insertion failed */ if (H5FD_onion_revision_index_insert(rix_p, &entry) < 0) - TEST_ERROR /* insertion failed */ - if (1 != rix_p->n_entries) - TEST_ERROR if (H5FD_onion_revision_index_find(rix_p, entry.logi_page, &entry_out_p) < 0) - TEST_ERROR /* lookup failed */ - if (NULL == entry_out_p) TEST_ERROR /* failure to set output parameter */ - if (entry.logi_page != entry_out_p->logi_page) - TEST_ERROR if (H5FD_onion_revision_index_find(rix_p, entry.logi_page + 1, &entry_out_p) != 0) - TEST_ERROR /* seeking other, absent page should miss */ - - /* Test / demonstrate stored entry independent of user object */ - - entry.logi_page = 100; + TEST_ERROR + if (1 != rix_p->n_entries) + TEST_ERROR + /* Lookup failed */ + if (H5FD_onion_revision_index_find(rix_p, entry.logi_page, &entry_out_p) < 0) + TEST_ERROR + /* Failure to set output parameter */ + if (NULL == entry_out_p) + TEST_ERROR + if (entry.logi_page != entry_out_p->logi_page) + TEST_ERROR + /* Seeking missing page should miss */ + if (H5FD_onion_revision_index_find(rix_p, entry.logi_page + 1, &entry_out_p) != 0) + TEST_ERROR + + /* Test / demonstrate stored entry independent of user object */ + + entry.logi_page = 100; entry.phys_addr = 101; if (H5FD_onion_revision_index_insert(rix_p, &entry) < 0) TEST_ERROR @@ -377,14 +383,19 @@ test_revision_index(void) entry.phys_addr = 101; if (H5FD_onion_revision_index_insert(rix_p, &entry) < 0) TEST_ERROR + + /* Should still be two unique entries, not three */ if (2 != rix_p->n_entries) - TEST_ERROR /* Should still be two unique entries, not three */ - if (H5FD_onion_revision_index_find(rix_p, 100, &entry_out_p) < 0) - TEST_ERROR if (100 != entry_out_p->logi_page || 101 != entry_out_p->phys_addr) TEST_ERROR + TEST_ERROR + if (H5FD_onion_revision_index_find(rix_p, 100, &entry_out_p) < 0) + TEST_ERROR + if (100 != entry_out_p->logi_page || 101 != entry_out_p->phys_addr) + TEST_ERROR - if (H5FD_onion_revision_index_destroy(rix_p) < 0) TEST_ERROR + if (H5FD_onion_revision_index_destroy(rix_p) < 0) + TEST_ERROR - PASSED(); + PASSED(); return 0; error: @@ -545,18 +556,17 @@ test_revision_index_to_archival_index(void) */ if (NULL == (rix_p = H5FD_onion_revision_index_init(ONION_TEST_PAGE_SIZE_5))) - TEST_ERROR /* Unable to initialize working index */ + TEST_ERROR - /* Add scattered entries in reverse order. */ - for (uint64_t i = 0; i < n_insert; i++) - { - uint64_t n = 2003 * (n_insert - i) + 47; + /* Add scattered entries in reverse order. */ + for (uint64_t i = 0; i < n_insert; i++) { + uint64_t n = 2003 * (n_insert - i) + 47; - rix_entry.logi_page = n; - rix_entry.phys_addr = n * 13; - if (H5FD_onion_revision_index_insert(rix_p, &rix_entry) < 0) - TEST_ERROR - } + rix_entry.logi_page = n; + rix_entry.phys_addr = n * 13; + if (H5FD_onion_revision_index_insert(rix_p, &rix_entry) < 0) + TEST_ERROR + } if (n_insert != rix_p->n_entries) TEST_ERROR @@ -570,22 +580,22 @@ test_revision_index_to_archival_index(void) TEST_ERROR if (!H5FD_onion_archival_index_is_valid(&aix)) - TEST_ERROR /* Entries not sorted, or other obscure issue */ + TEST_ERROR - if (n_insert != aix.n_entries) TEST_ERROR /* Failed to resize and/or update archival index info */ + if (n_insert != aix.n_entries) + TEST_ERROR + for (uint64_t i = 0; i < n_insert; i++) { + const H5FD_onion_index_entry_t *aix_entry_p = NULL; - for (uint64_t i = 0; i < n_insert; i++) - { - const H5FD_onion_index_entry_t *aix_entry_p = NULL; - uint64_t n = 2003 * (i + 1) + 47; + uint64_t n = 2003 * (i + 1) + 47; - aix_entry_p = &aix.list[i]; + aix_entry_p = &aix.list[i]; - if (aix_entry_p->logi_page != n) - TEST_ERROR - if (aix_entry_p->phys_addr != (n * 13)) - TEST_ERROR - } + if (aix_entry_p->logi_page != n) + TEST_ERROR + if (aix_entry_p->phys_addr != (n * 13)) + TEST_ERROR + } /* Successful merge into populated archival index */ @@ -600,27 +610,28 @@ test_revision_index_to_archival_index(void) aix.n_entries = 2; if (!H5FD_onion_archival_index_is_valid(&aix)) - TEST_ERROR /* entries not sorted, or other obscure issue */ + TEST_ERROR - if (H5FD_onion_merge_revision_index_into_archival_index(rix_p, &aix) < 0) TEST_ERROR + if (H5FD_onion_merge_revision_index_into_archival_index(rix_p, &aix) < 0) + TEST_ERROR + if (!H5FD_onion_archival_index_is_valid(&aix)) + TEST_ERROR - if (!H5FD_onion_archival_index_is_valid(&aix)) - TEST_ERROR /* entries not sorted, or other obscure issue */ + if (n_insert + 2 != aix.n_entries) + TEST_ERROR - if (n_insert + 2 != aix.n_entries) TEST_ERROR + for (uint64_t i = 0; i < (n_insert + 2); i++) { + const H5FD_onion_index_entry_t *aix_entry_p = NULL; - for (uint64_t i = 0; i < (n_insert + 2); i++) - { - const H5FD_onion_index_entry_t *aix_entry_p = NULL; - uint64_t n = 2003 * i + 47; + uint64_t n = 2003 * i + 47; - aix_entry_p = &aix.list[i]; + aix_entry_p = &aix.list[i]; - if (aix_entry_p->logi_page != n) - TEST_ERROR - if (aix_entry_p->phys_addr != (n * 13)) - TEST_ERROR - } + if (aix_entry_p->logi_page != n) + TEST_ERROR + if (aix_entry_p->phys_addr != (n * 13)) + TEST_ERROR + } /* Merged enties from revision index replace existing entries */ @@ -635,27 +646,28 @@ test_revision_index_to_archival_index(void) aix.n_entries = 2; if (!H5FD_onion_archival_index_is_valid(&aix)) - TEST_ERROR /* entries not sorted, or other obscure issue */ + TEST_ERROR - if (H5FD_onion_merge_revision_index_into_archival_index(rix_p, &aix) < 0) TEST_ERROR + if (H5FD_onion_merge_revision_index_into_archival_index(rix_p, &aix) < 0) + TEST_ERROR - if (!H5FD_onion_archival_index_is_valid(&aix)) - TEST_ERROR /* entries not sorted, or other obscure issue */ + if (!H5FD_onion_archival_index_is_valid(&aix)) + TEST_ERROR - if (n_insert != aix.n_entries) TEST_ERROR + if (n_insert != aix.n_entries) + TEST_ERROR - for (uint64_t i = 0; i < n_insert; i++) - { - const H5FD_onion_index_entry_t *aix_entry_p = NULL; - uint64_t n = 2003 * (i + 1) + 47; + for (uint64_t i = 0; i < n_insert; i++) { + const H5FD_onion_index_entry_t *aix_entry_p = NULL; + uint64_t n = 2003 * (i + 1) + 47; - aix_entry_p = &aix.list[i]; + aix_entry_p = &aix.list[i]; - if (aix_entry_p->logi_page != n) - TEST_ERROR - if (aix_entry_p->phys_addr != (n * 13)) - TEST_ERROR - } + if (aix_entry_p->logi_page != n) + TEST_ERROR + if (aix_entry_p->phys_addr != (n * 13)) + TEST_ERROR + } /* CLEANUP */ @@ -1155,7 +1167,7 @@ test_whole_history_encode_decode(void) whs.record_pointer_list[2].phys_addr = 918153371232ull; whs.record_pointer_list[2].record_size = 240ull; - /* populate revision pointer sums in exp */ + /* Populate revision pointer sums in exp */ for (i = 0; i < whs.n_revisions; i++) { uint64_t whs_pre = H5FD__ONION_ENCODED_SIZE_WHOLE_HISTORY - 4; uint64_t ptr_pre = H5FD__ONION_ENCODED_SIZE_RECORD_POINTER - 4; @@ -1167,7 +1179,7 @@ test_whole_history_encode_decode(void) UINT32ENCODE(buf_p, whs.record_pointer_list[i].checksum); } - /* compute, populate, and store exp final sum */ + /* Compute, populate, and store exp final sum */ whs.checksum = H5_checksum_fletcher32(exp, exp_size - 4); buf_p = exp + exp_size - 4; UINT32ENCODE(buf_p, whs.checksum); @@ -1184,8 +1196,7 @@ test_whole_history_encode_decode(void) if (whs.checksum != sum_out) TEST_ERROR - /* Initial decode, gets always-present components. - */ + /* Initial decode, gets always-present components */ whs_out.n_revisions = 0; /* must be initialized to 0 */ if (H5FD_onion_whole_history_decode(exp, &whs_out) != exp_size) @@ -1194,12 +1205,13 @@ test_whole_history_encode_decode(void) TEST_ERROR if (whs.n_revisions != whs_out.n_revisions) TEST_ERROR + /* Must be created by us */ if (NULL != whs_out.record_pointer_list) - TEST_ERROR /* Must be created by us */ + TEST_ERROR - /* True decode requires allocating space for record pointers */ + /* True decode requires allocating space for record pointers */ - whs_out.record_pointer_list = HDcalloc(whs_out.n_revisions, sizeof(H5FD_onion_record_pointer_t)); + whs_out.record_pointer_list = HDcalloc(whs_out.n_revisions, sizeof(H5FD_onion_record_pointer_t)); if (NULL == whs_out.record_pointer_list) TEST_ERROR @@ -1651,15 +1663,10 @@ verify_history_as_expected_onion(H5FD_t *raw_file, struct expected_history *filt /* Re-use buffer space to sanity-check checksum for record pointer(s). */ HDassert(readsize >= sizeof(H5FD_onion_record_pointer_t)); for (i = 0; i < whs_out.n_revisions; i++) { -#if 0 - uint32_t sum = 0; -#endif HDmemcpy(buf, &whs_out.record_pointer_list[i].phys_addr, 8); HDmemcpy(buf + 8, &whs_out.record_pointer_list[i].record_size, 8); -#if 0 - sum = H5_checksum_fletcher32(buf, 16); -#endif + if (whs_out.record_pointer_list[i].checksum != H5_checksum_fletcher32(buf, 16)) TEST_ERROR } @@ -1822,15 +1829,16 @@ verify_stored_onion_create_0_open(struct onion_filepaths *paths, H5FD_onion_fapl if (NULL == (act_buf = HDcalloc(1, 8))) TEST_ERROR + /* Should fail when reading from an empty file */ H5E_BEGIN_TRY { err_ret = H5FDread(file, H5FD_MEM_DRAW, H5P_DEFAULT, 0, 1, act_buf); } H5E_END_TRY; if (err_ret != FAIL) - TEST_ERROR /* cannot read from empty file */ + TEST_ERROR - HDfree(act_buf); + HDfree(act_buf); act_buf = NULL; if (H5FDclose(file) < 0) @@ -1906,18 +1914,14 @@ test_create_oniontarget(hbool_t truncate_canonical, hbool_t with_initial_data) struct expected_history filter; char * buf = NULL; - if (TRUE == truncate_canonical && TRUE == with_initial_data) { - TESTING("onion creation; truncate extant canonical; w/ initial data"); - } - else if (TRUE == truncate_canonical) { - TESTING("onion creation; truncate extant canonical; no initial data"); - } - else if (TRUE == with_initial_data) { - TESTING("onion creation; no extant canonical; w/ initial data"); - } - else { - TESTING("onion creation; no extant canonical; no initial data"); - } + if (TRUE == truncate_canonical && TRUE == with_initial_data) + TESTING("onion creation; truncate extant canonical; w/ initial data") + else if (TRUE == truncate_canonical) + TESTING("onion creation; truncate extant canonical; no initial data") + else if (TRUE == with_initial_data) + TESTING("onion creation; no extant canonical; w/ initial data") + else + TESTING("onion creation; no extant canonical; no initial data") /********* * SETUP * @@ -1938,7 +1942,7 @@ test_create_oniontarget(hbool_t truncate_canonical, hbool_t with_initial_data) HDremove(paths->onion); HDremove(paths->recovery); - /* create canonical file to be truncated */ + /* Create canonical file to be truncated */ if (TRUE == truncate_canonical) { /* Create canonical file. */ vfile_raw = H5FDopen(paths->canon, flags_create_s, onion_info.backing_fapl_id, HADDR_UNDEF); @@ -1957,11 +1961,12 @@ test_create_oniontarget(hbool_t truncate_canonical, hbool_t with_initial_data) vfile_raw = H5FDopen(paths->canon, H5F_ACC_RDONLY, fapl_id, HADDR_UNDEF); } H5E_END_TRY; + /* Check if onion history for onion-open created file */ if (NULL != vfile_raw) - TEST_ERROR /* no onion history to onion-open created file */ + TEST_ERROR - /* Create "existing onion file". */ - vfile_raw = H5FDopen(paths->onion, flags_create_s, onion_info.backing_fapl_id, HADDR_UNDEF); + /* Create "existing onion file". */ + vfile_raw = H5FDopen(paths->onion, flags_create_s, onion_info.backing_fapl_id, HADDR_UNDEF); if (NULL == vfile_raw) TEST_ERROR if (H5FDset_eoa(vfile_raw, H5FD_MEM_DRAW, b_list_size_s) < 0) @@ -1978,8 +1983,7 @@ test_create_oniontarget(hbool_t truncate_canonical, hbool_t with_initial_data) * OPENED */ - /* Begin creation of onionized file from nothing. - */ + /* Begin creation of onionized file from nothing */ vfile_rw = H5FDopen(paths->canon, flags_create_s, fapl_id, HADDR_UNDEF); if (NULL == vfile_rw) @@ -1993,73 +1997,73 @@ test_create_oniontarget(hbool_t truncate_canonical, hbool_t with_initial_data) vfile_ro = H5FDopen(paths->canon, H5F_ACC_RDONLY, fapl_id, HADDR_UNDEF); } H5E_END_TRY; + /* check if onionization (creation) not complete; nothing to open */ if (vfile_ro != NULL) - TEST_ERROR /* onionization (creation) not complete; nothing to open */ + TEST_ERROR - /* - * WRITING - */ + /* + * WRITING + */ - if (TRUE == with_initial_data) - { - haddr_t half_size = 0; - haddr_t buf_size = 0; + if (TRUE == with_initial_data) { + haddr_t half_size = 0; + haddr_t buf_size = 0; - /* Write the sub-page entry at addr 0 */ - if (4 >= onion_info.page_size) - TEST_ERROR - if (H5FDset_eoa(vfile_rw, H5FD_MEM_DRAW, 4) < 0) - TEST_ERROR - if (H5FDwrite(vfile_rw, H5FD_MEM_DRAW, H5P_DEFAULT, 0, 4, a_list_s) < 0) { - TEST_ERROR - } + /* Write the sub-page entry at addr 0 */ + if (4 >= onion_info.page_size) + TEST_ERROR + if (H5FDset_eoa(vfile_rw, H5FD_MEM_DRAW, 4) < 0) + TEST_ERROR + if (H5FDwrite(vfile_rw, H5FD_MEM_DRAW, H5P_DEFAULT, 0, 4, a_list_s) < 0) { + TEST_ERROR + } - /* Verify logical file contents. */ - if (NULL == (buf = HDmalloc(4 * sizeof(char)))) - TEST_ERROR - if (H5FDread(vfile_rw, H5FD_MEM_DRAW, H5P_DEFAULT, 0, 4, buf) < 0) - TEST_ERROR - if (HDmemcmp(a_list_s, buf, 4) != 0) - TEST_ERROR - HDfree(buf); - buf = NULL; + /* Verify logical file contents. */ + if (NULL == (buf = HDmalloc(4 * sizeof(char)))) + TEST_ERROR + if (H5FDread(vfile_rw, H5FD_MEM_DRAW, H5P_DEFAULT, 0, 4, buf) < 0) + TEST_ERROR + if (HDmemcmp(a_list_s, buf, 4) != 0) + TEST_ERROR + HDfree(buf); + buf = NULL; - /* Write the latter half of buffer at addr 0 (more than one page) */ - half_size = a_list_size_s / 2; - buf_size = a_list_size_s - half_size; - if (buf_size <= onion_info.page_size) - TEST_ERROR - if (H5FDset_eoa(vfile_rw, H5FD_MEM_DRAW, buf_size) < 0) - TEST_ERROR - if (H5FDwrite(vfile_rw, H5FD_MEM_DRAW, H5P_DEFAULT, 0, buf_size, a_list_s + half_size) < 0) - TEST_ERROR + /* Write the latter half of buffer at addr 0 (more than one page) */ + half_size = a_list_size_s / 2; + buf_size = a_list_size_s - half_size; + if (buf_size <= onion_info.page_size) + TEST_ERROR + if (H5FDset_eoa(vfile_rw, H5FD_MEM_DRAW, buf_size) < 0) + TEST_ERROR + if (H5FDwrite(vfile_rw, H5FD_MEM_DRAW, H5P_DEFAULT, 0, buf_size, a_list_s + half_size) < 0) + TEST_ERROR - /* Verify logical file contents. */ - if (NULL == (buf = HDmalloc(buf_size * sizeof(char)))) - TEST_ERROR - if (H5FDread(vfile_rw, H5FD_MEM_DRAW, H5P_DEFAULT, 0, buf_size, buf) < 0) - TEST_ERROR - if (HDmemcmp(a_list_s + half_size, buf, buf_size) != 0) - TEST_ERROR - HDfree(buf); - buf = NULL; + /* Verify logical file contents. */ + if (NULL == (buf = HDmalloc(buf_size * sizeof(char)))) + TEST_ERROR + if (H5FDread(vfile_rw, H5FD_MEM_DRAW, H5P_DEFAULT, 0, buf_size, buf) < 0) + TEST_ERROR + if (HDmemcmp(a_list_s + half_size, buf, buf_size) != 0) + TEST_ERROR + HDfree(buf); + buf = NULL; - /* Overwrite existing data with entire buffer at addr 0 */ - if (H5FDset_eoa(vfile_rw, H5FD_MEM_DRAW, a_list_size_s) < 0) - TEST_ERROR - if (H5FDwrite(vfile_rw, H5FD_MEM_DRAW, H5P_DEFAULT, 0, a_list_size_s, a_list_s) < 0) - TEST_ERROR + /* Overwrite existing data with entire buffer at addr 0 */ + if (H5FDset_eoa(vfile_rw, H5FD_MEM_DRAW, a_list_size_s) < 0) + TEST_ERROR + if (H5FDwrite(vfile_rw, H5FD_MEM_DRAW, H5P_DEFAULT, 0, a_list_size_s, a_list_s) < 0) + TEST_ERROR - /* Verify logical file contents. */ - if (NULL == (buf = HDmalloc(a_list_size_s * sizeof(char)))) - TEST_ERROR - if (H5FDread(vfile_rw, H5FD_MEM_DRAW, H5P_DEFAULT, 0, a_list_size_s, buf) < 0) - TEST_ERROR - if (HDmemcmp(a_list_s, buf, a_list_size_s) != 0) - TEST_ERROR - HDfree(buf); - buf = NULL; - } /* end if writing data to logical file */ + /* Verify logical file contents. */ + if (NULL == (buf = HDmalloc(a_list_size_s * sizeof(char)))) + TEST_ERROR + if (H5FDread(vfile_rw, H5FD_MEM_DRAW, H5P_DEFAULT, 0, a_list_size_s, buf) < 0) + TEST_ERROR + if (HDmemcmp(a_list_s, buf, a_list_size_s) != 0) + TEST_ERROR + HDfree(buf); + buf = NULL; + } /* end if writing data to logical file */ /* * CLOSED @@ -2069,16 +2073,12 @@ test_create_oniontarget(hbool_t truncate_canonical, hbool_t with_initial_data) TEST_ERROR vfile_rw = NULL; - /* Look at h5 file: should be known-empty - */ - + /* Look at h5 file: should be known-empty */ if (compare_file_bytes_exactly(paths->canon, onion_info.backing_fapl_id, 8, (const unsigned char *)"ONIONEOF") < 0) TEST_ERROR - /* Look at recovery file: should be gone. - */ - + /* Look at recovery file: should be gone */ H5E_BEGIN_TRY { vfile_raw = H5FDopen(paths->recovery, H5F_ACC_RDONLY, onion_info.backing_fapl_id, HADDR_UNDEF); @@ -2087,9 +2087,7 @@ test_create_oniontarget(hbool_t truncate_canonical, hbool_t with_initial_data) if (NULL != vfile_raw) TEST_ERROR - /* Inspect onion file. - */ - + /* Inspect onion file */ vfile_raw = H5FDopen(paths->onion, H5F_ACC_RDONLY, onion_info.backing_fapl_id, HADDR_UNDEF); if (NULL == vfile_raw) TEST_ERROR @@ -2110,8 +2108,7 @@ test_create_oniontarget(hbool_t truncate_canonical, hbool_t with_initial_data) TEST_ERROR vfile_raw = NULL; - /* R/O open the file with Onion VFD; inspect logial file. - */ + /* R/O open the file with Onion VFD; inspect logial file */ vfile_ro = H5FDopen(paths->canon, H5F_ACC_RDONLY, fapl_id, HADDR_UNDEF); if (NULL == vfile_ro) @@ -2218,14 +2215,10 @@ test_several_revisions_with_logical_gaps(void) 0, /* flags */ "first" /* comment */ }; - H5FD_t * file = NULL; /* Onion virtual file for read/write */ - struct expected_history filter; - unsigned char * buf = NULL; - struct revise_revision about[4]; -#if 0 - H5FD_onion_history_header_t hdr_out; - H5FD_onion_revision_record_t rev_out; -#endif + H5FD_t * file = NULL; /* Onion virtual file for read/write */ + struct expected_history filter; + unsigned char * buf = NULL; + struct revise_revision about[4]; H5FD_onion_whole_history_t whs_out; size_t i = 0; haddr_t size = 0; @@ -2239,10 +2232,6 @@ test_several_revisions_with_logical_gaps(void) * SETUP * *********/ -#if 0 - hdr_out.version = H5FD__ONION_HEADER_VERSION_CURR; - rev_out.version = H5FD__ONION_REVISION_RECORD_VERSION_CURR; -#endif whs_out.version = H5FD__ONION_WHOLE_HISTORY_VERSION_CURR; whs_out.n_revisions = 0; whs_out.record_pointer_list = NULL; @@ -2336,8 +2325,7 @@ test_several_revisions_with_logical_gaps(void) /* One offset block in second revision */ onion_info.revision_num = 2; - // onion_info.revision_num = 1; - fapl_id = H5Pcreate(H5P_FILE_ACCESS); + fapl_id = H5Pcreate(H5P_FILE_ACCESS); if (H5I_INVALID_HID == fapl_id) TEST_ERROR if (H5Pset_fapl_onion(fapl_id, &onion_info) < 0) @@ -2388,8 +2376,7 @@ test_several_revisions_with_logical_gaps(void) /* Two offset blocks in third revision */ onion_info.revision_num = 3; - // onion_info.revision_num = 2; - fapl_id = H5Pcreate(H5P_FILE_ACCESS); + fapl_id = H5Pcreate(H5P_FILE_ACCESS); if (H5I_INVALID_HID == fapl_id) TEST_ERROR if (H5Pset_fapl_onion(fapl_id, &onion_info) < 0) @@ -2429,8 +2416,7 @@ test_several_revisions_with_logical_gaps(void) /* From start and partial overwrite in fourth revision */ onion_info.revision_num = 4; - // onion_info.revision_num = 3; - fapl_id = H5Pcreate(H5P_FILE_ACCESS); + fapl_id = H5Pcreate(H5P_FILE_ACCESS); if (H5I_INVALID_HID == fapl_id) TEST_ERROR if (H5Pset_fapl_onion(fapl_id, &onion_info) < 0) @@ -2468,25 +2454,7 @@ test_several_revisions_with_logical_gaps(void) fapl_id = H5I_INVALID_HID; /* No fifth revision */ - // TODO: Can this be done without triggering an error? - /* onion_info.revision_num = 5; - //onion_info.revision_num = 4; - fapl_id = H5Pcreate(H5P_FILE_ACCESS); - if (H5I_INVALID_HID == fapl_id) - TEST_ERROR - if (H5Pset_fapl_onion(fapl_id, &onion_info) < 0) - TEST_ERROR - file = H5FDopen(paths->canon, H5F_ACC_RDONLY, fapl_id, HADDR_UNDEF); - if (NULL != file) - TEST_ERROR - if (H5FDclose(file) < 0) - TEST_ERROR - file = NULL; - if (H5Pclose(fapl_id) < 0) - TEST_ERROR - fapl_id = H5I_INVALID_HID; - */ /* Inspect history construction */ file = H5FDopen(paths->onion, H5F_ACC_RDONLY, onion_info.backing_fapl_id, HADDR_UNDEF); @@ -2696,12 +2664,9 @@ test_page_aligned_history_create(void) unsigned char * buf = NULL; struct revise_revision about[2]; H5FD_onion_history_header_t hdr_out; -#if 0 - H5FD_onion_revision_record_t rev_out; -#endif - H5FD_onion_whole_history_t whs_out; - size_t i = 0; - uint64_t a_off = b_list_size_s - a_list_size_s; + H5FD_onion_whole_history_t whs_out; + size_t i = 0; + uint64_t a_off = b_list_size_s - a_list_size_s; TESTING("page-aligned history on onion-created file"); @@ -2709,10 +2674,7 @@ test_page_aligned_history_create(void) * SETUP * *********/ - hdr_out.version = H5FD__ONION_HEADER_VERSION_CURR; -#if 0 - rev_out.version = H5FD__ONION_REVISION_RECORD_VERSION_CURR; -#endif + hdr_out.version = H5FD__ONION_HEADER_VERSION_CURR; whs_out.version = H5FD__ONION_WHOLE_HISTORY_VERSION_CURR; whs_out.n_revisions = 0; whs_out.record_pointer_list = NULL; @@ -2840,9 +2802,7 @@ test_page_aligned_history_create(void) HDfree(buf); buf = NULL; - /* - * CLEANUP - */ + /* CLEANUP */ if (H5Pclose(fapl_id) < 0) TEST_ERROR @@ -2894,6 +2854,11 @@ test_integration_create(void) { const char * basename = "integration_2d.h5"; hid_t fapl_id = H5I_INVALID_HID; + hid_t file_id = H5I_INVALID_HID; + hid_t file = H5I_INVALID_HID; + hid_t space = H5I_INVALID_HID; + hid_t dset = H5I_INVALID_HID; + hid_t dcpl = H5I_INVALID_HID; struct onion_filepaths *paths = NULL; H5FD_onion_fapl_info_t onion_info = { H5FD_ONION_FAPL_INFO_VERSION_CURR, @@ -2905,12 +2870,31 @@ test_integration_create(void) 0, /* creation flags, was H5FD_ONION_FAPL_INFO_CREATE_FLAG_ENABLE_PAGE_ALIGNMENT */ "initial commit" /* comment */ }; - hid_t file_id = H5I_INVALID_HID; + hsize_t dims[2] = {128, 256}; + hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; + hsize_t chunk[2] = {4, 4}; + int fillval; + struct { + int arr[128][256]; + } *wdata = NULL; + struct { + int arr[128][256]; + } *rdata = NULL; + struct { + int arr[128][256]; + } *dset_data = NULL; TESTING("onion-created two dimensional HDF5 file with revisions"); /* SETUP */ + if (NULL == (wdata = HDcalloc(1, sizeof(*wdata)))) + TEST_ERROR + if (NULL == (rdata = HDcalloc(1, sizeof(*rdata)))) + TEST_ERROR + if (NULL == (dset_data = HDcalloc(1, sizeof(*dset_data)))) + TEST_ERROR + onion_info.backing_fapl_id = h5_fileaccess(); if ((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR @@ -2928,23 +2912,19 @@ test_integration_create(void) * Create the skeleton file (create the file without Onion VFD) *---------------------------------------------------------------------- */ - hid_t file, space, dset, dcpl; /* Handles */ - hsize_t dims[2] = {128, 256}; - hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; - hsize_t chunk[2] = {4, 4}; - int wdata[128][256]; /* Write buffer */ - int fillval, i, j; /* Initialize data */ - for (i = 0; i < 128; i++) - for (j = 0; j < 256; j++) - wdata[i][j] = i * j - j; + for (int i = 0; i < 128; i++) + for (int j = 0; j < 256; j++) + wdata->arr[i][j] = i * j - j; /* Create a new file using the default properties */ - file = H5Fcreate(paths->canon, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + if ((file = H5Fcreate(paths->canon, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Create dataspace with unlimited dimensions */ - space = H5Screate_simple(2, dims, maxdims); + if ((space = H5Screate_simple(2, dims, maxdims)) < 0) + TEST_ERROR /* Create the dataset creation property list, and set the chunk * size @@ -2971,7 +2951,7 @@ test_integration_create(void) TEST_ERROR /* Write the data to the dataset */ - if (H5Dwrite(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata[0]) < 0) + if (H5Dwrite(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata) < 0) TEST_ERROR /* Close and release resources */ @@ -2991,19 +2971,12 @@ test_integration_create(void) if ((file_id = H5Fopen(paths->canon, H5F_ACC_RDWR, fapl_id)) < 0) TEST_ERROR - if (H5I_INVALID_HID == file_id) { - TEST_ERROR - } - - dset = H5Dopen(file_id, "DS1", H5P_DEFAULT); - if (dset < 0) { + if ((dset = H5Dopen(file_id, "DS1", H5P_DEFAULT)) < 0) TEST_ERROR - } - int dset_data[128][256]; - for (i = 0; i < 128; i++) - for (j = 0; j < 256; j++) - dset_data[i][j] = i * 6 + j + 1; + for (int i = 0; i < 128; i++) + for (int j = 0; j < 256; j++) + dset_data->arr[i][j] = i * 6 + j + 1; if (H5Dwrite(dset, H5T_STD_I32LE, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset_data) < 0) TEST_ERROR @@ -3025,9 +2998,9 @@ test_integration_create(void) if ((dset = H5Dopen(file_id, "DS1", H5P_DEFAULT)) < 0) TEST_ERROR - for (i = 0; i < 128; i++) - for (j = 0; j < 256; j++) - dset_data[i][j] = i * 3 + j + 5; + for (int i = 0; i < 128; i++) + for (int j = 0; j < 256; j++) + dset_data->arr[i][j] = i * 3 + j + 5; if (H5Dwrite(dset, H5T_STD_I32LE, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset_data) < 0) TEST_ERROR @@ -3052,32 +3025,26 @@ test_integration_create(void) *---------------------------------------------------------------------- */ onion_info.revision_num = 0; - fapl_id = H5Pcreate(H5P_FILE_ACCESS); - if (H5I_INVALID_HID == fapl_id) + + if ((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR if (H5Pset_fapl_onion(fapl_id, &onion_info) < 0) TEST_ERROR - file_id = H5Fopen(paths->canon, H5F_ACC_RDONLY, fapl_id); - - if (H5I_INVALID_HID == file_id) { + if ((file_id = H5Fopen(paths->canon, H5F_ACC_RDONLY, fapl_id)) < 0) TEST_ERROR - } - dset = H5Dopen(file_id, "DS1", H5P_DEFAULT); - if (dset < 0) { + if ((dset = H5Dopen(file_id, "DS1", H5P_DEFAULT)) < 0) TEST_ERROR - } - int rdata[128][256]; - if (H5Dread(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata[0]) < 0) + if (H5Dread(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata) < 0) TEST_ERROR - for (i = 0; i < 128; i++) { - for (j = 0; j < 256; j++) { + for (int i = 0; i < 128; i++) { + for (int j = 0; j < 256; j++) { int expected = i * j - j; - if (rdata[i][j] != expected) { - printf("ERROR!!! Expected: %d, Got: %d\n", expected, rdata[i][j]); + if (rdata->arr[i][j] != expected) { + HDprintf("ERROR!!! Expected: %d, Got: %d\n", expected, rdata->arr[i][j]); HDfflush(stdout); TEST_ERROR } @@ -3108,14 +3075,14 @@ test_integration_create(void) TEST_ERROR if ((dset = H5Dopen(file_id, "DS1", H5P_DEFAULT)) < 0) TEST_ERROR - if (H5Dread(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata[0]) < 0) + if (H5Dread(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata) < 0) TEST_ERROR - for (i = 0; i < 128; i++) { - for (j = 0; j < 256; j++) { + for (int i = 0; i < 128; i++) { + for (int j = 0; j < 256; j++) { int expected = i * 6 + j + 1; - if (rdata[i][j] != expected) { - printf("ERROR!!! Expected: %d, Got: %d\n", expected, rdata[i][j]); + if (rdata->arr[i][j] != expected) { + HDprintf("ERROR!!! Expected: %d, Got: %d\n", expected, rdata->arr[i][j]); HDfflush(stdout); TEST_ERROR } @@ -3147,14 +3114,14 @@ test_integration_create(void) TEST_ERROR if ((dset = H5Dopen(file_id, "DS1", H5P_DEFAULT)) < 0) TEST_ERROR - if (H5Dread(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata[0]) < 0) + if (H5Dread(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata) < 0) TEST_ERROR - for (i = 0; i < 128; i++) { - for (j = 0; j < 256; j++) { + for (int i = 0; i < 128; i++) { + for (int j = 0; j < 256; j++) { int expected = i * 3 + j + 5; - if (rdata[i][j] != expected) { - printf("ERROR!!! Expected: %d, Got: %d\n", expected, rdata[i][j]); + if (rdata->arr[i][j] != expected) { + HDprintf("ERROR!!! Expected: %d, Got: %d\n", expected, rdata->arr[i][j]); HDfflush(stdout); TEST_ERROR } @@ -3176,6 +3143,10 @@ test_integration_create(void) HDremove(paths->recovery); onion_filepaths_destroy(paths); + HDfree(wdata); + HDfree(rdata); + HDfree(dset_data); + PASSED(); return 0; @@ -3196,6 +3167,10 @@ error: } H5E_END_TRY; + HDfree(wdata); + HDfree(rdata); + HDfree(dset_data); + return -1; } /* end test_integration_create() */ @@ -3215,20 +3190,41 @@ test_integration_create_simple(void) 0, /* creation flags, was H5FD_ONION_FAPL_INFO_CREATE_FLAG_ENABLE_PAGE_ALIGNMENT */ "initial commit" /* comment */ }; - hid_t file_id = H5I_INVALID_HID; + hid_t file_id = H5I_INVALID_HID; + hid_t file = H5I_INVALID_HID; + hid_t space = H5I_INVALID_HID; + hid_t dset = H5I_INVALID_HID; + hid_t dcpl = H5I_INVALID_HID; + hsize_t dims[2] = {1, ONE_DIM_SIZE}; + hsize_t maxdims[2] = {1, ONE_DIM_SIZE}; + int fillval; + struct { + int arr[ONE_DIM_SIZE]; + } *wdata = NULL; + struct { + int arr[ONE_DIM_SIZE]; + } *rdata = NULL; + struct { + int arr[ONE_DIM_SIZE]; + } *dset_data = NULL; TESTING("onion-created one-dimensional HDF5 file with revisions"); /* Setup */ + if (NULL == (wdata = HDcalloc(1, sizeof(*wdata)))) + TEST_ERROR + if (NULL == (rdata = HDcalloc(1, sizeof(*rdata)))) + TEST_ERROR + if (NULL == (dset_data = HDcalloc(1, sizeof(*dset_data)))) + TEST_ERROR + onion_info.backing_fapl_id = h5_fileaccess(); - fapl_id = H5Pcreate(H5P_FILE_ACCESS); - if (H5I_INVALID_HID == fapl_id) + if ((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR if (H5Pset_fapl_onion(fapl_id, &onion_info) < 0) TEST_ERROR - paths = onion_filepaths_init(basename, &onion_info); - if (NULL == paths) + if (NULL == (paths = onion_filepaths_init(basename, &onion_info))) TEST_ERROR HDremove(paths->canon); @@ -3239,18 +3235,9 @@ test_integration_create_simple(void) * Create the skeleton file (create the file without Onion VFD) *---------------------------------------------------------------------- */ - hid_t file = H5I_INVALID_HID; - hid_t space = H5I_INVALID_HID; - hid_t dset = H5I_INVALID_HID; - hid_t dcpl = H5I_INVALID_HID; - hsize_t dims[2] = {1, ONE_DIM_SIZE}; - hsize_t maxdims[2] = {1, ONE_DIM_SIZE}; - int wdata[1][ONE_DIM_SIZE]; /* Write buffer */ - int fillval; - /* Initialize data */ for (int i = 0; i < ONE_DIM_SIZE; i++) - wdata[0][i] = i; + wdata->arr[i] = i; /* Create a new file using the default properties */ if ((file = H5Fcreate(paths->canon, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) @@ -3281,7 +3268,7 @@ test_integration_create_simple(void) TEST_ERROR /* Write the data to the dataset */ - if (H5Dwrite(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata[0]) < 0) + if (H5Dwrite(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata) < 0) TEST_ERROR /* Close everything */ @@ -3304,9 +3291,8 @@ test_integration_create_simple(void) if ((dset = H5Dopen(file_id, "DS1", H5P_DEFAULT)) < 0) TEST_ERROR - int dset_data[1][ONE_DIM_SIZE]; for (int i = 0; i < ONE_DIM_SIZE; i++) - dset_data[0][i] = i + ONE_DIM_SIZE; + dset_data->arr[i] = i + ONE_DIM_SIZE; if (H5Dwrite(dset, H5T_STD_I32LE, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset_data) < 0) TEST_ERROR @@ -3328,7 +3314,7 @@ test_integration_create_simple(void) TEST_ERROR for (int i = 0; i < ONE_DIM_SIZE; i++) - dset_data[0][i] = i + 2048; + dset_data->arr[i] = i + 2048; if (H5Dwrite(dset, H5T_STD_I32LE, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset_data) < 0) TEST_ERROR @@ -3351,7 +3337,7 @@ test_integration_create_simple(void) TEST_ERROR for (int i = 0; i < ONE_DIM_SIZE; i += 20) - dset_data[0][i] = i + 3072; + dset_data->arr[i] = i + 3072; if (H5Dwrite(dset, H5T_STD_I32LE, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset_data) < 0) TEST_ERROR @@ -3387,17 +3373,14 @@ test_integration_create_simple(void) if ((dset = H5Dopen(file_id, "DS1", H5P_DEFAULT)) < 0) TEST_ERROR - int rdata[1][ONE_DIM_SIZE]; - if (H5Dread(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata[0]) < 0) + if (H5Dread(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata) < 0) TEST_ERROR - for (int i = 0; i < 1; i++) { - for (int j = 0; j < ONE_DIM_SIZE; j += 20) { - int expected = j + 2048; - if (rdata[i][j] != expected) { - printf("ERROR!!! Expected: %d, Got: %d\n", expected, rdata[i][j]); - TEST_ERROR - } + for (int i = 0; i < ONE_DIM_SIZE; i += 20) { + int expected = i + 2048; + if (rdata->arr[i] != expected) { + HDprintf("ERROR!!! Expected: %d, Got: %d\n", expected, rdata->arr[i]); + TEST_ERROR } } @@ -3414,6 +3397,10 @@ test_integration_create_simple(void) HDremove(paths->recovery); onion_filepaths_destroy(paths); + HDfree(wdata); + HDfree(rdata); + HDfree(dset_data); + PASSED(); return 0; @@ -3434,6 +3421,10 @@ error: } H5E_END_TRY; + HDfree(wdata); + HDfree(rdata); + HDfree(dset_data); + return -1; } /* end test_integration_create_simple() */ @@ -3493,42 +3484,35 @@ test_integration_create_delete_objects(void) if ((file = H5Fcreate(paths->canon, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - /* - * Create dataspace with unlimited dimensions. - */ - space = H5Screate_simple(2, dims, maxdims); + /* Create dataspace with unlimited dimensions */ + if ((space = H5Screate_simple(2, dims, maxdims)) < 0) + TEST_ERROR - /* - * Create the dataset creation property list, and set the chunk - * size. + /* Create the dataset creation property list, and set the chunk + * size */ - dcpl = H5Pcreate(H5P_DATASET_CREATE); + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + TEST_ERROR if (H5Pset_chunk(dcpl, 2, chunk) < 0) TEST_ERROR - /* - * Set the fill value for the dataset. - */ + /* Set the fill value for the dataset */ fillval = 99; if (H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval) < 0) TEST_ERROR - /* - * Set the allocation time to "early". This way we can be sure + /* Set the allocation time to "early". This way we can be sure * that reading from the dataset immediately after creation will * return the fill value. */ if (H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY) < 0) TEST_ERROR - /* - * Create the dataset using the dataset creation property list. - */ - dset = H5Dcreate(file, "DS1", H5T_STD_I32LE, space, H5P_DEFAULT, dcpl, H5P_DEFAULT); + /* Create the dataset using the dataset creation property list */ + if ((dset = H5Dcreate(file, "DS1", H5T_STD_I32LE, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + TEST_ERROR - /* - * Write the data to the dataset. - */ + /* Write the data to the dataset */ if (H5Dwrite(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata) < 0) TEST_ERROR @@ -3541,19 +3525,14 @@ test_integration_create_delete_objects(void) * First revision: open the file with Onion VFD and add a dataset (DS2) to the file *---------------------------------------------------------------------- */ - file = H5Fopen(paths->canon, H5F_ACC_RDWR, fapl_id); - if (H5I_INVALID_HID == file) { + if ((file = H5Fopen(paths->canon, H5F_ACC_RDWR, fapl_id)) < 0) TEST_ERROR - } - /* - * Create the dataset using the dataset creation property list. - */ - dset = H5Dcreate(file, "DS2", H5T_STD_I32LE, space, H5P_DEFAULT, dcpl, H5P_DEFAULT); + /* Create the dataset using the dataset creation property list */ + if ((dset = H5Dcreate(file, "DS2", H5T_STD_I32LE, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + TEST_ERROR - /* - * Write the data to the dataset. - */ + /* Write the data to the dataset */ if (H5Dwrite(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata) < 0) TEST_ERROR @@ -3569,10 +3548,8 @@ test_integration_create_delete_objects(void) * which was added during the first revision. *---------------------------------------------------------------------- */ - file = H5Fopen(paths->canon, H5F_ACC_RDWR, fapl_id); - if (H5I_INVALID_HID == file) { + if ((file = H5Fopen(paths->canon, H5F_ACC_RDWR, fapl_id)) < 0) TEST_ERROR - } if (H5Ldelete(file, "DS2", H5P_DEFAULT) < 0) TEST_ERROR @@ -3585,13 +3562,12 @@ test_integration_create_delete_objects(void) * Third revision: open the file with Onion VFD and add an attribute to the file *---------------------------------------------------------------------- */ - file = H5Fopen(paths->canon, H5F_ACC_RDWR, fapl_id); - if (H5I_INVALID_HID == file) { + if ((file = H5Fopen(paths->canon, H5F_ACC_RDWR, fapl_id)) < 0) TEST_ERROR - } /* Create dataspace for attribute */ - attr_space_id = H5Screate_simple(1, attr_dim, NULL); + if ((attr_space_id = H5Screate_simple(1, attr_dim, NULL)) < 0) + TEST_ERROR if ((attr_id = H5Acreate(file, "file_attribute", H5T_STD_I32LE, attr_space_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) @@ -3609,10 +3585,8 @@ test_integration_create_delete_objects(void) * Fourth revision: open the file with Onion VFD and delete the attribute *---------------------------------------------------------------------- */ - file = H5Fopen(paths->canon, H5F_ACC_RDWR, fapl_id); - if (H5I_INVALID_HID == file) { + if ((file = H5Fopen(paths->canon, H5F_ACC_RDWR, fapl_id)) < 0) TEST_ERROR - } if (H5Adelete(file, "file_attribute") < 0) TEST_ERROR @@ -3625,10 +3599,8 @@ test_integration_create_delete_objects(void) * Fifth revision: open the file with Onion VFD and add a group to the file *---------------------------------------------------------------------- */ - file = H5Fopen(paths->canon, H5F_ACC_RDWR, fapl_id); - if (H5I_INVALID_HID == file) { + if ((file = H5Fopen(paths->canon, H5F_ACC_RDWR, fapl_id)) < 0) TEST_ERROR - } if ((group_id = H5Gcreate2(file, "new_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -3643,10 +3615,8 @@ test_integration_create_delete_objects(void) * Sixth revision: open the file with Onion VFD and delete the newly added group *---------------------------------------------------------------------- */ - file = H5Fopen(paths->canon, H5F_ACC_RDWR, fapl_id); - if (H5I_INVALID_HID == file) { + if ((file = H5Fopen(paths->canon, H5F_ACC_RDWR, fapl_id)) < 0) TEST_ERROR - } if (H5Ldelete(file, "new_group", H5P_DEFAULT) < 0) TEST_ERROR @@ -3667,11 +3637,8 @@ test_integration_create_delete_objects(void) if (H5Pset_fapl_onion(fapl_id, &onion_info) < 0) TEST_ERROR - - file = H5Fopen(paths->canon, H5F_ACC_RDWR, fapl_id); - if (H5I_INVALID_HID == file) { + if ((file = H5Fopen(paths->canon, H5F_ACC_RDWR, fapl_id)) < 0) TEST_ERROR - } /* The second dataset (DS2) should exist */ if (H5Lexists(file, "DS2", H5P_DEFAULT) <= 0) @@ -3689,11 +3656,8 @@ test_integration_create_delete_objects(void) if (H5Pset_fapl_onion(fapl_id, &onion_info) < 0) TEST_ERROR - - file = H5Fopen(paths->canon, H5F_ACC_RDWR, fapl_id); - if (H5I_INVALID_HID == file) { + if ((file = H5Fopen(paths->canon, H5F_ACC_RDWR, fapl_id)) < 0) TEST_ERROR - } /* The second dataset (DS2) shouldn't exist */ if (H5Lexists(file, "DS2", H5P_DEFAULT) > 0) @@ -3711,11 +3675,8 @@ test_integration_create_delete_objects(void) if (H5Pset_fapl_onion(fapl_id, &onion_info) < 0) TEST_ERROR - - file = H5Fopen(paths->canon, H5F_ACC_RDWR, fapl_id); - if (H5I_INVALID_HID == file) { + if ((file = H5Fopen(paths->canon, H5F_ACC_RDWR, fapl_id)) < 0) TEST_ERROR - } /* The file attribute should exist */ if (H5Aexists(file, "file_attribute") <= 0) @@ -3733,11 +3694,8 @@ test_integration_create_delete_objects(void) if (H5Pset_fapl_onion(fapl_id, &onion_info) < 0) TEST_ERROR - - file = H5Fopen(paths->canon, H5F_ACC_RDWR, fapl_id); - if (H5I_INVALID_HID == file) { + if ((file = H5Fopen(paths->canon, H5F_ACC_RDWR, fapl_id)) < 0) TEST_ERROR - } /* The file attribute should be removed */ if (H5Aexists(file, "file_attribute") > 0) @@ -3755,11 +3713,8 @@ test_integration_create_delete_objects(void) if (H5Pset_fapl_onion(fapl_id, &onion_info) < 0) TEST_ERROR - - file = H5Fopen(paths->canon, H5F_ACC_RDWR, fapl_id); - if (H5I_INVALID_HID == file) { + if ((file = H5Fopen(paths->canon, H5F_ACC_RDWR, fapl_id)) < 0) TEST_ERROR - } /* The new group should exist */ if (H5Lexists(file, "new_group", H5P_DEFAULT) <= 0) @@ -3777,11 +3732,8 @@ test_integration_create_delete_objects(void) if (H5Pset_fapl_onion(fapl_id, &onion_info) < 0) TEST_ERROR - - file = H5Fopen(paths->canon, H5F_ACC_RDWR, fapl_id); - if (H5I_INVALID_HID == file) { + if ((file = H5Fopen(paths->canon, H5F_ACC_RDWR, fapl_id)) < 0) TEST_ERROR - } /* The new group should exist */ if (H5Lexists(file, "new_group", H5P_DEFAULT) > 0) @@ -3996,7 +3948,6 @@ test_integration_dset_extension(void) if (H5Pset_fapl_onion(fapl_id, &onion_info) < 0) TEST_ERROR - if ((file = H5Fopen(paths->canon, H5F_ACC_RDWR, fapl_id)) < 0) TEST_ERROR @@ -4036,7 +3987,6 @@ test_integration_dset_extension(void) if (H5Pset_fapl_onion(fapl_id, &onion_info) < 0) TEST_ERROR - if ((file = H5Fopen(paths->canon, H5F_ACC_RDWR, fapl_id)) < 0) TEST_ERROR @@ -4336,10 +4286,6 @@ main(void) nerrors -= test_integration_dset_extension(); nerrors -= test_integration_ctl(); -#if H5FD_ONION_ENABLE_INDEX_STATS - nerrors -= test_working_index_stats(); /* TODO */ -#endif - if (nerrors > 0) { HDprintf("***** %d Onion TEST%s FAILED! *****\n", nerrors, nerrors > 1 ? "S" : ""); return EXIT_FAILURE; diff --git a/test/tcoords.c b/test/tcoords.c index b2d68d3..37c1c1a 100644 --- a/test/tcoords.c +++ b/test/tcoords.c @@ -380,10 +380,14 @@ test_multiple_ends(hid_t file, hbool_t is_chunked) int i, j, k, l, m, n, p; hsize_t da_dims[8] = {4, 5, 3, 4, 2, 3, 6, 2}; hsize_t da_chunksize[8] = {1, 5, 3, 2, 2, 3, 3, 2}; - int data_buf[4][5][3][4][2][3][6][2]; + struct { + int arr[4][5][3][4][2][3][6][2]; + } *data_buf = NULL; /* For testing the full selections in the fastest-growing end and in the middle dimensions */ - int mem1_buffer[1][1][1][4][2][1][6][2]; + struct { + int arr[1][1][1][4][2][1][6][2]; + } *mem1_buffer = NULL; hsize_t mem1_dims[8] = {1, 1, 1, 4, 2, 1, 6, 2}; hsize_t mem1_start[8] = {0, 0, 0, 0, 0, 0, 0, 0}; hsize_t mem1_count[8] = {1, 1, 1, 1, 1, 1, 1, 1}; @@ -391,7 +395,9 @@ test_multiple_ends(hid_t file, hbool_t is_chunked) hsize_t mem1_block[8] = {1, 1, 1, 4, 2, 1, 6, 2}; /* For testing the full selections in the slowest-growing end and in the middle dimensions */ - int mem2_buffer[4][5][1][4][2][1][1][1]; + struct { + int arr[4][5][1][4][2][1][1][1]; + } *mem2_buffer = NULL; hsize_t mem2_dims[8] = {4, 5, 1, 4, 2, 1, 1, 1}; hsize_t mem2_start[8] = {0, 0, 0, 0, 0, 0, 0, 0}; hsize_t mem2_count[8] = {1, 1, 1, 1, 1, 1, 1, 1}; @@ -399,7 +405,9 @@ test_multiple_ends(hid_t file, hbool_t is_chunked) hsize_t mem2_block[8] = {4, 5, 1, 4, 2, 1, 1, 1}; /* For testing two unadjacent full selections in the middle dimensions */ - int mem3_buffer[1][5][3][1][1][3][6][1]; + struct { + int arr[1][5][3][1][1][3][6][1]; + } *mem3_buffer = NULL; hsize_t mem3_dims[8] = {1, 5, 3, 1, 1, 3, 6, 1}; hsize_t mem3_start[8] = {0, 0, 0, 0, 0, 0, 0, 0}; hsize_t mem3_count[8] = {1, 1, 1, 1, 1, 1, 1, 1}; @@ -407,7 +415,9 @@ test_multiple_ends(hid_t file, hbool_t is_chunked) hsize_t mem3_block[8] = {1, 5, 3, 1, 1, 3, 6, 1}; /* For testing the full selections in the fastest-growing end and the slowest-growing end */ - int mem4_buffer[4][5][1][1][1][1][6][2]; + struct { + int arr[4][5][1][1][1][1][6][2]; + } *mem4_buffer = NULL; hsize_t mem4_dims[8] = {4, 5, 1, 1, 1, 1, 6, 2}; hsize_t mem4_start[8] = {0, 0, 0, 0, 0, 0, 0, 0}; hsize_t mem4_count[8] = {1, 1, 1, 1, 1, 1, 1, 1}; @@ -416,13 +426,29 @@ test_multiple_ends(hid_t file, hbool_t is_chunked) /* For testing the full selections in the fastest-growing end and slowest-growing end, * also in the middle dimensions */ - int mem5_buffer[4][5][1][4][2][1][6][2]; + struct { + int arr[4][5][1][4][2][1][6][2]; + } *mem5_buffer = NULL; hsize_t mem5_dims[8] = {4, 5, 1, 4, 2, 1, 6, 2}; hsize_t mem5_start[8] = {0, 0, 0, 0, 0, 0, 0, 0}; hsize_t mem5_count[8] = {1, 1, 1, 1, 1, 1, 1, 1}; hsize_t mem5_stride[8] = {1, 1, 1, 1, 1, 1, 1, 1}; hsize_t mem5_block[8] = {4, 5, 1, 4, 2, 1, 6, 2}; + /* Initialize dynamic arrays */ + data_buf = HDcalloc(1, sizeof(*data_buf)); + CHECK_PTR(data_buf, "HDcalloc"); + mem1_buffer = HDcalloc(1, sizeof(*mem1_buffer)); + CHECK_PTR(data_buf, "HDcalloc"); + mem2_buffer = HDcalloc(1, sizeof(*mem2_buffer)); + CHECK_PTR(data_buf, "HDcalloc"); + mem3_buffer = HDcalloc(1, sizeof(*mem3_buffer)); + CHECK_PTR(data_buf, "HDcalloc"); + mem4_buffer = HDcalloc(1, sizeof(*mem4_buffer)); + CHECK_PTR(data_buf, "HDcalloc"); + mem5_buffer = HDcalloc(1, sizeof(*mem5_buffer)); + CHECK_PTR(data_buf, "HDcalloc"); + /* Create and write the dataset */ sid = H5Screate_simple(8, da_dims, da_dims); CHECK(sid, FAIL, "H5Screate_simple"); @@ -451,10 +477,10 @@ test_multiple_ends(hid_t file, hbool_t is_chunked) for (m = 0; m < 2; m++) for (n = 0; n < 3; n++) for (p = 0; p < 6; p++) { - data_buf[i][j][k][l][m][n][p][0] = + data_buf->arr[i][j][k][l][m][n][p][0] = i * 1000000 + j * 100000 + k * 10000 + l * 1000 + m * 100 + n * 10 + p; - data_buf[i][j][k][l][m][n][p][1] = i * 1000000 + j * 100000 + k * 10000 + - l * 1000 + m * 100 + n * 10 + p + 1; + data_buf->arr[i][j][k][l][m][n][p][1] = i * 1000000 + j * 100000 + k * 10000 + + l * 1000 + m * 100 + n * 10 + p + 1; } ret = H5Dwrite(did, H5T_NATIVE_INT, sid, sid, H5P_DEFAULT, data_buf); @@ -491,7 +517,7 @@ test_multiple_ends(hid_t file, hbool_t is_chunked) for (j = 0; j < 2; j++) for (k = 0; k < 6; k++) for (l = 0; l < 2; l++) - if (data_buf[0][0][0][i][j][0][k][l] != mem1_buffer[0][0][0][i][j][0][k][l]) { + if (data_buf->arr[0][0][0][i][j][0][k][l] != mem1_buffer->arr[0][0][0][i][j][0][k][l]) { TestErrPrintf("%u: Read different values than written at index 0,0,0,%d,%d,0,%d,%d\n", __LINE__, i, j, k, l); } @@ -524,7 +550,7 @@ test_multiple_ends(hid_t file, hbool_t is_chunked) for (j = 0; j < 5; j++) for (k = 0; k < 4; k++) for (l = 0; l < 2; l++) - if (data_buf[i][j][0][k][l][0][0][0] != mem2_buffer[i][j][0][k][l][0][0][0]) { + if (data_buf->arr[i][j][0][k][l][0][0][0] != mem2_buffer->arr[i][j][0][k][l][0][0][0]) { TestErrPrintf("%u: Read different values than written at index %d,%d,0,%d,%d,0,0,0\n", __LINE__, i, j, k, l); } @@ -557,7 +583,7 @@ test_multiple_ends(hid_t file, hbool_t is_chunked) for (j = 0; j < 3; j++) for (k = 0; k < 3; k++) for (l = 0; l < 6; l++) - if (data_buf[0][i][j][0][0][k][l][0] != mem3_buffer[0][i][j][0][0][k][l][0]) { + if (data_buf->arr[0][i][j][0][0][k][l][0] != mem3_buffer->arr[0][i][j][0][0][k][l][0]) { TestErrPrintf("%u: Read different values than written at index 0,%d,%d,0,0,%d,%d,0\n", __LINE__, i, j, k, l); } @@ -590,7 +616,7 @@ test_multiple_ends(hid_t file, hbool_t is_chunked) for (j = 0; j < 5; j++) for (k = 0; k < 6; k++) for (l = 0; l < 2; l++) - if (data_buf[i][j][0][0][0][0][k][l] != mem4_buffer[i][j][0][0][0][0][k][l]) { + if (data_buf->arr[i][j][0][0][0][0][k][l] != mem4_buffer->arr[i][j][0][0][0][0][k][l]) { TestErrPrintf("%u: Read different values than written at index %d,%d,0,0,0,0,%d,%d\n", __LINE__, i, j, k, l); } @@ -626,7 +652,8 @@ test_multiple_ends(hid_t file, hbool_t is_chunked) for (l = 0; l < 2; l++) for (m = 0; m < 6; m++) for (n = 0; n < 2; n++) - if (data_buf[i][j][0][k][l][0][m][n] != mem5_buffer[i][j][0][k][l][0][m][n]) { + if (data_buf->arr[i][j][0][k][l][0][m][n] != + mem5_buffer->arr[i][j][0][k][l][0][m][n]) { TestErrPrintf( "%u: Read different values than written at index %d,%d,0,%d,%d,0,%d,%d\n", __LINE__, i, j, k, l, m, n); @@ -637,6 +664,13 @@ test_multiple_ends(hid_t file, hbool_t is_chunked) ret = H5Pclose(plid); CHECK(ret, FAIL, "H5Pclose"); + + HDfree(data_buf); + HDfree(mem1_buffer); + HDfree(mem2_buffer); + HDfree(mem3_buffer); + HDfree(mem4_buffer); + HDfree(mem5_buffer); } /**************************************************************** diff --git a/test/vfd.c b/test/vfd.c index 1b83228..b1b176a 100644 --- a/test/vfd.c +++ b/test/vfd.c @@ -4053,10 +4053,11 @@ error: static hbool_t test_vector_io__setup_v(uint32_t count, H5FD_mem_t types[], haddr_t addrs[], size_t sizes[], - void *write_bufs[], void *read_bufs[], char base_fill_char) + const void *write_bufs[], void *read_bufs[], char base_fill_char) { hbool_t result = TRUE; /* will set to FALSE on failure */ char fill_char = base_fill_char; + void * temp_buf = NULL; uint32_t i; uint32_t j; H5FD_mem_t mem_types[6] = {H5FD_MEM_SUPER, H5FD_MEM_BTREE, H5FD_MEM_DRAW, @@ -4072,17 +4073,16 @@ test_vector_io__setup_v(uint32_t count, H5FD_mem_t types[], haddr_t addrs[], siz } for (i = 0; i < count; i++) { - types[i] = mem_types[i % 6]; addrs[i] = HADDR_UNDEF; sizes[i] = (size_t)((rand() & 1023) + 1); - write_bufs[i] = HDmalloc(sizes[i] + 1); - read_bufs[i] = HDmalloc(sizes[i] + 1); + temp_buf = HDmalloc(sizes[i] + 1); + read_bufs[i] = HDmalloc(sizes[i] + 1); - if ((NULL == write_bufs[i]) || (NULL == read_bufs[i])) { + if ((NULL == temp_buf) || (NULL == read_bufs[i])) { HDfprintf(stderr, "%s: can't malloc read / write bufs.\n", __func__); result = FALSE; @@ -4091,23 +4091,28 @@ test_vector_io__setup_v(uint32_t count, H5FD_mem_t types[], haddr_t addrs[], siz for (j = 0; j < sizes[i]; j++) { - ((char *)(write_bufs[i]))[j] = fill_char; - ((char *)(read_bufs[i]))[j] = '\0'; + ((char *)temp_buf)[j] = fill_char; + ((char *)(read_bufs[i]))[j] = '\0'; } - ((char *)(write_bufs[i]))[sizes[i]] = '\0'; - ((char *)(read_bufs[i]))[sizes[i]] = '\0'; + ((char *)temp_buf)[sizes[i]] = '\0'; + ((char *)(read_bufs[i]))[sizes[i]] = '\0'; + + write_bufs[i] = (const void *)temp_buf; + temp_buf = NULL; fill_char++; } if (!result) { /* free buffers */ + HDfree(temp_buf); + for (i = 0; i < count; i++) { if (write_bufs[i]) { - HDfree(write_bufs[i]); + HDfree((void *)write_bufs[i]); write_bufs[i] = NULL; } @@ -4154,10 +4159,11 @@ test_vector_io__setup_v(uint32_t count, H5FD_mem_t types[], haddr_t addrs[], siz static hbool_t test_vector_io__setup_fixed_size_v(uint32_t count, H5FD_mem_t types[], haddr_t addrs[], size_t sizes[], - void *write_bufs[], void *read_bufs[], char base_fill_char) + const void *write_bufs[], void *read_bufs[], char base_fill_char) { hbool_t result = TRUE; /* will set to FALSE on failure */ char fill_char = base_fill_char; + void * temp_buf = NULL; uint32_t fix_point; uint32_t i; uint32_t j; @@ -4197,8 +4203,8 @@ test_vector_io__setup_fixed_size_v(uint32_t count, H5FD_mem_t types[], haddr_t a sizes[i] = (size_t)((rand() & 1023) + 1); - write_bufs[i] = HDmalloc(sizes[i] + 1); - read_bufs[i] = HDmalloc(sizes[i] + 1); + temp_buf = HDmalloc(sizes[i] + 1); + read_bufs[i] = HDmalloc(sizes[i] + 1); } else { @@ -4213,11 +4219,11 @@ test_vector_io__setup_fixed_size_v(uint32_t count, H5FD_mem_t types[], haddr_t a addrs[i] = HADDR_UNDEF; - write_bufs[i] = HDmalloc(sizes[fix_point] + 1); - read_bufs[i] = HDmalloc(sizes[fix_point] + 1); + temp_buf = HDmalloc(sizes[fix_point] + 1); + read_bufs[i] = HDmalloc(sizes[fix_point] + 1); } - if ((NULL == write_bufs[i]) || (NULL == read_bufs[i])) { + if ((NULL == temp_buf) || (NULL == read_bufs[i])) { HDfprintf(stderr, "%s: can't malloc read / write bufs.\n", __func__); result = FALSE; @@ -4229,23 +4235,28 @@ test_vector_io__setup_fixed_size_v(uint32_t count, H5FD_mem_t types[], haddr_t a for (j = 0; j < sizes[k]; j++) { - ((char *)(write_bufs[i]))[j] = fill_char; - ((char *)(read_bufs[i]))[j] = '\0'; + ((char *)temp_buf)[j] = fill_char; + ((char *)(read_bufs[i]))[j] = '\0'; } - ((char *)(write_bufs[i]))[sizes[k]] = '\0'; - ((char *)(read_bufs[i]))[sizes[k]] = '\0'; + ((char *)temp_buf)[sizes[k]] = '\0'; + ((char *)(read_bufs[i]))[sizes[k]] = '\0'; + + write_bufs[i] = (const void *)temp_buf; + temp_buf = NULL; fill_char++; } if (!result) { /* free buffers */ + HDfree(temp_buf); + for (i = 0; i < count; i++) { if (write_bufs[i]) { - HDfree(write_bufs[i]); + HDfree((void *)write_bufs[i]); write_bufs[i] = NULL; } @@ -4340,7 +4351,7 @@ test_vector_io__read_v_indiv(H5FD_t *lf, uint32_t count, H5FD_mem_t types[], had static hbool_t test_vector_io__write_v_indiv(H5FD_t *lf, uint32_t count, H5FD_mem_t types[], haddr_t addrs[], size_t sizes[], - void *write_bufs[]) + const void *write_bufs[]) { hbool_t size_fixed = FALSE; hbool_t type_fixed = FALSE; @@ -4390,7 +4401,7 @@ test_vector_io__write_v_indiv(H5FD_t *lf, uint32_t count, H5FD_mem_t types[], ha */ static hbool_t -test_vector_io__verify_v(uint32_t count, H5FD_mem_t types[], size_t sizes[], void *write_bufs[], +test_vector_io__verify_v(uint32_t count, H5FD_mem_t types[], size_t sizes[], const void *write_bufs[], void *read_bufs[], const char *name) { hbool_t size_fixed = FALSE; @@ -4399,7 +4410,7 @@ test_vector_io__verify_v(uint32_t count, H5FD_mem_t types[], size_t sizes[], voi hbool_t verbose = TRUE; uint32_t i; size_t j; - char * w_buf; + const char *w_buf; char * r_buf; const char *mem_type_names[7] = {"H5FD_MEM_DEFAULT", "H5FD_MEM_SUPER", "H5FD_MEM_BTREE", "H5FD_MEM_DRAW", "H5FD_MEM_GHEAP", "H5FD_MEM_LHEAP", "H5FD_MEM_OHDR"}; @@ -4414,7 +4425,7 @@ test_vector_io__verify_v(uint32_t count, H5FD_mem_t types[], size_t sizes[], voi SET_TYPE(type_fixed, types, type, i); - w_buf = (char *)(write_bufs[i]); + w_buf = (const char *)(write_bufs[i]); r_buf = (char *)(read_bufs[i]); j = 0; @@ -4462,7 +4473,7 @@ test_vector_io__verify_v(uint32_t count, H5FD_mem_t types[], size_t sizes[], voi static void test_vector_io__dump_test_vectors(uint32_t count, H5FD_mem_t types[], haddr_t addrs[], size_t sizes[], - void *write_bufs[], void *read_bufs[], const char *name) + const void *write_bufs[], void *read_bufs[], const char *name) { hbool_t size_fixed = FALSE; hbool_t type_fixed = FALSE; @@ -4472,8 +4483,8 @@ test_vector_io__dump_test_vectors(uint32_t count, H5FD_mem_t types[], haddr_t ad size_t size = SIZE_MAX; H5FD_mem_t type = H5FD_MEM_NTYPES; - char *w_buf; - char *r_buf; + const char *w_buf; + char * r_buf; HDfprintf(stdout, "\n\nDumping test vector \"%s\" of length %d\n\n", name, count); @@ -4485,7 +4496,7 @@ test_vector_io__dump_test_vectors(uint32_t count, H5FD_mem_t types[], haddr_t ad HDassert((H5FD_MEM_DEFAULT <= type) && (type <= H5FD_MEM_OHDR)); - w_buf = (char *)(write_bufs[i]); + w_buf = (const char *)(write_bufs[i]); if (read_bufs) { @@ -4540,59 +4551,59 @@ test_vector_io__dump_test_vectors(uint32_t count, H5FD_mem_t types[], haddr_t ad static herr_t test_vector_io(const char *vfd_name) { - char test_title[80]; - hbool_t size_fixed_0 = FALSE; /* whether remaining entry */ - hbool_t size_fixed_1 = FALSE; /* sizes in vector are fixed. */ - hbool_t size_fixed_2 = FALSE; /* */ - hbool_t type_fixed_0 = FALSE; /* whether remaining entry */ - hbool_t type_fixed_1 = FALSE; /* types in vector are fixed. */ - hbool_t type_fixed_2 = FALSE; /* */ - hbool_t verbose = FALSE; - hid_t fapl_id = -1; /* file access property list ID */ - haddr_t eoa; /* file eoa */ - char filename[1024]; /* filename */ - char * buf; /* tmp ptr to buf */ - unsigned flags = 0; /* file open flags */ - H5FD_t * lf; /* VFD struct ptr */ - uint32_t i; /* index */ - uint32_t j; /* index */ - uint32_t count = VECTOR_LEN; /* length of vectors */ - H5FD_mem_t types_0[VECTOR_LEN]; /* types vector */ - H5FD_mem_t types_1[VECTOR_LEN]; /* types vector */ - H5FD_mem_t types_2[VECTOR_LEN]; /* types vector */ - H5FD_mem_t f_types_0[VECTOR_LEN]; /* fixed types vector */ - H5FD_mem_t f_types_1[VECTOR_LEN]; /* fixed types vector */ - H5FD_mem_t f_types_2[VECTOR_LEN]; /* fixed types vector */ - H5FD_mem_t f_type_0 = H5FD_MEM_NTYPES; /* current type for f vector 0 */ - H5FD_mem_t f_type_1 = H5FD_MEM_NTYPES; /* current type for f vector 1 */ - H5FD_mem_t f_type_2 = H5FD_MEM_NTYPES; /* current type for f vector 2 */ - haddr_t addrs_0[VECTOR_LEN]; /* addresses vector */ - haddr_t addrs_1[VECTOR_LEN]; /* addresses vector */ - haddr_t addrs_2[VECTOR_LEN]; /* addresses vector */ - haddr_t f_addrs_0[VECTOR_LEN]; /* fixed addresses vector */ - haddr_t f_addrs_1[VECTOR_LEN]; /* fixed addresses vector */ - haddr_t f_addrs_2[VECTOR_LEN]; /* fixed addresses vector */ - size_t sizes_0[VECTOR_LEN]; /* sizes vector */ - size_t sizes_1[VECTOR_LEN]; /* sizes vector */ - size_t sizes_2[VECTOR_LEN]; /* sizes vector */ - size_t f_sizes_0[VECTOR_LEN]; /* fixed sizes vector */ - size_t f_sizes_1[VECTOR_LEN]; /* fixed sizes vector */ - size_t f_sizes_2[VECTOR_LEN]; /* fixed sizes vector */ - size_t f_size_0 = 0; /* current size for f vector 0 */ - size_t f_size_1 = 0; /* current size for f vector 1 */ - size_t f_size_2 = 0; /* current size for f vector 2 */ - void * write_bufs_0[VECTOR_LEN]; /* write bufs vector */ - void * write_bufs_1[VECTOR_LEN]; /* write bufs vector */ - void * write_bufs_2[VECTOR_LEN]; /* write bufs vector */ - void * f_write_bufs_0[VECTOR_LEN]; /* fixed write bufs vector */ - void * f_write_bufs_1[VECTOR_LEN]; /* fixed write bufs vector */ - void * f_write_bufs_2[VECTOR_LEN]; /* fixed write bufs vector */ - void * read_bufs_0[VECTOR_LEN]; /* read bufs vector */ - void * read_bufs_1[VECTOR_LEN]; /* read bufs vector */ - void * read_bufs_2[VECTOR_LEN]; /* read bufs vector */ - void * f_read_bufs_0[VECTOR_LEN]; /* fixed read bufs vector */ - void * f_read_bufs_1[VECTOR_LEN]; /* fixed read bufs vector */ - void * f_read_bufs_2[VECTOR_LEN]; /* fixed read bufs vector */ + char test_title[80]; + hbool_t size_fixed_0 = FALSE; /* whether remaining entry */ + hbool_t size_fixed_1 = FALSE; /* sizes in vector are fixed. */ + hbool_t size_fixed_2 = FALSE; /* */ + hbool_t type_fixed_0 = FALSE; /* whether remaining entry */ + hbool_t type_fixed_1 = FALSE; /* types in vector are fixed. */ + hbool_t type_fixed_2 = FALSE; /* */ + hbool_t verbose = FALSE; + hid_t fapl_id = -1; /* file access property list ID */ + haddr_t eoa; /* file eoa */ + char filename[1024]; /* filename */ + char * buf; /* tmp ptr to buf */ + unsigned flags = 0; /* file open flags */ + H5FD_t * lf; /* VFD struct ptr */ + uint32_t i; /* index */ + uint32_t j; /* index */ + uint32_t count = VECTOR_LEN; /* length of vectors */ + H5FD_mem_t types_0[VECTOR_LEN]; /* types vector */ + H5FD_mem_t types_1[VECTOR_LEN]; /* types vector */ + H5FD_mem_t types_2[VECTOR_LEN]; /* types vector */ + H5FD_mem_t f_types_0[VECTOR_LEN]; /* fixed types vector */ + H5FD_mem_t f_types_1[VECTOR_LEN]; /* fixed types vector */ + H5FD_mem_t f_types_2[VECTOR_LEN]; /* fixed types vector */ + H5FD_mem_t f_type_0 = H5FD_MEM_NTYPES; /* current type for f vector 0 */ + H5FD_mem_t f_type_1 = H5FD_MEM_NTYPES; /* current type for f vector 1 */ + H5FD_mem_t f_type_2 = H5FD_MEM_NTYPES; /* current type for f vector 2 */ + haddr_t addrs_0[VECTOR_LEN]; /* addresses vector */ + haddr_t addrs_1[VECTOR_LEN]; /* addresses vector */ + haddr_t addrs_2[VECTOR_LEN]; /* addresses vector */ + haddr_t f_addrs_0[VECTOR_LEN]; /* fixed addresses vector */ + haddr_t f_addrs_1[VECTOR_LEN]; /* fixed addresses vector */ + haddr_t f_addrs_2[VECTOR_LEN]; /* fixed addresses vector */ + size_t sizes_0[VECTOR_LEN]; /* sizes vector */ + size_t sizes_1[VECTOR_LEN]; /* sizes vector */ + size_t sizes_2[VECTOR_LEN]; /* sizes vector */ + size_t f_sizes_0[VECTOR_LEN]; /* fixed sizes vector */ + size_t f_sizes_1[VECTOR_LEN]; /* fixed sizes vector */ + size_t f_sizes_2[VECTOR_LEN]; /* fixed sizes vector */ + size_t f_size_0 = 0; /* current size for f vector 0 */ + size_t f_size_1 = 0; /* current size for f vector 1 */ + size_t f_size_2 = 0; /* current size for f vector 2 */ + const void *write_bufs_0[VECTOR_LEN]; /* write bufs vector */ + const void *write_bufs_1[VECTOR_LEN]; /* write bufs vector */ + const void *write_bufs_2[VECTOR_LEN]; /* write bufs vector */ + const void *f_write_bufs_0[VECTOR_LEN]; /* fixed write bufs vector */ + const void *f_write_bufs_1[VECTOR_LEN]; /* fixed write bufs vector */ + const void *f_write_bufs_2[VECTOR_LEN]; /* fixed write bufs vector */ + void * read_bufs_0[VECTOR_LEN]; /* read bufs vector */ + void * read_bufs_1[VECTOR_LEN]; /* read bufs vector */ + void * read_bufs_2[VECTOR_LEN]; /* read bufs vector */ + void * f_read_bufs_0[VECTOR_LEN]; /* fixed read bufs vector */ + void * f_read_bufs_1[VECTOR_LEN]; /* fixed read bufs vector */ + void * f_read_bufs_2[VECTOR_LEN]; /* fixed read bufs vector */ HDsnprintf(test_title, sizeof(test_title), "vector I/O with %s VFD", vfd_name); @@ -4911,13 +4922,13 @@ test_vector_io(const char *vfd_name) for (i = 0; i < count; i++) { - HDfree(write_bufs_0[i]); + HDfree((void *)write_bufs_0[i]); write_bufs_0[i] = NULL; - HDfree(write_bufs_1[i]); + HDfree((void *)write_bufs_1[i]); write_bufs_1[i] = NULL; - HDfree(write_bufs_2[i]); + HDfree((void *)write_bufs_2[i]); write_bufs_2[i] = NULL; HDfree(read_bufs_0[i]); @@ -4929,13 +4940,13 @@ test_vector_io(const char *vfd_name) HDfree(read_bufs_2[i]); read_bufs_2[i] = NULL; - HDfree(f_write_bufs_0[i]); + HDfree((void *)f_write_bufs_0[i]); f_write_bufs_0[i] = NULL; - HDfree(f_write_bufs_1[i]); + HDfree((void *)f_write_bufs_1[i]); f_write_bufs_1[i] = NULL; - HDfree(f_write_bufs_2[i]); + HDfree((void *)f_write_bufs_2[i]); f_write_bufs_2[i] = NULL; HDfree(f_read_bufs_0[i]); diff --git a/testpar/t_bigio.c b/testpar/t_bigio.c index 0a971c5..406e7bf 100644 --- a/testpar/t_bigio.c +++ b/testpar/t_bigio.c @@ -1151,14 +1151,14 @@ single_rank_independent_io(void) VRFY_G((mspace_id >= 0), "H5Screate_simple mspace_id succeeded"); /* Write data */ - H5Dwrite(dset_id, H5T_NATIVE_INT, mspace_id, fspace_id, H5P_DEFAULT, data); + ret = H5Dwrite(dset_id, H5T_NATIVE_INT, mspace_id, fspace_id, H5P_DEFAULT, data); VRFY_G((ret >= 0), "H5Dwrite succeeded"); /* Wipe buffer */ HDmemset(data, 0, LARGE_DIM * sizeof(int)); /* Read data back */ - H5Dread(dset_id, H5T_NATIVE_INT, mspace_id, fspace_id, H5P_DEFAULT, data); + ret = H5Dread(dset_id, H5T_NATIVE_INT, mspace_id, fspace_id, H5P_DEFAULT, data); VRFY_G((ret >= 0), "H5Dread succeeded"); /* Verify data */ diff --git a/testpar/t_filters_parallel.c b/testpar/t_filters_parallel.c index 8a55519..01f309a 100644 --- a/testpar/t_filters_parallel.c +++ b/testpar/t_filters_parallel.c @@ -7815,8 +7815,10 @@ test_edge_chunks_overlap(const char *parent_group, H5Z_filter_t filter_id, hid_t * edge chunk and writes to just a portion of the edge chunk. */ static void -test_edge_chunks_partial_write(const char *parent_group, H5Z_filter_t filter_id, hid_t fapl_id, hid_t dcpl_id, - hid_t dxpl_id) +test_edge_chunks_partial_write(const char H5_ATTR_PARALLEL_UNUSED * parent_group, + H5Z_filter_t H5_ATTR_PARALLEL_UNUSED filter_id, + hid_t H5_ATTR_PARALLEL_UNUSED fapl_id, hid_t H5_ATTR_PARALLEL_UNUSED dcpl_id, + hid_t H5_ATTR_PARALLEL_UNUSED dxpl_id) { /* TODO */ } diff --git a/testpar/t_vfd.c b/testpar/t_vfd.c index 2072afe..81e4983 100644 --- a/testpar/t_vfd.c +++ b/testpar/t_vfd.c @@ -2196,7 +2196,7 @@ vector_write_test_1(int file_name_id, int mpi_rank, int mpi_size, H5FD_mpio_xfer H5FD_mem_t types[1]; haddr_t addrs[1]; size_t sizes[1]; - void * bufs[1]; + const void *bufs[1]; pass = TRUE; @@ -2248,7 +2248,7 @@ vector_write_test_1(int file_name_id, int mpi_rank, int mpi_size, H5FD_mpio_xfer types[0] = H5FD_MEM_DRAW; addrs[0] = (haddr_t)mpi_rank * (haddr_t)INTS_PER_RANK * (haddr_t)(sizeof(int32_t)); sizes[0] = (size_t)INTS_PER_RANK * sizeof(int32_t); - bufs[0] = (void *)(&(increasing_fi_buf[mpi_rank * INTS_PER_RANK])); + bufs[0] = (const void *)(&(increasing_fi_buf[mpi_rank * INTS_PER_RANK])); if (H5FDwrite_vector(lf, dxpl_id, count, types, addrs, sizes, bufs) < 0) { @@ -2395,7 +2395,7 @@ vector_write_test_2(int file_name_id, int mpi_rank, int mpi_size, H5FD_mpio_xfer H5FD_mem_t types[1]; haddr_t addrs[1]; size_t sizes[1]; - void * bufs[1]; + const void *bufs[1]; pass = TRUE; @@ -2452,7 +2452,7 @@ vector_write_test_2(int file_name_id, int mpi_rank, int mpi_size, H5FD_mpio_xfer types[0] = H5FD_MEM_DRAW; addrs[0] = (haddr_t)mpi_rank * (haddr_t)INTS_PER_RANK * (haddr_t)(sizeof(int32_t)); sizes[0] = (size_t)INTS_PER_RANK * sizeof(int32_t); - bufs[0] = (void *)(&(increasing_fi_buf[mpi_rank * INTS_PER_RANK])); + bufs[0] = (const void *)(&(increasing_fi_buf[mpi_rank * INTS_PER_RANK])); if (H5FDwrite_vector(lf, dxpl_id, count, types, addrs, sizes, bufs) < 0) { @@ -2493,7 +2493,7 @@ vector_write_test_2(int file_name_id, int mpi_rank, int mpi_size, H5FD_mpio_xfer types[0] = H5FD_MEM_DRAW; addrs[0] = (haddr_t)mpi_rank * (haddr_t)INTS_PER_RANK * (haddr_t)(sizeof(int32_t)); sizes[0] = (size_t)INTS_PER_RANK * sizeof(int32_t); - bufs[0] = (void *)(&(negative_fi_buf[mpi_rank * INTS_PER_RANK])); + bufs[0] = (const void *)(&(negative_fi_buf[mpi_rank * INTS_PER_RANK])); if (H5FDwrite_vector(lf, dxpl_id, count, types, addrs, sizes, bufs) < 0) { @@ -2660,7 +2660,7 @@ vector_write_test_3(int file_name_id, int mpi_rank, int mpi_size, H5FD_mpio_xfer H5FD_mem_t types[4]; haddr_t addrs[4]; size_t sizes[4]; - void * bufs[4]; + const void *bufs[4]; pass = TRUE; @@ -2720,22 +2720,22 @@ vector_write_test_3(int file_name_id, int mpi_rank, int mpi_size, H5FD_mpio_xfer types[0] = H5FD_MEM_DRAW; addrs[0] = base_addr; sizes[0] = bytes_per_write; - bufs[0] = (void *)(&(increasing_fi_buf[mpi_rank * INTS_PER_RANK])); + bufs[0] = (const void *)(&(increasing_fi_buf[mpi_rank * INTS_PER_RANK])); types[1] = H5FD_MEM_DRAW; addrs[1] = addrs[0] + (haddr_t)(bytes_per_write); sizes[1] = bytes_per_write; - bufs[1] = (void *)(&(decreasing_fi_buf[(mpi_rank * INTS_PER_RANK) + (INTS_PER_RANK / 4)])); + bufs[1] = (const void *)(&(decreasing_fi_buf[(mpi_rank * INTS_PER_RANK) + (INTS_PER_RANK / 4)])); types[2] = H5FD_MEM_DRAW; addrs[2] = addrs[1] + (haddr_t)(bytes_per_write); sizes[2] = bytes_per_write; - bufs[2] = (void *)(&(negative_fi_buf[(mpi_rank * INTS_PER_RANK) + (INTS_PER_RANK / 2)])); + bufs[2] = (const void *)(&(negative_fi_buf[(mpi_rank * INTS_PER_RANK) + (INTS_PER_RANK / 2)])); types[3] = H5FD_MEM_DRAW; addrs[3] = addrs[2] + (haddr_t)(bytes_per_write); sizes[3] = bytes_per_write; - bufs[3] = (void *)(&(zero_fi_buf[(mpi_rank * INTS_PER_RANK) + (3 * (INTS_PER_RANK / 4))])); + bufs[3] = (const void *)(&(zero_fi_buf[(mpi_rank * INTS_PER_RANK) + (3 * (INTS_PER_RANK / 4))])); #if 0 /* JRM */ HDfprintf(stdout, "addrs = { %lld, %lld, %lld, %lld}\n", @@ -2942,7 +2942,7 @@ vector_write_test_4(int file_name_id, int mpi_rank, int mpi_size, H5FD_mpio_xfer H5FD_mem_t types[4]; haddr_t addrs[4]; size_t sizes[4]; - void * bufs[4]; + const void *bufs[4]; pass = TRUE; @@ -3002,22 +3002,23 @@ vector_write_test_4(int file_name_id, int mpi_rank, int mpi_size, H5FD_mpio_xfer types[0] = H5FD_MEM_DRAW; addrs[0] = base_addr; sizes[0] = bytes_per_write; - bufs[0] = (void *)(&(zero_fi_buf[mpi_rank * INTS_PER_RANK])); + bufs[0] = (const void *)(&(zero_fi_buf[mpi_rank * INTS_PER_RANK])); types[1] = H5FD_MEM_DRAW; addrs[1] = addrs[0] + (haddr_t)(bytes_per_write); sizes[1] = bytes_per_write; - bufs[1] = (void *)(&(negative_fi_buf[(mpi_rank * INTS_PER_RANK) + (INTS_PER_RANK / 4)])); + bufs[1] = (const void *)(&(negative_fi_buf[(mpi_rank * INTS_PER_RANK) + (INTS_PER_RANK / 4)])); types[2] = H5FD_MEM_DRAW; addrs[2] = addrs[1] + (haddr_t)(bytes_per_write); sizes[2] = bytes_per_write; - bufs[2] = (void *)(&(decreasing_fi_buf[(mpi_rank * INTS_PER_RANK) + (INTS_PER_RANK / 2)])); + bufs[2] = (const void *)(&(decreasing_fi_buf[(mpi_rank * INTS_PER_RANK) + (INTS_PER_RANK / 2)])); types[3] = H5FD_MEM_DRAW; addrs[3] = addrs[2] + (haddr_t)(bytes_per_write); sizes[3] = bytes_per_write; - bufs[3] = (void *)(&(increasing_fi_buf[(mpi_rank * INTS_PER_RANK) + (3 * (INTS_PER_RANK / 4))])); + bufs[3] = + (const void *)(&(increasing_fi_buf[(mpi_rank * INTS_PER_RANK) + (3 * (INTS_PER_RANK / 4))])); #if 0 /* JRM */ HDfprintf(stdout, "addrs = { %lld, %lld, %lld, %lld}\n", @@ -3260,7 +3261,7 @@ vector_write_test_5(int file_name_id, int mpi_rank, int mpi_size, H5FD_mpio_xfer H5FD_mem_t types[4]; haddr_t addrs[4]; size_t sizes[4]; - void * bufs[4]; + const void *bufs[4]; pass = TRUE; @@ -3311,7 +3312,7 @@ vector_write_test_5(int file_name_id, int mpi_rank, int mpi_size, H5FD_mpio_xfer types[0] = H5FD_MEM_DRAW; addrs[0] = (haddr_t)mpi_rank * (haddr_t)INTS_PER_RANK * (haddr_t)(sizeof(int32_t)); sizes[0] = (size_t)INTS_PER_RANK * sizeof(int32_t); - bufs[0] = (void *)(&(zero_fi_buf[mpi_rank * INTS_PER_RANK])); + bufs[0] = (const void *)(&(zero_fi_buf[mpi_rank * INTS_PER_RANK])); if (H5FDwrite_vector(lf, dxpl_id, count, types, addrs, sizes, bufs) < 0) { @@ -3374,17 +3375,17 @@ vector_write_test_5(int file_name_id, int mpi_rank, int mpi_size, H5FD_mpio_xfer types[0] = H5FD_MEM_DRAW; addrs[0] = base_addr + (haddr_t)((size_t)(INTS_PER_RANK / 2) * sizeof(int32_t)); sizes[0] = (size_t)(INTS_PER_RANK / 4) * sizeof(int32_t); - bufs[0] = (void *)(&(negative_fi_buf[base_index + (INTS_PER_RANK / 2)])); + bufs[0] = (const void *)(&(negative_fi_buf[base_index + (INTS_PER_RANK / 2)])); types[1] = H5FD_MEM_DRAW; addrs[1] = base_addr + (haddr_t)((size_t)(INTS_PER_RANK / 4) * sizeof(int32_t)); sizes[1] = (size_t)(INTS_PER_RANK / 8) * sizeof(int32_t); - bufs[1] = (void *)(&(decreasing_fi_buf[base_index + (INTS_PER_RANK / 4)])); + bufs[1] = (const void *)(&(decreasing_fi_buf[base_index + (INTS_PER_RANK / 4)])); types[2] = H5FD_MEM_DRAW; addrs[2] = base_addr + (haddr_t)((size_t)(INTS_PER_RANK / 16) * sizeof(int32_t)); sizes[2] = (size_t)(INTS_PER_RANK / 16) * sizeof(int32_t); - bufs[2] = (void *)(&(increasing_fi_buf[base_index + (INTS_PER_RANK / 16)])); + bufs[2] = (const void *)(&(increasing_fi_buf[base_index + (INTS_PER_RANK / 16)])); } else if ((mpi_rank % 4) == 1) { @@ -3404,12 +3405,12 @@ vector_write_test_5(int file_name_id, int mpi_rank, int mpi_size, H5FD_mpio_xfer types[0] = H5FD_MEM_DRAW; addrs[0] = base_addr + (haddr_t)(sizeof(int32_t)); sizes[0] = (size_t)((INTS_PER_RANK / 2) - 2) * sizeof(int32_t); - bufs[0] = (void *)(&(increasing_fi_buf[base_index + 1])); + bufs[0] = (const void *)(&(increasing_fi_buf[base_index + 1])); types[1] = H5FD_MEM_DRAW; addrs[1] = base_addr + (haddr_t)((size_t)((INTS_PER_RANK / 2) + 1) * sizeof(int32_t)); sizes[1] = (size_t)((INTS_PER_RANK / 2) - 2) * sizeof(int32_t); - bufs[1] = (void *)(&(decreasing_fi_buf[base_index + (INTS_PER_RANK / 2) + 1])); + bufs[1] = (const void *)(&(decreasing_fi_buf[base_index + (INTS_PER_RANK / 2) + 1])); } else if ((mpi_rank % 4) == 2) { @@ -3425,7 +3426,7 @@ vector_write_test_5(int file_name_id, int mpi_rank, int mpi_size, H5FD_mpio_xfer types[0] = H5FD_MEM_DRAW; addrs[0] = base_addr + (haddr_t)((size_t)(INTS_PER_RANK / 2) * sizeof(int32_t)); sizes[0] = sizeof(int32_t); - bufs[0] = (void *)(&(negative_fi_buf[base_index + (INTS_PER_RANK / 2)])); + bufs[0] = (const void *)(&(negative_fi_buf[base_index + (INTS_PER_RANK / 2)])); } else if ((mpi_rank % 4) == 3) { @@ -3692,7 +3693,7 @@ vector_write_test_6(int file_name_id, int mpi_rank, int mpi_size, H5FD_mpio_xfer H5FD_mem_t types[(INTS_PER_RANK / 16) + 1]; haddr_t addrs[(INTS_PER_RANK / 16) + 1]; size_t sizes[2]; - void * bufs[(INTS_PER_RANK / 16) + 1]; + const void *bufs[(INTS_PER_RANK / 16) + 1]; pass = TRUE; @@ -3791,7 +3792,7 @@ vector_write_test_6(int file_name_id, int mpi_rank, int mpi_size, H5FD_mpio_xfer types[i] = H5FD_MEM_DRAW; addrs[i] = base_addr + ((haddr_t)(16 * i) * (haddr_t)sizeof(int32_t)); - bufs[i] = (void *)(&(increasing_fi_buf[base_index + (i * 16)])); + bufs[i] = (const void *)(&(increasing_fi_buf[base_index + (i * 16)])); } if (H5FDwrite_vector(lf, dxpl_id, count, types, addrs, sizes, bufs) < 0) { @@ -3914,8 +3915,6 @@ int main(int argc, char **argv) { unsigned nerrs = 0; - MPI_Comm comm = MPI_COMM_WORLD; - MPI_Info info = MPI_INFO_NULL; int mpi_size; int mpi_rank; diff --git a/tools/src/h5diff/ph5diff_main.c b/tools/src/h5diff/ph5diff_main.c index 8e5c3e8..75fb9a4 100644 --- a/tools/src/h5diff/ph5diff_main.c +++ b/tools/src/h5diff/ph5diff_main.c @@ -312,5 +312,5 @@ h5diff_exit(int status) /* Always exit(0), since MPI implementations do weird stuff when they * receive a non-zero exit value. - QAK */ - HDexit(0); + HDexit(status); } diff --git a/tools/src/h5perf/sio_engine.c b/tools/src/h5perf/sio_engine.c index bdd2c08..abf8b9a 100644 --- a/tools/src/h5perf/sio_engine.c +++ b/tools/src/h5perf/sio_engine.c @@ -123,7 +123,6 @@ static hid_t h5dxpl = H5I_INVALID_HID; /* Dataset transfer property * Purpose: SIO Engine where IO are executed. * Return: results * Programmer: Christian Chilan, April, 2008 - * Modifications: */ void do_sio(parameters param, results *res) @@ -134,18 +133,20 @@ do_sio(parameters param, results *res) iotype iot; /* API type */ char base_name[256]; /* test file base name */ /* return codes */ - herr_t ret_code = 0; /*return code */ + herr_t ret_code = 0; /* return code */ - char fname[FILENAME_MAX]; /* test file name */ - int i; - /* HDF5 variables */ - herr_t hrc; /*HDF5 return code */ + char *fname = NULL; + int i; - /* Sanity check parameters */ + /* HDF5 variables */ + herr_t hrc; /* HDF5 return code */ /* IO type */ iot = param.io_type; + if (NULL == (fname = HDcalloc(FILENAME_MAX, sizeof(char)))) + GOTOERROR(FAIL); + switch (iot) { case POSIXIO: fd.posixfd = -1; @@ -267,8 +268,8 @@ done: } /* release generic resources */ - if (buffer) - free(buffer); + HDfree(buffer); + HDfree(fname); res->ret_code = ret_code; } @@ -1125,7 +1126,6 @@ done: * Purpose: Sets file driver. * Return: SUCCESS or FAIL * Programmer: Christian Chilan, April, 2008 - * Modifications: */ hid_t @@ -1164,9 +1164,11 @@ set_vfd(parameters *param) H5FD_mem_t memb_map[H5FD_MEM_NTYPES]; hid_t memb_fapl[H5FD_MEM_NTYPES]; const char *memb_name[H5FD_MEM_NTYPES]; - char sv[H5FD_MEM_NTYPES][1024]; haddr_t memb_addr[H5FD_MEM_NTYPES]; H5FD_mem_t mt; + struct { + char arr[H5FD_MEM_NTYPES][1024]; + } *sv = NULL; HDmemset(memb_map, 0, sizeof memb_map); HDmemset(memb_fapl, 0, sizeof memb_fapl); @@ -1174,16 +1176,22 @@ set_vfd(parameters *param) HDmemset(memb_addr, 0, sizeof memb_addr); HDassert(HDstrlen(multi_letters) == H5FD_MEM_NTYPES); + + if (NULL == (sv = HDcalloc(1, sizeof(*sv)))) + return -1; for (mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt++) { memb_fapl[mt] = H5P_DEFAULT; - HDsprintf(sv[mt], "%%s-%c.h5", multi_letters[mt]); - memb_name[mt] = sv[mt]; + HDsprintf(sv->arr[mt], "%%s-%c.h5", multi_letters[mt]); + memb_name[mt] = sv->arr[mt]; memb_addr[mt] = (haddr_t)MAX(mt - 1, 0) * (HADDR_MAX / 10); } if (H5Pset_fapl_multi(my_fapl, memb_map, memb_fapl, memb_name, memb_addr, FALSE) < 0) { + HDfree(sv); return -1; } + + HDfree(sv); } else if (vfd == family) { hsize_t fam_size = 1 * 1024 * 1024; /*100 MB*/ @@ -1262,14 +1270,18 @@ done: * Purpose: Cleanup temporary file unless HDF5_NOCLEANUP is set. * Return: void * Programmer: Albert Cheng 2001/12/12 - * Modifications: Support for file drivers. Christian Chilan, April, 2008 */ static void do_cleanupfile(iotype iot, char *filename) { - char temp[4096 + sizeof("-?.h5")]; - int j; - hid_t driver; + char * temp = NULL; + size_t temp_sz; + int j; + hid_t driver; + + temp_sz = (4096 + sizeof("-?.h5")) * sizeof(char); + if (NULL == (temp = HDcalloc(1, temp_sz))) + goto done; if (clean_file_g == -1) clean_file_g = (HDgetenv(HDF5_NOCLEANUP) == NULL) ? 1 : 0; @@ -1286,7 +1298,7 @@ do_cleanupfile(iotype iot, char *filename) if (driver == H5FD_FAMILY) { for (j = 0; /*void*/; j++) { - HDsnprintf(temp, sizeof temp, filename, j); + HDsnprintf(temp, temp_sz, filename, j); if (HDaccess(temp, F_OK) < 0) break; @@ -1305,10 +1317,10 @@ do_cleanupfile(iotype iot, char *filename) } else if (driver == H5FD_MULTI) { H5FD_mem_t mt; - assert(HDstrlen(multi_letters) == H5FD_MEM_NTYPES); + HDassert(HDstrlen(multi_letters) == H5FD_MEM_NTYPES); for (mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt++) { - HDsnprintf(temp, sizeof temp, "%s-%c.h5", filename, multi_letters[mt]); + HDsnprintf(temp, temp_sz, "%s-%c.h5", filename, multi_letters[mt]); HDremove(temp); /*don't care if it fails*/ } } @@ -1325,4 +1337,7 @@ do_cleanupfile(iotype iot, char *filename) break; } } + +done: + HDfree(temp); } -- cgit v0.12