From eebaee65290de59a4fbf1a426df09e32872d9efc Mon Sep 17 00:00:00 2001 From: Dana Robinson <43805+derobins@users.noreply.github.com> Date: Mon, 12 Jul 2021 13:30:20 -0700 Subject: VFD SWMR: sync with develop (#830) * Normalization with develop * Removes checks and work-arounds for strtoll and strtoull (#769) * Removes checks for (v)snprintf, which are C99 (#772) * Update missing release note info. (#776) * Replaces the H5_OVERRIDE macro with override (#773) The macro is no longer necessary now that we require C++11. * Cleans up some POSIX header bits in H5private.h (#783) * Removes outdated checks for ways inline might be defined (#781) These are obsolete now that we require C99. * Removes checks for system(), which is C89/90 (#782) * Removes C++ dependency on H5private.h (#774) * Removes C++ dependency on H5private.h Most C API calls have been removed, aside from a few uses of free, where we just dropped the 'HD'. A couple of H5_ATTR_UNUSED macros were also replaced with (void) statements. * Committing clang-format changes Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Further simplifies Autotools type size checks (#789) Also fixes an issue where clock_gettime and difftime are not detected due to earlier simplifications of this code. * Release Note (#784) * Normalization of CMake H5pubconf.h with Autotools (#791) Mostly just moving things around and changing the comments to keep the delta small. The only symbol change is that for curl/curl.h which I changed to H5_HAVE_CURL_CURL_H to match the Autotools. This symbol is not used in the library and is just an artifact of the checks. * Fix tools test (#794) * Removes ancient Autotools cruft (#790) * Reorganization of C and POSIX headers in H5public.h & H5private.h (#793) * Reorganization of C and POSIX headers in H5public.h & H5private.h Consolidated and removed duplicates * It turns out Windows has sys/types.h Co-authored-by: Larry Knox * Removes checks for signal and set/longjmp, which are C89 (#798) Also removes checks for setjmp.h and stddef.h * Assume frexpl/f and fabsl/f, which are C99 (#799) * Assume the library has C99 types in C++ type code (#806) * Assume the library has C99 types in C++ type code * Committing clang-format changes Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Removes obsolete equivalents of C99's __func__ (#800) * Cleans up POSIX/C bits in H5private.h (#804) * Cleans up POSIX/C bits in H5private.h * Assume difftime exists (C89) * Reorg AC_CHECK_HEADERS so headers are in alphabetical order * Split off networking-related AC_CHECK_HEADERS * Remove unused UNAME_CYGWIN from configure.ac * Remove checks for unused sys/timeb.h * Tidying pass over H5private.h HD prefix macros * Tidy H5win32defs.h * Add HD prefix to various scanf calls * Committing clang-format changes * Fixes to the alarm(2) code used in the tests to make Windows happy Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Brings the tools getopt(3) replacement into the main library (#803) * Moves get_option from the tools library to the C library * Adds H5 prefix to get_option call and variables * Renames the H5_get_option long options struct and enum * Removes type guesses when C99 types are missing (#807) * Assume C99 types exist in H5detect.c (#808) * Fixes parallel issues from recent C99 changes * Adds MPE FUNC --> __func__ changes missed in earlier PRs * Fix typo * Fixes parallel issues from recent C99 changes (#809) * Fixes parallel issues from recent C99 changes * Adds MPE FUNC --> __func__ changes missed in earlier PRs * Even more missed FUNC --> __func__ macros * Removes remaining H5_TIME_WITH_SYS_TIME cruft (#810) Mostly from CMake * Merges with develop * Committing clang-format changes * Normalization with develop * direct_chunk test and H5Dget_chunk_storage_size changes * Removes unused H5O call * Brings some dataspace changes from the combo branch merge Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Larry Knox --- .gitignore | 6 - config/cmake/H5pubconf.h.in | 3 - config/cmake_ext_mod/ConfigureChecks.cmake | 6 - src/H5Dchunk.c | 67 ++++--- src/H5Dprivate.h | 11 +- src/H5Oattribute.c | 45 ----- src/H5Pdxpl.c | 278 ++++++++++++++++++++++++++++- src/H5S.c | 51 +----- src/H5Sprivate.h | 1 - src/H5Spublic.h | 8 +- src/H5VLnative_dataset.c | 154 ++++++++++++++-- src/H5private.h | 13 +- src/H5system.c | 6 +- test/cmpd_dset.c | 4 + test/cross_read.c | 2 + test/direct_chunk.c | 100 ++++++----- test/dsets.c | 43 +++-- test/dtypes.c | 56 ++++-- test/earray.c | 4 +- test/farray.c | 4 +- test/file_image.c | 16 +- test/h5test.c | 33 +--- test/h5test.h | 14 +- test/hyperslab.c | 7 +- test/istore.c | 6 +- test/links.c | 8 +- test/objcopy.c | 12 ++ test/page_buffer.c | 12 +- test/testfiles/err_compat_1 | 4 +- test/testfiles/links_env.out | 4 +- test/tfile.c | 1 + test/trefer_deprec.c | 6 + test/trefstr.c | 2 +- test/unlink.c | 2 +- test/use_common.c | 21 +++ testpar/t_file.c | 5 +- testpar/t_span_tree.c | 5 +- tools/lib/io_timer.h | 2 +- 38 files changed, 698 insertions(+), 324 deletions(-) diff --git a/.gitignore b/.gitignore index bdeae42..3caf16a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,5 @@ # .gitignore file for HDF5 -# ctags -**/tags - -# vim swap files -**/.*.swp - # Makefile.in files **/Makefile.in diff --git a/config/cmake/H5pubconf.h.in b/config/cmake/H5pubconf.h.in index 11b56a4..740a0cf 100644 --- a/config/cmake/H5pubconf.h.in +++ b/config/cmake/H5pubconf.h.in @@ -394,9 +394,6 @@ /* Define if your system has window style path name. */ #cmakedefine H5_HAVE_WINDOW_PATH @H5_HAVE_WINDOW_PATH@ -/* Define to 1 if you have the header file. */ -#cmakedefine H5_HAVE_WINSOCK2_H @H5_HAVE_WINSOCK2_H@ - /* Define to 1 if you have the header file. */ #cmakedefine H5_HAVE_ZLIB_H @H5_HAVE_ZLIB_H@ diff --git a/config/cmake_ext_mod/ConfigureChecks.cmake b/config/cmake_ext_mod/ConfigureChecks.cmake index d014535..61cec8b 100644 --- a/config/cmake_ext_mod/ConfigureChecks.cmake +++ b/config/cmake_ext_mod/ConfigureChecks.cmake @@ -53,7 +53,6 @@ if (MINGW) set (${HDF_PREFIX}_HAVE_MINGW 1) set (WINDOWS 1) # MinGW tries to imitate Windows set (CMAKE_REQUIRED_FLAGS "-DWIN32_LEAN_AND_MEAN=1 -DNOGDI=1") - set (${HDF_PREFIX}_HAVE_WINSOCK2_H 1) set (__USE_MINGW_ANSI_STDIO 1) endif () @@ -117,11 +116,6 @@ CHECK_INCLUDE_FILE_CONCAT ("features.h" ${HDF_PREFIX}_HAVE_FEATURES_H) CHECK_INCLUDE_FILE_CONCAT ("dirent.h" ${HDF_PREFIX}_HAVE_DIRENT_H) CHECK_INCLUDE_FILE_CONCAT ("unistd.h" ${HDF_PREFIX}_HAVE_UNISTD_H) -# Windows -if (NOT CYGWIN) - CHECK_INCLUDE_FILE_CONCAT ("winsock2.h" ${HDF_PREFIX}_HAVE_WINSOCK2_H) -endif () - CHECK_INCLUDE_FILE_CONCAT ("globus/common.h" ${HDF_PREFIX}_HAVE_GLOBUS_COMMON_H) CHECK_INCLUDE_FILE_CONCAT ("pdb.h" ${HDF_PREFIX}_HAVE_PDB_H) CHECK_INCLUDE_FILE_CONCAT ("pthread.h" ${HDF_PREFIX}_HAVE_PTHREAD_H) diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index d6eb715..5fc7abb 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -604,8 +604,6 @@ H5D__get_chunk_storage_size(H5D_t *dset, const hsize_t *offset, hsize_t *storage HDassert(offset); HDassert(storage_size); - *storage_size = 0; - /* Allocate dataspace and initialize it if it hasn't been. */ if (!(*layout->ops->is_space_alloc)(&layout->storage)) HGOTO_DONE(SUCCEED) @@ -5031,7 +5029,7 @@ H5D__chunk_collective_fill(const H5D_t *dset, H5D_chunk_coll_info_t *chunk_info, * order of offset in the file. */ if (need_addr_sort) - HDqsort(chunk_disp_array, blocks, sizeof(MPI_Aint), H5D__chunk_cmp_addr); + HDqsort(chunk_disp_array, (size_t)blocks, sizeof(MPI_Aint), H5D__chunk_cmp_addr); /* MSC - should use this if MPI_type_create_hindexed block is working: * mpi_code = MPI_Type_create_hindexed_block(blocks, block_len, chunk_disp_array, MPI_BYTE, @@ -6066,6 +6064,7 @@ H5D__chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) if (udata->chunk_in_cache) { HDassert(H5F_addr_defined(chunk_rec->chunk_addr)); + HDassert(ent); HDassert(H5F_addr_defined(ent->chunk_block.offset)); H5_CHECKED_ASSIGN(nbytes, size_t, shared_fo->layout.u.chunk.size, uint32_t); @@ -7499,6 +7498,36 @@ done: } /* end H5D__get_chunk_info_by_coord() */ /*------------------------------------------------------------------------- + * Function: H5D__chunk_iter_cb + * + * Purpose: Call the user-defined function with the chunk data. The iterator continues if + * the user-defined function returns H5_ITER_CONT, and stops if H5_ITER_STOP is + * returned. + * + * Return: Success: H5_ITER_CONT or H5_ITER_STOP + * Failure: Negative (H5_ITER_ERROR) + * + * Programmer: Gaute Hope + * August 2020 + * + *------------------------------------------------------------------------- + */ +static int +H5D__chunk_iter_cb(const H5D_chunk_rec_t *chunk_rec, void *udata) +{ + int ret_value = 0; + + FUNC_ENTER_STATIC_NOERR + + const H5D_chunk_iter_cb_data_t *data = (H5D_chunk_iter_cb_data_t *)udata; + + ret_value = (data->cb)(chunk_rec->scaled, chunk_rec->filter_mask, chunk_rec->chunk_addr, + chunk_rec->nbytes, data->op_data); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5D__chunk_iter_cb */ + +/*------------------------------------------------------------------------- * Function: H5D__chunk_iter * * Purpose: Iterate over all the chunks in the dataset with given callbak. @@ -7537,7 +7566,7 @@ H5D__chunk_iter(const H5D_t *dset, H5D_chunk_iter_op_t cb, void *op_data) for (ent = rdcc->head; ent; ent = ent->next) /* Flush the chunk out to disk, to make certain the size is correct later */ if (H5D__chunk_flush_entry(dset, ent, FALSE) < 0) - HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "cannot flush indexed storage buffer") + HGOTO_ERROR(H5E_DATASET, H5E_CANTFLUSH, FAIL, "cannot flush indexed storage buffer") /* Compose chunked index info struct */ idx_info.f = dset->oloc.file; @@ -7559,33 +7588,3 @@ H5D__chunk_iter(const H5D_t *dset, H5D_chunk_iter_op_t cb, void *op_data) done: FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5D__chunk_iter() */ - -/*------------------------------------------------------------------------- - * Function: H5D__chunk_iter_cb - * - * Purpose: Call the user-defined function with the chunk data. The iterator continues if - * the user-defined function returns H5_ITER_CONT, and stops if H5_ITER_STOP is - * returned. - * - * Return: Success: H5_ITER_CONT or H5_ITER_STOP - * Failure: Negative (H5_ITER_ERROR) - * - * Programmer: Gaute Hope - * August 2020 - * - *------------------------------------------------------------------------- - */ -static int -H5D__chunk_iter_cb(const H5D_chunk_rec_t *chunk_rec, void *udata) -{ - int ret_value = 0; - - FUNC_ENTER_STATIC_NOERR - - const H5D_chunk_iter_cb_data_t *data = (H5D_chunk_iter_cb_data_t *)udata; - - ret_value = (data->cb)(chunk_rec->scaled, chunk_rec->filter_mask, chunk_rec->chunk_addr, - chunk_rec->nbytes, data->op_data); - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5D__chunk_iter_cb */ diff --git a/src/H5Dprivate.h b/src/H5Dprivate.h index f9ef772..ad9794d 100644 --- a/src/H5Dprivate.h +++ b/src/H5Dprivate.h @@ -79,11 +79,12 @@ #define H5D_MPIO_LOCAL_NO_COLLECTIVE_CAUSE_NAME \ "local_no_collective_cause" /* cause of broken collective I/O in each process */ #define H5D_MPIO_GLOBAL_NO_COLLECTIVE_CAUSE_NAME \ - "global_no_collective_cause" /* cause of broken collective I/O in all processes */ -#define H5D_XFER_EDC_NAME "err_detect" /* EDC */ -#define H5D_XFER_FILTER_CB_NAME "filter_cb" /* Filter callback function */ -#define H5D_XFER_CONV_CB_NAME "type_conv_cb" /* Type conversion callback function */ -#define H5D_XFER_XFORM_NAME "data_transform" /* Data transform */ + "global_no_collective_cause" /* cause of broken collective I/O in all processes */ +#define H5D_XFER_EDC_NAME "err_detect" /* EDC */ +#define H5D_XFER_FILTER_CB_NAME "filter_cb" /* Filter callback function */ +#define H5D_XFER_CONV_CB_NAME "type_conv_cb" /* Type conversion callback function */ +#define H5D_XFER_XFORM_NAME "data_transform" /* Data transform */ +#define H5D_XFER_DSET_IO_SEL_NAME "dset_io_selection" /* Dataset I/O selection */ #ifdef H5_HAVE_INSTRUMENTED_LIBRARY /* Collective chunk instrumentation properties */ #define H5D_XFER_COLL_CHUNK_LINK_HARD_NAME "coll_chunk_link_hard" diff --git a/src/H5Oattribute.c b/src/H5Oattribute.c index 0fc4cc6..56f7145 100644 --- a/src/H5Oattribute.c +++ b/src/H5Oattribute.c @@ -1901,48 +1901,3 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5O__attr_bh_info() */ - -#ifndef H5_NO_DEPRECATED_SYMBOLS - -/*------------------------------------------------------------------------- - * Function: H5O__attr_count - * - * Purpose: Determine the # of attributes on an object - * - * Return: SUCCEED/FAIL - * - * Programmer: Quincey Koziol - * Monday, December 11, 2006 - * - *------------------------------------------------------------------------- - */ -int -H5O__attr_count(const H5O_loc_t *loc) -{ - H5O_t * oh = NULL; /* Pointer to actual object header */ - hsize_t nattrs; /* Number of attributes */ - int ret_value = -1; /* Return value */ - - FUNC_ENTER_PACKAGE - - /* Check arguments */ - HDassert(loc); - - /* Protect the object header to iterate over */ - if (NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTPROTECT, FAIL, "unable to load object header") - - /* Retrieve # of attributes on object */ - if (H5O__attr_count_real(loc->file, oh, &nattrs) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't retrieve attribute count") - - /* Set return value */ - ret_value = (int)nattrs; - -done: - if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O__attr_count */ -#endif /* H5_NO_DEPRECATED_SYMBOLS */ diff --git a/src/H5Pdxpl.c b/src/H5Pdxpl.c index de67dfd..046b046 100644 --- a/src/H5Pdxpl.c +++ b/src/H5Pdxpl.c @@ -159,6 +159,16 @@ #define H5D_XFER_XFORM_COPY H5P__dxfr_xform_copy #define H5D_XFER_XFORM_CMP H5P__dxfr_xform_cmp #define H5D_XFER_XFORM_CLOSE H5P__dxfr_xform_close +/* Definitions for dataset I/O selection property */ +#define H5D_XFER_DSET_IO_SEL_SIZE sizeof(H5S_t *) +#define H5D_XFER_DSET_IO_SEL_DEF NULL +#define H5D_XFER_DSET_IO_SEL_COPY H5P__dxfr_dset_io_hyp_sel_copy +#define H5D_XFER_DSET_IO_SEL_CMP H5P__dxfr_dset_io_hyp_sel_cmp +#define H5D_XFER_DSET_IO_SEL_CLOSE H5P__dxfr_dset_io_hyp_sel_close +#ifdef QAK +#define H5D_XFER_DSET_IO_SEL_ENC H5P__dxfr_edc_enc +#define H5D_XFER_DSET_IO_SEL_DEC H5P__dxfr_edc_dec +#endif /* QAK */ /******************/ /* Local Typedefs */ @@ -196,6 +206,9 @@ static herr_t H5P__dxfr_xform_del(hid_t prop_id, const char *name, size_t size, static herr_t H5P__dxfr_xform_copy(const char *name, size_t size, void *value); static int H5P__dxfr_xform_cmp(const void *value1, const void *value2, size_t size); static herr_t H5P__dxfr_xform_close(const char *name, size_t size, void *value); +static herr_t H5P__dxfr_dset_io_hyp_sel_copy(const char *name, size_t size, void *value); +static int H5P__dxfr_dset_io_hyp_sel_cmp(const void *value1, const void *value2, size_t size); +static herr_t H5P__dxfr_dset_io_hyp_sel_close(const char *name, size_t size, void *value); /*********************/ /* Package Variables */ @@ -262,7 +275,9 @@ static const H5Z_EDC_t H5D_def_enable_edc_g = H5D_XFER_EDC_DEF; /* Default static const H5Z_cb_t H5D_def_filter_cb_g = H5D_XFER_FILTER_CB_DEF; /* Default value for filter callback */ static const H5T_conv_cb_t H5D_def_conv_cb_g = H5D_XFER_CONV_CB_DEF; /* Default value for datatype conversion callback */ -static const void *H5D_def_xfer_xform_g = H5D_XFER_XFORM_DEF; /* Default value for data transform */ +static const void * H5D_def_xfer_xform_g = H5D_XFER_XFORM_DEF; /* Default value for data transform */ +static const H5S_t *H5D_def_dset_io_sel_g = + H5D_XFER_DSET_IO_SEL_DEF; /* Default value for dataset I/O selection */ /*------------------------------------------------------------------------- * Function: H5P__dxfr_reg_prop @@ -420,6 +435,13 @@ H5P__dxfr_reg_prop(H5P_genclass_t *pclass) H5D_XFER_XFORM_CLOSE) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + /* Register the dataset I/O selection property */ + if (H5P__register_real(pclass, H5D_XFER_DSET_IO_SEL_NAME, H5D_XFER_DSET_IO_SEL_SIZE, + &H5D_def_dset_io_sel_g, NULL, NULL, NULL, NULL, NULL, NULL, + H5D_XFER_DSET_IO_SEL_COPY, H5D_XFER_DSET_IO_SEL_CMP, + H5D_XFER_DSET_IO_SEL_CLOSE) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dxfr_reg_prop() */ @@ -894,7 +916,7 @@ H5P__dxfr_xform_cmp(const void *_xform1, const void *_xform2, size_t H5_ATTR_UNU done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P__dxfr_xform_copy() */ +} /* end H5P__dxfr_xform_cmp() */ /*------------------------------------------------------------------------- * Function: H5P__dxfr_xform_close @@ -965,7 +987,7 @@ H5Pset_data_transform(hid_t plist_id, const char *expression) /* Create data transform info from expression */ if (NULL == (data_xform_prop = H5Z_xform_create(expression))) - HGOTO_ERROR(H5E_PLINE, H5E_NOSPACE, FAIL, "unable to create data transform info") + HGOTO_ERROR(H5E_PLIST, H5E_NOSPACE, FAIL, "unable to create data transform info") /* Update property list (takes ownership of transform) */ if (H5P_poke(plist, H5D_XFER_XFORM_NAME, &data_xform_prop) < 0) @@ -974,7 +996,7 @@ H5Pset_data_transform(hid_t plist_id, const char *expression) done: if (ret_value < 0) if (data_xform_prop && H5Z_xform_destroy(data_xform_prop) < 0) - HDONE_ERROR(H5E_PLINE, H5E_CLOSEERROR, FAIL, "unable to release data transform expression") + HDONE_ERROR(H5E_PLIST, H5E_CLOSEERROR, FAIL, "unable to release data transform expression") FUNC_LEAVE_API(ret_value) } /* end H5Pset_data_transform() */ @@ -2109,3 +2131,251 @@ H5P__dxfr_edc_dec(const void **_pp, void *_value) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__dxfr_edc_dec() */ + +/*------------------------------------------------------------------------- + * Function: H5P__dxfr_dset_io_hyp_sel_copy + * + * Purpose: Creates a copy of the dataset I/O selection. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * Sunday, January 31, 2021 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__dxfr_dset_io_hyp_sel_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) +{ + H5S_t *orig_space = *(H5S_t **)value; /* Original dataspace for property */ + H5S_t *new_space = NULL; /* New dataspace for property */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* If there's a dataspace I/O selection set, copy it */ + if (orig_space) { + /* Make copy of dataspace */ + if (NULL == (new_space = H5S_copy(orig_space, FALSE, TRUE))) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "error copying the dataset I/O selection") + + /* Set new value for property */ + *(void **)value = new_space; + } /* end if */ + +done: + /* Cleanup on error */ + if (ret_value < 0) + if (new_space && H5S_close(new_space) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCLOSEOBJ, FAIL, "error closing dataset I/O selection dataspace") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__dxfr_dset_io_hyp_sel_copy() */ + +/*------------------------------------------------------------------------- + * Function: H5P__dxfr_dset_io_hyp_sel_cmp + * + * Purpose: Compare two dataset I/O selections. + * + * Return: positive if VALUE1 is greater than VALUE2, negative if VALUE2 is + * greater than VALUE1 and zero if VALUE1 and VALUE2 are equal. + * + * Programmer: Quincey Koziol + * Sunday, January 31, 2021 + * + *------------------------------------------------------------------------- + */ +static int +H5P__dxfr_dset_io_hyp_sel_cmp(const void *_space1, const void *_space2, size_t H5_ATTR_UNUSED size) +{ + const H5S_t *const *space1 = (const H5S_t *const *)_space1; /* Create local aliases for values */ + const H5S_t *const *space2 = (const H5S_t *const *)_space2; /* Create local aliases for values */ + herr_t ret_value = 0; /* Return value */ + + FUNC_ENTER_STATIC_NOERR + + /* Sanity check */ + HDassert(space1); + HDassert(space1); + HDassert(size == sizeof(H5S_t *)); + + /* Check for a property being set */ + if (*space1 == NULL && *space2 != NULL) + HGOTO_DONE(-1); + if (*space1 != NULL && *space2 == NULL) + HGOTO_DONE(1); + + if (*space1) { + HDassert(*space2); + + /* Compare the extents of the dataspaces */ + /* (Error & not-equal count the same) */ + if (TRUE != H5S_extent_equal(*space1, *space2)) + HGOTO_DONE(-1); + + /* Compare the selection "shape" of the dataspaces */ + /* (Error & not-equal count the same) */ + if (TRUE != H5S_select_shape_same(*space1, *space2)) + HGOTO_DONE(-1); + } /* end if */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__dxfr_dset_io_hyp_sel_cmp() */ + +/*------------------------------------------------------------------------- + * Function: H5P__dxfr_dset_io_hyp_sel_close + * + * Purpose: Frees resources for dataset I/O selection + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * Sunday, January 31, 2021 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__dxfr_dset_io_hyp_sel_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *_value) +{ + H5S_t *space = *(H5S_t **)_value; /* Dataspace for property */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Release any dataspace */ + if (space && H5S_close(space) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCLOSEOBJ, FAIL, "error closing dataset I/O selection dataspace") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__dxfr_dset_io_hyp_sel_close() */ + +/*------------------------------------------------------------------------- + * Function: H5Pset_dataset_io_hyperslab_selection + * + * Purpose: H5Pset_dataset_io_hyperslab_selection() is designed to be used + * in conjunction with using H5S_PLIST for the file dataspace + * ID when making a call to H5Dread() or H5Dwrite(). When used + * with H5S_PLIST, the selection created by one or more calls to + * this routine is used for determining which dataset elements to + * access. + * + * 'rank' is the dimensionality of the selection and determines + * the size of the 'start', 'stride', 'count', and 'block' arrays. + * 'rank' must be between 1 and H5S_MAX_RANK, inclusive. + * + * The 'op', 'start', 'stride', 'count', and 'block' parameters + * behave identically to their behavior for H5Sselect_hyperslab(), + * please see the documentation for that routine for details about + * their use. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * Saturday, January 30, 2021 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Pset_dataset_io_hyperslab_selection(hid_t plist_id, unsigned rank, H5S_seloper_t op, const hsize_t start[], + const hsize_t stride[], const hsize_t count[], const hsize_t block[]) +{ + H5P_genplist_t *plist; /* Property list pointer */ + H5S_t * space; /* Dataspace to hold selection */ + hbool_t space_created = FALSE; /* Whether a new dataspace has been created */ + hbool_t reset_prop_on_error = FALSE; /* Whether to reset the property on failure */ + herr_t ret_value = SUCCEED; /* return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE7("e", "iIuSs*h*h*h*h", plist_id, rank, op, start, stride, count, block); + + /* Check arguments */ + if (rank < 1 || rank > H5S_MAX_RANK) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid rank value: %u", rank) + if (!(op > H5S_SELECT_NOOP && op < H5S_SELECT_INVALID)) + HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation") + if (start == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "'count' pointer is NULL") + if (stride != NULL) { + unsigned u; /* Local index variable */ + + /* Check for 0-sized strides */ + for (u = 0; u < rank; u++) + if (stride[u] == 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid value - stride[%u]==0", u) + } /* end if */ + if (count == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "'start' pointer is NULL") + /* block is allowed to be NULL, and will be assumed to be all '1's when NULL */ + + /* Get the plist structure */ + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) + HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID") + + /* See if a dataset I/O selection is already set, and free it if it is */ + if (H5P_peek(plist, H5D_XFER_DSET_IO_SEL_NAME, &space) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "error getting dataset I/O selection") + + /* Check for operation on existing dataspace selection */ + if (NULL != space) { + int sndims; /* Rank of existing dataspace */ + + /* Get dimensions from current dataspace for selection */ + if ((sndims = H5S_GET_EXTENT_NDIMS(space)) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get selection's dataspace rank") + + /* Check for different # of dimensions */ + if ((unsigned)sndims != rank) { + /* Set up new dataspace for 'set' operation, otherwise fail */ + if (op == H5S_SELECT_SET) { + /* Close previous dataspace */ + if (H5S_close(space) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CLOSEERROR, FAIL, "unable to release dataspace") + + /* Reset 'space' pointer, so it's re-created */ + space = NULL; + + /* Set flag to reset property list on error */ + reset_prop_on_error = TRUE; + } /* end if */ + else + HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "different rank for previous and new selections") + } /* end if */ + } /* end if */ + + /* Check for first time called */ + if (NULL == space) { + hsize_t dims[H5S_MAX_RANK]; /* Dimensions for new dataspace */ + unsigned u; /* Local index variable */ + + /* Initialize dimensions to largest possible actual size */ + for (u = 0; u < rank; u++) + dims[u] = (H5S_UNLIMITED - 1); + + /* Create dataspace of the correct dimensionality, with maximum dimensions */ + if (NULL == (space = H5S_create_simple(rank, dims, NULL))) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, FAIL, "unable to create dataspace for selection") + space_created = TRUE; + } /* end if */ + + /* Set selection for dataspace */ + if (H5S_select_hyperslab(space, op, start, stride, count, block) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSELECT, FAIL, "can't create selection") + + /* Update property list (takes ownership of dataspace, if new) */ + if (H5P_poke(plist, H5D_XFER_DSET_IO_SEL_NAME, &space) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "error setting dataset I/O selection") + space_created = FALSE; /* Reset now that property owns the dataspace */ + +done: + /* Cleanup on failure */ + if (ret_value < 0) { + if (reset_prop_on_error && H5P_poke(plist, H5D_XFER_DSET_IO_SEL_NAME, &space) < 0) + HDONE_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "error setting dataset I/O selection") + if (space_created && H5S_close(space) < 0) + HDONE_ERROR(H5E_PLIST, H5E_CLOSEERROR, FAIL, "unable to release dataspace") + } /* end if */ + + FUNC_LEAVE_API(ret_value) +} /* end H5Pset_dataset_io_hyperslab_selection() */ diff --git a/src/H5S.c b/src/H5S.c index 747d297..13d32cf 100644 --- a/src/H5S.c +++ b/src/H5S.c @@ -84,7 +84,7 @@ H5FL_ARR_DEFINE(hsize_t, H5S_MAX_RANK); static const H5I_class_t H5I_DATASPACE_CLS[1] = {{ H5I_DATASPACE, /* ID class value */ 0, /* Class flags */ - 2, /* # of reserved IDs for class */ + 3, /* # of reserved IDs for class */ (H5I_free_t)H5S__close_cb /* Callback routine for closing objects of this class */ }}; @@ -277,55 +277,6 @@ done: /*-------------------------------------------------------------------------- NAME - H5S_get_validiated_dataspace - PURPOSE - Get a pointer to a validated H5S_t pointer - USAGE - H5S_t *H5S_get_validated_space(dataspace_id, space) - hid_t space_id; IN: The ID of the dataspace - const H5S_t * space; OUT: A pointer to the dataspace - RETURNS - SUCCEED/FAIL - DESCRIPTION - Gets a pointer to a dataspace struct after validating it. The pointer - can be NULL (if the ID is H5S_ALL, for example). - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -herr_t -H5S_get_validated_dataspace(hid_t space_id, const H5S_t **space) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - HDassert(space); - - /* Check for invalid ID */ - if (space_id < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid space_id (ID cannot be a negative number)") - - /* No special dataspace struct for H5S_ALL */ - if (H5S_ALL == space_id) - *space = NULL; - else { - /* Get the dataspace pointer */ - if (NULL == (*space = (const H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "space_id is not a dataspace ID") - - /* Check for valid selection */ - if (H5S_SELECT_VALID(*space) != TRUE) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "selection + offset not within extent") - } - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5S_get_validated_dataspace() */ - -/*-------------------------------------------------------------------------- - NAME H5S_create PURPOSE Create empty, typed dataspace diff --git a/src/H5Sprivate.h b/src/H5Sprivate.h index 56c1646..51a98a6 100644 --- a/src/H5Sprivate.h +++ b/src/H5Sprivate.h @@ -217,7 +217,6 @@ H5_DLL htri_t H5S_set_extent(H5S_t *space, const hsize_t *size); H5_DLL herr_t H5S_set_extent_real(H5S_t *space, const hsize_t *size); H5_DLL herr_t H5S_set_extent_simple(H5S_t *space, unsigned rank, const hsize_t *dims, const hsize_t *max); H5_DLL H5S_t *H5S_create(H5S_class_t type); -H5_DLL herr_t H5S_get_validated_dataspace(hid_t space_id, const H5S_t **space /*out*/); H5_DLL H5S_t *H5S_create_simple(unsigned rank, const hsize_t dims[/*rank*/], const hsize_t maxdims[/*rank*/]); H5_DLL herr_t H5S_set_version(H5F_t *f, H5S_t *ds); H5_DLL herr_t H5S_encode(H5S_t *obj, unsigned char **p, size_t *nalloc); diff --git a/src/H5Spublic.h b/src/H5Spublic.h index c2c0aef..7962035 100644 --- a/src/H5Spublic.h +++ b/src/H5Spublic.h @@ -21,8 +21,12 @@ #include "H5public.h" #include "H5Ipublic.h" -/* Define atomic datatypes */ -#define H5S_ALL 0 /* (hid_t) */ +/* Define special dataspaces for dataset I/O operations */ +#define H5S_ALL 0 /* (hid_t) */ +#define H5S_BLOCK 1 /* (hid_t) */ +#define H5S_PLIST 2 /* (hid_t) */ + +/* Define value for 'unlimited' dimensions */ #define H5S_UNLIMITED HSIZE_UNDEF /* Define user-level maximum number of dimensions */ diff --git a/src/H5VLnative_dataset.c b/src/H5VLnative_dataset.c index 978ecb3..3a7f105 100644 --- a/src/H5VLnative_dataset.c +++ b/src/H5VLnative_dataset.c @@ -49,6 +49,10 @@ /* Local Prototypes */ /********************/ +/* Helper routines for read/write API calls */ +static herr_t H5VL__native_dataset_io_setup(H5D_t *dset, hid_t dxpl_id, hid_t file_space_id, + hid_t mem_space_id, H5S_t **file_space, H5S_t **mem_space); + /*********************/ /* Package Variables */ /*********************/ @@ -62,6 +66,100 @@ /*******************/ /*------------------------------------------------------------------------- + * Function: H5VL__native_dataset_io_setup + * + * Purpose: Set up file and memory dataspaces for dataset I/O operation + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__native_dataset_io_setup(H5D_t *dset, hid_t dxpl_id, hid_t file_space_id, hid_t mem_space_id, + H5S_t **file_space, H5S_t **mem_space) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(dset); + HDassert(file_space && NULL == *file_space); + HDassert(mem_space && NULL == *mem_space); + + /* Set up file dataspace */ + if (H5S_ALL == file_space_id) + /* Use dataspace for dataset */ + *file_space = dset->shared->space; + else if (H5S_BLOCK == file_space_id) + HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "H5S_BLOCK is not allowed for file dataspace") + else if (H5S_PLIST == file_space_id) { + H5P_genplist_t *plist; /* Property list pointer */ + H5S_t * space; /* Dataspace to hold selection */ + + /* Get the plist structure */ + if (NULL == (plist = H5P_object_verify(dxpl_id, H5P_DATASET_XFER))) + HGOTO_ERROR(H5E_DATASET, H5E_BADID, FAIL, "bad dataset transfer property list") + + /* See if a dataset I/O selection is already set, and free it if it is */ + if (H5P_peek(plist, H5D_XFER_DSET_IO_SEL_NAME, &space) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "error getting dataset I/O selection") + + /* Use dataspace for dataset */ + *file_space = dset->shared->space; + + /* Copy, but share, selection from property list to dataset's dataspace */ + if (H5S_SELECT_COPY(*file_space, space, TRUE) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "can't copy dataset I/O selection") + } /* end else-if */ + else { + /* Get the dataspace pointer */ + if (NULL == (*file_space = (H5S_t *)H5I_object_verify(file_space_id, H5I_DATASPACE))) + HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "file_space_id is not a dataspace ID") + } /* end else */ + + /* Get dataspace for memory buffer */ + if (H5S_ALL == mem_space_id) + *mem_space = *file_space; + else if (H5S_BLOCK == mem_space_id) { + hsize_t nelmts; /* # of selected elements in file */ + + /* Get the # of elements selected */ + nelmts = H5S_GET_SELECT_NPOINTS(*file_space); + + /* Check for any elements */ + if (nelmts > 0) { + /* Create a 1-D dataspace of the same # of elements */ + if (NULL == (*mem_space = H5S_create_simple(1, &nelmts, NULL))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCREATE, FAIL, "unable to create simple memory dataspace") + } /* end if */ + else { + /* Create a NULL dataspace of the same # of elements */ + if (NULL == (*mem_space = H5S_create(H5S_NULL))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCREATE, FAIL, "unable to create NULL memory dataspace") + } /* end else */ + } /* end if */ + else if (H5S_PLIST == mem_space_id) + HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "H5S_PLIST is not allowed for memory dataspace") + else { + /* Get the dataspace pointer */ + if (NULL == (*mem_space = (H5S_t *)H5I_object_verify(mem_space_id, H5I_DATASPACE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "mem_space_id is not a dataspace ID") + } /* end else */ + + /* Check for valid selections */ + if (H5S_SELECT_VALID(*file_space) != TRUE) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, + "selection + offset not within extent for file dataspace") + if (H5S_SELECT_VALID(*mem_space) != TRUE) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, + "selection + offset not within extent for memory dataspace") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_dataset_io_setup() */ + +/*------------------------------------------------------------------------- * Function: H5VL__native_dataset_create * * Purpose: Handles the dataset create callback @@ -172,10 +270,10 @@ herr_t H5VL__native_dataset_read(void *obj, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t dxpl_id, void *buf, void H5_ATTR_UNUSED **req) { - H5D_t * dset = (H5D_t *)obj; - const H5S_t *mem_space = NULL; - const H5S_t *file_space = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + H5D_t *dset = (H5D_t *)obj; + H5S_t *mem_space = NULL; + H5S_t *file_space = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -183,11 +281,10 @@ H5VL__native_dataset_read(void *obj, hid_t mem_type_id, hid_t mem_space_id, hid_ if (NULL == dset->oloc.file) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not associated with a file") - /* Get validated dataspace pointers */ - if (H5S_get_validated_dataspace(mem_space_id, &mem_space) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not get a validated dataspace from mem_space_id") - if (H5S_get_validated_dataspace(file_space_id, &file_space) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not get a validated dataspace from file_space_id") + /* Get file & memory dataspaces */ + if (H5VL__native_dataset_io_setup(dset, dxpl_id, file_space_id, mem_space_id, &file_space, &mem_space) < + 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to set up file and memory dataspaces") /* Set DXPL for operation */ H5CX_set_dxpl(dxpl_id); @@ -197,6 +294,17 @@ H5VL__native_dataset_read(void *obj, hid_t mem_type_id, hid_t mem_space_id, hid_ HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read data") done: + /* Clean up */ + if (H5S_BLOCK == mem_space_id && mem_space) { + if (H5S_close(mem_space) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, + "unable to release temporary memory dataspace for H5S_BLOCK") + } /* end if */ + else if (H5S_PLIST == file_space_id && file_space) + if (H5S_select_all(file_space, TRUE) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, + "unable to release file dataspace selection for H5S_PLIST") + FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__native_dataset_read() */ @@ -213,10 +321,10 @@ herr_t H5VL__native_dataset_write(void *obj, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t dxpl_id, const void *buf, void H5_ATTR_UNUSED **req) { - H5D_t * dset = (H5D_t *)obj; - const H5S_t *mem_space = NULL; - const H5S_t *file_space = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + H5D_t *dset = (H5D_t *)obj; + H5S_t *mem_space = NULL; + H5S_t *file_space = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -224,11 +332,10 @@ H5VL__native_dataset_write(void *obj, hid_t mem_type_id, hid_t mem_space_id, hid if (NULL == dset->oloc.file) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not associated with a file") - /* Get validated dataspace pointers */ - if (H5S_get_validated_dataspace(mem_space_id, &mem_space) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not get a validated dataspace from mem_space_id") - if (H5S_get_validated_dataspace(file_space_id, &file_space) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not get a validated dataspace from file_space_id") + /* Get file & memory dataspaces */ + if (H5VL__native_dataset_io_setup(dset, dxpl_id, file_space_id, mem_space_id, &file_space, &mem_space) < + 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to set up file and memory dataspaces") /* Set DXPL for operation */ H5CX_set_dxpl(dxpl_id); @@ -238,6 +345,17 @@ H5VL__native_dataset_write(void *obj, hid_t mem_type_id, hid_t mem_space_id, hid HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write data") done: + /* Clean up */ + if (H5S_BLOCK == mem_space_id && mem_space) { + if (H5S_close(mem_space) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, + "unable to release temporary memory dataspace for H5S_BLOCK") + } /* end if */ + else if (H5S_PLIST == file_space_id && file_space) + if (H5S_select_all(file_space, TRUE) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, + "unable to release file dataspace selection for H5S_PLIST") + FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__native_dataset_write() */ diff --git a/src/H5private.h b/src/H5private.h index 0e2cdec..bb416ef 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -113,22 +113,21 @@ #define H5_DEFAULT_VOL H5VL_NATIVE #ifdef H5_HAVE_WIN32_API + /* The following two defines must be before any windows headers are included */ #define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */ #define NOGDI /* Exclude Graphic Display Interface macros */ -#ifdef H5_HAVE_WINSOCK2_H -#include -#endif +#include + +#include /* For _getcwd() */ +#include /* POSIX I/O */ +#include /* For GetUserName() */ #ifdef H5_HAVE_THREADSAFE #include /* For _beginthread() */ #endif -#include -#include /* For _getcwd() */ -#include /* POSIX I/O */ - #endif /*H5_HAVE_WIN32_API*/ #ifndef F_OK diff --git a/src/H5system.c b/src/H5system.c index dcb77dd..adfb758 100644 --- a/src/H5system.c +++ b/src/H5system.c @@ -365,7 +365,7 @@ Wsetenv(const char *name, const char *value, int overwrite) return (int)_putenv_s(name, value); } /* end Wsetenv() */ -#ifdef H5_HAVE_WINSOCK2_H +#ifdef H5_HAVE_WIN32_API #pragma comment(lib, "advapi32.lib") #endif @@ -450,12 +450,12 @@ char * Wgetlogin(void) { -#ifdef H5_HAVE_WINSOCK2_H +#ifdef H5_HAVE_WIN32_API DWORD bufferCount = WloginBuffer_count; if (GetUserName(Wlogin_buffer, &bufferCount) != 0) return (Wlogin_buffer); else -#endif /* H5_HAVE_WINSOCK2_H */ +#endif return NULL; } diff --git a/test/cmpd_dset.c b/test/cmpd_dset.c index e74b438..4c3233d 100644 --- a/test/cmpd_dset.c +++ b/test/cmpd_dset.c @@ -1466,6 +1466,10 @@ test_hdf5_src_subset(char *filename, hid_t fapl) return 0; error: + HDfree(orig); + HDfree(rbuf); + HDfree(rew_buf); + HDputs("*** DATASET TESTS FAILED ***"); return 1; } diff --git a/test/cross_read.c b/test/cross_read.c index eef814f..cb71996 100644 --- a/test/cross_read.c +++ b/test/cross_read.c @@ -41,8 +41,10 @@ const char *FILENAME[] = {"vms_data", "le_data", "be_data", NULL}; #define DATASETNAME14 "Fletcher_float_data_le" #define DATASETNAME15 "Fletcher_float_data_be" +#ifdef H5_HAVE_FILTER_DEFLATE #define DATASETNAME16 "Deflate_float_data_le" #define DATASETNAME17 "Deflate_float_data_be" +#endif #ifdef H5_HAVE_FILTER_SZIP #define DATASETNAME18 "Szip_float_data_le" #define DATASETNAME19 "Szip_float_data_be" diff --git a/test/direct_chunk.c b/test/direct_chunk.c index 61e3df9..8960784 100644 --- a/test/direct_chunk.c +++ b/test/direct_chunk.c @@ -23,7 +23,9 @@ #define FILE_NAME "direct_chunk.h5" /* Datasets for Direct Write tests */ +#ifdef H5_HAVE_FILTER_DEFLATE #define DATASETNAME1 "direct_write" +#endif #define DATASETNAME2 "skip_one_filter" #define DATASETNAME3 "skip_two_filters" #define DATASETNAME4 "data_conv" @@ -31,9 +33,11 @@ #define DATASETNAME6 "invalid_argue" #define DATASETNAME7 "overwrite_chunk" /* Datasets for Direct Read tests */ +#ifdef H5_HAVE_FILTER_DEFLATE #define DATASETNAME8 "disabled_chunk_cache" #define DATASETNAME9 "flush_chunk_cache" #define DATASETNAME10 "read_w_valid_cache" +#endif #define DATASETNAME11 "unallocated_chunk" #define DATASETNAME12 "unfiltered_data" @@ -43,7 +47,9 @@ #define CHUNK_NX 4 #define CHUNK_NY 4 +#ifdef H5_HAVE_FILTER_DEFLATE #define DEFLATE_SIZE_ADJUST(s) (HDceil(((double)(s)) * 1.001) + 12.0) +#endif /* Temporary filter IDs used for testing */ #define H5Z_FILTER_BOGUS1 305 @@ -1990,23 +1996,23 @@ test_read_unallocated_chunk(hid_t file) /* Create the data space with unlimited dimensions. */ if ((dataspace = H5Screate_simple(RANK, dims, maxdims)) < 0) - goto error; + FAIL_STACK_ERROR; if ((mem_space = H5Screate_simple(RANK, chunk_dims, NULL)) < 0) - goto error; + FAIL_STACK_ERROR; /* Modify dataset creation properties, i.e. enable chunking, no compression */ if ((cparms = H5Pcreate(H5P_DATASET_CREATE)) < 0) - goto error; + FAIL_STACK_ERROR; if ((status = H5Pset_chunk(cparms, RANK, chunk_dims)) < 0) - goto error; + FAIL_STACK_ERROR; /* Create a new dataset within the file using cparms creation properties. */ if ((dataset = H5Dcreate2(file, DATASETNAME11, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, cparms, H5P_DEFAULT)) < 0) - goto error; + FAIL_STACK_ERROR; if ((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) - goto error; + FAIL_STACK_ERROR; /* Write a single chunk to intialize the chunk storage */ HDmemset(direct_buf, 0, CHUNK_NX * CHUNK_NY * sizeof(int)); @@ -2014,7 +2020,7 @@ test_read_unallocated_chunk(hid_t file) offset[1] = 0; if (H5Dwrite_chunk(dataset, dxpl, filter_mask, offset, chunk_nbytes, direct_buf) < 0) - goto error; + FAIL_STACK_ERROR; /* Attempt to read each chunk in the dataset. Chunks are not allocated, * therefore we expect the result of H5Dread_chunk to fail. Chunk idx starts @@ -2034,7 +2040,7 @@ test_read_unallocated_chunk(hid_t file) /* Check that the chunk read call does not succeed. */ if (status != -1) - goto error; + TEST_ERROR /* Query the size of the non-existant chunk */ direct_chunk_nbytes = ULONG_MAX; @@ -2046,18 +2052,23 @@ test_read_unallocated_chunk(hid_t file) /* Check that the chunk storage size call does not succeed. */ if (status != -1) - goto error; - if (direct_chunk_nbytes != 0) - goto error; + TEST_ERROR + if (direct_chunk_nbytes != ULONG_MAX) + TEST_ERROR } } /* Close/release resources. */ - H5Dclose(dataset); - H5Sclose(mem_space); - H5Sclose(dataspace); - H5Pclose(cparms); - H5Pclose(dxpl); + if (H5Dclose(dataset) < 0) + FAIL_STACK_ERROR; + if (H5Sclose(mem_space) < 0) + FAIL_STACK_ERROR; + if (H5Sclose(dataspace) < 0) + FAIL_STACK_ERROR; + if (H5Pclose(cparms) < 0) + FAIL_STACK_ERROR; + if (H5Pclose(dxpl) < 0) + FAIL_STACK_ERROR; PASSED(); return 0; @@ -2121,103 +2132,100 @@ test_single_chunk(unsigned config) TESTING("Single chunk I/O"); /* Initialize data */ - for (i = 0; i < DIM0; i++) { + for (i = 0; i < DIM0; i++) for (j = 0; j < DIM1; j++) wdata[i][j] = j / CHUNK0; - } /* Create a new file with the latest format */ if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) - goto error; + FAIL_STACK_ERROR; if (config & CONFIG_LATEST) if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) - goto error; + FAIL_STACK_ERROR; if ((fid = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - goto error; + FAIL_STACK_ERROR; /* Create dataspace */ if ((sid = H5Screate_simple(2, dims, NULL)) < 0) - goto error; + FAIL_STACK_ERROR; /* Create the dataset creation property list and set the chunk size */ if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) - goto error; + FAIL_STACK_ERROR; if (H5Pset_chunk(dcpl, 2, chunk) < 0) - goto error; + FAIL_STACK_ERROR; /* Create the dataset */ if ((did = H5Dcreate2(fid, DATASET, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) - goto error; + FAIL_STACK_ERROR; if (config & CONFIG_DIRECT_WRITE) { /* Write the data directly to the dataset */ if (H5Dwrite_chunk(did, H5P_DEFAULT, 0, offset, CHUNK0 * CHUNK1 * 4, (void *)wdata) < 0) - goto error; + FAIL_STACK_ERROR; } /* end if */ else /* Write the data to the dataset */ if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, (void *)wdata) < 0) - goto error; + FAIL_STACK_ERROR; /* * Close and release resources. */ if (H5Pclose(dcpl) < 0) - goto error; + FAIL_STACK_ERROR; if (config & CONFIG_REOPEN_DSET) if (H5Dclose(did) < 0) - goto error; + FAIL_STACK_ERROR; if (H5Sclose(sid) < 0) - goto error; + FAIL_STACK_ERROR; if (H5Pclose(fapl) < 0) - goto error; + FAIL_STACK_ERROR; if (config & CONFIG_REOPEN_FILE) if (H5Fclose(fid) < 0) - goto error; + FAIL_STACK_ERROR; /* Open the file and dataset with default properties */ if (config & CONFIG_REOPEN_FILE) if ((fid = H5Fopen(FILE, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) - goto error; + FAIL_STACK_ERROR; if (config & CONFIG_REOPEN_DSET) if ((did = H5Dopen2(fid, DATASET, H5P_DEFAULT)) < 0) - goto error; + FAIL_STACK_ERROR; /* Retrieve dataset creation property list */ if ((dcpl = H5Dget_create_plist(did)) < 0) - goto error; + FAIL_STACK_ERROR; if (config & CONFIG_DIRECT_READ) { /* Read the data directly */ if (H5Dread_chunk(did, H5P_DEFAULT, offset, &filters, rdata) < 0) - goto error; + FAIL_STACK_ERROR; /* Verify returned filter mask */ if (filters != 0) - goto error; + TEST_ERROR } /* end if */ else /* Read the data */ if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata) < 0) - goto error; + FAIL_STACK_ERROR; /* Verify that the data read was correct. */ - for (i = 0; i < DIM0; i++) { - for (j = 0; j < DIM1; j++) { + for (i = 0; i < DIM0; i++) + for (j = 0; j < DIM1; j++) if (rdata[i][j] != wdata[i][j]) - goto error; - } - } + TEST_ERROR /* * Close and release resources */ if (H5Pclose(dcpl) < 0) - goto error; + FAIL_STACK_ERROR; if (H5Dclose(did) < 0) - goto error; + FAIL_STACK_ERROR; if (H5Fclose(fid) < 0) - goto error; + FAIL_STACK_ERROR; PASSED(); return 0; diff --git a/test/dsets.c b/test/dsets.c index 96f8b81..3a17575 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -93,25 +93,29 @@ const char *FILENAME[] = {"dataset", /* 0 */ #define FILE_DEFLATE_NAME "deflate.h5" /* Dataset names for testing filters */ -#define DSET_DEFAULT_NAME "default" -#define DSET_CHUNKED_NAME "chunked" -#define DSET_COMPACT_NAME "compact" -#define DSET_SIMPLE_IO_NAME "simple_io" -#define DSET_USERBLOCK_IO_NAME "userblock_io" -#define DSET_COMPACT_IO_NAME "compact_io" -#define DSET_COMPACT_MAX_NAME "max_compact" -#define DSET_COMPACT_MAX2_NAME "max_compact_2" -#define DSET_CONV_BUF_NAME "conv_buf" -#define DSET_TCONV_NAME "tconv" -#define DSET_DEFLATE_NAME "deflate" -#define DSET_SHUFFLE_NAME "shuffle" -#define DSET_FLETCHER32_NAME "fletcher32" -#define DSET_FLETCHER32_NAME_2 "fletcher32_2" -#define DSET_FLETCHER32_NAME_3 "fletcher32_3" +#define DSET_DEFAULT_NAME "default" +#define DSET_CHUNKED_NAME "chunked" +#define DSET_COMPACT_NAME "compact" +#define DSET_SIMPLE_IO_NAME "simple_io" +#define DSET_USERBLOCK_IO_NAME "userblock_io" +#define DSET_COMPACT_IO_NAME "compact_io" +#define DSET_COMPACT_MAX_NAME "max_compact" +#define DSET_COMPACT_MAX2_NAME "max_compact_2" +#define DSET_CONV_BUF_NAME "conv_buf" +#define DSET_TCONV_NAME "tconv" +#ifdef H5_HAVE_FILTER_DEFLATE +#define DSET_DEFLATE_NAME "deflate" +#endif +#define DSET_SHUFFLE_NAME "shuffle" +#define DSET_FLETCHER32_NAME "fletcher32" +#define DSET_FLETCHER32_NAME_2 "fletcher32_2" +#define DSET_FLETCHER32_NAME_3 "fletcher32_3" +#ifdef H5_HAVE_FILTER_DEFLATE #define DSET_SHUF_DEF_FLET_NAME "shuffle+deflate+fletcher32" #define DSET_SHUF_DEF_FLET_NAME_2 "shuffle+deflate+fletcher32_2" -#define DSET_OPTIONAL_SCALAR "dataset_with_scalar_space" -#define DSET_OPTIONAL_VLEN "dataset_with_vlen_type" +#endif +#define DSET_OPTIONAL_SCALAR "dataset_with_scalar_space" +#define DSET_OPTIONAL_VLEN "dataset_with_vlen_type" #ifdef H5_HAVE_FILTER_SZIP #define DSET_SZIP_NAME "szip" #define DSET_SHUF_SZIP_FLET_NAME "shuffle+szip+fletcher32" @@ -1502,6 +1506,9 @@ test_conv_buffer(hid_t fid) return SUCCEED; error: + HDfree(cfrR); + HDfree(cf); + H5E_BEGIN_TRY { H5Pclose(xfer_list); @@ -7160,6 +7167,7 @@ error: H5E_END_TRY; return FAIL; #else + (void)file; /* Silence compiler */ SKIPPED(); return SUCCEED; #endif @@ -15407,6 +15415,7 @@ main(void) /* Tests version bounds using its own file */ nerrors += (test_versionbounds() < 0 ? 1 : 0); + /* Tests that use their own file */ nerrors += (test_object_header_minimization_dcpl() < 0 ? 1 : 0); /* Run misc tests */ diff --git a/test/dtypes.c b/test/dtypes.c index 52eb0ea..2a18302 100644 --- a/test/dtypes.c +++ b/test/dtypes.c @@ -783,9 +783,12 @@ test_compound_2(void) FAIL_STACK_ERROR /* Sizes should be the same, but be careful just in case */ - buf = (unsigned char *)HDmalloc(nelmts * MAX(sizeof(struct st), sizeof(struct dt))); - bkg = (unsigned char *)HDmalloc(nelmts * sizeof(struct dt)); - orig = (unsigned char *)HDmalloc(nelmts * sizeof(struct st)); + if (NULL == (buf = (unsigned char *)HDmalloc(nelmts * MAX(sizeof(struct st), sizeof(struct dt))))) + goto error; + if (NULL == (bkg = (unsigned char *)HDmalloc(nelmts * sizeof(struct dt)))) + goto error; + if (NULL == (orig = (unsigned char *)HDmalloc(nelmts * sizeof(struct st)))) + goto error; for (i = 0; i < (int)nelmts; i++) { s_ptr = ((struct st *)((void *)orig)) + i; s_ptr->a = i * 8 + 0; @@ -857,6 +860,10 @@ test_compound_2(void) return 0; error: + HDfree(buf); + HDfree(bkg); + HDfree(orig); + /* Restore the default error handler (set in h5_reset()) */ h5_restore_err(); @@ -903,9 +910,12 @@ test_compound_3(void) FAIL_STACK_ERROR /* Initialize */ - buf = (unsigned char *)HDmalloc(nelmts * MAX(sizeof(struct st), sizeof(struct dt))); - bkg = (unsigned char *)HDmalloc(nelmts * sizeof(struct dt)); - orig = (unsigned char *)HDmalloc(nelmts * sizeof(struct st)); + if (NULL == (buf = (unsigned char *)HDmalloc(nelmts * MAX(sizeof(struct st), sizeof(struct dt))))) + goto error; + if (NULL == (bkg = (unsigned char *)HDmalloc(nelmts * sizeof(struct dt)))) + goto error; + if (NULL == (orig = (unsigned char *)HDmalloc(nelmts * sizeof(struct st)))) + goto error; for (i = 0; i < (int)nelmts; i++) { s_ptr = ((struct st *)((void *)orig)) + i; s_ptr->a = i * 8 + 0; @@ -973,6 +983,10 @@ test_compound_3(void) return 0; error: + HDfree(buf); + HDfree(bkg); + HDfree(orig); + /* Restore the default error handler (set in h5_reset()) */ h5_restore_err(); @@ -1023,9 +1037,12 @@ test_compound_4(void) FAIL_STACK_ERROR /* Sizes should be the same, but be careful just in case */ - buf = (unsigned char *)HDmalloc(nelmts * MAX(sizeof(struct st), sizeof(struct dt))); - bkg = (unsigned char *)HDmalloc(nelmts * sizeof(struct dt)); - orig = (unsigned char *)HDmalloc(nelmts * sizeof(struct st)); + if (NULL == (buf = (unsigned char *)HDmalloc(nelmts * MAX(sizeof(struct st), sizeof(struct dt))))) + goto error; + if (NULL == (bkg = (unsigned char *)HDmalloc(nelmts * sizeof(struct dt)))) + goto error; + if (NULL == (orig = (unsigned char *)HDmalloc(nelmts * sizeof(struct st)))) + goto error; for (i = 0; i < (int)nelmts; i++) { s_ptr = ((struct st *)((void *)orig)) + i; s_ptr->a = i * 8 + 0; @@ -1096,6 +1113,10 @@ test_compound_4(void) return 0; error: + HDfree(buf); + HDfree(bkg); + HDfree(orig); + /* Restore the default error handler (set in h5_reset()) */ h5_restore_err(); @@ -1146,6 +1167,12 @@ test_compound_5(void) TESTING("optimized struct converter"); + if (!buf || !bkg) { + HDfree(buf); + HDfree(bkg); + return 1; + } + /* Build datatypes */ short_array = H5Tcreate(H5T_COMPOUND, 4 * sizeof(short)); array_dt = H5Tarray_create2(H5T_NATIVE_SHORT, 1, dims); @@ -1238,9 +1265,12 @@ test_compound_6(void) FAIL_STACK_ERROR /* Sizes should be the same, but be careful just in case */ - buf = (unsigned char *)HDmalloc(nelmts * MAX(sizeof(struct st), sizeof(struct dt))); - bkg = (unsigned char *)HDmalloc(nelmts * sizeof(struct dt)); - orig = (unsigned char *)HDmalloc(nelmts * sizeof(struct st)); + if (NULL == (buf = (unsigned char *)HDmalloc(nelmts * MAX(sizeof(struct st), sizeof(struct dt))))) + goto error; + if (NULL == (bkg = (unsigned char *)HDmalloc(nelmts * sizeof(struct dt)))) + goto error; + if (NULL == (orig = (unsigned char *)HDmalloc(nelmts * sizeof(struct st)))) + goto error; for (i = 0; i < (int)nelmts; i++) { s_ptr = ((struct st *)((void *)orig)) + i; s_ptr->b = (int16_t)((i * 8 + 1) & 0x7fff); @@ -2290,6 +2320,8 @@ test_compound_11(void) ((big_t *)buf)[u].i1 = (int)(u * 3); ((big_t *)buf)[u].i2 = (int)(u * 5); ((big_t *)buf)[u].s1 = (char *)HDmalloc((size_t)32); + if (!((big_t *)buf)[u].s1) + TEST_ERROR HDsprintf(((big_t *)buf)[u].s1, "%u", (unsigned)u); } /* end for */ diff --git a/test/earray.c b/test/earray.c index bf7dcf3..337e818 100644 --- a/test/earray.c +++ b/test/earray.c @@ -2087,7 +2087,7 @@ test_set_elmts(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam, h /* * Display testing message */ - TESTING("%s", test_str); + TESTING(test_str); /* Create file & retrieve pointer to internal file object */ if (create_file(H5F_ACC_TRUNC, fapl, &file, &f) < 0) @@ -2261,7 +2261,7 @@ test_skip_elmts(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam, /* * Display testing message */ - TESTING("%s", test_str); + TESTING(test_str); /* Create file & retrieve pointer to internal file object */ if (create_file(H5F_ACC_TRUNC, fapl, &file, &f) < 0) diff --git a/test/farray.c b/test/farray.c index bb5e3fc..950c7a7 100644 --- a/test/farray.c +++ b/test/farray.c @@ -1361,7 +1361,7 @@ test_set_elmts(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t *tparam, h /* * Display testing message */ - TESTING("%s", test_str); + TESTING(test_str); /* Create file & retrieve pointer to internal file object */ if (create_file(fapl, &file, &f) < 0) @@ -1516,7 +1516,7 @@ test_skip_elmts(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t *tparam, /* * Display testing message */ - TESTING("%s", test_str); + TESTING(test_str); /* Create file & retrieve pointer to internal file object */ if (create_file(fapl, &file, &f) < 0) diff --git a/test/file_image.c b/test/file_image.c index 4fb1ef3..0373468 100644 --- a/test/file_image.c +++ b/test/file_image.c @@ -102,8 +102,9 @@ test_properties(void) * property list functions. In the file driver tests further down, this will * not be the case. */ - size = (size_t)count * sizeof(char); - buffer = (char *)HDmalloc(size); + size = (size_t)count * sizeof(char); + if (NULL == (buffer = (char *)HDmalloc(size))) + TEST_ERROR for (i = 0; i < count - 1; i++) buffer[i] = (char)(65 + i); buffer[count - 1] = '\0'; @@ -338,8 +339,8 @@ test_callbacks(void) H5FD_file_image_callbacks_t callbacks; hid_t fapl_1; hid_t fapl_2; - udata_t * udata; - char * file_image; + udata_t * udata = NULL; + char * file_image = NULL; char * temp_file_image; int count = 10; int i; @@ -350,6 +351,7 @@ test_callbacks(void) /* Allocate and initialize udata */ udata = (udata_t *)HDmalloc(sizeof(udata_t)); + VERIFY(udata != NULL, "udata malloc failed"); reset_udata(udata); /* copy the address of the user data into read_callbacks */ @@ -358,6 +360,7 @@ test_callbacks(void) /* Allocate and initialize file image buffer */ size = (size_t)count * sizeof(char); file_image = (char *)HDmalloc(size); + VERIFY(file_image != NULL, "file_image malloc failed"); for (i = 0; i < count - 1; i++) file_image[i] = (char)(65 + i); file_image[count - 1] = '\0'; @@ -529,6 +532,9 @@ test_callbacks(void) return 0; error: + HDfree(file_image); + HDfree(udata); + return 1; } /* test_callbacks() */ @@ -735,7 +741,7 @@ test_get_file_image(const char *test_banner, const int file_name_num, hid_t fapl hid_t fcpl = -1; herr_t ret; - TESTING("%s", test_banner); + TESTING(test_banner); /* set flag if we are dealing with a family file */ driver = H5Pget_driver(fapl); diff --git a/test/h5test.c b/test/h5test.c index 8f74e45..9ec29ed 100644 --- a/test/h5test.c +++ b/test/h5test.c @@ -148,29 +148,6 @@ h5_errors(hid_t estack, void H5_ATTR_UNUSED *client_data) } /*------------------------------------------------------------------------- - * Function: h5_testing - * - * Purpose: Prints "Testing" + formatted options to stdout - * Used in the TESTING macro - * - * Return: void - *------------------------------------------------------------------------- - */ -void -h5_testing(const char *fmt, ...) -{ - va_list ap; - char buf[62 + 1]; /* room for 62-char field + NUL */ - - HDva_start(ap, fmt); - HDvsnprintf(buf, sizeof(buf), fmt, ap); - HDva_end(ap); - - HDprintf("Testing %s", buf); - HDfflush(stdout); -} - -/*------------------------------------------------------------------------- * Function: h5_clean_files * * Purpose: Cleanup temporary test files (always). @@ -1218,9 +1195,10 @@ h5_set_info_object(void) valp++; /* copy key/value pair into temporary buffer */ - len = strcspn(valp, ";"); - next = &valp[len]; - key_val = (char *)HDcalloc(1, len + 1); + len = HDstrcspn(valp, ";"); + next = &valp[len]; + if (NULL == (key_val = (char *)HDcalloc(1, len + 1))) + return -1; /* increment the next pointer past the terminating semicolon */ if (*next == ';') @@ -1616,6 +1594,9 @@ h5_make_local_copy(const char *origfilename, const char *local_copy_name) void * buf = NULL; /* Buffer for copying data */ const char *filename = H5_get_srcdir_filename(origfilename); /* Get the test file name to copy */ + if (!filename) + goto error; + /* Allocate copy buffer */ if (NULL == (buf = HDcalloc((size_t)1, (size_t)READ_BUF_SIZE))) goto error; diff --git a/test/h5test.h b/test/h5test.h index 3736537..2855fb5 100644 --- a/test/h5test.h +++ b/test/h5test.h @@ -100,7 +100,11 @@ H5TEST_DLLVAR MPI_Info h5_io_info_g; /* MPI INFO object for IO */ * spaces. If the h5_errors() is used for automatic error handling then * the H5_FAILED() macro is invoked automatically when an API function fails. */ -#define TESTING(...) h5_testing(__VA_ARGS__); +#define TESTING(WHAT) \ + { \ + HDprintf("Testing %-62s", WHAT); \ + HDfflush(stdout); \ + } #define TESTING_2(WHAT) \ { \ HDprintf(" Testing %-60s", WHAT); \ @@ -157,13 +161,6 @@ H5TEST_DLLVAR MPI_Info h5_io_info_g; /* MPI INFO object for IO */ HDputs(s); \ goto error; \ } -#define FAIL_PRINTF_ERROR(fmt, ...) \ - { \ - H5_FAILED(); \ - AT(); \ - HDprintf(fmt, __VA_ARGS__); \ - goto error; \ - } /* Number of seconds to wait before killing a test (requires alarm(2)) */ #define H5_ALARM_SEC 1200 /* default is 20 minutes */ @@ -235,7 +232,6 @@ extern "C" { #endif /* Generally useful testing routines */ -H5TEST_DLL void h5_testing(const char *, ...) H5_ATTR_FORMAT(printf, 1, 2); H5TEST_DLL void h5_clean_files(const char *base_name[], hid_t fapl); H5TEST_DLL int h5_cleanup(const char *base_name[], hid_t fapl); H5TEST_DLL char * h5_fixname(const char *base_name, hid_t fapl, char *fullname, size_t size); diff --git a/test/hyperslab.c b/test/hyperslab.c index 41528ad..1f57e3b 100644 --- a/test/hyperslab.c +++ b/test/hyperslab.c @@ -1014,7 +1014,8 @@ test_array_fill(size_t lo, size_t hi) size_t u, v, w; /* Local index variables */ char s[256]; - TESTING("array filling %4zu-%-4zu elements", lo, hi); + HDsprintf(s, "array filling %4lu-%-4lu elements", (unsigned long)lo, (unsigned long)hi); + TESTING(s); /* Initialize */ if (NULL == (dst = (int *)HDcalloc(sizeof(int), ARRAY_FILL_SIZE * hi))) @@ -1077,7 +1078,9 @@ test_array_offset_n_calc(size_t n, size_t x, size_t y, size_t z) hsize_t new_coords[ARRAY_OFFSET_NDIMS]; /* X, Y & X coordinates of offset */ char s[256]; - TESTING("array offset %4zux%4zux%4zu elements", z, y, x); + HDsprintf(s, "array offset %4lux%4lux%4lu elements", (unsigned long)z, (unsigned long)y, + (unsigned long)x); + TESTING(s); /* Initialize */ if (NULL == (a = (hsize_t *)HDmalloc(sizeof(hsize_t) * x * y * z))) diff --git a/test/istore.c b/test/istore.c index 192e184..c75b8bf 100644 --- a/test/istore.c +++ b/test/istore.c @@ -284,7 +284,8 @@ test_extend(hid_t f, const char *prefix, size_t nx, size_t ny, size_t nz) HDsprintf(dims, "%lux%lux%lu", (unsigned long)nx, (unsigned long)ny, (unsigned long)nz); } - TESTING("istore extend: %s", dims); + HDsprintf(s, "istore extend: %s", dims); + TESTING(s); buf = (uint8_t *)HDmalloc(nx * ny * nz); check = (uint8_t *)HDmalloc(nx * ny * nz); whole = (uint8_t *)HDcalloc((size_t)1, nx * ny * nz); @@ -499,7 +500,8 @@ test_sparse(hid_t f, const char *prefix, size_t nblocks, size_t nx, size_t ny, s HDsprintf(dims, "%lux%lux%lu", (unsigned long)nx, (unsigned long)ny, (unsigned long)nz); } - TESTING("istore sparse: %s", dims); + HDsprintf(s, "istore sparse: %s", dims); + TESTING(s); if (skip_test) { SKIPPED() return SUCCEED; diff --git a/test/links.c b/test/links.c index b2d0d9a..f022783 100644 --- a/test/links.c +++ b/test/links.c @@ -3507,6 +3507,7 @@ done: case H5I_ERROR_MSG: case H5I_ERROR_STACK: case H5I_SPACE_SEL_ITER: + case H5I_EVENTSET: case H5I_NTYPES: default: return FAIL; @@ -3597,6 +3598,7 @@ done: case H5I_ERROR_MSG: case H5I_ERROR_STACK: case H5I_SPACE_SEL_ITER: + case H5I_EVENTSET: case H5I_NTYPES: default: return FAIL; @@ -13785,6 +13787,7 @@ done: case H5I_ERROR_MSG: case H5I_ERROR_STACK: case H5I_SPACE_SEL_ITER: + case H5I_EVENTSET: case H5I_NTYPES: default: return FAIL; @@ -13876,6 +13879,7 @@ done: case H5I_ERROR_MSG: case H5I_ERROR_STACK: case H5I_SPACE_SEL_ITER: + case H5I_EVENTSET: case H5I_NTYPES: default: return FAIL; @@ -16683,7 +16687,7 @@ obj_exists(hid_t fapl, hbool_t new_format) FAIL_STACK_ERROR /* Hard links */ - /* Verify that H5Oexists_by_name() fails for non-existent link in root group */ + /* Verify that H5Oexists_by_name() returns false for non-existent link in root group */ H5E_BEGIN_TRY { status = H5Oexists_by_name(fid, "foo", H5P_DEFAULT); @@ -16702,7 +16706,7 @@ obj_exists(hid_t fapl, hbool_t new_format) if (TRUE != H5Oexists_by_name(fid, "group", H5P_DEFAULT)) TEST_ERROR - /* Verify that H5Oexists_by_name() fails for non-existent link in non-root group */ + /* Verify that H5Oexists_by_name() returns false for non-existent object in non-root group */ H5E_BEGIN_TRY { status = H5Oexists_by_name(fid, "group/foo", H5P_DEFAULT); diff --git a/test/objcopy.c b/test/objcopy.c index 43a5756..e01083d 100644 --- a/test/objcopy.c +++ b/test/objcopy.c @@ -4498,6 +4498,10 @@ test_copy_dataset_compressed(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid TESTING("H5Ocopy(): compressed dataset"); #ifndef H5_HAVE_FILTER_DEFLATE + (void)fcpl_src; + (void)fcpl_dst; + (void)src_fapl; + (void)dst_fapl; /* Silence compiler */ SKIPPED(); HDputs(" Deflation filter not available"); #else /* H5_HAVE_FILTER_DEFLATE */ @@ -4923,6 +4927,10 @@ test_copy_dataset_no_edge_filt(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, h } #ifndef H5_HAVE_FILTER_DEFLATE + (void)fcpl_src; + (void)fcpl_dst; + (void)src_fapl; + (void)dst_fapl; /* Silence compiler */ SKIPPED(); HDputs(" Deflation filter not available"); #else /* H5_HAVE_FILTER_DEFLATE */ @@ -7277,6 +7285,10 @@ test_copy_dataset_compressed_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, TESTING("H5Ocopy(): compressed dataset with VLEN datatype"); #ifndef H5_HAVE_FILTER_DEFLATE + (void)fcpl_src; + (void)fcpl_dst; + (void)src_fapl; + (void)dst_fapl; /* Silence compiler */ SKIPPED(); HDputs(" Deflation filter not available"); #else /* H5_HAVE_FILTER_DEFLATE */ diff --git a/test/page_buffer.c b/test/page_buffer.c index b04d1a2..61e9696 100644 --- a/test/page_buffer.c +++ b/test/page_buffer.c @@ -1167,8 +1167,10 @@ test_raw_data_handling(hid_t orig_fapl, const char *env_h5_drvr, bool vfd_swmr_m int * data = NULL; H5F_t * f = NULL; const uint32_t max_lag = 5; + char s[256]; - TESTING("%sRaw Data Handling", vfd_swmr_mode ? "VFD SWMR " : ""); + HDsprintf(s, "%sRaw Data Handling", vfd_swmr_mode ? "VFD SWMR " : ""); + TESTING(s); h5_fixname(namebase, orig_fapl, filename, sizeof(filename)); @@ -2909,8 +2911,10 @@ md_entry_splitting_smoke_check(hid_t orig_fapl, const char *env_h5_drvr, bool vf haddr_t p2_addr; H5F_t * f = NULL; const uint32_t max_lag = 5; + char s[256]; - TESTING("%sMetadata Entry Splitting Smoke Check", vfd_swmr_mode ? "VFD SWMR " : ""); + HDsprintf(s, "%sMetadata Entry Splitting Smoke Check", vfd_swmr_mode ? "VFD SWMR " : ""); + TESTING(s); h5_fixname(namebase, orig_fapl, filename, sizeof(filename)); @@ -3202,8 +3206,10 @@ md_entry_splitting_boundary_test(hid_t orig_fapl, const char *env_h5_drvr, bool haddr_t first_page_addr = HADDR_UNDEF; haddr_t start_addr = HADDR_UNDEF; size_t test_len; + char s[256]; - TESTING("%sMetadata Entry Splitting Boundary Test", vfd_swmr_mode ? "VFD SWMR " : ""); + HDsprintf(s, "%sMetadata Entry Splitting Boundary Test", vfd_swmr_mode ? "VFD SWMR " : ""); + TESTING(s); h5_fixname(namebase, orig_fapl, filename, sizeof(filename)); diff --git a/test/testfiles/err_compat_1 b/test/testfiles/err_compat_1 index e588a8b..e0c4654 100644 --- a/test/testfiles/err_compat_1 +++ b/test/testfiles/err_compat_1 @@ -1,5 +1,5 @@ -Testing error API H5Eset/get_auto -Testing error API based on data I/O +Testing error API H5Eset/get_auto +Testing error API based on data I/O All error API tests passed. This program tests the Error API compatible with HDF5 version (number). There are supposed to be some error messages ********* Print error stack in HDF5 default way ********* diff --git a/test/testfiles/links_env.out b/test/testfiles/links_env.out index b9a9893..3f10fc6 100644 --- a/test/testfiles/links_env.out +++ b/test/testfiles/links_env.out @@ -1,3 +1,3 @@ -Testing external links via environment variable PASSED -Testing external links via environment variable (w/new group format) PASSED +Testing external links via environment variable PASSED +Testing external links via environment variable (w/new group format) PASSED All external Link (HDF5_EXT_PREFIX) tests passed. diff --git a/test/tfile.c b/test/tfile.c index 19263e8..d85d188 100644 --- a/test/tfile.c +++ b/test/tfile.c @@ -1452,6 +1452,7 @@ test_obj_count_and_id(hid_t fid1, hid_t fid2, hid_t did, hid_t gid1, hid_t gid2, case H5I_ERROR_MSG: case H5I_ERROR_STACK: case H5I_SPACE_SEL_ITER: + case H5I_EVENTSET: case H5I_NTYPES: default: ERROR("H5Fget_obj_ids"); diff --git a/test/trefer_deprec.c b/test/trefer_deprec.c index 24371ef..755df68 100644 --- a/test/trefer_deprec.c +++ b/test/trefer_deprec.c @@ -87,8 +87,11 @@ test_reference_params(void) /* Allocate write & read buffers */ wbuf = (hobj_ref_t *)HDmalloc(MAX(sizeof(unsigned), sizeof(hobj_ref_t)) * SPACE1_DIM1); + CHECK_PTR(wbuf, "HDmalloc"); rbuf = (hobj_ref_t *)HDmalloc(MAX(sizeof(unsigned), sizeof(hobj_ref_t)) * SPACE1_DIM1); + CHECK_PTR(rbuf, "HDmalloc"); tbuf = (hobj_ref_t *)HDmalloc(MAX(sizeof(unsigned), sizeof(hobj_ref_t)) * SPACE1_DIM1); + CHECK_PTR(tbuf, "HDmalloc"); /* Create file */ fid1 = H5Fcreate(FILE1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -269,8 +272,11 @@ test_reference_obj(void) /* Allocate write & read buffers */ wbuf = (hobj_ref_t *)HDmalloc(MAX(sizeof(unsigned), sizeof(hobj_ref_t)) * SPACE1_DIM1); + CHECK_PTR(wbuf, "HDmalloc"); rbuf = (hobj_ref_t *)HDmalloc(MAX(sizeof(unsigned), sizeof(hobj_ref_t)) * SPACE1_DIM1); + CHECK_PTR(rbuf, "HDmalloc"); tbuf = (hobj_ref_t *)HDmalloc(MAX(sizeof(unsigned), sizeof(hobj_ref_t)) * SPACE1_DIM1); + CHECK_PTR(tbuf, "HDmalloc"); /* Create file */ fid1 = H5Fcreate(FILE1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); diff --git a/test/trefstr.c b/test/trefstr.c index a3f568a..d0575ab 100644 --- a/test/trefstr.c +++ b/test/trefstr.c @@ -186,7 +186,7 @@ test_refstr_cmp(void) H5RS_str_t *rs1; /* Ref-counted string created */ H5RS_str_t *rs2; /* Ref-counted string created */ int cmp; /* Comparison value */ - ssize_t len; /* Length of string */ + size_t len; /* Length of string */ herr_t ret; /* Generic return value */ /* Output message about test being performed */ diff --git a/test/unlink.c b/test/unlink.c index 73e3b25..94bd035 100644 --- a/test/unlink.c +++ b/test/unlink.c @@ -1493,7 +1493,7 @@ test_create_unlink(const char *msg, hid_t fapl) char groupname[1024]; char filename[1024]; - TESTING("%s", msg); + TESTING(msg); /* Create file */ h5_fixname(FILENAME[3], fapl, filename, sizeof filename); diff --git a/test/use_common.c b/test/use_common.c index 0ea2c83..8f78f3b 100644 --- a/test/use_common.c +++ b/test/use_common.c @@ -322,10 +322,12 @@ write_uc_file(hbool_t tosend, hid_t file_id, options_t *opts) rank = H5Sget_simple_extent_ndims(f_sid); if (rank != UC_RANK) { HDfprintf(stderr, "rank(%d) of dataset does not match\n", rank); + HDfree(buffer); return -1; } if (H5Sget_simple_extent_dims(f_sid, dims, NULL) < 0) { HDfprintf(stderr, "H5Sget_simple_extent_dims got error\n"); + HDfree(buffer); return -1; } HDprintf("dataset rank %d, dimensions %llu x %llu x %llu\n", rank, (unsigned long long)(dims[0]), @@ -334,12 +336,14 @@ write_uc_file(hbool_t tosend, hid_t file_id, options_t *opts) if (dims[0] != 0 || dims[1] != memdims[1] || dims[2] != memdims[2]) { HDfprintf(stderr, "dataset is not empty. Got dims=(%llu,%llu,%llu)\n", (unsigned long long)dims[0], (unsigned long long)dims[1], (unsigned long long)dims[2]); + HDfree(buffer); return -1; } /* setup mem-space for buffer */ if ((m_sid = H5Screate_simple(rank, memdims, NULL)) < 0) { HDfprintf(stderr, "H5Screate_simple for memory failed\n"); + HDfree(buffer); return -1; } @@ -360,6 +364,7 @@ write_uc_file(hbool_t tosend, hid_t file_id, options_t *opts) if (opts->use_swmr) { if (H5Odisable_mdc_flushes(dsid) < 0) { HDfprintf(stderr, "H5Odisable_mdc_flushes failed\n"); + HDfree(buffer); return -1; } } @@ -368,12 +373,14 @@ write_uc_file(hbool_t tosend, hid_t file_id, options_t *opts) dims[0] = i + 1; if (H5Dset_extent(dsid, dims) < 0) { HDfprintf(stderr, "H5Dset_extent failed\n"); + HDfree(buffer); return -1; } /* Get the dataset's dataspace */ if ((f_sid = H5Dget_space(dsid)) < 0) { HDfprintf(stderr, "H5Dset_extent failed\n"); + HDfree(buffer); return -1; } @@ -381,12 +388,14 @@ write_uc_file(hbool_t tosend, hid_t file_id, options_t *opts) /* Choose the next plane to write */ if (H5Sselect_hyperslab(f_sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0) { HDfprintf(stderr, "Failed H5Sselect_hyperslab\n"); + HDfree(buffer); return -1; } /* Write plane to the dataset */ if (H5Dwrite(dsid, UC_DATATYPE, m_sid, f_sid, H5P_DEFAULT, buffer) < 0) { HDfprintf(stderr, "Failed H5Dwrite\n"); + HDfree(buffer); return -1; } @@ -394,6 +403,7 @@ write_uc_file(hbool_t tosend, hid_t file_id, options_t *opts) if (opts->use_swmr) { if (H5Oenable_mdc_flushes(dsid) < 0) { HDfprintf(stderr, "H5Oenable_mdc_flushes failed\n"); + HDfree(buffer); return -1; } } @@ -401,6 +411,7 @@ write_uc_file(hbool_t tosend, hid_t file_id, options_t *opts) /* flush file to make the just written plane available. */ if (H5Dflush(dsid) < 0) { HDfprintf(stderr, "Failed to H5Fflush file\n"); + HDfree(buffer); return -1; } } /* end for each plane to write */ @@ -488,10 +499,12 @@ read_uc_file(hbool_t towait, options_t *opts) rank = H5Sget_simple_extent_ndims(f_sid); if (rank != UC_RANK) { HDfprintf(stderr, "rank(%d) of dataset does not match\n", rank); + HDfree(buffer); return -1; } if (H5Sget_simple_extent_dims(f_sid, dims, NULL) < 0) { HDfprintf(stderr, "H5Sget_simple_extent_dims got error\n"); + HDfree(buffer); return -1; } HDprintf("dataset rank %d, dimensions %llu x %llu x %llu\n", rank, (unsigned long long)(dims[0]), @@ -502,12 +515,14 @@ read_uc_file(hbool_t towait, options_t *opts) (unsigned long long)dims[0], (unsigned long long)dims[1], (unsigned long long)dims[2]); HDfprintf(stderr, "But memdims=(%llu,%llu,%llu)\n", (unsigned long long)memdims[0], (unsigned long long)memdims[1], (unsigned long long)memdims[2]); + HDfree(buffer); return -1; } /* Setup mem-space for buffer */ if ((m_sid = H5Screate_simple(rank, memdims, NULL)) < 0) { HDfprintf(stderr, "H5Screate_simple for memory failed\n"); + HDfree(buffer); return -1; } @@ -533,6 +548,7 @@ read_uc_file(hbool_t towait, options_t *opts) HDprintf("."); if (loops_waiting_for_plane >= 30) { HDfprintf(stderr, "waited too long for new plane, quit.\n"); + HDfree(buffer); return -1; } } @@ -550,6 +566,7 @@ read_uc_file(hbool_t towait, options_t *opts) /* Get the dataset's dataspace */ if ((f_sid = H5Dget_space(dsid)) < 0) { HDfprintf(stderr, "H5Dget_space failed\n"); + HDfree(buffer); return -1; } @@ -557,12 +574,14 @@ read_uc_file(hbool_t towait, options_t *opts) /* Choose the next plane to read */ if (H5Sselect_hyperslab(f_sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0) { HDfprintf(stderr, "H5Sselect_hyperslab failed\n"); + HDfree(buffer); return -1; } /* Read the plane from the dataset */ if (H5Dread(dsid, UC_DATATYPE, m_sid, f_sid, H5P_DEFAULT, buffer) < 0) { HDfprintf(stderr, "H5Dread failed\n"); + HDfree(buffer); return -1; } @@ -594,12 +613,14 @@ read_uc_file(hbool_t towait, options_t *opts) f_sid = H5Dget_space(dsid); /* Get filespace handle first. */ if (H5Sget_simple_extent_dims(f_sid, dims, NULL) < 0) { HDfprintf(stderr, "H5Sget_simple_extent_dims got error\n"); + HDfree(buffer); return -1; } } /* end while (expecting more planes to read) */ if (H5Fclose(fid) < 0) { HDfprintf(stderr, "H5Fclose failed\n"); + HDfree(buffer); return -1; } diff --git a/testpar/t_file.c b/testpar/t_file.c index f18c447..9554052 100644 --- a/testpar/t_file.c +++ b/testpar/t_file.c @@ -954,9 +954,8 @@ test_file_properties(void) void test_delete(void) { - hid_t fid = H5I_INVALID_HID; /* HDF5 file ID */ - hid_t fapl_id = H5I_INVALID_HID; /* File access plist */ - hbool_t is_coll; + hid_t fid = H5I_INVALID_HID; /* HDF5 file ID */ + hid_t fapl_id = H5I_INVALID_HID; /* File access plist */ const char *filename = NULL; MPI_Comm comm = MPI_COMM_WORLD; MPI_Info info = MPI_INFO_NULL; diff --git a/testpar/t_span_tree.c b/testpar/t_span_tree.c index 7c2763c..518741d 100644 --- a/testpar/t_span_tree.c +++ b/testpar/t_span_tree.c @@ -35,6 +35,8 @@ #include "H5private.h" #include "testphdf5.h" +#define LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG 0 + static void coll_write_test(int chunk_factor); static void coll_read_test(void); @@ -1431,8 +1433,7 @@ lower_dim_size_comp_test__verify_data(uint32_t *buf_ptr, *------------------------------------------------------------------------- */ -#define LDSCT_DS_RANK 5 -#define LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG 0 +#define LDSCT_DS_RANK 5 static void lower_dim_size_comp_test__run_test(const int chunk_edge_size, const hbool_t use_collective_io, diff --git a/tools/lib/io_timer.h b/tools/lib/io_timer.h index 75db660..0b0f0bb 100644 --- a/tools/lib/io_timer.h +++ b/tools/lib/io_timer.h @@ -22,7 +22,7 @@ #include #endif -#ifdef H5_HAVE_WINSOCK2_H +#ifdef H5_HAVE_WIN32_API #include #endif -- cgit v0.12