From 3109f9e32378087d73fe9b0cd956e41efa1ca6cd Mon Sep 17 00:00:00 2001 From: David Young Date: Fri, 7 Feb 2020 16:34:01 -0600 Subject: Follow HDF5 conventions. --- src/H5TS.c | 119 +++++++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 89 insertions(+), 30 deletions(-) diff --git a/src/H5TS.c b/src/H5TS.c index 7a801e2..a3b7a14 100644 --- a/src/H5TS.c +++ b/src/H5TS.c @@ -39,26 +39,26 @@ H5TS_key_t H5TS_cancel_key_g; #ifndef H5_HAVE_WIN_THREADS -/* An h5_tid_t is a record of a thread identifier that is +/* An H5TS_tid_t is a record of a thread identifier that is * available for reuse. */ struct _tid; -typedef struct _tid h5_tid_t; +typedef struct _tid H5TS_tid_t; struct _tid { - h5_tid_t *next; + H5TS_tid_t *next; uint64_t id; }; /* Pointer to first free thread ID record or NULL. */ -static h5_tid_t *tid_next_free = NULL; -static uint64_t tid_next_id = 0; +static H5TS_tid_t *H5TS_tid_next_free = NULL; +static uint64_t H5TS_tid_next_id = 0; -/* Mutual exclusion for access to tid_next_free and tid_next_id. */ -static pthread_mutex_t tid_mtx; +/* Mutual exclusion for access to H5TS_tid_next_free and H5TS_tid_next_id. */ +static pthread_mutex_t H5TS_tid_mtx; /* Key for thread-local storage of the thread ID. */ -static H5TS_key_t tid_key; +static H5TS_key_t H5TS_tid_key; #endif /* H5_HAVE_WIN_THREADS */ @@ -93,29 +93,61 @@ H5TS_key_destructor(void *key_val) #ifndef H5_HAVE_WIN_THREADS -/* When a thread shuts down, put its ID record on the free list. */ +/*-------------------------------------------------------------------------- + * NAME + * H5TS_tid_destructor + * + * USAGE + * H5TS_tid_destructor() + * + * RETURNS + * + * DESCRIPTION + * When a thread shuts down, put its ID record on the free list. + * + * PROGRAMMER: Rusty Shackleford + * February 7, 2020 + * + *-------------------------------------------------------------------------- + */ static void -tid_destructor(void *_v) +H5TS_tid_destructor(void *_v) { - h5_tid_t *tid = _v; + H5TS_tid_t *tid = _v; if (tid == NULL) return; /* XXX I can use mutexes in destructors, right? */ /* TBD use an atomic CAS */ - pthread_mutex_lock(&tid_mtx); - tid->next = tid_next_free; - tid_next_free = tid; - pthread_mutex_unlock(&tid_mtx); + pthread_mutex_lock(&H5TS_tid_mtx); + tid->next = H5TS_tid_next_free; + H5TS_tid_next_free = tid; + pthread_mutex_unlock(&H5TS_tid_mtx); } -/* Initialize for integer thread identifiers. */ +/*-------------------------------------------------------------------------- + * NAME + * H5TS_tid_init + * + * USAGE + * H5TS_tid_init() + * + * RETURNS + * + * DESCRIPTION + * Initialize for integer thread identifiers. + * + * PROGRAMMER: Dale Alvin Gribble + * February 7, 2020 + * + *-------------------------------------------------------------------------- + */ static void -tid_init(void) +H5TS_tid_init(void) { - pthread_mutex_init(&tid_mtx, NULL); - pthread_key_create(&tid_key, tid_destructor); + pthread_mutex_init(&H5TS_tid_mtx, NULL); + pthread_key_create(&H5TS_tid_key, H5TS_tid_destructor); } /* Return an integer identifier, ID, for the current thread satisfying the @@ -129,11 +161,38 @@ tid_init(void) * ID 0 is reserved. H5TS_thread_id() returns 0 if the library was not built * with thread safety or if an error prevents it from assigning an ID. */ +/*-------------------------------------------------------------------------- + * NAME + * H5TS_thread_id + * + * USAGE + * uint64_t id = H5TS_thread_id() + * + * RETURNS + * Return an integer identifier, ID, for the current thread. + * + * DESCRIPTION + * The ID satisfies the following properties: + * + * 1 1 <= ID <= UINT64_MAX + * 2 ID is constant over the thread's lifetime. + * 3 No two threads share an ID during their lifetimes. + * 4 A thread's ID is available for reuse as soon as it is joined. + * + * ID 0 is reserved. H5TS_thread_id() returns 0 if the library was not + * built with thread safety or if an error prevents it from assigning an + * ID. + * + * PROGRAMMER: Rusty Shackleford + * February 7, 2020 + * + *-------------------------------------------------------------------------- + */ uint64_t H5TS_thread_id(void) { - h5_tid_t *tid = pthread_getspecific(tid_key); - h5_tid_t proto_tid; + H5TS_tid_t *tid = pthread_getspecific(H5TS_tid_key); + H5TS_tid_t proto_tid; /* An ID is already assigned. */ if (tid != NULL) @@ -146,14 +205,14 @@ H5TS_thread_id(void) * point `tid` at `proto_tid` if we need to allocate some * memory. */ - pthread_mutex_lock(&tid_mtx); - if ((tid = tid_next_free) != NULL) - tid_next_free = tid->next; - else if (tid_next_id != UINT64_MAX) { + pthread_mutex_lock(&H5TS_tid_mtx); + if ((tid = H5TS_tid_next_free) != NULL) + H5TS_tid_next_free = tid->next; + else if (H5TS_tid_next_id != UINT64_MAX) { tid = &proto_tid; - tid->id = ++tid_next_id; + tid->id = ++H5TS_tid_next_id; } - pthread_mutex_unlock(&tid_mtx); + pthread_mutex_unlock(&H5TS_tid_mtx); /* If a prototype ID record was established, copy it to the heap. */ if (tid == &proto_tid) { @@ -168,8 +227,8 @@ H5TS_thread_id(void) * to it. */ tid->next = NULL; - if (pthread_setspecific(tid_key, tid) != 0) { - tid_destructor(tid); + if (pthread_setspecific(H5TS_tid_key, tid) != 0) { + H5TS_tid_destructor(tid); return 0; } @@ -213,7 +272,7 @@ H5TS_pthread_first_thread_init(void) H5_g.init_lock.lock_count = 0; /* Initialize integer thread identifiers. */ - tid_init(); + H5TS_tid_init(); /* initialize key for thread-specific error stacks */ pthread_key_create(&H5TS_errstk_key_g, H5TS_key_destructor); -- cgit v0.12 From 63c95faf49559ea66e3066427961095b69fdb213 Mon Sep 17 00:00:00 2001 From: David Young Date: Mon, 10 Feb 2020 17:24:04 -0600 Subject: Remove tongue-in-cheek credit for Rusty Shackleford and Dale Alvin Gribble. Delete the comment questioning whether pthread_mutex_lock is allowed in a key destructor, since pthread_key_create(3) provides the answer: There is no notion of a destructor-safe function. If an application does not call pthread_exit() from a signal handler, or if it blocks any signal whose handler may call pthread_exit() while calling async-unsafe functions, all functions may be safely called from destructors. Delete redundant comment. --- src/H5TS.c | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/src/H5TS.c b/src/H5TS.c index a3b7a14..dd6a850 100644 --- a/src/H5TS.c +++ b/src/H5TS.c @@ -105,9 +105,6 @@ H5TS_key_destructor(void *key_val) * DESCRIPTION * When a thread shuts down, put its ID record on the free list. * - * PROGRAMMER: Rusty Shackleford - * February 7, 2020 - * *-------------------------------------------------------------------------- */ static void @@ -118,7 +115,6 @@ H5TS_tid_destructor(void *_v) if (tid == NULL) return; - /* XXX I can use mutexes in destructors, right? */ /* TBD use an atomic CAS */ pthread_mutex_lock(&H5TS_tid_mtx); tid->next = H5TS_tid_next_free; @@ -138,9 +134,6 @@ H5TS_tid_destructor(void *_v) * DESCRIPTION * Initialize for integer thread identifiers. * - * PROGRAMMER: Dale Alvin Gribble - * February 7, 2020 - * *-------------------------------------------------------------------------- */ static void @@ -150,17 +143,6 @@ H5TS_tid_init(void) pthread_key_create(&H5TS_tid_key, H5TS_tid_destructor); } -/* Return an integer identifier, ID, for the current thread satisfying the - * following properties: - * - * 1 1 <= ID <= UINT64_MAX - * 2 ID is constant over the thread's lifetime. - * 3 No two threads share an ID during their lifetimes. - * 4 A thread's ID is available for reuse as soon as it is joined. - * - * ID 0 is reserved. H5TS_thread_id() returns 0 if the library was not built - * with thread safety or if an error prevents it from assigning an ID. - */ /*-------------------------------------------------------------------------- * NAME * H5TS_thread_id @@ -183,9 +165,6 @@ H5TS_tid_init(void) * built with thread safety or if an error prevents it from assigning an * ID. * - * PROGRAMMER: Rusty Shackleford - * February 7, 2020 - * *-------------------------------------------------------------------------- */ uint64_t -- cgit v0.12 From afdcac28b85d690eebc80ab568fa5266081baaaa Mon Sep 17 00:00:00 2001 From: vchoi Date: Mon, 23 Mar 2020 01:16:32 -0500 Subject: A fix in the cleaning up code for datatype when datatype initialization via H5D__init_type() fails. This is triggered by the tests for revised references when the libver bounds setting does not allow version 4 datatype message to be created. The test failure is abort core dumped. This is due to the datatype initialization fails before the datatype ID is registered. The datatype cleanup code should provide for the above situation. The code to fix the problem is the same as what is done in H5D__open_oid(). --- src/H5Dint.c | 14 +- test/trefer.c | 736 +++++++++++++++++++++++++++++++--------------------------- 2 files changed, 400 insertions(+), 350 deletions(-) diff --git a/src/H5Dint.c b/src/H5Dint.c index 1624f7b..173ae3f 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -1418,8 +1418,18 @@ done: HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, NULL, "unable to reset external file list info") if(new_dset->shared->space && H5S_close(new_dset->shared->space) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release dataspace") - if(new_dset->shared->type && H5I_dec_ref(new_dset->shared->type_id) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release datatype") + + if(new_dset->shared->type) { + if(new_dset->shared->type_id > 0) { + if(H5I_dec_ref(new_dset->shared->type_id) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release datatype") + } /* end if */ + else { + if(H5T_close_real(new_dset->shared->type) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release datatype") + } /* end else */ + } /* end if */ + if(H5F_addr_defined(new_dset->oloc.addr)) { if(H5O_dec_rc_by_loc(&(new_dset->oloc)) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, NULL, "unable to decrement refcount on newly created object") diff --git a/test/trefer.c b/test/trefer.c index 32caf5e..d399fef 100644 --- a/test/trefer.c +++ b/test/trefer.c @@ -631,173 +631,179 @@ test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high) CHECK(sid1, H5I_INVALID_HID, "H5Screate_simple"); /* Create a dataset */ - dset1 = H5Dcreate2(fid1, "Dataset1", H5T_STD_REF, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - CHECK(dset1, H5I_INVALID_HID, "H5Dcreate2"); + H5E_BEGIN_TRY { + dset1 = H5Dcreate2(fid1, "Dataset1", H5T_STD_REF, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + } H5E_END_TRY; + + if(dset1 < 0) { + VERIFY(libver_high <= H5F_LIBVER_V110, TRUE, "H5Dcreate2"); - /* Create references */ + ret = H5Sclose(sid1); + CHECK(ret, FAIL, "H5Sclose"); - /* Select 6x6 hyperslab for first reference */ - start[0] = 2; start[1] = 2; - stride[0] = 1; stride[1] = 1; - count[0] = 1; count[1] = 1; - block[0] = 6; block[1] = 6; - ret = H5Sselect_hyperslab(sid2, H5S_SELECT_SET, start, stride, count, block); - CHECK(ret, FAIL, "H5Sselect_hyperslab"); + ret = H5Sclose(sid2); + CHECK(ret, FAIL, "H5Sclose"); - ret = (int)H5Sget_select_npoints(sid2); - VERIFY(ret, 36, "H5Sget_select_npoints"); + ret = H5Pclose(fapl); + CHECK(ret, FAIL, "H5Pclose"); - /* Store first dataset region */ - ret = H5Rcreate_region(fid1, "/Dataset2", sid2, H5P_DEFAULT, &wbuf[0]); - CHECK(ret, FAIL, "H5Rcreate_region"); - ret = H5Rget_obj_type3(&wbuf[0], H5P_DEFAULT, &obj_type); - CHECK(ret, FAIL, "H5Rget_obj_type3"); - VERIFY(obj_type, H5O_TYPE_DATASET, "H5Rget_obj_type3"); + ret = H5Fclose(fid1); + CHECK(ret, FAIL, "H5Fclose"); + } else { - /* Select sequence of ten points for second reference */ - coord1[0][0] = 6; coord1[0][1] = 9; - coord1[1][0] = 2; coord1[1][1] = 2; - coord1[2][0] = 8; coord1[2][1] = 4; - coord1[3][0] = 1; coord1[3][1] = 6; - coord1[4][0] = 2; coord1[4][1] = 8; - coord1[5][0] = 3; coord1[5][1] = 2; - coord1[6][0] = 0; coord1[6][1] = 4; - coord1[7][0] = 9; coord1[7][1] = 0; - coord1[8][0] = 7; coord1[8][1] = 1; - coord1[9][0] = 3; coord1[9][1] = 3; - ret = H5Sselect_elements(sid2, H5S_SELECT_SET, (size_t)POINT1_NPOINTS, (const hsize_t *)coord1); - CHECK(ret, FAIL, "H5Sselect_elements"); + CHECK(dset1, H5I_INVALID_HID, "H5Dcreate2"); - ret = (int)H5Sget_select_npoints(sid2); - VERIFY(ret, SPACE2_DIM2, "H5Sget_select_npoints"); + /* Create references */ - /* Store second dataset region */ - ret = H5Rcreate_region(fid1, "/Dataset2", sid2, H5P_DEFAULT, &wbuf[1]); - CHECK(ret, FAIL, "H5Rcreate_region"); + /* Select 6x6 hyperslab for first reference */ + start[0] = 2; start[1] = 2; + stride[0] = 1; stride[1] = 1; + count[0] = 1; count[1] = 1; + block[0] = 6; block[1] = 6; + ret = H5Sselect_hyperslab(sid2, H5S_SELECT_SET, start, stride, count, block); + CHECK(ret, FAIL, "H5Sselect_hyperslab"); - /* Select unlimited hyperslab for third reference */ - start[0] = 1; - start[1] = 8; - stride[0] = 4; - stride[1] = 1; - count[0] = H5S_UNLIMITED; - count[1] = 1; - block[0] = 2; - block[1] = 2; - ret = H5Sselect_hyperslab(sid2, H5S_SELECT_SET, start, stride, count, block); - CHECK(ret, FAIL, "H5Sselect_hyperslab"); + ret = (int)H5Sget_select_npoints(sid2); + VERIFY(ret, 36, "H5Sget_select_npoints"); - hssize_ret = H5Sget_select_npoints(sid2); - VERIFY(hssize_ret, (hssize_t)H5S_UNLIMITED, "H5Sget_select_npoints"); + /* Store first dataset region */ + ret = H5Rcreate_region(fid1, "/Dataset2", sid2, H5P_DEFAULT, &wbuf[0]); + CHECK(ret, FAIL, "H5Rcreate_region"); + ret = H5Rget_obj_type3(&wbuf[0], H5P_DEFAULT, &obj_type); + CHECK(ret, FAIL, "H5Rget_obj_type3"); + VERIFY(obj_type, H5O_TYPE_DATASET, "H5Rget_obj_type3"); - /* Store third dataset region */ - ret = H5Rcreate_region(fid1, "/Dataset2", sid2, H5P_DEFAULT, &wbuf[2]); - CHECK(ret, FAIL, "H5Rcreate_region"); + /* Select sequence of ten points for second reference */ + coord1[0][0] = 6; coord1[0][1] = 9; + coord1[1][0] = 2; coord1[1][1] = 2; + coord1[2][0] = 8; coord1[2][1] = 4; + coord1[3][0] = 1; coord1[3][1] = 6; + coord1[4][0] = 2; coord1[4][1] = 8; + coord1[5][0] = 3; coord1[5][1] = 2; + coord1[6][0] = 0; coord1[6][1] = 4; + coord1[7][0] = 9; coord1[7][1] = 0; + coord1[8][0] = 7; coord1[8][1] = 1; + coord1[9][0] = 3; coord1[9][1] = 3; + ret = H5Sselect_elements(sid2, H5S_SELECT_SET, (size_t)POINT1_NPOINTS, (const hsize_t *)coord1); + CHECK(ret, FAIL, "H5Sselect_elements"); - ret = H5Rget_obj_type3(&wbuf[2], H5P_DEFAULT, &obj_type); - CHECK(ret, FAIL, "H5Rget_obj_type3"); - VERIFY(obj_type, H5O_TYPE_DATASET, "H5Rget_obj_type3"); + ret = (int)H5Sget_select_npoints(sid2); + VERIFY(ret, SPACE2_DIM2, "H5Sget_select_npoints"); - /* Store fourth dataset region */ - ret = H5Rcreate_region(fid1, "/Dataset2", sid2, H5P_DEFAULT, &wbuf[3]); - CHECK(ret, FAIL, "H5Rcreate_region"); + /* Store second dataset region */ + ret = H5Rcreate_region(fid1, "/Dataset2", sid2, H5P_DEFAULT, &wbuf[1]); + CHECK(ret, FAIL, "H5Rcreate_region"); - /* Write selection to disk */ - H5E_BEGIN_TRY { - ret = H5Dwrite(dset1, H5T_STD_REF, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf); - } H5E_END_TRY; + /* Select unlimited hyperslab for third reference */ + start[0] = 1; + start[1] = 8; + stride[0] = 4; + stride[1] = 1; + count[0] = H5S_UNLIMITED; + count[1] = 1; + block[0] = 2; + block[1] = 2; + ret = H5Sselect_hyperslab(sid2, H5S_SELECT_SET, start, stride, count, block); + CHECK(ret, FAIL, "H5Sselect_hyperslab"); - if(libver_high < H5F_LIBVER_V110) - VERIFY(ret, FAIL, "H5Dwrite"); - else - CHECK(ret, FAIL, "H5Dwrite"); + hssize_ret = H5Sget_select_npoints(sid2); + VERIFY(hssize_ret, (hssize_t)H5S_UNLIMITED, "H5Sget_select_npoints"); - /* - * Store a dataset region reference which will not get written to disk - */ + /* Store third dataset region */ + ret = H5Rcreate_region(fid1, "/Dataset2", sid2, H5P_DEFAULT, &wbuf[2]); + CHECK(ret, FAIL, "H5Rcreate_region"); - /* Create the dataspace of the region references */ - space_NA = H5Screate_simple(1, dims_NA, NULL); - CHECK(space_NA, H5I_INVALID_HID, "H5Screate_simple"); + ret = H5Rget_obj_type3(&wbuf[2], H5P_DEFAULT, &obj_type); + CHECK(ret, FAIL, "H5Rget_obj_type3"); + VERIFY(obj_type, H5O_TYPE_DATASET, "H5Rget_obj_type3"); - /* Create the dataset and write the region references to it */ - dset_NA = H5Dcreate2(fid1, "DS_NA", H5T_STD_REF, space_NA, H5P_DEFAULT, - H5P_DEFAULT, H5P_DEFAULT); - CHECK(dset_NA, H5I_INVALID_HID, "H5Dcreate"); + /* Store fourth dataset region */ + ret = H5Rcreate_region(fid1, "/Dataset2", sid2, H5P_DEFAULT, &wbuf[3]); + CHECK(ret, FAIL, "H5Rcreate_region"); - /* Close and release resources for undefined region reference tests */ - ret = H5Dclose(dset_NA); - CHECK(ret, FAIL, "H5Dclose"); - ret = H5Sclose(space_NA); - CHECK(ret, FAIL, "H5Sclose"); + /* Write selection to disk */ + ret = H5Dwrite(dset1, H5T_STD_REF, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf); - /* Close disk dataspace */ - ret = H5Sclose(sid1); - CHECK(ret, FAIL, "H5Sclose"); + /* + * Store a dataset region reference which will not get written to disk + */ - /* Close Dataset */ - ret = H5Dclose(dset1); - CHECK(ret, FAIL, "H5Dclose"); + /* Create the dataspace of the region references */ + space_NA = H5Screate_simple(1, dims_NA, NULL); + CHECK(space_NA, H5I_INVALID_HID, "H5Screate_simple"); - /* Close uint8 dataset dataspace */ - ret = H5Sclose(sid2); - CHECK(ret, FAIL, "H5Sclose"); + /* Create the dataset and write the region references to it */ + dset_NA = H5Dcreate2(fid1, "DS_NA", H5T_STD_REF, space_NA, H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT); + CHECK(dset_NA, H5I_INVALID_HID, "H5Dcreate"); - /* Close file */ - ret = H5Fclose(fid1); - CHECK(ret, FAIL, "H5Fclose"); + /* Close and release resources for undefined region reference tests */ + ret = H5Dclose(dset_NA); + CHECK(ret, FAIL, "H5Dclose"); + ret = H5Sclose(space_NA); + CHECK(ret, FAIL, "H5Sclose"); - /* Re-open the file */ - fid1 = H5Fopen(FILE_REF_REG, H5F_ACC_RDWR, fapl); - CHECK(fid1, H5I_INVALID_HID, "H5Fopen"); + /* Close disk dataspace */ + ret = H5Sclose(sid1); + CHECK(ret, FAIL, "H5Sclose"); + + /* Close Dataset */ + ret = H5Dclose(dset1); + CHECK(ret, FAIL, "H5Dclose"); - /* - * Start the test of an undefined reference - */ + /* Close uint8 dataset dataspace */ + ret = H5Sclose(sid2); + CHECK(ret, FAIL, "H5Sclose"); - /* Open the dataset of the undefined references */ - dset_NA = H5Dopen2(fid1, "DS_NA", H5P_DEFAULT); - CHECK(dset_NA, H5I_INVALID_HID, "H5Dopen2"); + /* Close file */ + ret = H5Fclose(fid1); + CHECK(ret, FAIL, "H5Fclose"); - /* Read the data */ - ret = H5Dread(dset_NA, H5T_STD_REF, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata_NA); - CHECK(ret, FAIL, "H5Dread"); + /* Re-open the file */ + fid1 = H5Fopen(FILE_REF_REG, H5F_ACC_RDWR, fapl); + CHECK(fid1, H5I_INVALID_HID, "H5Fopen"); - /* - * Dereference an undefined reference (should fail) - */ - H5E_BEGIN_TRY { - dset2 = H5Ropen_object(&rdata_NA[0], H5P_DEFAULT, H5P_DEFAULT); - } H5E_END_TRY; - VERIFY(dset2, H5I_INVALID_HID, "H5Ropen_object"); + /* + * Start the test of an undefined reference + */ - /* Close and release resources. */ - ret = H5Dclose(dset_NA); - CHECK(ret, FAIL, "H5Dclose"); + /* Open the dataset of the undefined references */ + dset_NA = H5Dopen2(fid1, "DS_NA", H5P_DEFAULT); + CHECK(dset_NA, H5I_INVALID_HID, "H5Dopen2"); - /* This close should fail since H5Ropen_object never created - * the id of the referenced object. */ - H5E_BEGIN_TRY { - ret = H5Dclose(dset2); - } H5E_END_TRY; - VERIFY(ret, FAIL, "H5Dclose"); + /* Read the data */ + ret = H5Dread(dset_NA, H5T_STD_REF, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata_NA); + CHECK(ret, FAIL, "H5Dread"); - /* - * End the test of an undefined reference - */ + /* + * Dereference an undefined reference (should fail) + */ + H5E_BEGIN_TRY { + dset2 = H5Ropen_object(&rdata_NA[0], H5P_DEFAULT, H5P_DEFAULT); + } H5E_END_TRY; + VERIFY(dset2, H5I_INVALID_HID, "H5Ropen_object"); - /* Open the dataset */ - dset1 = H5Dopen2(fid1, "/Dataset1", H5P_DEFAULT); - CHECK(dset1, H5I_INVALID_HID, "H5Dopen2"); + /* Close and release resources. */ + ret = H5Dclose(dset_NA); + CHECK(ret, FAIL, "H5Dclose"); - /* Read selection from disk */ - H5E_BEGIN_TRY { - ret = H5Dread(dset1, H5T_STD_REF, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf); - } H5E_END_TRY; + /* This close should fail since H5Ropen_object never created + * the id of the referenced object. */ + H5E_BEGIN_TRY { + ret = H5Dclose(dset2); + } H5E_END_TRY; + VERIFY(ret, FAIL, "H5Dclose"); - if(libver_high < H5F_LIBVER_V110) - CHECK(ret, FAIL, "H5Dread"); - else { + /* + * End the test of an undefined reference + */ + + /* Open the dataset */ + dset1 = H5Dopen2(fid1, "/Dataset1", H5P_DEFAULT); + CHECK(dset1, H5I_INVALID_HID, "H5Dopen2"); + + /* Read selection from disk */ + ret = H5Dread(dset1, H5T_STD_REF, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf); CHECK(ret, FAIL, "H5Dread"); /* Try to open objects */ @@ -832,7 +838,10 @@ test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high) VERIFY(ret, 36, "H5Sget_select_npoints"); ret = (int)H5Sget_select_hyper_nblocks(sid2); VERIFY(ret, 1, "H5Sget_select_hyper_nblocks"); - coords = (hsize_t *)HDmalloc((size_t)ret * SPACE2_RANK * sizeof(hsize_t) * 2); /* allocate space for the hyperslab blocks */ + + /* allocate space for the hyperslab blocks */ + coords = (hsize_t *)HDmalloc((size_t)ret * SPACE2_RANK * sizeof(hsize_t) * 2); + ret = H5Sget_select_hyper_blocklist(sid2, (hsize_t)0, (hsize_t)ret, coords); CHECK(ret, FAIL, "H5Sget_select_hyper_blocklist"); VERIFY(coords[0], 2, "Hyperslab Coordinates"); @@ -860,7 +869,10 @@ test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high) VERIFY(ret, SPACE2_DIM2, "H5Sget_select_npoints"); ret = (int)H5Sget_select_elem_npoints(sid2); VERIFY(ret, SPACE2_DIM2, "H5Sget_select_elem_npoints"); - coords = (hsize_t *)HDmalloc((size_t)ret * SPACE2_RANK * sizeof(hsize_t)); /* allocate space for the element points */ + + /* allocate space for the element points */ + coords = (hsize_t *)HDmalloc((size_t)ret * SPACE2_RANK * sizeof(hsize_t)); + ret = H5Sget_select_elem_pointlist(sid2, (hsize_t)0, (hsize_t)ret, coords); CHECK(ret, FAIL, "H5Sget_select_elem_pointlist"); VERIFY(coords[0], coord1[0][0], "Element Coordinates"); @@ -935,35 +947,34 @@ test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high) } H5E_END_TRY; VERIFY(ret, FAIL, "H5Rget_obj_type3"); } /* end for */ - } - /* Close Dataset */ - ret = H5Dclose(dset1); - CHECK(ret, FAIL, "H5Dclose"); + /* Close Dataset */ + ret = H5Dclose(dset1); + CHECK(ret, FAIL, "H5Dclose"); - /* Close dataset access property list */ - ret = H5Pclose(dapl_id); - CHECK(ret, FAIL, "H5Pclose"); + /* Close dataset access property list */ + ret = H5Pclose(dapl_id); + CHECK(ret, FAIL, "H5Pclose"); - /* Close file */ - ret = H5Fclose(fid1); - CHECK(ret, FAIL, "H5Fclose"); + /* Close file */ + ret = H5Fclose(fid1); + CHECK(ret, FAIL, "H5Fclose"); - /* Destroy references */ - for(j = 0; j < SPACE1_DIM1; j++) { - ret = H5Rdestroy(&wbuf[j]); - CHECK(ret, FAIL, "H5Rdestroy"); - if(libver_high >= H5F_LIBVER_V110) { + /* Destroy references */ + for(j = 0; j < SPACE1_DIM1; j++) { + ret = H5Rdestroy(&wbuf[j]); + CHECK(ret, FAIL, "H5Rdestroy"); ret = H5Rdestroy(&rbuf[j]); CHECK(ret, FAIL, "H5Rdestroy"); } - } - /* Free memory buffers */ - HDfree(wbuf); - HDfree(rbuf); - HDfree(dwbuf); - HDfree(drbuf); + /* Free memory buffers */ + HDfree(wbuf); + HDfree(rbuf); + HDfree(dwbuf); + HDfree(drbuf); + + } } /* test_reference_region() */ /**************************************************************** @@ -1054,226 +1065,255 @@ test_reference_region_1D(H5F_libver_t libver_low, H5F_libver_t libver_high) CHECK(sid1, H5I_INVALID_HID, "H5Screate_simple"); /* Create a dataset */ - dset1 = H5Dcreate2(fid1, "Dataset1", H5T_STD_REF, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - CHECK(ret, FAIL, "H5Dcreate2"); + H5E_BEGIN_TRY { + dset1 = H5Dcreate2(fid1, "Dataset1", H5T_STD_REF, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + } H5E_END_TRY; - /* Create references */ + if(dset1 < 0) { - /* Select 15 2x1 hyperslabs for first reference */ - start[0] = 2; - stride[0] = 5; - count[0] = 15; - block[0] = 2; - ret = H5Sselect_hyperslab(sid3, H5S_SELECT_SET, start, stride, count, block); - CHECK(ret, FAIL, "H5Sselect_hyperslab"); + VERIFY(libver_high <= H5F_LIBVER_V110, TRUE, "H5Dcreate2"); - ret = (int)H5Sget_select_npoints(sid3); - VERIFY(ret, (block[0] * count[0]), "H5Sget_select_npoints"); + ret = H5Sclose(sid1); + CHECK(ret, FAIL, "H5Sclose"); - /* Store first dataset region */ - ret = H5Rcreate_region(fid1, "/Dataset2", sid3, H5P_DEFAULT, &wbuf[0]); - CHECK(ret, FAIL, "H5Rcreate_region"); - ret = H5Rget_obj_type3(&wbuf[0], H5P_DEFAULT, &obj_type); - CHECK(ret, FAIL, "H5Rget_obj_type3"); - VERIFY(obj_type, H5O_TYPE_DATASET, "H5Rget_obj_type3"); + ret = H5Sclose(sid3); + CHECK(ret, FAIL, "H5Sclose"); - /* Select sequence of ten points for second reference */ - coord1[0][0] = 16; - coord1[1][0] = 22; - coord1[2][0] = 38; - coord1[3][0] = 41; - coord1[4][0] = 52; - coord1[5][0] = 63; - coord1[6][0] = 70; - coord1[7][0] = 89; - coord1[8][0] = 97; - coord1[9][0] = 03; - ret = H5Sselect_elements(sid3, H5S_SELECT_SET, (size_t)POINT1_NPOINTS, (const hsize_t *)coord1); - CHECK(ret, FAIL, "H5Sselect_elements"); + ret = H5Pclose(fapl); + CHECK(ret, FAIL, "H5Pclose"); - ret = (int)H5Sget_select_npoints(sid3); - VERIFY(ret, POINT1_NPOINTS, "H5Sget_select_npoints"); + ret = H5Fclose(fid1); + CHECK(ret, FAIL, "H5Fclose"); - /* Store second dataset region */ - ret = H5Rcreate_region(fid1, "/Dataset2", sid3, H5P_DEFAULT, &wbuf[1]); - CHECK(ret, FAIL, "H5Rcreate_region"); + } else { - /* Write selection to disk */ - ret = H5Dwrite(dset1, H5T_STD_REF, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf); - CHECK(ret, FAIL, "H5Dwrite"); + CHECK(ret, FAIL, "H5Dcreate2"); - /* Close disk dataspace */ - ret = H5Sclose(sid1); - CHECK(ret, FAIL, "H5Sclose"); + /* Create references */ - /* Close Dataset */ - ret = H5Dclose(dset1); - CHECK(ret, FAIL, "H5Dclose"); + /* Select 15 2x1 hyperslabs for first reference */ + start[0] = 2; + stride[0] = 5; + count[0] = 15; + block[0] = 2; + ret = H5Sselect_hyperslab(sid3, H5S_SELECT_SET, start, stride, count, block); + CHECK(ret, FAIL, "H5Sselect_hyperslab"); - /* Close uint8 dataset dataspace */ - ret = H5Sclose(sid3); - CHECK(ret, FAIL, "H5Sclose"); + ret = (int)H5Sget_select_npoints(sid3); + VERIFY(ret, (block[0] * count[0]), "H5Sget_select_npoints"); - /* Close file */ - ret = H5Fclose(fid1); - CHECK(ret, FAIL, "H5Fclose"); + /* Store first dataset region */ + ret = H5Rcreate_region(fid1, "/Dataset2", sid3, H5P_DEFAULT, &wbuf[0]); + CHECK(ret, FAIL, "H5Rcreate_region"); + ret = H5Rget_obj_type3(&wbuf[0], H5P_DEFAULT, &obj_type); + CHECK(ret, FAIL, "H5Rget_obj_type3"); + VERIFY(obj_type, H5O_TYPE_DATASET, "H5Rget_obj_type3"); - /* Re-open the file */ - fid1 = H5Fopen(FILE_REF_REG_1D, H5F_ACC_RDWR, fapl); - CHECK(fid1, H5I_INVALID_HID, "H5Fopen"); + /* Select sequence of ten points for second reference */ + coord1[0][0] = 16; + coord1[1][0] = 22; + coord1[2][0] = 38; + coord1[3][0] = 41; + coord1[4][0] = 52; + coord1[5][0] = 63; + coord1[6][0] = 70; + coord1[7][0] = 89; + coord1[8][0] = 97; + coord1[9][0] = 03; + ret = H5Sselect_elements(sid3, H5S_SELECT_SET, (size_t)POINT1_NPOINTS, (const hsize_t *)coord1); + CHECK(ret, FAIL, "H5Sselect_elements"); + + ret = (int)H5Sget_select_npoints(sid3); + VERIFY(ret, POINT1_NPOINTS, "H5Sget_select_npoints"); + + /* Store second dataset region */ + ret = H5Rcreate_region(fid1, "/Dataset2", sid3, H5P_DEFAULT, &wbuf[1]); + CHECK(ret, FAIL, "H5Rcreate_region"); - /* Open the dataset */ - dset1 = H5Dopen2(fid1, "/Dataset1", H5P_DEFAULT); - CHECK(dset1, H5I_INVALID_HID, "H5Dopen2"); + /* Write selection to disk */ + ret = H5Dwrite(dset1, H5T_STD_REF, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf); + CHECK(ret, FAIL, "H5Dwrite"); - /* Read selection from disk */ - ret = H5Dread(dset1, H5T_STD_REF, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf); - CHECK(ret, FAIL, "H5Dread"); + /* Close disk dataspace */ + ret = H5Sclose(sid1); + CHECK(ret, FAIL, "H5Sclose"); - /* Try to open objects */ - dset3 = H5Ropen_object(&rbuf[0], H5P_DEFAULT, dapl_id); - CHECK(dset3, H5I_INVALID_HID, "H5Ropen_object"); + /* Close Dataset */ + ret = H5Dclose(dset1); + CHECK(ret, FAIL, "H5Dclose"); - /* Check what H5Rget_obj_type3 function returns */ - ret = H5Rget_obj_type3(&rbuf[0], H5P_DEFAULT, &obj_type); - CHECK(ret, FAIL, "H5Rget_obj_type3"); - VERIFY(obj_type, H5O_TYPE_DATASET, "H5Rget_obj_type3"); + /* Close uint8 dataset dataspace */ + ret = H5Sclose(sid3); + CHECK(ret, FAIL, "H5Sclose"); - /* Check information in referenced dataset */ - sid1 = H5Dget_space(dset3); - CHECK(sid1, H5I_INVALID_HID, "H5Dget_space"); + /* Close file */ + ret = H5Fclose(fid1); + CHECK(ret, FAIL, "H5Fclose"); - ret = (int)H5Sget_simple_extent_npoints(sid1); - VERIFY(ret, SPACE3_DIM1, "H5Sget_simple_extent_npoints"); + /* Re-open the file */ + fid1 = H5Fopen(FILE_REF_REG_1D, H5F_ACC_RDWR, fapl); + CHECK(fid1, H5I_INVALID_HID, "H5Fopen"); - /* Read from disk */ - ret = H5Dread(dset3, H5T_STD_U8LE, H5S_ALL, H5S_ALL, H5P_DEFAULT, drbuf); - CHECK(ret, FAIL, "H5Dread"); + /* Open the dataset */ + dset1 = H5Dopen2(fid1, "/Dataset1", H5P_DEFAULT); + CHECK(dset1, H5I_INVALID_HID, "H5Dopen2"); - for(tu8 = (uint8_t *)drbuf, i = 0; i < SPACE3_DIM1; i++, tu8++) - VERIFY(*tu8, (uint8_t)(i * 3), "Data"); - - /* Get the hyperslab selection */ - sid3 = H5Ropen_region(&rbuf[0], H5P_DEFAULT, H5P_DEFAULT); - CHECK(sid3, H5I_INVALID_HID, "H5Ropen_region"); - - /* Verify correct hyperslab selected */ - ret = (int)H5Sget_select_npoints(sid3); - VERIFY(ret, 30, "H5Sget_select_npoints"); - ret = (int)H5Sget_select_hyper_nblocks(sid3); - VERIFY(ret, 15, "H5Sget_select_hyper_nblocks"); - coords = (hsize_t *)HDmalloc((size_t)ret * SPACE3_RANK * sizeof(hsize_t) * 2); /* allocate space for the hyperslab blocks */ - ret = H5Sget_select_hyper_blocklist(sid3, (hsize_t)0, (hsize_t)ret, coords); - CHECK(ret, FAIL, "H5Sget_select_hyper_blocklist"); - VERIFY(coords[0], 2, "Hyperslab Coordinates"); - VERIFY(coords[1], 3, "Hyperslab Coordinates"); - VERIFY(coords[2], 7, "Hyperslab Coordinates"); - VERIFY(coords[3], 8, "Hyperslab Coordinates"); - VERIFY(coords[4], 12, "Hyperslab Coordinates"); - VERIFY(coords[5], 13, "Hyperslab Coordinates"); - VERIFY(coords[6], 17, "Hyperslab Coordinates"); - VERIFY(coords[7], 18, "Hyperslab Coordinates"); - VERIFY(coords[8], 22, "Hyperslab Coordinates"); - VERIFY(coords[9], 23, "Hyperslab Coordinates"); - VERIFY(coords[10], 27, "Hyperslab Coordinates"); - VERIFY(coords[11], 28, "Hyperslab Coordinates"); - VERIFY(coords[12], 32, "Hyperslab Coordinates"); - VERIFY(coords[13], 33, "Hyperslab Coordinates"); - VERIFY(coords[14], 37, "Hyperslab Coordinates"); - VERIFY(coords[15], 38, "Hyperslab Coordinates"); - VERIFY(coords[16], 42, "Hyperslab Coordinates"); - VERIFY(coords[17], 43, "Hyperslab Coordinates"); - VERIFY(coords[18], 47, "Hyperslab Coordinates"); - VERIFY(coords[19], 48, "Hyperslab Coordinates"); - VERIFY(coords[20], 52, "Hyperslab Coordinates"); - VERIFY(coords[21], 53, "Hyperslab Coordinates"); - VERIFY(coords[22], 57, "Hyperslab Coordinates"); - VERIFY(coords[23], 58, "Hyperslab Coordinates"); - VERIFY(coords[24], 62, "Hyperslab Coordinates"); - VERIFY(coords[25], 63, "Hyperslab Coordinates"); - VERIFY(coords[26], 67, "Hyperslab Coordinates"); - VERIFY(coords[27], 68, "Hyperslab Coordinates"); - VERIFY(coords[28], 72, "Hyperslab Coordinates"); - VERIFY(coords[29], 73, "Hyperslab Coordinates"); - HDfree(coords); - ret = H5Sget_select_bounds(sid3, low, high); - CHECK(ret, FAIL, "H5Sget_select_bounds"); - VERIFY(low[0], 2, "Selection Bounds"); - VERIFY(high[0], 73, "Selection Bounds"); - - /* Close region space */ - ret = H5Sclose(sid3); - CHECK(ret, FAIL, "H5Sclose"); + /* Read selection from disk */ + ret = H5Dread(dset1, H5T_STD_REF, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf); + CHECK(ret, FAIL, "H5Dread"); - /* Get the element selection */ - sid3 = H5Ropen_region(&rbuf[1], H5P_DEFAULT, H5P_DEFAULT); - CHECK(sid3, H5I_INVALID_HID, "H5Ropen_region"); - - /* Verify correct elements selected */ - ret = (int)H5Sget_select_npoints(sid3); - VERIFY(ret, 10, "H5Sget_select_npoints"); - ret = (int)H5Sget_select_elem_npoints(sid3); - VERIFY(ret, 10, "H5Sget_select_elem_npoints"); - coords = (hsize_t *)HDmalloc((size_t)ret * SPACE3_RANK * sizeof(hsize_t)); /* allocate space for the element points */ - ret = H5Sget_select_elem_pointlist(sid3, (hsize_t)0, (hsize_t)ret, coords); - CHECK(ret, FAIL, "H5Sget_select_elem_pointlist"); - VERIFY(coords[0], coord1[0][0], "Element Coordinates"); - VERIFY(coords[1], coord1[1][0], "Element Coordinates"); - VERIFY(coords[2], coord1[2][0], "Element Coordinates"); - VERIFY(coords[3], coord1[3][0], "Element Coordinates"); - VERIFY(coords[4], coord1[4][0], "Element Coordinates"); - VERIFY(coords[5], coord1[5][0], "Element Coordinates"); - VERIFY(coords[6], coord1[6][0], "Element Coordinates"); - VERIFY(coords[7], coord1[7][0], "Element Coordinates"); - VERIFY(coords[8], coord1[8][0], "Element Coordinates"); - VERIFY(coords[9], coord1[9][0], "Element Coordinates"); - HDfree(coords); - ret = H5Sget_select_bounds(sid3, low, high); - CHECK(ret, FAIL, "H5Sget_select_bounds"); - VERIFY(low[0], 3, "Selection Bounds"); - VERIFY(high[0], 97, "Selection Bounds"); - - /* Close region space */ - ret = H5Sclose(sid3); - CHECK(ret, FAIL, "H5Sclose"); + /* Try to open objects */ + dset3 = H5Ropen_object(&rbuf[0], H5P_DEFAULT, dapl_id); + CHECK(dset3, H5I_INVALID_HID, "H5Ropen_object"); - /* Close first space */ - ret = H5Sclose(sid1); - CHECK(ret, FAIL, "H5Sclose"); + /* Check what H5Rget_obj_type3 function returns */ + ret = H5Rget_obj_type3(&rbuf[0], H5P_DEFAULT, &obj_type); + CHECK(ret, FAIL, "H5Rget_obj_type3"); + VERIFY(obj_type, H5O_TYPE_DATASET, "H5Rget_obj_type3"); - /* Close dereferenced Dataset */ - ret = H5Dclose(dset3); - CHECK(ret, FAIL, "H5Dclose"); + /* Check information in referenced dataset */ + sid1 = H5Dget_space(dset3); + CHECK(sid1, H5I_INVALID_HID, "H5Dget_space"); - /* Close Dataset */ - ret = H5Dclose(dset1); - CHECK(ret, FAIL, "H5Dclose"); + ret = (int)H5Sget_simple_extent_npoints(sid1); + VERIFY(ret, SPACE3_DIM1, "H5Sget_simple_extent_npoints"); - /* Close dataset access property list */ - ret = H5Pclose(dapl_id); - CHECK(ret, FAIL, "H5Pclose"); + /* Read from disk */ + ret = H5Dread(dset3, H5T_STD_U8LE, H5S_ALL, H5S_ALL, H5P_DEFAULT, drbuf); + CHECK(ret, FAIL, "H5Dread"); - /* Close file access property list */ - ret = H5Pclose(fapl); - CHECK(ret, FAIL, "H5Pclose"); + for(tu8 = (uint8_t *)drbuf, i = 0; i < SPACE3_DIM1; i++, tu8++) + VERIFY(*tu8, (uint8_t)(i * 3), "Data"); - /* Close file */ - ret = H5Fclose(fid1); - CHECK(ret, FAIL, "H5Fclose"); + /* Get the hyperslab selection */ + sid3 = H5Ropen_region(&rbuf[0], H5P_DEFAULT, H5P_DEFAULT); + CHECK(sid3, H5I_INVALID_HID, "H5Ropen_region"); - /* Destroy references */ - for(i = 0; i < 2; i++) { - ret = H5Rdestroy(&wbuf[i]); - CHECK(ret, FAIL, "H5Rdestroy"); - ret = H5Rdestroy(&rbuf[i]); - CHECK(ret, FAIL, "H5Rdestroy"); - } + /* Verify correct hyperslab selected */ + ret = (int)H5Sget_select_npoints(sid3); + VERIFY(ret, 30, "H5Sget_select_npoints"); + ret = (int)H5Sget_select_hyper_nblocks(sid3); + VERIFY(ret, 15, "H5Sget_select_hyper_nblocks"); - /* Free memory buffers */ - HDfree(wbuf); - HDfree(rbuf); - HDfree(dwbuf); - HDfree(drbuf); + /* allocate space for the hyperslab blocks */ + coords = (hsize_t *)HDmalloc((size_t)ret * SPACE3_RANK * sizeof(hsize_t) * 2); + + ret = H5Sget_select_hyper_blocklist(sid3, (hsize_t)0, (hsize_t)ret, coords); + CHECK(ret, FAIL, "H5Sget_select_hyper_blocklist"); + VERIFY(coords[0], 2, "Hyperslab Coordinates"); + VERIFY(coords[1], 3, "Hyperslab Coordinates"); + VERIFY(coords[2], 7, "Hyperslab Coordinates"); + VERIFY(coords[3], 8, "Hyperslab Coordinates"); + VERIFY(coords[4], 12, "Hyperslab Coordinates"); + VERIFY(coords[5], 13, "Hyperslab Coordinates"); + VERIFY(coords[6], 17, "Hyperslab Coordinates"); + VERIFY(coords[7], 18, "Hyperslab Coordinates"); + VERIFY(coords[8], 22, "Hyperslab Coordinates"); + VERIFY(coords[9], 23, "Hyperslab Coordinates"); + VERIFY(coords[10], 27, "Hyperslab Coordinates"); + VERIFY(coords[11], 28, "Hyperslab Coordinates"); + VERIFY(coords[12], 32, "Hyperslab Coordinates"); + VERIFY(coords[13], 33, "Hyperslab Coordinates"); + VERIFY(coords[14], 37, "Hyperslab Coordinates"); + VERIFY(coords[15], 38, "Hyperslab Coordinates"); + VERIFY(coords[16], 42, "Hyperslab Coordinates"); + VERIFY(coords[17], 43, "Hyperslab Coordinates"); + VERIFY(coords[18], 47, "Hyperslab Coordinates"); + VERIFY(coords[19], 48, "Hyperslab Coordinates"); + VERIFY(coords[20], 52, "Hyperslab Coordinates"); + VERIFY(coords[21], 53, "Hyperslab Coordinates"); + VERIFY(coords[22], 57, "Hyperslab Coordinates"); + VERIFY(coords[23], 58, "Hyperslab Coordinates"); + VERIFY(coords[24], 62, "Hyperslab Coordinates"); + VERIFY(coords[25], 63, "Hyperslab Coordinates"); + VERIFY(coords[26], 67, "Hyperslab Coordinates"); + VERIFY(coords[27], 68, "Hyperslab Coordinates"); + VERIFY(coords[28], 72, "Hyperslab Coordinates"); + VERIFY(coords[29], 73, "Hyperslab Coordinates"); + HDfree(coords); + ret = H5Sget_select_bounds(sid3, low, high); + CHECK(ret, FAIL, "H5Sget_select_bounds"); + VERIFY(low[0], 2, "Selection Bounds"); + VERIFY(high[0], 73, "Selection Bounds"); + + /* Close region space */ + ret = H5Sclose(sid3); + CHECK(ret, FAIL, "H5Sclose"); + + /* Get the element selection */ + sid3 = H5Ropen_region(&rbuf[1], H5P_DEFAULT, H5P_DEFAULT); + CHECK(sid3, H5I_INVALID_HID, "H5Ropen_region"); + + /* Verify correct elements selected */ + ret = (int)H5Sget_select_npoints(sid3); + VERIFY(ret, 10, "H5Sget_select_npoints"); + ret = (int)H5Sget_select_elem_npoints(sid3); + VERIFY(ret, 10, "H5Sget_select_elem_npoints"); + + /* allocate space for the element points */ + coords = (hsize_t *)HDmalloc((size_t)ret * SPACE3_RANK * sizeof(hsize_t)); + + ret = H5Sget_select_elem_pointlist(sid3, (hsize_t)0, (hsize_t)ret, coords); + CHECK(ret, FAIL, "H5Sget_select_elem_pointlist"); + VERIFY(coords[0], coord1[0][0], "Element Coordinates"); + VERIFY(coords[1], coord1[1][0], "Element Coordinates"); + VERIFY(coords[2], coord1[2][0], "Element Coordinates"); + VERIFY(coords[3], coord1[3][0], "Element Coordinates"); + VERIFY(coords[4], coord1[4][0], "Element Coordinates"); + VERIFY(coords[5], coord1[5][0], "Element Coordinates"); + VERIFY(coords[6], coord1[6][0], "Element Coordinates"); + VERIFY(coords[7], coord1[7][0], "Element Coordinates"); + VERIFY(coords[8], coord1[8][0], "Element Coordinates"); + VERIFY(coords[9], coord1[9][0], "Element Coordinates"); + HDfree(coords); + ret = H5Sget_select_bounds(sid3, low, high); + CHECK(ret, FAIL, "H5Sget_select_bounds"); + VERIFY(low[0], 3, "Selection Bounds"); + VERIFY(high[0], 97, "Selection Bounds"); + + /* Close region space */ + ret = H5Sclose(sid3); + CHECK(ret, FAIL, "H5Sclose"); + + /* Close first space */ + ret = H5Sclose(sid1); + CHECK(ret, FAIL, "H5Sclose"); + + /* Close dereferenced Dataset */ + ret = H5Dclose(dset3); + CHECK(ret, FAIL, "H5Dclose"); + + /* Close Dataset */ + ret = H5Dclose(dset1); + CHECK(ret, FAIL, "H5Dclose"); + + /* Close dataset access property list */ + ret = H5Pclose(dapl_id); + CHECK(ret, FAIL, "H5Pclose"); + + /* Close file access property list */ + ret = H5Pclose(fapl); + CHECK(ret, FAIL, "H5Pclose"); + + /* Close file */ + ret = H5Fclose(fid1); + CHECK(ret, FAIL, "H5Fclose"); + + /* Destroy references */ + for(i = 0; i < 2; i++) { + ret = H5Rdestroy(&wbuf[i]); + CHECK(ret, FAIL, "H5Rdestroy"); + ret = H5Rdestroy(&rbuf[i]); + CHECK(ret, FAIL, "H5Rdestroy"); + } + + /* Free memory buffers */ + HDfree(wbuf); + HDfree(rbuf); + HDfree(dwbuf); + HDfree(drbuf); + + } } /* test_reference_region_1D() */ /**************************************************************** @@ -2828,7 +2868,7 @@ test_reference(void) for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { /* Invalid combinations, just continue */ - if(high <= H5F_LIBVER_V110 || high < low) + if(high == H5F_LIBVER_EARLIEST || high < low) continue; test_reference_region(low, high); /* Test basic H5R dataset region reference code */ -- cgit v0.12 From 0da53027d995b7ea670394b13bbe09c95e90b73d Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Fri, 27 Mar 2020 17:10:38 -0500 Subject: TRILAB-192 add comparable clang flags --- MANIFEST | 4 ++ config/clang-warnings/developer-general | 4 ++ config/clang-warnings/error-general | 79 ++++++++++++++++++++++++++++++ config/clang-warnings/general | 26 ++++++++++ config/clang-warnings/no-developer-general | 1 + config/cmake/HDFCompilerFlags.cmake | 14 ++++-- config/cmake/libhdf5.settings.cmake.in | 4 +- release_docs/RELEASE.txt | 2 + 8 files changed, 129 insertions(+), 5 deletions(-) create mode 100644 config/clang-warnings/developer-general create mode 100644 config/clang-warnings/error-general create mode 100644 config/clang-warnings/general create mode 100644 config/clang-warnings/no-developer-general diff --git a/MANIFEST b/MANIFEST index 04fbfdd..7078128 100644 --- a/MANIFEST +++ b/MANIFEST @@ -143,6 +143,10 @@ ./config/solaris #warnings files for both autotools and CMake +./config/clang-warnings/developer-general +./config/clang-warnings/error-general +./config/clang-warnings/general +./config/clang-warnings/no-developer-general ./config/gnu-warnings/4.2-4.3 ./config/gnu-warnings/4.2-4.4 ./config/gnu-warnings/4.2-4.6 diff --git a/config/clang-warnings/developer-general b/config/clang-warnings/developer-general new file mode 100644 index 0000000..db434e4 --- /dev/null +++ b/config/clang-warnings/developer-general @@ -0,0 +1,4 @@ +# NOTE: -Wformat-nonliteral added back in here (from being disabled in +-Wformat-nonliteral +-Wmissing-noreturn +-Wswitch-enum diff --git a/config/clang-warnings/error-general b/config/clang-warnings/error-general new file mode 100644 index 0000000..a9aa516 --- /dev/null +++ b/config/clang-warnings/error-general @@ -0,0 +1,79 @@ +# +# HDF5 code should not trigger the following warnings under any +# circumstances, so ask the compiler to treat them as errors: +# +-Werror=bad-function-cast +-Werror=implicit-function-declaration +-Werror=incompatible-pointer-types +-Werror=missing-declarations +-Werror=packed +-Werror=shadow +-Werror=sometimes-uninitialized +-Werror=switch +# +#-Werror=discarded-qualifiers +# +# +# NOTE: File Driver files are not compatible with these warnings as errors +# H5FDdirect.c,H5FDmpio.c,H5FDros3.c, +# -Werror=unused-function +# +-Wunused-function +# +# H5FDdrvr_module.h +# -Werror=unused-variable +# +-Wunused-variable +# +# H5VLpassthru.c +# -Werror=unused-parameter +# +-Wunused-parameter +# +# +# +# NOTE: Tools files are not compatible with these warnings as errors +# lib/h5tools.c +# -Werror=cast-align +# +-Wcast-align +# +# lib/h5tools_utils.c +# -Werror=unused-parameter +# +# +# NOTE: JNI files are not compatible with these warnings as errors +# jni/h5pDCPLImp.c,jni/nativeData.c,jni/h5util.c,jni/h5rImp.c +# jni/h5sImp.c,jni/h5tImp.c +# -Werror=cast-align +# jni/h5util.c +# -Werror=format(-overflow) +# +-Wformat +# +# +#Examples and tests do not use the same set of extensive warning flags as libraries +# Here is a list of tests and examples that have issues with the stricter warnings as error +# +# NOTE: Test files are not compatible with these warnings as errors +# thread_id.c, +# -Werror=unused-function +# dsets.c +# -Werror=unused-parameter +# +# +# NOTE: Examples files are not compatible with these warnings as errors +# h5_vds-eiger.c,h5_vds-exclim.c,h5_vds.c,h5_vds-exc.c,h5_vds-percival-unlim-maxmin.c +# h5_vds-percival.c,h5_read.c,h5_rdwt.c,h5_mount.c,h5_extend.c,h5_extend_write.c +# h5_write.c,h5_vds-simpleIO.c,h5_ref2reg_deprec.c,h5_crtgrp.c,h5_select.c +# h5_vds-percival-unlim.c,h5_crtatt.c,h5_group.c,h5_attribute.c,h5_crtdat.c +# h5_reference_deprec.c +# h5_rdwt.c,h5_crtgrp.c,h5_crtatt.c,h5_crtdat.c +# -Werror=strict-prototypes +# h5_rdwt.c,h5_crtgrp.c,h5_crtatt.c,h5_crtdat.c +# -Werror=old-style-definition +# h5_vds-exclim.c,h5_vds.c,h5_vds-exc.c, +# -Werror=unused-variable +# h5_elink_unix2win.c,h5_extlink.c,h5_attribute.c +# -Werror=unused-parameter + diff --git a/config/clang-warnings/general b/config/clang-warnings/general new file mode 100644 index 0000000..f0c9b93 --- /dev/null +++ b/config/clang-warnings/general @@ -0,0 +1,26 @@ +# general clang warnings flags +-Wall +-Warray-bounds +-Wcast-qual +-Wconversion +-Wdouble-promotion +-Wextra +-Wformat=2 +-Wframe-larger-than=16384 +-Wimplicit-fallthrough +# +# NOTE: Due to the divergence in the C and C++, we're dropping support for +# compiling the C library with a C++ compiler and dropping the -Wc++-compat +# warning. +# +-Wno-c++-compat +# +# NOTE: Disable the -Wformat-nonliteral from -Wformat=2 here and re-add +# it to the developer flags. +# +-Wno-format-nonliteral +-Wnull-dereference +-Wunused-const-variable +-Wwrite-strings +-Wpedantic +-Wvolatile-register-var diff --git a/config/clang-warnings/no-developer-general b/config/clang-warnings/no-developer-general new file mode 100644 index 0000000..2f4e0c5 --- /dev/null +++ b/config/clang-warnings/no-developer-general @@ -0,0 +1 @@ +-Wmissing-noreturn diff --git a/config/cmake/HDFCompilerFlags.cmake b/config/cmake/HDFCompilerFlags.cmake index 5faffc2..03c6936 100644 --- a/config/cmake/HDFCompilerFlags.cmake +++ b/config/cmake/HDFCompilerFlags.cmake @@ -105,7 +105,7 @@ endif () # CDash is configured to only allow 3000 warnings, so # break into groups (from the config/gnu-flags file) #----------------------------------------------------------------------------- -if (NOT MSVC AND CMAKE_COMPILER_IS_GNUCC) +if (NOT MSVC) if (${CMAKE_SYSTEM_NAME} MATCHES "SunOS") list (APPEND HDF5_CMAKE_C_FLAGS "-erroff=%none -DBSD_COMP") else () @@ -137,6 +137,12 @@ if (NOT MSVC AND CMAKE_COMPILER_IS_GNUCC) # gcc automatically inlines based on the optimization level # this is just a failsafe list (APPEND H5_CFLAGS0 "-finline-functions") + elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang") + ADD_H5_FLAGS (HDF5_CMAKE_C_FLAGS "${HDF5_SOURCE_DIR}/config/clang-warnings/general") + message (STATUS "CMAKE_C_FLAGS_GENERAL=${HDF5_CMAKE_C_FLAGS}") + ADD_H5_FLAGS (H5_CFLAGS0 "${HDF5_SOURCE_DIR}/config/clang-warnings/error-general") + elseif (CMAKE_C_COMPILER_ID STREQUAL "PGI") + list (APPEND HDF5_CMAKE_C_FLAGS "-Minform=inform") endif () endif () @@ -151,10 +157,14 @@ if (NOT MSVC AND CMAKE_COMPILER_IS_GNUCC) list (APPEND H5_CFLAGS0 "-Winline -Wreorder -Wport -Wstrict-aliasing") elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU") ADD_H5_FLAGS (H5_CFLAGS0 "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-general") + elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang") + ADD_H5_FLAGS (H5_CFLAGS0 "${HDF5_SOURCE_DIR}/config/clang-warnings/developer-general") endif () else () if (CMAKE_C_COMPILER_ID STREQUAL "GNU") ADD_H5_FLAGS (H5_CFLAGS0 "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-general") + elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang") + ADD_H5_FLAGS (H5_CFLAGS0 "${HDF5_SOURCE_DIR}/config/clang-warnings/no-developer-general") endif () endif () @@ -265,8 +275,6 @@ if (NOT MSVC AND CMAKE_COMPILER_IS_GNUCC) if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 9.0) ADD_H5_FLAGS (H5_CFLAGS4 "${HDF5_SOURCE_DIR}/config/gnu-warnings/9") endif () -elseif (CMAKE_C_COMPILER_ID STREQUAL "PGI") - list (APPEND HDF5_CMAKE_C_FLAGS "-Minform=inform") endif () #----------------------------------------------------------------------------- diff --git a/config/cmake/libhdf5.settings.cmake.in b/config/cmake/libhdf5.settings.cmake.in index 8397d68..292eaca 100644 --- a/config/cmake/libhdf5.settings.cmake.in +++ b/config/cmake/libhdf5.settings.cmake.in @@ -38,7 +38,7 @@ Languages: H5_CPPFLAGS: @H5_CPPFLAGS@ AM_CPPFLAGS: @AM_CPPFLAGS@ CFLAGS: @CMAKE_C_FLAGS@ - H5_CFLAGS: @H5_CFLAGS@ + H5_CFLAGS: @HDF5_CMAKE_C_FLAGS@ AM_CFLAGS: @AM_CFLAGS@ Shared C Library: @H5_ENABLE_SHARED_LIB@ Static C Library: @H5_ENABLE_STATIC_LIB@ @@ -54,7 +54,7 @@ Languages: C++: @HDF5_BUILD_CPP_LIB@ @BUILD_CXX_CONDITIONAL_TRUE@ C++ Compiler: @CMAKE_CXX_COMPILER@ @CMAKE_CXX_COMPILER_VERSION@ @BUILD_CXX_CONDITIONAL_TRUE@ C++ Flags: @CMAKE_CXX_FLAGS@ -@BUILD_CXX_CONDITIONAL_TRUE@ H5 C++ Flags: @H5_CXXFLAGS@ +@BUILD_CXX_CONDITIONAL_TRUE@ H5 C++ Flags: @HDF5_CMAKE_CXX_FLAGS@ @BUILD_CXX_CONDITIONAL_TRUE@ AM C++ Flags: @AM_CXXFLAGS@ @BUILD_CXX_CONDITIONAL_TRUE@ Shared C++ Library: @H5_ENABLE_SHARED_LIB@ @BUILD_CXX_CONDITIONAL_TRUE@ Static C++ Library: @H5_ENABLE_STATIC_LIB@ diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index 5451e85..ff1d99b 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -60,6 +60,8 @@ New Features GNU C warnings flags were moved to files in a config sub-folder named gnu-warnings. Flags that only are available for a specific version of the compiler are in files named with that version. + Clang C warnings flags were moved to files in a config sub-folder + named clang-warnings. There are flags in named "error-xxx" files with warnings that may be promoted to errors. Some source files may still need fixes. -- cgit v0.12 From d2a75d211d08a1f4ffb6ee22970fabcea0e25758 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Sun, 29 Mar 2020 07:51:35 -0500 Subject: TRILAB-192 remove comment --- config/clang-warnings/developer-general | 1 - 1 file changed, 1 deletion(-) diff --git a/config/clang-warnings/developer-general b/config/clang-warnings/developer-general index db434e4..aa8c32e 100644 --- a/config/clang-warnings/developer-general +++ b/config/clang-warnings/developer-general @@ -1,4 +1,3 @@ -# NOTE: -Wformat-nonliteral added back in here (from being disabled in -Wformat-nonliteral -Wmissing-noreturn -Wswitch-enum -- cgit v0.12 From 9676029742f18aaae37dd48947bc1faf23406169 Mon Sep 17 00:00:00 2001 From: Jordan Henderson Date: Sun, 29 Mar 2020 12:37:14 -0500 Subject: Fix latent bug in h5repack options file reading Add 'enable-error-stack' option to h5format_convert --- tools/src/h5format_convert/h5format_convert.c | 95 ++++++++++++++------------- tools/src/h5repack/h5repack_main.c | 2 + tools/test/h5format_convert/testh5fc.sh.in | 2 +- 3 files changed, 53 insertions(+), 46 deletions(-) diff --git a/tools/src/h5format_convert/h5format_convert.c b/tools/src/h5format_convert/h5format_convert.c index 01e7fe0..ae72ea9 100644 --- a/tools/src/h5format_convert/h5format_convert.c +++ b/tools/src/h5format_convert/h5format_convert.c @@ -42,13 +42,13 @@ static int verbose_g = 0; static const char *s_opts = "hVvd:n"; static struct long_options l_opts[] = { { "help", no_arg, 'h' }, - { "hel", no_arg, 'h'}, - { "he", no_arg, 'h'}, + { "hel", no_arg, 'h'}, + { "he", no_arg, 'h'}, { "version", no_arg, 'V' }, - { "version", no_arg, 'V' }, - { "versio", no_arg, 'V' }, - { "versi", no_arg, 'V' }, - { "vers", no_arg, 'V' }, + { "version", no_arg, 'V' }, + { "versio", no_arg, 'V' }, + { "versi", no_arg, 'V' }, + { "vers", no_arg, 'V' }, { "verbose", no_arg, 'v' }, { "verbos", no_arg, 'v' }, { "verbo", no_arg, 'v' }, @@ -60,6 +60,7 @@ static struct long_options l_opts[] = { { "noop", no_arg, 'n' }, { "noo", no_arg, 'n' }, { "no", no_arg, 'n' }, + { "enable-error-stack", no_arg, 'E' }, { NULL, 0, '\0' } }; @@ -120,55 +121,59 @@ parse_command_line(int argc, const char **argv) /* no arguments */ if (argc == 1) { usage(h5tools_getprogname()); - h5tools_setstatus(EXIT_FAILURE); + h5tools_setstatus(EXIT_FAILURE); goto error; } /* parse command line options */ while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) { - switch((char) opt) { - case 'h': - usage(h5tools_getprogname()); - h5tools_setstatus(EXIT_SUCCESS); - goto error; - - case 'V': - print_version(h5tools_getprogname()); - h5tools_setstatus(EXIT_SUCCESS); - goto error; - - case 'v': - verbose_g = TRUE; - break; - - case 'd': /* -d dname */ - if(opt_arg != NULL && *opt_arg) - dname_g = HDstrdup(opt_arg); - if(dname_g == NULL) { - h5tools_setstatus(EXIT_FAILURE); - error_msg("No dataset name\n", opt_arg); - usage(h5tools_getprogname()); - goto error; - } - dset_g = TRUE; - break; - - case 'n': /* -n */ - noop_g = TRUE; - break; - - default: - h5tools_setstatus(EXIT_FAILURE); - usage(h5tools_getprogname()); - goto error; - break; - } /* switch */ + switch((char) opt) { + case 'h': + usage(h5tools_getprogname()); + h5tools_setstatus(EXIT_SUCCESS); + goto error; + + case 'V': + print_version(h5tools_getprogname()); + h5tools_setstatus(EXIT_SUCCESS); + goto error; + + case 'v': + verbose_g = TRUE; + break; + + case 'd': /* -d dname */ + if(opt_arg != NULL && *opt_arg) + dname_g = HDstrdup(opt_arg); + if(dname_g == NULL) { + h5tools_setstatus(EXIT_FAILURE); + error_msg("No dataset name\n", opt_arg); + usage(h5tools_getprogname()); + goto error; + } + dset_g = TRUE; + break; + + case 'n': /* -n */ + noop_g = TRUE; + break; + + case 'E': + enable_error_stack = 1; + break; + + default: + h5tools_setstatus(EXIT_FAILURE); + usage(h5tools_getprogname()); + goto error; + break; + } /* switch */ } /* while */ if (argc <= opt_ind) { error_msg("missing file name\n"); usage(h5tools_getprogname()); - h5tools_setstatus(EXIT_FAILURE); + h5tools_setstatus(EXIT_FAILURE); goto error; } diff --git a/tools/src/h5repack/h5repack_main.c b/tools/src/h5repack/h5repack_main.c index 44b4b6c..f0a94ab 100644 --- a/tools/src/h5repack/h5repack_main.c +++ b/tools/src/h5repack/h5repack_main.c @@ -311,6 +311,8 @@ int read_info(const char *filename, pack_opt_t *options) /* cycle until end of file reached */ while (1) { + if (EOF == fscanf(fp, "%9s", stype)) + break; /* Info indicator must be for layout or filter */ if (HDstrcmp(stype,"-l") && HDstrcmp(stype, "-f")) { diff --git a/tools/test/h5format_convert/testh5fc.sh.in b/tools/test/h5format_convert/testh5fc.sh.in index 2cdd445..d780a3d 100644 --- a/tools/test/h5format_convert/testh5fc.sh.in +++ b/tools/test/h5format_convert/testh5fc.sh.in @@ -483,7 +483,7 @@ TOOLTEST_OUT h5fc_v_n_all.ddl h5fc_non_v3.h5 -v -n # # # h5format_convert -v h5fc_err_level.h5 (error encountered in converting the dataset) -TOOLTEST_MASK_OUT h5fc_v_err.ddl h5fc_err_level.h5 -v +TOOLTEST_MASK_OUT h5fc_v_err.ddl h5fc_err_level.h5 -v --enable-error-stack # # # -- cgit v0.12 From 2dfc047bc4aca7c13bccf44da97bff026cbbf5a6 Mon Sep 17 00:00:00 2001 From: Gerd Heber Date: Sun, 29 Mar 2020 16:04:58 -0500 Subject: Fix for HDFFV-11065. --- tools/src/h5ls/h5ls.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/src/h5ls/h5ls.c b/tools/src/h5ls/h5ls.c index 6c48d6e..f46d70a 100644 --- a/tools/src/h5ls/h5ls.c +++ b/tools/src/h5ls/h5ls.c @@ -3006,6 +3006,8 @@ main(int argc, const char *argv[]) } else if (!HDstrncmp(argv[argno], "--s3-cred=", (size_t)10)) { #ifdef H5_HAVE_ROS3_VFD + char const *start = NULL; + start = strchr(argv[argno], '='); if (start == NULL) { HDfprintf(rawerrorstream, "Error: Unable to parse null credentials tuple\n" -- cgit v0.12 From b1533616f28996983ec505fff8f62edf3dd820b3 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Tue, 31 Mar 2020 16:58:24 -0700 Subject: Minor renaming in the tools code. --- tools/lib/h5tools.c | 110 +++++++++++++++++++------------------ tools/lib/h5tools.h | 18 +++--- tools/libtest/h5tools_test_utils.c | 10 ++-- tools/src/h5dump/h5dump.c | 14 ++--- tools/src/h5ls/h5ls.c | 14 ++--- tools/src/h5repack/h5repack_main.c | 32 +++++------ tools/src/h5stat/h5stat.c | 14 ++--- 7 files changed, 107 insertions(+), 105 deletions(-) diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c index 6f95457..a975f4c 100644 --- a/tools/lib/h5tools.c +++ b/tools/lib/h5tools.c @@ -446,20 +446,20 @@ h5tools_set_error_file(const char *fname, int is_bin) *------------------------------------------------------------------------- */ static herr_t -h5tools_set_vfd_fapl(hid_t fapl, h5tools_get_fapl_info_t *get_info) +h5tools_set_vfd_fapl(hid_t fapl, h5tools_fapl_info_t *fapl_info) { herr_t ret_value = SUCCEED; - switch (get_info->get_type) { + switch (fapl_info->type) { /* Currently, only retrieving a VFD by name is supported */ - case GET_VFD_BY_NAME: + case VFD_BY_NAME: /* Determine which driver the user wants to open the file with */ - if (!HDstrcmp(get_info->u.name, drivernames[SEC2_VFD_IDX])) { + if (!HDstrcmp(fapl_info->u.name, drivernames[SEC2_VFD_IDX])) { /* SEC2 Driver */ if (H5Pset_fapl_sec2(fapl) < 0) H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_sec2 failed"); } - else if (!HDstrcmp(get_info->u.name, drivernames[DIRECT_VFD_IDX])) { + else if (!HDstrcmp(fapl_info->u.name, drivernames[DIRECT_VFD_IDX])) { #ifdef H5_HAVE_DIRECT /* Direct Driver */ if (H5Pset_fapl_direct(fapl, 1024, 4096, 8 * 4096) < 0) @@ -468,31 +468,31 @@ h5tools_set_vfd_fapl(hid_t fapl, h5tools_get_fapl_info_t *get_info) H5TOOLS_GOTO_ERROR(FAIL, "Direct VFD is not enabled"); #endif } - else if (!HDstrcmp(get_info->u.name, drivernames[LOG_VFD_IDX])) { + else if (!HDstrcmp(fapl_info->u.name, drivernames[LOG_VFD_IDX])) { unsigned long long log_flags = H5FD_LOG_LOC_IO | H5FD_LOG_ALLOC; /* Log Driver */ if (H5Pset_fapl_log(fapl, NULL, log_flags, (size_t) 0) < 0) H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_sec2 failed"); } - else if (!HDstrcmp(get_info->u.name, drivernames[WINDOWS_VFD_IDX])) { + else if (!HDstrcmp(fapl_info->u.name, drivernames[WINDOWS_VFD_IDX])) { #ifdef H5_HAVE_WINDOWS #else H5TOOLS_GOTO_ERROR(FAIL, "Windows VFD is not enabled"); #endif } - else if (!HDstrcmp(get_info->u.name, drivernames[STDIO_VFD_IDX])) { + else if (!HDstrcmp(fapl_info->u.name, drivernames[STDIO_VFD_IDX])) { /* Stdio Driver */ if (H5Pset_fapl_stdio(fapl) < 0) H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_stdio failed"); } - else if (!HDstrcmp(get_info->u.name, drivernames[CORE_VFD_IDX])) { + else if (!HDstrcmp(fapl_info->u.name, drivernames[CORE_VFD_IDX])) { /* Core Driver */ if (H5Pset_fapl_core(fapl, (size_t) H5_MB, TRUE) < 0) H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_stdio failed"); } - else if (!HDstrcmp(get_info->u.name, drivernames[FAMILY_VFD_IDX])) { + else if (!HDstrcmp(fapl_info->u.name, drivernames[FAMILY_VFD_IDX])) { /* FAMILY Driver */ /* Set member size to be 0 to indicate the current first member size @@ -501,17 +501,17 @@ h5tools_set_vfd_fapl(hid_t fapl, h5tools_get_fapl_info_t *get_info) if (H5Pset_fapl_family(fapl, (hsize_t) 0, H5P_DEFAULT) < 0) H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_family failed"); } - else if (!HDstrcmp(get_info->u.name, drivernames[SPLIT_VFD_IDX])) { + else if (!HDstrcmp(fapl_info->u.name, drivernames[SPLIT_VFD_IDX])) { /* SPLIT Driver */ if (H5Pset_fapl_split(fapl, "-m.h5", H5P_DEFAULT, "-r.h5", H5P_DEFAULT) < 0) H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_split failed"); } - else if (!HDstrcmp(get_info->u.name, drivernames[MULTI_VFD_IDX])) { + else if (!HDstrcmp(fapl_info->u.name, drivernames[MULTI_VFD_IDX])) { /* MULTI Driver */ if (H5Pset_fapl_multi(fapl, NULL, NULL, NULL, NULL, TRUE) < 0) H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_multi failed"); } - else if (!HDstrcmp(get_info->u.name, drivernames[MPIO_VFD_IDX])) { + else if (!HDstrcmp(fapl_info->u.name, drivernames[MPIO_VFD_IDX])) { #ifdef H5_HAVE_PARALLEL int mpi_initialized, mpi_finalized; @@ -529,21 +529,21 @@ h5tools_set_vfd_fapl(hid_t fapl, h5tools_get_fapl_info_t *get_info) H5TOOLS_GOTO_ERROR(FAIL, "MPI-I/O VFD is not enabled"); #endif /* H5_HAVE_PARALLEL */ } - else if (!HDstrcmp(get_info->u.name, drivernames[ROS3_VFD_IDX])) { + else if (!HDstrcmp(fapl_info->u.name, drivernames[ROS3_VFD_IDX])) { #ifdef H5_HAVE_ROS3_VFD - if (!get_info->info) + if (!fapl_info->info) H5TOOLS_GOTO_ERROR(FAIL, "Read-only S3 VFD info is invalid"); - if (H5Pset_fapl_ros3(fapl, (H5FD_ros3_fapl_t *)get_info->info) < 0) + if (H5Pset_fapl_ros3(fapl, (H5FD_ros3_fapl_t *)fapl_info->info) < 0) H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_ros3() failed"); #else H5TOOLS_GOTO_ERROR(FAIL, "Read-only S3 VFD is not enabled"); #endif } - else if (!HDstrcmp(get_info->u.name, drivernames[HDFS_VFD_IDX])) { + else if (!HDstrcmp(fapl_info->u.name, drivernames[HDFS_VFD_IDX])) { #ifdef H5_HAVE_LIBHDFS - if (!get_info->info) + if (!fapl_info->info) H5TOOLS_GOTO_ERROR(FAIL, "HDFS VFD info is invalid"); - if (H5Pset_fapl_hdfs(fapl, (H5FD_hdfs_fapl_t *)get_info->info) < 0) + if (H5Pset_fapl_hdfs(fapl, (H5FD_hdfs_fapl_t *)fapl_info->info) < 0) H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_hdfs() failed"); #else H5TOOLS_GOTO_ERROR(FAIL, "The HDFS VFD is not enabled"); @@ -554,8 +554,8 @@ h5tools_set_vfd_fapl(hid_t fapl, h5tools_get_fapl_info_t *get_info) break; - case GET_VOL_BY_NAME: - case GET_VOL_BY_ID: + case VOL_BY_NAME: + case VOL_BY_ID: default: H5TOOLS_GOTO_ERROR(FAIL, "invalid VFD retrieval type"); } @@ -575,67 +575,67 @@ done: *------------------------------------------------------------------------- */ static herr_t -h5tools_set_vol_fapl(hid_t fapl, h5tools_get_fapl_info_t *get_info) +h5tools_set_vol_fapl(hid_t fapl, h5tools_fapl_info_t *fapl_info) { htri_t connector_is_registered; hid_t connector_id = H5I_INVALID_HID; herr_t ret_value = SUCCEED; - switch (get_info->get_type) { - case GET_VOL_BY_NAME: + switch (fapl_info->type) { + case VOL_BY_NAME: /* Retrieve VOL connector by name */ - if ((connector_is_registered = H5VLis_connector_registered_by_name(get_info->u.name)) < 0) + if ((connector_is_registered = H5VLis_connector_registered_by_name(fapl_info->u.name)) < 0) H5TOOLS_GOTO_ERROR(FAIL, "can't check if VOL connector is registered"); if (connector_is_registered) { - if ((connector_id = H5VLget_connector_id_by_name(get_info->u.name)) < 0) + if ((connector_id = H5VLget_connector_id_by_name(fapl_info->u.name)) < 0) H5TOOLS_GOTO_ERROR(FAIL, "can't get VOL connector ID"); } else { /* Check for VOL connectors that ship with the library */ - if (!HDstrcmp(get_info->u.name, H5VL_NATIVE_NAME)) { + if (!HDstrcmp(fapl_info->u.name, H5VL_NATIVE_NAME)) { connector_id = H5VL_NATIVE; } - else if (!HDstrcmp(get_info->u.name, H5VL_PASSTHRU_NAME)) { + else if (!HDstrcmp(fapl_info->u.name, H5VL_PASSTHRU_NAME)) { connector_id = H5VL_PASSTHRU; } else { - if ((connector_id = H5VLregister_connector_by_name(get_info->u.name, H5P_DEFAULT)) < 0) + if ((connector_id = H5VLregister_connector_by_name(fapl_info->u.name, H5P_DEFAULT)) < 0) H5TOOLS_GOTO_ERROR(FAIL, "can't register VOL connector"); } } break; - case GET_VOL_BY_ID: + case VOL_BY_ID: /* Retrieve VOL connector by ID */ - if ((connector_is_registered = H5VLis_connector_registered_by_value((H5VL_class_value_t) get_info->u.id)) < 0) + if ((connector_is_registered = H5VLis_connector_registered_by_value((H5VL_class_value_t) fapl_info->u.id)) < 0) H5TOOLS_GOTO_ERROR(FAIL, "can't check if VOL connector is registered"); if (connector_is_registered) { - if ((connector_id = H5VLget_connector_id_by_value((H5VL_class_value_t) get_info->u.id)) < 0) + if ((connector_id = H5VLget_connector_id_by_value((H5VL_class_value_t) fapl_info->u.id)) < 0) H5TOOLS_GOTO_ERROR(FAIL, "can't get VOL connector ID"); } else { /* Check for VOL connectors that ship with the library */ - if (get_info->u.id == H5VL_NATIVE_VALUE) { + if (fapl_info->u.id == H5VL_NATIVE_VALUE) { connector_id = H5VL_NATIVE; } - else if (get_info->u.id == H5VL_PASSTHRU_VALUE) { + else if (fapl_info->u.id == H5VL_PASSTHRU_VALUE) { connector_id = H5VL_PASSTHRU; } else { - if ((connector_id = H5VLregister_connector_by_value((H5VL_class_value_t) get_info->u.id, H5P_DEFAULT)) < 0) + if ((connector_id = H5VLregister_connector_by_value((H5VL_class_value_t) fapl_info->u.id, H5P_DEFAULT)) < 0) H5TOOLS_GOTO_ERROR(FAIL, "can't register VOL connector"); } } break; - case GET_VFD_BY_NAME: + case VFD_BY_NAME: default: H5TOOLS_GOTO_ERROR(FAIL, "invalid VOL retrieval type"); } - if (H5Pset_vol(fapl, connector_id, get_info->info) < 0) + if (H5Pset_vol(fapl, connector_id, fapl_info->info) < 0) H5TOOLS_GOTO_ERROR(FAIL, "can't set VOL connector on FAPL"); done: @@ -658,14 +658,14 @@ done: *------------------------------------------------------------------------- */ hid_t -h5tools_get_fapl(hid_t fapl, h5tools_get_fapl_info_t *get_info) +h5tools_get_fapl(hid_t fapl, h5tools_fapl_info_t *fapl_info) { hid_t new_fapl = H5I_INVALID_HID; hid_t ret_value = H5I_INVALID_HID; if (fapl < 0) H5TOOLS_GOTO_ERROR(FAIL, "invalid FAPL"); - if (!get_info) + if (!fapl_info) H5TOOLS_GOTO_ERROR(FAIL, "invalid FAPL retrieval info"); /* Make a copy of the FAPL if necessary, or create a FAPL if @@ -679,12 +679,12 @@ h5tools_get_fapl(hid_t fapl, h5tools_get_fapl_info_t *get_info) H5TOOLS_GOTO_ERROR(H5I_INVALID_HID, "H5Pcopy failed"); } - if (GET_VFD_BY_NAME == get_info->get_type) { - if (h5tools_set_vfd_fapl(new_fapl, get_info) < 0) + if (VFD_BY_NAME == fapl_info->type) { + if (h5tools_set_vfd_fapl(new_fapl, fapl_info) < 0) H5TOOLS_GOTO_ERROR(H5I_INVALID_HID, "failed to set VFD on FAPL"); } - else if (GET_VOL_BY_NAME == get_info->get_type || GET_VOL_BY_ID == get_info->get_type) { - if (h5tools_set_vol_fapl(new_fapl, get_info) < 0) + else if (VOL_BY_NAME == fapl_info->type || VOL_BY_ID == fapl_info->type) { + if (h5tools_set_vol_fapl(new_fapl, fapl_info) < 0) H5TOOLS_GOTO_ERROR(H5I_INVALID_HID, "failed to set VOL on FAPL"); } else @@ -885,14 +885,14 @@ h5tools_fopen(const char *fname, unsigned flags, hid_t fapl, hbool_t use_specifi * connector being looked at, also try using each of the available VFL drivers. */ for (volnum = 0; volnum < NUM_VOLS; volnum++) { - h5tools_get_fapl_info_t get_vol_info; + h5tools_fapl_info_t vol_info; - get_vol_info.get_type = GET_VOL_BY_NAME; - get_vol_info.info = NULL; - get_vol_info.u.name = volnames[volnum]; + vol_info.type = VOL_BY_NAME; + vol_info.info = NULL; + vol_info.u.name = volnames[volnum]; /* Get a FAPL for the current VOL connector */ - if ((tmp_vol_fapl = h5tools_get_fapl(fapl, &get_vol_info)) < 0) + if ((tmp_vol_fapl = h5tools_get_fapl(fapl, &vol_info)) < 0) continue; /* TODO: For now, we have no way of determining if an arbitrary @@ -904,18 +904,20 @@ h5tools_fopen(const char *fname, unsigned flags, hid_t fapl, hbool_t use_specifi * VFL drivers as well. */ for (drivernum = 0; drivernum < NUM_DRIVERS; drivernum++) { - h5tools_get_fapl_info_t get_vfd_info; + h5tools_fapl_info_t vfd_info; - /* Skip the log VFD as it prints out to standard out */ + /* Skip the log VFD as it prints out to standard out + * and is fundamentally SEC2 anyway. + */ if (drivernum == LOG_VFD_IDX) continue; - get_vfd_info.get_type = GET_VFD_BY_NAME; - get_vfd_info.info = NULL; - get_vfd_info.u.name = drivernames[drivernum]; + vfd_info.type = VFD_BY_NAME; + vfd_info.info = NULL; + vfd_info.u.name = drivernames[drivernum]; /* Using the current VOL FAPL as a base, get the correct FAPL for the given VFL driver */ - if ((tmp_vfd_fapl = h5tools_get_fapl(tmp_vol_fapl, &get_vfd_info)) < 0) + if ((tmp_vfd_fapl = h5tools_get_fapl(tmp_vol_fapl, &vfd_info)) < 0) continue; if ((fid = h5tools_fopen(fname, flags, tmp_vfd_fapl, TRUE, drivername, drivername_size)) >= 0) { diff --git a/tools/lib/h5tools.h b/tools/lib/h5tools.h index 1b01c35..5244f7be 100644 --- a/tools/lib/h5tools.h +++ b/tools/lib/h5tools.h @@ -540,23 +540,23 @@ typedef struct h5tools_context_t { } h5tools_context_t; typedef enum { - GET_VFD_BY_NAME, - GET_VOL_BY_NAME, - GET_VOL_BY_ID -} h5tools_get_fapl_type_t; + VFD_BY_NAME, + VOL_BY_NAME, + VOL_BY_ID +} h5tools_fapl_info_type_t; -typedef struct h5tools_get_fapl_info_t { - h5tools_get_fapl_type_t get_type; +typedef struct h5tools_fapl_info_t { + h5tools_fapl_info_type_t type; /* Pointer to information to be passed to the driver/connector for its setup */ const void *info; - /* Field specifying either the driver's/connector's name, or the driver's/connector's ID */ + /* Field specifying either the driver's/connector's name or ID */ union { const char *name; long id; } u; -} h5tools_get_fapl_info_t; +} h5tools_fapl_info_t; H5TOOLS_DLLVAR const char *volnames[]; H5TOOLS_DLLVAR const char *drivernames[]; @@ -637,7 +637,7 @@ H5TOOLS_DLL int h5tools_set_attr_output_file(const char *fname, int is_bin); H5TOOLS_DLL int h5tools_set_input_file(const char *fname, int is_bin); H5TOOLS_DLL int h5tools_set_output_file(const char *fname, int is_bin); H5TOOLS_DLL int h5tools_set_error_file(const char *fname, int is_bin); -H5TOOLS_DLL hid_t h5tools_get_fapl(hid_t fapl, h5tools_get_fapl_info_t *get_info); +H5TOOLS_DLL hid_t h5tools_get_fapl(hid_t fapl, h5tools_fapl_info_t *fapl_info); H5TOOLS_DLL herr_t h5tools_get_vfd_name(hid_t fapl_id, char *drivername, size_t drivername_size); H5TOOLS_DLL hid_t h5tools_fopen(const char *fname, unsigned flags, hid_t fapl, hbool_t use_specific_driver, char *drivername, size_t drivername_size); diff --git a/tools/libtest/h5tools_test_utils.c b/tools/libtest/h5tools_test_utils.c index 160e06f..2f9958b 100644 --- a/tools/libtest/h5tools_test_utils.c +++ b/tools/libtest/h5tools_test_utils.c @@ -1147,7 +1147,7 @@ test_set_configured_fapl(void) TESTING("programmatic fapl set"); for (i = 0; i < n_cases; i++) { - h5tools_get_fapl_info_t get_fapl_info; + h5tools_fapl_info_t fapl_info; hid_t result; testcase C = cases[i]; @@ -1170,10 +1170,10 @@ test_set_configured_fapl(void) #endif /* UTIL_TEST_DEBUG */ /* test */ - get_fapl_info.get_type = GET_VFD_BY_NAME; - get_fapl_info.info = C.conf_fa; - get_fapl_info.u.name = C.vfdname; - result = h5tools_get_fapl(H5P_DEFAULT, &get_fapl_info); + fapl_info.type = VFD_BY_NAME; + fapl_info.info = C.conf_fa; + fapl_info.u.name = C.vfdname; + result = h5tools_get_fapl(H5P_DEFAULT, &fapl_info); if (C.expected == 0) JSVERIFY( result, H5I_INVALID_HID, C.message) else diff --git a/tools/src/h5dump/h5dump.c b/tools/src/h5dump/h5dump.c index 1848d3d..e49141d 100644 --- a/tools/src/h5dump/h5dump.c +++ b/tools/src/h5dump/h5dump.c @@ -1415,16 +1415,16 @@ main(int argc, const char *argv[]) h5trav_set_index(sort_by, sort_order); if (driver != NULL) { - h5tools_get_fapl_info_t get_fapl_info; + h5tools_fapl_info_t fapl_info; /* Currently, only retrieval of VFDs is supported. */ - get_fapl_info.get_type = GET_VFD_BY_NAME; - get_fapl_info.info = NULL; - get_fapl_info.u.name = driver; + fapl_info.type = VFD_BY_NAME; + fapl_info.info = NULL; + fapl_info.u.name = driver; if (!HDstrcmp(driver, drivernames[ROS3_VFD_IDX])) { #ifdef H5_HAVE_ROS3_VFD - get_fapl_info.info = (void *)&ros3_fa; + fapl_info.info = (void *)&ros3_fa; #else error_msg("Read-Only S3 VFD not enabled.\n"); h5tools_setstatus(EXIT_FAILURE); @@ -1433,7 +1433,7 @@ main(int argc, const char *argv[]) } else if (!HDstrcmp(driver, drivernames[HDFS_VFD_IDX])) { #ifdef H5_HAVE_LIBHDFS - get_fapl_info.info = (void *)&hdfs_fa; + fapl_info.info = (void *)&hdfs_fa; #else error_msg("The HDFS VFD is not enabled.\n"); h5tools_setstatus(EXIT_FAILURE); @@ -1441,7 +1441,7 @@ main(int argc, const char *argv[]) #endif } - if ((fapl_id = h5tools_get_fapl(H5P_DEFAULT, &get_fapl_info)) < 0) { + if ((fapl_id = h5tools_get_fapl(H5P_DEFAULT, &fapl_info)) < 0) { error_msg("unable to create FAPL for file access\n"); h5tools_setstatus(EXIT_FAILURE); goto done; diff --git a/tools/src/h5ls/h5ls.c b/tools/src/h5ls/h5ls.c index f46d70a..7ab5001 100644 --- a/tools/src/h5ls/h5ls.c +++ b/tools/src/h5ls/h5ls.c @@ -3141,16 +3141,16 @@ main(int argc, const char *argv[]) } if (preferred_driver) { - h5tools_get_fapl_info_t get_fapl_info; + h5tools_fapl_info_t fapl_info; /* Currently, only retrieval of VFDs is supported. */ - get_fapl_info.get_type = GET_VFD_BY_NAME; - get_fapl_info.info = NULL; - get_fapl_info.u.name = preferred_driver; + fapl_info.type = VFD_BY_NAME; + fapl_info.info = NULL; + fapl_info.u.name = preferred_driver; if (!HDstrcmp(preferred_driver, drivernames[ROS3_VFD_IDX])) { #ifdef H5_HAVE_ROS3_VFD - get_fapl_info.info = (void *)&ros3_fa; + fapl_info.info = (void *)&ros3_fa; #else HDfprintf(rawerrorstream, "Error: Read-Only S3 VFD is not enabled\n\n"); leave(EXIT_FAILURE); @@ -3158,14 +3158,14 @@ main(int argc, const char *argv[]) } else if (!HDstrcmp(preferred_driver, drivernames[HDFS_VFD_IDX])) { #ifdef H5_HAVE_LIBHDFS - get_fapl_info.info = (void *)&hdfs_fa; + fapl_info.info = (void *)&hdfs_fa; #else HDfprintf(rawerrorstream, "Error: The HDFS VFD is not enabled\n\n"); leave(EXIT_FAILURE); #endif } - if ((fapl_id = h5tools_get_fapl(H5P_DEFAULT, &get_fapl_info)) < 0) { + if ((fapl_id = h5tools_get_fapl(H5P_DEFAULT, &fapl_info)) < 0) { HDfprintf(rawerrorstream, "Error: Unable to create FAPL for file access\n\n"); leave(EXIT_FAILURE); } diff --git a/tools/src/h5repack/h5repack_main.c b/tools/src/h5repack/h5repack_main.c index f0a94ab..1761fb4 100644 --- a/tools/src/h5repack/h5repack_main.c +++ b/tools/src/h5repack/h5repack_main.c @@ -432,16 +432,16 @@ set_sort_order(const char *form) static int parse_command_line(int argc, const char **argv, pack_opt_t* options) { - h5tools_get_fapl_info_t get_in_vol_info; - h5tools_get_fapl_info_t get_out_vol_info; + h5tools_fapl_info_t in_vol_info; + h5tools_fapl_info_t out_vol_info; hbool_t custom_in_fapl = FALSE; hbool_t custom_out_fapl = FALSE; hid_t tmp_fapl = H5I_INVALID_HID; int bound, opt; int ret_value = 0; - HDmemset(&get_in_vol_info, 0, sizeof(h5tools_get_fapl_info_t)); - HDmemset(&get_out_vol_info, 0, sizeof(h5tools_get_fapl_info_t)); + HDmemset(&in_vol_info, 0, sizeof(h5tools_fapl_info_t)); + HDmemset(&out_vol_info, 0, sizeof(h5tools_fapl_info_t)); /* parse command line options */ while (EOF != (opt = get_option(argc, argv, s_opts, l_opts))) { @@ -682,35 +682,35 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options) break; case '1': - get_in_vol_info.get_type = GET_VOL_BY_ID; - get_in_vol_info.u.id = HDatol(opt_arg); + in_vol_info.type = VOL_BY_ID; + in_vol_info.u.id = HDatol(opt_arg); custom_in_fapl = TRUE; break; case '2': - get_in_vol_info.get_type = GET_VOL_BY_NAME; - get_in_vol_info.u.name = opt_arg; + in_vol_info.type = VOL_BY_NAME; + in_vol_info.u.name = opt_arg; custom_in_fapl = TRUE; break; case '3': - get_in_vol_info.info = opt_arg; + in_vol_info.info = opt_arg; break; case '4': - get_out_vol_info.get_type = GET_VOL_BY_ID; - get_out_vol_info.u.id = HDatol(opt_arg); + out_vol_info.type = VOL_BY_ID; + out_vol_info.u.id = HDatol(opt_arg); custom_out_fapl = TRUE; break; case '5': - get_out_vol_info.get_type = GET_VOL_BY_NAME; - get_out_vol_info.u.name = opt_arg; + out_vol_info.type = VOL_BY_NAME; + out_vol_info.u.name = opt_arg; custom_out_fapl = TRUE; break; case '6': - get_out_vol_info.info = opt_arg; + out_vol_info.info = opt_arg; break; default: @@ -747,7 +747,7 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options) /* Setup FAPL for input and output file accesses */ if (custom_in_fapl) { - if ((tmp_fapl = h5tools_get_fapl(options->fin_fapl, &get_in_vol_info)) < 0) { + if ((tmp_fapl = h5tools_get_fapl(options->fin_fapl, &in_vol_info)) < 0) { error_msg("failed to setup FAPL for input file\n"); h5tools_setstatus(EXIT_FAILURE); ret_value = -1; @@ -767,7 +767,7 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options) } if (custom_out_fapl) { - if ((tmp_fapl = h5tools_get_fapl(options->fout_fapl, &get_out_vol_info)) < 0) { + if ((tmp_fapl = h5tools_get_fapl(options->fout_fapl, &out_vol_info)) < 0) { error_msg("failed to setup FAPL for output file\n"); h5tools_setstatus(EXIT_FAILURE); ret_value = -1; diff --git a/tools/src/h5stat/h5stat.c b/tools/src/h5stat/h5stat.c index c1d3cfe..fdf49cd 100644 --- a/tools/src/h5stat/h5stat.c +++ b/tools/src/h5stat/h5stat.c @@ -1813,16 +1813,16 @@ main(int argc, const char *argv[]) goto done; if (drivername) { - h5tools_get_fapl_info_t get_fapl_info; + h5tools_fapl_info_t fapl_info; /* Currently, only retrieval of VFDs is supported. */ - get_fapl_info.get_type = GET_VFD_BY_NAME; - get_fapl_info.info = NULL; - get_fapl_info.u.name = drivername; + fapl_info.type = VFD_BY_NAME; + fapl_info.info = NULL; + fapl_info.u.name = drivername; if (!HDstrcmp(drivername, drivernames[ROS3_VFD_IDX])) { #ifdef H5_HAVE_ROS3_VFD - get_fapl_info.info = (void *)&ros3_fa; + fapl_info.info = (void *)&ros3_fa; #else error_msg("Read-Only S3 VFD not enabled.\n"); goto done; @@ -1830,14 +1830,14 @@ main(int argc, const char *argv[]) } else if (!HDstrcmp(drivername, drivernames[HDFS_VFD_IDX])) { #ifdef H5_HAVE_LIBHDFS - get_fapl_info.info = (void *)&hdfs_fa; + fapl_info.info = (void *)&hdfs_fa; #else error_msg("HDFS VFD not enabled.\n"); goto done; #endif } - if ((fapl_id = h5tools_get_fapl(H5P_DEFAULT, &get_fapl_info)) < 0) { + if ((fapl_id = h5tools_get_fapl(H5P_DEFAULT, &fapl_info)) < 0) { error_msg("Unable to create FAPL for file access\n"); goto done; } -- cgit v0.12 From 196193c18d43d71b6dd8a0727fc59b91c8299341 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Wed, 1 Apr 2020 11:46:26 -0500 Subject: Correct extra flags --- config/cmake_ext_mod/ConfigureChecks.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/cmake_ext_mod/ConfigureChecks.cmake b/config/cmake_ext_mod/ConfigureChecks.cmake index 33d4d6e..93b977e 100644 --- a/config/cmake_ext_mod/ConfigureChecks.cmake +++ b/config/cmake_ext_mod/ConfigureChecks.cmake @@ -274,11 +274,11 @@ if (MINGW OR NOT WINDOWS) # systems. # POSIX feature information can be found in the gcc manual at: # http://www.gnu.org/s/libc/manual/html_node/Feature-Test-Macros.html - set (HDF_EXTRA_C_FLAGS -D_POSIX_C_SOURCE=200112L) + set (HDF_EXTRA_C_FLAGS -D_POSIX_C_SOURCE=200809L) # Need to add this so that O_DIRECT is visible for the direct # VFD on Linux systems. - set (HDF_EXTRA_C_FLAGS -D_GNU_SOURCE) + set (HDF_EXTRA_C_FLAGS ${HDF_EXTRA_C_FLAGS} -D_GNU_SOURCE) option (HDF_ENABLE_LARGE_FILE "Enable support for large (64-bit) files on Linux." ON) if (HDF_ENABLE_LARGE_FILE AND NOT DEFINED TEST_LFS_WORKS_RUN) -- cgit v0.12 From a267c4e5d37f00bf6cff942b57b5a13affaa8bd5 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 1 Apr 2020 18:46:07 -0700 Subject: Changed default dataset shared struct to initialize hid_t IDs to H5I_INVALID_HID. --- src/H5Dint.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/H5Dint.c b/src/H5Dint.c index 1624f7b..2539b2c 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -207,6 +207,9 @@ H5D__init_package(void) /* Reset the "default dataset" information */ HDmemset(&H5D_def_dset, 0, sizeof(H5D_shared_t)); + H5D_def_dset.type_id = H5I_INVALID_HID; + H5D_def_dset.dapl_id = H5I_INVALID_HID; + H5D_def_dset.dcpl_id = H5I_INVALID_HID; /* Get the default dataset creation property list values and initialize the * default dataset with them. -- cgit v0.12 From 1c854737665f3f853a324c34292390ab57431fec Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Thu, 2 Apr 2020 03:57:05 -0700 Subject: Fixed unnecessary H5R casts in the tools that were raising warnings. --- tools/lib/h5tools.c | 4 ++-- tools/lib/h5tools_dump.c | 16 ++++++++-------- tools/src/h5ls/h5ls.c | 16 ++++++++-------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c index a975f4c..102822d 100644 --- a/tools/lib/h5tools.c +++ b/tools/lib/h5tools.c @@ -1787,10 +1787,10 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t for (block_index = 0; block_index < block_nelmts; block_index++) { mem = ((unsigned char*)_mem) + block_index * size; - if((region_id = H5Ropen_object((const H5R_ref_t *)mem, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if((region_id = H5Ropen_object((H5R_ref_t *)mem, H5P_DEFAULT, H5P_DEFAULT)) < 0) H5TOOLS_INFO("H5Ropen_object H5T_STD_REF failed"); else { - if((region_space = H5Ropen_region((const H5R_ref_t *)mem, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { + if((region_space = H5Ropen_region((H5R_ref_t *)mem, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { if (!h5tools_is_zero(mem, H5Tget_size(H5T_STD_REF))) { region_type = H5Sget_select_type(region_space); if(region_type == H5S_SEL_POINTS) diff --git a/tools/lib/h5tools_dump.c b/tools/lib/h5tools_dump.c index 96545c8..c10b36b 100644 --- a/tools/lib/h5tools_dump.c +++ b/tools/lib/h5tools_dump.c @@ -4091,10 +4091,10 @@ h5tools_dump_data(FILE *stream, const h5tool_format_t *info, h5tools_context_t * switch (ref_type) { case H5R_OBJECT1: H5TOOLS_DEBUG("ref_type is H5R_OBJECT1"); - if (H5Rget_obj_type3((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, &obj_type) >= 0) { + if (H5Rget_obj_type3(&ref_buf[i], H5P_DEFAULT, &obj_type) >= 0) { switch (obj_type) { case H5O_TYPE_DATASET: - if((new_obj_id = H5Ropen_object((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) { + if((new_obj_id = H5Ropen_object(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) { datactx.indent_level++; h5tools_dump_data(stream, &outputformat, &datactx, new_obj_id, TRUE); datactx.indent_level--; @@ -4119,7 +4119,7 @@ h5tools_dump_data(FILE *stream, const h5tool_format_t *info, h5tools_context_t * break; case H5R_DATASET_REGION1: H5TOOLS_DEBUG("ref_type is H5R_DATASET_REGION1"); - if((new_obj_id = H5Ropen_object((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) { + if((new_obj_id = H5Ropen_object(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) { datactx.indent_level++; h5tools_dump_data(stream, &outputformat, &datactx, new_obj_id, TRUE); datactx.indent_level--; @@ -4131,13 +4131,13 @@ h5tools_dump_data(FILE *stream, const h5tool_format_t *info, h5tools_context_t * break; case H5R_OBJECT2: H5TOOLS_DEBUG("ref_type is H5R_OBJECT2"); - if (H5Rget_obj_type3((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, &obj_type) >= 0) { + if (H5Rget_obj_type3(&ref_buf[i], H5P_DEFAULT, &obj_type) >= 0) { switch (obj_type) { case H5O_TYPE_GROUP: break; case H5O_TYPE_DATASET: - if((new_obj_id = H5Ropen_object((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) { + if((new_obj_id = H5Ropen_object(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) { datactx.indent_level++; h5tools_dump_data(stream, &outputformat, &datactx, new_obj_id, TRUE); datactx.indent_level--; @@ -4168,10 +4168,10 @@ h5tools_dump_data(FILE *stream, const h5tool_format_t *info, h5tools_context_t * ncols = outputformat.line_ncols; /* if (new_obj_id < 0) - could mean that no reference was written do not throw failure */ - if((new_obj_id = H5Ropen_object((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) < 0) + if((new_obj_id = H5Ropen_object(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) < 0) H5TOOLS_INFO("H5Ropen_object H5R_DATASET_REGION2 failed"); else { - if((new_obj_sid = H5Ropen_region((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) { + if((new_obj_sid = H5Ropen_region(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) { if (h5tools_is_zero(&ref_buf[i], H5Tget_size(H5T_STD_REF))) { H5TOOLS_DEBUG("NULL H5R_DATASET_REGION2"); @@ -4223,7 +4223,7 @@ h5tools_dump_data(FILE *stream, const h5tool_format_t *info, h5tools_context_t * break; case H5R_ATTR: H5TOOLS_DEBUG("ref_type is H5R_ATTR"); - if((new_obj_id = H5Ropen_attr((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) { + if((new_obj_id = H5Ropen_attr(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) { h5tools_dump_region_attribute(new_obj_id, stream, &outputformat, &datactx, &buffer, &curr_pos, ncols, i, elmt_counter); if(H5Aclose(new_obj_id) < 0) diff --git a/tools/src/h5ls/h5ls.c b/tools/src/h5ls/h5ls.c index 7ab5001..d954367 100644 --- a/tools/src/h5ls/h5ls.c +++ b/tools/src/h5ls/h5ls.c @@ -1333,10 +1333,10 @@ dump_reference(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx switch (ref_type) { case H5R_OBJECT1: H5TOOLS_DEBUG("ref_type is H5R_OBJECT1"); - if (H5Rget_obj_type3((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, &obj_type) >= 0) { + if (H5Rget_obj_type3(&ref_buf[i], H5P_DEFAULT, &obj_type) >= 0) { switch (obj_type) { case H5O_TYPE_DATASET: - if((new_obj_id = H5Ropen_object((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) { + if((new_obj_id = H5Ropen_object(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) { datactx.indent_level++; h5tools_dump_dset(stream, info, &datactx, new_obj_id); datactx.indent_level--; @@ -1363,7 +1363,7 @@ dump_reference(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx break; case H5R_DATASET_REGION1: H5TOOLS_DEBUG("ref_type is H5R_DATASET_REGION1"); - if((new_obj_id = H5Ropen_object((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) { + if((new_obj_id = H5Ropen_object(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) { datactx.indent_level++; h5tools_dump_dset(stream, info, &datactx, new_obj_id); datactx.indent_level--; @@ -1377,13 +1377,13 @@ dump_reference(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx break; case H5R_OBJECT2: H5TOOLS_DEBUG("ref_type is H5R_OBJECT2"); - if (H5Rget_obj_type3((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, &obj_type) >= 0) { + if (H5Rget_obj_type3(&ref_buf[i], H5P_DEFAULT, &obj_type) >= 0) { switch (obj_type) { case H5O_TYPE_GROUP: break; case H5O_TYPE_DATASET: - if((new_obj_id = H5Ropen_object((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) { + if((new_obj_id = H5Ropen_object(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) { datactx.indent_level++; h5tools_dump_dset(stream, info, &datactx, new_obj_id); datactx.indent_level--; @@ -1416,10 +1416,10 @@ dump_reference(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx ncols = info->line_ncols; /* if (new_obj_id < 0) - could mean that no reference was written do not throw failure */ - if((new_obj_id = H5Ropen_object((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) < 0) + if((new_obj_id = H5Ropen_object(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) < 0) H5TOOLS_INFO("H5Ropen_object H5R_DATASET_REGION2 failed"); else { - if((new_obj_sid = H5Ropen_region((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) { + if((new_obj_sid = H5Ropen_region(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) { if (h5tools_is_zero(&ref_buf[i], H5Tget_size(H5T_STD_REF))) { H5TOOLS_DEBUG("NULL H5R_DATASET_REGION2"); @@ -1471,7 +1471,7 @@ dump_reference(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx break; case H5R_ATTR: H5TOOLS_DEBUG("ref_type is H5R_ATTR"); - if((new_obj_id = H5Ropen_attr((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) { + if((new_obj_id = H5Ropen_attr(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) { h5tools_dump_region_attribute(new_obj_id, stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); if(H5Aclose(new_obj_id) < 0) H5TOOLS_INFO("H5Aclose H5R_ATTR failed"); -- cgit v0.12