diff options
43 files changed, 699 insertions, 541 deletions
diff --git a/fortran/test/fortranlib_test_F03.F90 b/fortran/test/fortranlib_test_F03.F90 index 9a74120..808cb4d 100644 --- a/fortran/test/fortranlib_test_F03.F90 +++ b/fortran/test/fortranlib_test_F03.F90 @@ -153,7 +153,7 @@ PROGRAM fortranlibtest_F03 ! write(*,*) ! write(*,*) '=========================================' -! write(*,*) 'Testing GROUP interface ' +! write(*,*) 'Testing OBJECT interface ' ! write(*,*) '=========================================' ret_total_error = 0 @@ -161,11 +161,11 @@ PROGRAM fortranlibtest_F03 CALL write_test_status(ret_total_error, ' Testing object functions ', total_error) ret_total_error = 0 - CALL obj_visit(ret_total_error) + CALL test_obj_visit(ret_total_error) CALL write_test_status(ret_total_error, ' Testing object visiting functions ', total_error) ret_total_error = 0 - CALL obj_info(ret_total_error) + CALL test_obj_info(ret_total_error) CALL write_test_status(ret_total_error, ' Testing object info functions ', total_error) ret_total_error = 0 diff --git a/fortran/test/tH5O_F03.F90 b/fortran/test/tH5O_F03.F90 index bc3668c..5b446a4 100644 --- a/fortran/test/tH5O_F03.F90 +++ b/fortran/test/tH5O_F03.F90 @@ -486,11 +486,11 @@ END SUBROUTINE test_h5o_refcount !**************************************************************** !** -!** test_h5o_refcount(): Test H5O visit functions. +!** test_obj_visit(): Test H5O visit functions. !** !**************************************************************** -SUBROUTINE obj_visit(total_error) +SUBROUTINE test_obj_visit(total_error) USE HDF5 USE TH5_MISC @@ -648,15 +648,15 @@ SUBROUTINE obj_visit(total_error) CALL h5fclose_f(fid, error) CALL check("h5fclose_f",error, total_error) -END SUBROUTINE obj_visit +END SUBROUTINE test_obj_visit !**************************************************************** !** -!** test_h5o_refcount(): Test H5O info functions. +!** test_obj_info(): Test H5O info functions. !** !**************************************************************** -SUBROUTINE obj_info(total_error) +SUBROUTINE test_obj_info(total_error) USE HDF5 USE TH5_MISC @@ -796,7 +796,7 @@ SUBROUTINE obj_info(total_error) CALL h5fclose_f(fid, error) CALL check("h5fclose_f", error, total_error) -END SUBROUTINE obj_info +END SUBROUTINE test_obj_info !------------------------------------------------------------------------- ! Function: build_visit_file diff --git a/hl/src/H5DS.c b/hl/src/H5DS.c index b24f887..c91ea1f 100644 --- a/hl/src/H5DS.c +++ b/hl/src/H5DS.c @@ -177,7 +177,7 @@ herr_t H5DSattach_scale(hid_t did, if ((it2 = H5Iget_type(dsid)) < 0) return FAIL; - if (H5I_DATASET!=it1 || H5I_DATASET!=it2) + if (H5I_DATASET != it1 || H5I_DATASET != it2) return FAIL; /* the DS dataset cannot have dimension scales */ @@ -202,19 +202,19 @@ herr_t H5DSattach_scale(hid_t did, return FAIL; /* get rank */ - if ((rank=H5Sget_simple_extent_ndims(sid)) < 0) + if ((rank = H5Sget_simple_extent_ndims(sid)) < 0) goto out; /* scalar rank */ - if (rank==0) - rank=1; + if (rank == 0) + rank = 1; /* close dataset space */ if (H5Sclose(sid) < 0) return FAIL; /* parameter range checking */ - if (idx>(unsigned)rank-1) + if (idx > (unsigned)rank-1) return FAIL; /*------------------------------------------------------------------------- @@ -508,7 +508,7 @@ herr_t H5DSattach_scale(hid_t did, *------------------------------------------------------------------------- */ - if((is_ds=H5DSis_scale(dsid)) < 0) + if((is_ds = H5DSis_scale(dsid)) < 0) return FAIL; if(is_ds == 0) { @@ -598,7 +598,7 @@ herr_t H5DSdetach_scale(hid_t did, /* check for valid types of identifiers */ - if(H5I_DATASET!=H5Iget_type(did) || H5I_DATASET!=H5Iget_type(dsid)) + if(H5I_DATASET != H5Iget_type(did) || H5I_DATASET != H5Iget_type(dsid)) return FAIL; if((is_scale = H5DSis_scale(did)) < 0) @@ -626,7 +626,7 @@ herr_t H5DSdetach_scale(hid_t did, *------------------------------------------------------------------------- */ /* try to find the attribute "DIMENSION_LIST" on the >>data<< dataset */ - if ((has_dimlist = H5LT_find_attribute(did,DIMENSION_LIST)) < 0) + if ((has_dimlist = H5LT_find_attribute(did, DIMENSION_LIST)) < 0) return FAIL; if (has_dimlist == 0) @@ -637,7 +637,7 @@ herr_t H5DSdetach_scale(hid_t did, return FAIL; /* get rank */ - if ((rank=H5Sget_simple_extent_ndims(sid)) < 0) + if ((rank = H5Sget_simple_extent_ndims(sid)) < 0) goto out; /* close dataset space */ @@ -645,7 +645,7 @@ herr_t H5DSdetach_scale(hid_t did, return FAIL; /* parameter range checking */ - if (idx>(unsigned)rank-1) + if (idx > (unsigned)rank-1) return FAIL; /*------------------------------------------------------------------------- @@ -795,7 +795,7 @@ herr_t H5DSdetach_scale(hid_t did, if(H5Aread(aid, ntid, dsbuf) < 0) goto out; - for(ii=0; ii<nelmts; ii++) { + for(ii = 0; ii < nelmts; ii++) { /* First check if we have the same dimension index */ if(idx == dsbuf[ii].dim_idx) { /* get the reference to the dataset */ @@ -990,7 +990,7 @@ htri_t H5DSis_attached(hid_t did, if ((it2 = H5Iget_type(dsid)) < 0) return FAIL; - if (H5I_DATASET!=it1 || H5I_DATASET!=it2) + if (H5I_DATASET != it1 || H5I_DATASET != it2) return FAIL; /*------------------------------------------------------------------------- @@ -1040,7 +1040,7 @@ htri_t H5DSis_attached(hid_t did, goto out; /* read */ - if (H5Aread(aid,tid,buf) < 0) + if (H5Aread(aid, tid, buf) < 0) goto out; /* iterate all the REFs in this dimension IDX */ @@ -1050,7 +1050,7 @@ htri_t H5DSis_attached(hid_t did, ref = ((hobj_ref_t *)buf[idx].p)[i]; /* get the scale id for this REF */ - if ((dsid_j = H5Rdereference2(did,H5P_DEFAULT,H5R_OBJECT,&ref)) < 0) + if ((dsid_j = H5Rdereference2(did, H5P_DEFAULT, H5R_OBJECT, &ref)) < 0) goto out; /* get info for DS in the parameter list */ @@ -1073,7 +1073,7 @@ htri_t H5DSis_attached(hid_t did, /* close */ - if (H5Treclaim(tid,sid,H5P_DEFAULT,buf) < 0) + if (H5Treclaim(tid, sid, H5P_DEFAULT, buf) < 0) goto out; if (H5Sclose(sid) < 0) goto out; @@ -1123,7 +1123,7 @@ htri_t H5DSis_attached(hid_t did, if (dsbuf == NULL) goto out; - if (H5Aread(aid,ntid,dsbuf) < 0) + if (H5Aread(aid, ntid, dsbuf) < 0) goto out; /*------------------------------------------------------------------------- @@ -1131,7 +1131,7 @@ htri_t H5DSis_attached(hid_t did, *------------------------------------------------------------------------- */ - for(i=0; i<nelmts; i++) + for(i = 0; i < nelmts; i++) { /* get the reference */ ref = dsbuf[i].ref; @@ -1140,7 +1140,7 @@ htri_t H5DSis_attached(hid_t did, if (ref) { /* get the dataset id */ - if ((did_i = H5Rdereference2(did,H5P_DEFAULT,H5R_OBJECT,&ref)) < 0) + if ((did_i = H5Rdereference2(did, H5P_DEFAULT, H5R_OBJECT, &ref)) < 0) goto out; /* get info for dataset in the parameter list */ diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index 4008eb8..75ef0a9 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -247,29 +247,29 @@ typedef struct H5F_t H5F_t; } /* Address-related macros */ -#define H5F_addr_overflow(X,Z) (HADDR_UNDEF==(X) || \ - HADDR_UNDEF==(X)+(haddr_t)(Z) || \ +#define H5F_addr_overflow(X,Z) (HADDR_UNDEF==(X) || \ + HADDR_UNDEF==(X)+(haddr_t)(Z) || \ (X)+(haddr_t)(Z)<(X)) #define H5F_addr_defined(X) ((X)!=HADDR_UNDEF) /* The H5F_addr_eq() macro guarantees that Y is not HADDR_UNDEF by making * certain that X is not HADDR_UNDEF and then checking that X equals Y */ -#define H5F_addr_eq(X,Y) ((X)!=HADDR_UNDEF && \ +#define H5F_addr_eq(X,Y) ((X)!=HADDR_UNDEF && \ (X)==(Y)) #define H5F_addr_ne(X,Y) (!H5F_addr_eq((X),(Y))) -#define H5F_addr_lt(X,Y) ((X)!=HADDR_UNDEF && \ - (Y)!=HADDR_UNDEF && \ +#define H5F_addr_lt(X,Y) ((X)!=HADDR_UNDEF && \ + (Y)!=HADDR_UNDEF && \ (X)<(Y)) -#define H5F_addr_le(X,Y) ((X)!=HADDR_UNDEF && \ - (Y)!=HADDR_UNDEF && \ +#define H5F_addr_le(X,Y) ((X)!=HADDR_UNDEF && \ + (Y)!=HADDR_UNDEF && \ (X)<=(Y)) -#define H5F_addr_gt(X,Y) ((X)!=HADDR_UNDEF && \ - (Y)!=HADDR_UNDEF && \ +#define H5F_addr_gt(X,Y) ((X)!=HADDR_UNDEF && \ + (Y)!=HADDR_UNDEF && \ (X)>(Y)) -#define H5F_addr_ge(X,Y) ((X)!=HADDR_UNDEF && \ - (Y)!=HADDR_UNDEF && \ +#define H5F_addr_ge(X,Y) ((X)!=HADDR_UNDEF && \ + (Y)!=HADDR_UNDEF && \ (X)>=(Y)) -#define H5F_addr_cmp(X,Y) (H5F_addr_eq((X), (Y)) ? 0 : \ +#define H5F_addr_cmp(X,Y) (H5F_addr_eq((X), (Y)) ? 0 : \ (H5F_addr_lt((X), (Y)) ? -1 : 1)) #define H5F_addr_pow2(N) ((haddr_t)1<<(N)) #define H5F_addr_overlap(O1,L1,O2,L2) (((O1) < (O2) && ((O1) + (L1)) > (O2)) || \ diff --git a/src/H5Gdeprec.c b/src/H5Gdeprec.c index c321e97..5f16f67 100644 --- a/src/H5Gdeprec.c +++ b/src/H5Gdeprec.c @@ -984,15 +984,15 @@ H5G__get_objinfo_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char *name, c FUNC_ENTER_STATIC; /* Check if the name in this group resolved to a valid link */ - if (lnk == NULL && obj_loc == NULL) + if(lnk == NULL && obj_loc == NULL) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "'%s' doesn't exist", name); - /* Only modify user's buffer if it's available */ - if (udata->statbuf) { + /* Only modify user's buffer if it's available */ + if(udata->statbuf) { H5G_stat_t *statbuf = udata->statbuf; /* Convenience pointer for statbuf */ /* Common code to retrieve the file's fileno */ - if (H5F_get_fileno((obj_loc ? obj_loc : grp_loc)->oloc->file, &statbuf->fileno[0]) < 0) + if(H5F_get_fileno((obj_loc ? obj_loc : grp_loc)->oloc->file, &statbuf->fileno[0]) < 0) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "unable to read fileno"); /* Info for soft and UD links is gotten by H5L_get_info. If we have diff --git a/src/H5Gloc.c b/src/H5Gloc.c index 40d56c6..56608e2 100644 --- a/src/H5Gloc.c +++ b/src/H5Gloc.c @@ -112,6 +112,10 @@ static herr_t H5G__loc_find_cb(H5G_loc_t *grp_loc, const char *name, static herr_t H5G__loc_find_by_idx_cb(H5G_loc_t *grp_loc, const char *name, const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata, H5G_own_loc_t *own_loc); +static herr_t H5G__loc_addr_cb(H5G_loc_t *grp_loc, const char *name, + const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata, H5G_own_loc_t *own_loc); +static herr_t H5G__loc_info_cb(H5G_loc_t *grp_loc, const char *name, + const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata, H5G_own_loc_t *own_loc); static herr_t H5G__loc_set_comment_cb(H5G_loc_t *grp_loc, const char *name, const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata, H5G_own_loc_t *own_loc); @@ -684,7 +688,79 @@ done: /*------------------------------------------------------------------------- - * Function: H5G_loc_info_cb + * Function: H5G__loc_addr_cb + * + * Purpose: Callback for retrieving the address for an object in a group + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * Saturday, December 21, 2019 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5G__loc_addr_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_ATTR_UNUSED *name, + const H5O_link_t H5_ATTR_UNUSED *lnk, H5G_loc_t *obj_loc, + void *_udata/*in,out*/, H5G_own_loc_t *own_loc/*out*/) +{ + haddr_t *udata = (haddr_t *)_udata; /* User data passed in */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the name in this group resolved to a valid link */ + if(obj_loc == NULL) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "name doesn't exist") + + /* Set address of object */ + *udata = obj_loc->oloc->addr; + +done: + /* Indicate that this callback didn't take ownership of the group * + * location for the object */ + *own_loc = H5G_OWN_NONE; + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5G__loc_addr_cb() */ + + +/*------------------------------------------------------------------------- + * Function: H5G__loc_addr + * + * Purpose: Retrieve the information for an object from a group location + * and path to that object + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * Thursday, November 23, 2006 + * + *------------------------------------------------------------------------- + */ +herr_t +H5G__loc_addr(const H5G_loc_t *loc, const char *name, haddr_t *addr/*out*/) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Check args. */ + HDassert(loc); + HDassert(name && *name); + HDassert(addr); + + /* Traverse group hierarchy to locate object */ + if(H5G_traverse(loc, name, H5G_TARGET_NORMAL, H5G__loc_addr_cb, addr) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't find object") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5G__loc_addr() */ + + +/*------------------------------------------------------------------------- + * Function: H5G__loc_info_cb * * Purpose: Callback for retrieving object info for an object in a group * @@ -696,13 +772,13 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5G_loc_info_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_ATTR_UNUSED *name, const H5O_link_t H5_ATTR_UNUSED *lnk, +H5G__loc_info_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_ATTR_UNUSED *name, const H5O_link_t H5_ATTR_UNUSED *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, H5G_own_loc_t *own_loc/*out*/) { H5G_loc_info_t *udata = (H5G_loc_info_t *)_udata; /* User data passed in */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Check if the name in this group resolved to a valid link */ if(obj_loc == NULL) @@ -718,7 +794,7 @@ done: *own_loc = H5G_OWN_NONE; FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G_loc_info_cb() */ +} /* end H5G__loc_info_cb() */ /*------------------------------------------------------------------------- @@ -752,7 +828,7 @@ H5G_loc_info(const H5G_loc_t *loc, const char *name, H5O_info_t *oinfo/*out*/, u udata.oinfo = oinfo; /* Traverse group hierarchy to locate object */ - if(H5G_traverse(loc, name, H5G_TARGET_NORMAL, H5G_loc_info_cb, &udata) < 0) + if(H5G_traverse(loc, name, H5G_TARGET_NORMAL, H5G__loc_info_cb, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't find object") done: diff --git a/src/H5Gname.c b/src/H5Gname.c index 86a0c2f..ab8ddf4 100644 --- a/src/H5Gname.c +++ b/src/H5Gname.c @@ -1195,11 +1195,11 @@ done: * Purpose: Callback for retrieving object's name by address * * Return: Positive if path is for object desired - * 0 if not correct object - * negative on failure. + * 0 if not correct object + * negative on failure. * * Programmer: Quincey Koziol - * November 4 2007 + * November 4 2007 * *------------------------------------------------------------------------- */ diff --git a/src/H5Gnode.c b/src/H5Gnode.c index b79b7d2..d11d7a0 100644 --- a/src/H5Gnode.c +++ b/src/H5Gnode.c @@ -1256,7 +1256,7 @@ H5G__node_copy(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, haddr_t addr, /* expand soft link */ if(H5G_CACHED_SLINK == src_ent->type && cpy_info->expand_soft_link) { - H5O_info_t oinfo; /* Information about object pointed to by soft link */ + haddr_t obj_addr; /* Address of object pointed to by soft link */ H5G_loc_t grp_loc; /* Group location holding soft link */ H5G_name_t grp_path; /* Path for group holding soft link */ char *link_name; /* Pointer to value of soft link */ @@ -1274,9 +1274,8 @@ H5G__node_copy(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, haddr_t addr, HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, H5_ITER_ERROR, "unable to get link name") /* Check if the object pointed by the soft link exists in the source file */ - /* Only basic information is needed */ - if(H5G_loc_info(&grp_loc, link_name, &oinfo, H5O_INFO_BASIC) >= 0) { - tmp_src_ent.header = oinfo.addr; + if(H5G__loc_addr(&grp_loc, link_name, &obj_addr) >= 0) { + tmp_src_ent.header = obj_addr; src_ent = &tmp_src_ent; } /* end if */ else diff --git a/src/H5Gpkg.h b/src/H5Gpkg.h index f475bde..6dc025c 100644 --- a/src/H5Gpkg.h +++ b/src/H5Gpkg.h @@ -498,6 +498,8 @@ H5_DLL herr_t H5G__name_init(H5G_name_t *name, const char *path); */ H5_DLL herr_t H5G__loc_insert(H5G_loc_t *grp_loc, const char *name, H5G_loc_t *obj_loc, H5O_type_t obj_type, const void *crt_info); +H5_DLL herr_t H5G__loc_addr(const H5G_loc_t *loc, const char *name, + haddr_t *addr/*out*/); /* Testing functions */ #ifdef H5G_TESTING @@ -982,9 +982,9 @@ herr_t H5Lget_info(hid_t loc_id, const char *name, H5L_info_t *linfo /*out*/, hid_t lapl_id) { - H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ - H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*sxi", loc_id, name, linfo, lapl_id); @@ -1018,11 +1018,11 @@ done: /*------------------------------------------------------------------------- * Function: H5Lget_info_by_idx * - * Purpose: Gets metadata for a link, according to the order within an + * Purpose: Gets metadata for a link, according to the order within an * index. * - * Return: Success: Non-negative with information in LINFO - * Failure: Negative + * Return: Success: Non-negative with information in LINFO + * Failure: Negative * * Programmer: Quincey Koziol * Monday, November 6, 2006 @@ -1034,9 +1034,9 @@ H5Lget_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5L_info_t *linfo /*out*/, hid_t lapl_id) { - H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ - H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE7("e", "i*sIiIohxi", loc_id, group_name, idx_type, order, n, linfo, @@ -1346,7 +1346,7 @@ done: * of the operators. * * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Thursday, November 16, 2006 * *------------------------------------------------------------------------- @@ -1490,8 +1490,8 @@ done: * library, or the negative value returned by one * of the operators. * - * Programmer: Quincey Koziol - * November 3 2007 + * Programmer: Quincey Koziol + * November 3 2007 * *------------------------------------------------------------------------- */ @@ -3174,7 +3174,7 @@ done: * * Purpose: Returns metadata about a link. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * * Programmer: James Laird * Monday, April 17 2006 diff --git a/src/H5Lprivate.h b/src/H5Lprivate.h index fa3c097..6652352 100644 --- a/src/H5Lprivate.h +++ b/src/H5Lprivate.h @@ -63,7 +63,7 @@ typedef struct { /* User data for path traversal routine for getting link info by index */ typedef struct { /* In */ - H5_index_t idx_type; /* Index to use */ + H5_index_t idx_type; /* Index to use */ H5_iter_order_t order; /* Order to iterate in index */ hsize_t n; /* Offset of link within index */ diff --git a/src/H5Oint.c b/src/H5Oint.c index 75be714..23094b9 100644 --- a/src/H5Oint.c +++ b/src/H5Oint.c @@ -56,7 +56,7 @@ /* User data for recursive traversal over objects from a group */ typedef struct { hid_t obj_id; /* The ID for the starting group */ - H5G_loc_t *start_loc; /* Location of starting group */ + H5G_loc_t *start_loc; /* Location of starting group */ H5SL_t *visited; /* Skip list for tracking visited nodes */ H5O_iterate_t op; /* Application callback */ void *op_data; /* Application's op data */ @@ -2283,63 +2283,6 @@ done: /*------------------------------------------------------------------------- - * Function: H5O__get_info_by_idx - * - * Purpose: Internal routine to retrieve an object's info according to - * an index within a group. - * - * - * Note: Add a parameter "fields" to indicate selection of object info. - * - * Return: Success: Non-negative - * Failure: Negative - * - * Programmer: Quincey Koziol - * December 28, 2017 - * - *------------------------------------------------------------------------- - */ -herr_t -H5O__get_info_by_idx(const H5G_loc_t *loc, const char *group_name, H5_index_t idx_type, - H5_iter_order_t order, hsize_t n, H5O_info_t *oinfo, unsigned fields) -{ - H5G_loc_t obj_loc; /* Location used to open group */ - H5G_name_t obj_path; /* Opened object group hier. path */ - H5O_loc_t obj_oloc; /* Opened object object location */ - hbool_t loc_found = FALSE; /* Entry at 'name' found */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE - - /* Check arguments */ - HDassert(loc); - HDassert(group_name && *group_name); - HDassert(oinfo); - - /* Set up opened group location to fill in */ - obj_loc.oloc = &obj_oloc; - obj_loc.path = &obj_path; - H5G_loc_reset(&obj_loc); - - /* Find the object's location, according to the order in the index */ - if(H5G_loc_find_by_idx(loc, group_name, idx_type, order, n, &obj_loc/*out*/) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") - loc_found = TRUE; - - /* Retrieve the object's information */ - if(H5O_get_info(obj_loc.oloc, oinfo, fields) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object info") - -done: - /* Release the object location */ - if(loc_found && H5G_loc_free(&obj_loc) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't free location") - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O__get_info_by_idx() */ - - -/*------------------------------------------------------------------------- * Function: H5O_get_create_plist * * Purpose: Retrieve the object creation properties for an object diff --git a/src/H5Opkg.h b/src/H5Opkg.h index 4afa452..c7167c7 100644 --- a/src/H5Opkg.h +++ b/src/H5Opkg.h @@ -556,8 +556,6 @@ H5_DLLVAR const H5O_obj_class_t H5O_OBJ_DATATYPE[1]; /* Package-local function prototypes */ H5_DLL const H5O_obj_class_t *H5O__obj_class(const H5O_loc_t *loc); H5_DLL int H5O__link_oh(H5F_t *f, int adjust, H5O_t *oh, hbool_t *deleted); -H5_DLL herr_t H5O__get_info_by_idx(const H5G_loc_t *loc, const char *group_name, - H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5O_info_t *oinfo, unsigned fields); H5_DLL herr_t H5O__visit(H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, H5O_iterate_t op, void *op_data, unsigned fields); H5_DLL herr_t H5O__inc_rc(H5O_t *oh); diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h index 54e8ec8..5965fc6 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -877,6 +877,7 @@ typedef struct { void *new_obj; /* Pointer to new object created */ } H5O_obj_create_t; + /* Forward declarations for prototype arguments */ struct H5P_genplist_t; diff --git a/src/H5Opublic.h b/src/H5Opublic.h index 234f4f0..cda446b 100644 --- a/src/H5Opublic.h +++ b/src/H5Opublic.h @@ -75,7 +75,7 @@ /* Flags for H5Oget_info. * Theses flags determine which fields will be filled in in the H5O_info_t - * struct. + * struct. */ #define H5O_INFO_BASIC 0x0001u /* Fill in the fileno, addr, type, and rc fields */ #define H5O_INFO_TIME 0x0002u /* Fill in the atime, mtime, ctime, and btime fields */ @@ -237,7 +237,7 @@ H5Rcreate_region(hid_t loc_id, const char *name, hid_t space_id, done: if(file_id != H5I_INVALID_HID && H5I_dec_ref(file_id) < 0) - HDONE_ERROR(H5E_REFERENCE, H5E_CANTDEC, H5I_INVALID_HID, "unable to decrement refcount on file") + HDONE_ERROR(H5E_REFERENCE, H5E_CANTDEC, FAIL, "unable to decrement refcount on file") FUNC_LEAVE_API(ret_value) } /* end H5Rcreate_region() */ @@ -326,7 +326,7 @@ H5Rcreate_attr(hid_t loc_id, const char *name, const char *attr_name, done: if(file_id != H5I_INVALID_HID && H5I_dec_ref(file_id) < 0) - HDONE_ERROR(H5E_REFERENCE, H5E_CANTDEC, H5I_INVALID_HID, "unable to decrement refcount on file") + HDONE_ERROR(H5E_REFERENCE, H5E_CANTDEC, FAIL, "unable to decrement refcount on file") FUNC_LEAVE_API(ret_value) } /* end H5Rcreate_attr() */ @@ -616,7 +616,7 @@ done: HDONE_ERROR(H5E_REFERENCE, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close object") if(H5I_INVALID_HID == ret_value) /* Cleanup on failure */ if((space_id != H5I_INVALID_HID) && (H5I_dec_ref(space_id) < 0)) - HDONE_ERROR(H5E_REFERENCE, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close dataspace") + HDONE_ERROR(H5E_REFERENCE, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close dataspace") FUNC_LEAVE_API(ret_value) } /* end H5Ropen_region() */ @@ -688,7 +688,7 @@ H5Ropen_attr(const H5R_ref_t *ref_ptr, hid_t rapl_id, hid_t aapl_id) /* Verify access property list and set up collective metadata if appropriate */ if(H5CX_set_apl(&aapl_id, H5P_CLS_AACC, loc_id, FALSE) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") /* Set location parameters */ loc_params.type = H5VL_OBJECT_BY_SELF; @@ -700,18 +700,18 @@ H5Ropen_attr(const H5R_ref_t *ref_ptr, hid_t rapl_id, hid_t aapl_id) /* Open the attribute */ if(NULL == (opened_attr = H5VL_attr_open(opened_obj, &loc_params, H5R_REF_ATTRNAME((const H5R_ref_priv_t *)ref_ptr), aapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open attribute: '%s'", H5R_REF_ATTRNAME((const H5R_ref_priv_t *)ref_ptr)) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open attribute: '%s'", H5R_REF_ATTRNAME((const H5R_ref_priv_t *)ref_ptr)) /* Register the attribute and get an ID for it */ if((ret_value = H5VL_register(H5I_ATTR, opened_attr, vol_obj->connector, TRUE)) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize attribute handle") + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize attribute handle") done: if((opened_obj_id != H5I_INVALID_HID) && (H5I_dec_ref(opened_obj_id) < 0)) HDONE_ERROR(H5E_REFERENCE, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close object") if(H5I_INVALID_HID == ret_value) /* Cleanup on failure */ if(opened_attr && H5VL_attr_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close attribute") + HDONE_ERROR(H5E_REFERENCE, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close attribute") FUNC_LEAVE_API(ret_value) } /* end H5Ropen_attr() */ @@ -746,7 +746,7 @@ H5Rget_obj_type3(const H5R_ref_t *ref_ptr, hid_t rapl_id, H5O_type_t *obj_type) || H5R__get_type((const H5R_ref_priv_t *)ref_ptr) >= H5R_MAXTYPE) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type") if(rapl_id < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a property list") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") /* Retrieve loc_id from reference */ if(H5I_INVALID_HID == (loc_id = H5R__get_loc_id((const H5R_ref_priv_t *)ref_ptr))) { @@ -770,7 +770,7 @@ H5Rget_obj_type3(const H5R_ref_t *ref_ptr, hid_t rapl_id, H5O_type_t *obj_type) /* Retrieve object's type */ if(H5VL_object_get(vol_obj, &loc_params, H5VL_OBJECT_GET_TYPE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, obj_type) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't retrieve object type") + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "can't retrieve object type") done: FUNC_LEAVE_API(ret_value) @@ -854,7 +854,7 @@ H5Rget_obj_name(const H5R_ref_t *ref_ptr, hid_t rapl_id, char *buf, size_t size) || H5R__get_type((const H5R_ref_priv_t *)ref_ptr) >= H5R_MAXTYPE) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "invalid reference type") if(rapl_id < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a property list") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "not a property list") /* Retrieve loc_id from reference */ if(H5I_INVALID_HID == (loc_id = H5R__get_loc_id((const H5R_ref_priv_t *)ref_ptr))) { @@ -878,7 +878,7 @@ H5Rget_obj_name(const H5R_ref_t *ref_ptr, hid_t rapl_id, char *buf, size_t size) /* Retrieve object's name */ if(H5VL_object_get(vol_obj, &loc_params, H5VL_OBJECT_GET_NAME, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value, buf, size) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, (-1), "can't retrieve object name") + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, (-1), "can't retrieve object name") done: FUNC_LEAVE_API(ret_value) @@ -915,3 +915,4 @@ H5Rget_attr_name(const H5R_ref_t *ref_ptr, char *buf, size_t size) done: FUNC_LEAVE_API(ret_value) } /* end H5Rget_attr_name() */ + diff --git a/src/H5Rdeprec.c b/src/H5Rdeprec.c index 25cce85..256c930 100644 --- a/src/H5Rdeprec.c +++ b/src/H5Rdeprec.c @@ -133,7 +133,7 @@ H5Rget_obj_type1(hid_t id, H5R_type_t ref_type, const void *ref) /* Retrieve object's type */ if(H5VL_object_get(vol_obj, &loc_params, H5VL_OBJECT_GET_TYPE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &obj_type) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, H5G_UNKNOWN, "can't retrieve object type") + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, H5G_UNKNOWN, "can't retrieve object type") /* Set return value */ ret_value = H5G_map_obj_type(obj_type); @@ -373,7 +373,7 @@ H5Rget_obj_type2(hid_t id, H5R_type_t ref_type, const void *ref, /* Retrieve object's type */ if(H5VL_object_get(vol_obj, &loc_params, H5VL_OBJECT_GET_TYPE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, obj_type) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't retrieve object type") + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "can't retrieve object type") done: FUNC_LEAVE_API(ret_value) @@ -492,7 +492,7 @@ H5Rget_region(hid_t id, H5R_type_t ref_type, const void *ref) /* Check if using native VOL connector */ if(H5VL_object_is_native(vol_obj, &is_native) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "can't query if file uses native VOL connector") + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, H5I_INVALID_HID, "can't query if file uses native VOL connector") /* Must use native VOL connector for this operation */ HDassert(is_native); @@ -525,7 +525,7 @@ H5Rget_region(hid_t id, H5R_type_t ref_type, const void *ref) /* Atomize */ if((ret_value = H5I_register(H5I_DATASPACE, space, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register dataspace atom") + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register dataspace atom") done: if(file_id != H5I_INVALID_HID && H5I_dec_ref(file_id) < 0) @@ -583,7 +583,7 @@ H5Rget_name(hid_t id, H5R_type_t ref_type, const void *ref, char *name, /* Retrieve object's name */ if(H5VL_object_get(vol_obj, &loc_params, H5VL_OBJECT_GET_NAME, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value, name, size) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, (-1), "can't retrieve object name") + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, (-1), "can't retrieve object name") done: FUNC_LEAVE_API(ret_value) diff --git a/src/H5Rint.c b/src/H5Rint.c index 590b3bf..c6e3875 100644 --- a/src/H5Rint.c +++ b/src/H5Rint.c @@ -529,26 +529,26 @@ H5R__reopen_file(H5R_ref_priv_t *ref, hid_t fapl_id) if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a file access property list") if(H5P_peek(plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "can't get VOL connector info") + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, H5I_INVALID_HID, "can't get VOL connector info") /* Stash a copy of the "top-level" connector property, before any pass-through * connectors modify or unwrap it. */ if(H5CX_set_vol_connector_prop(&connector_prop) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set VOL connector info in API context") + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, H5I_INVALID_HID, "can't set VOL connector info in API context") /* Open the file */ /* (Must open file read-write to allow for object modifications) */ if(NULL == (new_file = H5VL_file_open(&connector_prop, H5R_REF_FILENAME(ref), H5F_ACC_RDWR, fapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, H5I_INVALID_HID, "unable to open file") + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTOPENFILE, H5I_INVALID_HID, "unable to open file") /* Get an ID for the file */ if((ret_value = H5VL_register_using_vol_id(H5I_FILE, new_file, connector_prop.connector_id, TRUE)) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize file handle") + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize file handle") /* Get the file object */ if(NULL == (vol_obj = H5VL_vol_object(ret_value))) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "invalid object identifier") + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, H5I_INVALID_HID, "invalid object identifier") /* Make the 'post open' callback */ supported = FALSE; @@ -1382,7 +1382,7 @@ H5R__encode_heap(H5F_t *f, unsigned char *buf, size_t *nalloc, /* Write the reference information to disk (allocates space also) */ if(H5HG_insert(f, data_size, data, &hobjid) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL, "Unable to write reference information") + HGOTO_ERROR(H5E_REFERENCE, H5E_WRITEERROR, FAIL, "Unable to write reference information") /* Encode the heap information */ H5F_addr_encode(f, &p, hobjid.addr); @@ -1433,7 +1433,7 @@ H5R__decode_heap(H5F_t *f, const unsigned char *buf, size_t *nbytes, /* Read the information from disk */ if(NULL == (*data_ptr = (unsigned char *)H5HG_read(f, &hobjid, (void *)*data_ptr, data_size))) - HGOTO_ERROR(H5E_DATATYPE, H5E_READERROR, FAIL, "Unable to read reference data") + HGOTO_ERROR(H5E_REFERENCE, H5E_READERROR, FAIL, "Unable to read reference data") *nbytes = buf_size; @@ -1479,7 +1479,7 @@ H5R__free_heap(H5F_t *f, const unsigned char *buf, size_t nbytes) if(hobjid.addr > 0) { /* Free heap object */ if(H5HG_remove(f, &hobjid) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL, "Unable to remove heap object") + HGOTO_ERROR(H5E_REFERENCE, H5E_WRITEERROR, FAIL, "Unable to remove heap object") } /* end if */ done: @@ -1677,7 +1677,7 @@ H5R__encode_token_region_compat(H5F_t *f, const H5VL_token_t *obj_token, /* Allocate the space to store the serialized information */ H5_CHECK_OVERFLOW(data_size, hssize_t, size_t); if(NULL == (data = (uint8_t *)H5MM_malloc((size_t)data_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + HGOTO_ERROR(H5E_REFERENCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Serialize information for dataset OID into heap buffer */ p = (uint8_t *)data; @@ -1748,7 +1748,7 @@ H5R__decode_token_region_compat(H5F_t *f, const unsigned char *buf, /* Open and copy the dataset's dataspace */ if(NULL == (space = H5S_read(&oloc))) - HGOTO_ERROR(H5E_DATASPACE, H5E_NOTFOUND, FAIL, "not found") + HGOTO_ERROR(H5E_REFERENCE, H5E_NOTFOUND, FAIL, "not found") /* Unserialize the selection */ if(H5S_SELECT_DESERIALIZE(&space, &p) < 0) diff --git a/src/H5Rprivate.h b/src/H5Rprivate.h index 6afec47..870deaf 100644 --- a/src/H5Rprivate.h +++ b/src/H5Rprivate.h @@ -43,3 +43,4 @@ /******************************/ #endif /* _H5Rprivate_H */ + diff --git a/src/H5Rpublic.h b/src/H5Rpublic.h index a13d54b..cfbf3c8 100644 --- a/src/H5Rpublic.h +++ b/src/H5Rpublic.h @@ -71,7 +71,7 @@ typedef haddr_t hobj_ref_t; * Note! This type can only be used with the "native" HDF5 VOL connector. */ typedef struct { - char __data[H5R_DSET_REG_REF_BUF_SIZE]; + uint8_t __data[H5R_DSET_REG_REF_BUF_SIZE]; } hdset_reg_ref_t; /** @@ -80,7 +80,7 @@ typedef struct { * should always be used with the current reference API. */ typedef struct { - char __data[H5R_REF_BUF_SIZE]; + uint8_t __data[H5R_REF_BUF_SIZE]; } H5R_ref_t; /********************/ diff --git a/src/H5VLconnector.h b/src/H5VLconnector.h index 6ae43c0..4ce6bb1 100644 --- a/src/H5VLconnector.h +++ b/src/H5VLconnector.h @@ -459,14 +459,6 @@ typedef struct H5VL_blob_class_t { herr_t (*optional)(void *obj, void *blob_id, H5VL_blob_optional_t opt_type, va_list arguments); } H5VL_blob_class_t; -/* - * VOL connector identifiers. Values 0 through 255 are for connectors defined - * by the HDF5 library. Values 256 through 511 are available for testing new - * filters. Subsequent values should be obtained from the HDF5 development - * team at help@hdfgroup.org. - */ -typedef int H5VL_class_value_t; - /* Class information for each VOL connector */ typedef struct H5VL_class_t { /* Overall connector fields & callbacks */ @@ -514,6 +506,7 @@ extern "C" { #endif /* Helper routines for VOL connector authors */ +H5_DLL hid_t H5VLregister_connector(const H5VL_class_t *cls, hid_t vipl_id); H5_DLL void *H5VLobject(hid_t obj_id); H5_DLL hid_t H5VLget_file_type(void *file_obj, hid_t connector_id, hid_t dtype_id); diff --git a/src/H5VLnative.h b/src/H5VLnative.h index 2f8d5bd..44ed670 100644 --- a/src/H5VLnative.h +++ b/src/H5VLnative.h @@ -20,6 +20,11 @@ /* Public headers needed by this file */ #include "H5VLpublic.h" /* Virtual Object Layer */ + +/*****************/ +/* Public Macros */ +/*****************/ + /* Identifier for the native VOL connector */ #define H5VL_NATIVE (H5VL_native_register()) @@ -89,6 +94,18 @@ #define H5VL_NATIVE_OBJECT_ENABLE_MDC_FLUSHES 4 /* H5Oenable_mdc_flushes */ #define H5VL_NATIVE_OBJECT_ARE_MDC_FLUSHES_DISABLED 5 /* H5Oare_mdc_flushes_disabled */ +/*******************/ +/* Public Typedefs */ +/*******************/ + +/********************/ +/* Public Variables */ +/********************/ + +/*********************/ +/* Public Prototypes */ +/*********************/ + #ifdef __cplusplus extern "C" { #endif diff --git a/src/H5VLnative_link.c b/src/H5VLnative_link.c index 2a8c27a..9a633ac 100644 --- a/src/H5VLnative_link.c +++ b/src/H5VLnative_link.c @@ -255,6 +255,7 @@ H5VL__native_link_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_ } /* end else-if */ else HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link info") + break; } diff --git a/src/H5VLpublic.h b/src/H5VLpublic.h index 88afea9..34a642e 100644 --- a/src/H5VLpublic.h +++ b/src/H5VLpublic.h @@ -21,12 +21,6 @@ #include "H5public.h" /* Generic Functions */ #include "H5Ipublic.h" /* IDs */ -/* Semi-public headers mainly for VOL connector authors */ -#include "H5VLconnector.h" /* VOL connector author routines */ -#include "H5VLconnector_passthru.h" /* Pass-through VOL connector author routines */ -#include "H5VLnative.h" /* Native VOL connector macros, for VOL connector authors */ - - /*****************/ /* Public Macros */ /*****************/ @@ -34,7 +28,7 @@ /* VOL connector identifier values * These are H5VL_class_value_t values, NOT hid_t values! */ -#define H5_VOL_INVALID (-1) /* Invalid ID for VOL connector iD */ +#define H5_VOL_INVALID (-1) /* Invalid ID for VOL connector ID */ #define H5_VOL_NATIVE 0 /* Native HDF5 file format VOL connector */ #define H5_VOL_RESERVED 256 /* VOL connector IDs below this value are reserved for library use */ #define H5_VOL_MAX 65535 /* Maximum VOL connector ID */ @@ -44,6 +38,16 @@ /* Public Typedefs */ /*******************/ + +/* + * VOL connector identifiers. Values 0 through 255 are for connectors defined + * by the HDF5 library. Values 256 through 511 are available for testing new + * filters. Subsequent values should be obtained from the HDF5 development + * team at help@hdfgroup.org. + */ +typedef int H5VL_class_value_t; + + /********************/ /* Public Variables */ /********************/ @@ -59,8 +63,6 @@ extern "C" { /* The H5VL types uses in the API calls are not opaque - they are defined in * H5VLconnector.h, which is included at the top of this file. */ - -H5_DLL hid_t H5VLregister_connector(const H5VL_class_t *cls, hid_t vipl_id); H5_DLL hid_t H5VLregister_connector_by_name(const char *connector_name, hid_t vipl_id); H5_DLL hid_t H5VLregister_connector_by_value(H5VL_class_value_t connector_value, hid_t vipl_id); H5_DLL htri_t H5VLis_connector_registered(const char *name); @@ -74,5 +76,10 @@ H5_DLL herr_t H5VLunregister_connector(hid_t connector_id); } #endif +/* Semi-public headers mainly for VOL connector authors */ +#include "H5VLconnector.h" /* VOL connector author routines */ +#include "H5VLconnector_passthru.h" /* Pass-through VOL connector author routines */ +#include "H5VLnative.h" /* Native VOL connector macros, for VOL connector authors */ + #endif /* _H5VLpublic_H */ diff --git a/src/H5system.c b/src/H5system.c index 384360d..4b5e290 100644 --- a/src/H5system.c +++ b/src/H5system.c @@ -86,7 +86,9 @@ static hbool_t H5_ntzset = FALSE; * prints an `hsize_t' value as a hex number right justified and * zero filled in an 18-character field. * - * The conversion `a' refers to an `haddr_t' type. + * The conversion 'a' refers to an haddr_t type. + * + * The conversion 't' refers to an htri_t type. * * Return: Success: Number of characters printed * diff --git a/src/H5vers.txt b/src/H5vers.txt index 22117c3..4b2f222 100644 --- a/src/H5vers.txt +++ b/src/H5vers.txt @@ -20,7 +20,7 @@ # Blank lines and lines beginning with '#' are ignored # # The format of this file is as follows: -# <type>: <base routine name>; <list of parameter types for function>; <version introduced>, <list of revised versions> +# <type>: <base routine name>; <list of versioned parameter types for function>; <version introduced>, <list of revised versions> # # Where <type> is either 'FUNCTION' or 'TYPEDEF' # diff --git a/test/cork.c b/test/cork.c index 06a520d..78b6b01 100644 --- a/test/cork.c +++ b/test/cork.c @@ -99,8 +99,9 @@ verify_old_dset_cork(void) hsize_t dims[2] = {100, 20}; /* Dataset dimension sizes */ hsize_t max_dims[2] = {100, H5S_UNLIMITED}; /* Dataset maximum dimension sizes */ hsize_t chunk_dims[2] = {2, 5}; /* Dataset chunked dimension sizes */ - int buf[100][20]; /* Data buffer */ - int i = 0, j = 0; /* Local index variable */ + int **buf = NULL; /* Data bufer (pointers to fake 2D array) */ + int *buf_data = NULL; /* Data buffer (actual data) */ + int i = 0, j = 0; /* Local index variables */ H5O_info_t oinfo, oinfo2, oinfo3; /* Object metadata information */ hsize_t dims2[2] = {8, 16}; /* Dataset dimension sizes */ @@ -137,13 +138,21 @@ verify_old_dset_cork(void) if(H5C__verify_cork_tag_test(fid, oinfo.addr, TRUE) < 0) TEST_ERROR + /* Set up data array */ + if(NULL == (buf_data = (int *)HDcalloc(100 * 20, sizeof(int)))) + TEST_ERROR; + if(NULL == (buf = (int **)HDcalloc(100, sizeof(buf_data)))) + TEST_ERROR; + for (i = 0; i < 100; i++) + buf[i] = buf_data + (i * 20); + /* Initialize data buffer */ for(i = 0; i < (int)dims[0]; i++) for(j = 0; j < (int)dims[1]; j++) buf[i][j] = (i + 1) * (j + 1); /* Write to the dataset: DSET_BT1 */ - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_data) < 0) TEST_ERROR /* Verify the cork status for DSET_BT1 */ @@ -196,11 +205,6 @@ verify_old_dset_cork(void) if((fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) TEST_ERROR - /* Initialize data buffer */ - for(i = 0; i < (int)dims[0]; i++) - for(j = 0; j < (int)dims[1]; j++) - buf[i][j] = (i + 1) * (j + 1); - /* Open and write to the dataset: DSET_BT1 */ if((did = H5Dopen2(fid, DSET_BT1, H5P_DEFAULT)) < 0) TEST_ERROR @@ -249,6 +253,9 @@ verify_old_dset_cork(void) if(H5Fclose(fid) < 0) TEST_ERROR + HDfree(buf); + HDfree(buf_data); + PASSED(); return 0; @@ -265,6 +272,10 @@ error: H5Pclose(dcpl3); H5Fclose(fid); } H5E_END_TRY; + + HDfree(buf); + HDfree(buf_data); + return 1; } /* verify_old_dset_cork */ @@ -496,7 +507,9 @@ verify_dset_cork(hbool_t swmr, hbool_t new_format) hsize_t dims[2] = {100, 20}; /* Dataset dimension sizes */ hsize_t max_dims[2] = {100, H5S_UNLIMITED}; /* Dataset maximum dimension sizes */ hsize_t chunk_dims[2] = {2, 5}; /* Dataset chunked dimension sizes */ - int buf[100][20]; int i = 0, j = 0; /* Data buffer */ + int **buf = NULL; /* Data bufer (pointers to fake 2D array) */ + int *buf_data = NULL; /* Data buffer (actual data) */ + int i = 0, j = 0; /* Local index variables */ H5O_info_t oinfo, oinfo2, oinfo3; /* Object metadata information */ unsigned flags; /* File access flags */ @@ -630,6 +643,14 @@ verify_dset_cork(hbool_t swmr, hbool_t new_format) if((fid = H5Fopen(FILENAME, flags, fapl)) < 0) TEST_ERROR + /* Set up data array */ + if(NULL == (buf_data = (int *)HDcalloc(100 * 20, sizeof(int)))) + TEST_ERROR; + if(NULL == (buf = (int **)HDcalloc(100, sizeof(buf_data)))) + TEST_ERROR; + for (i = 0; i < 100; i++) + buf[i] = buf_data + (i * 20); + /* Initialize data buffer */ for(i = 0; i < (int)dims[0]; i++) for(j = 0; j < (int)dims[1]; j++) @@ -638,7 +659,7 @@ verify_dset_cork(hbool_t swmr, hbool_t new_format) /* Open and write to the dataset: DSET_EA */ if((did = H5Dopen2(fid, DSET_EA, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_data) < 0) TEST_ERROR /* Verify the cork status for DSET_EA */ @@ -648,7 +669,7 @@ verify_dset_cork(hbool_t swmr, hbool_t new_format) /* Open and write to the dataset: DSET_FA */ if((did2 = H5Dopen2(fid, DSET_FA, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Dwrite(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if(H5Dwrite(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_data) < 0) TEST_ERROR /* Cork the dataset: DSET_FA */ @@ -662,7 +683,7 @@ verify_dset_cork(hbool_t swmr, hbool_t new_format) /* Open and write to the dataset: DSET_BT2 */ if((did3 = H5Dopen2(fid, DSET_BT2, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Dwrite(did3, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if(H5Dwrite(did3, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_data) < 0) TEST_ERROR /* Verify the cork status for DSET_BT2 */ @@ -689,6 +710,9 @@ verify_dset_cork(hbool_t swmr, hbool_t new_format) if(H5Fclose(fid) < 0) TEST_ERROR + HDfree(buf); + HDfree(buf_data); + PASSED(); return 0; @@ -704,6 +728,10 @@ error: H5Pclose(fapl); H5Fclose(fid); } H5E_END_TRY; + + HDfree(buf); + HDfree(buf_data); + return 1; } /* verify_dset_cork */ @@ -1826,8 +1854,9 @@ test_dset_cork(hbool_t swmr, hbool_t new_format) hsize_t cdims[RANK] = {2,2}; /* Chunk dimensions */ int fillval = 0; /* Fill value */ int i, j, k = 0; /* Local index variables */ - int data[DIMS0][DIMS1]; /* Data buffer */ - int rbuf[DIMS0][DIMS1]; /* Data buffer */ + int **wbuf = NULL; /* Data buffer for writes (pointers to fake 2D array) */ + int *wbuf_data = NULL; /* Data buffer for writes (real data) */ + int *rbuf_data = NULL; /* Data buffer for reads (real data) */ hbool_t corked; /* Cork status of an object */ unsigned flags; /* File access flags */ @@ -1923,13 +1952,21 @@ test_dset_cork(hbool_t swmr, hbool_t new_format) if(corked) TEST_ERROR + /* Set up data array */ + if(NULL == (wbuf_data = (int *)HDcalloc(DIMS0 * DIMS1, sizeof(int)))) + TEST_ERROR; + if(NULL == (wbuf = (int **)HDcalloc(DIMS0, sizeof(wbuf_data)))) + TEST_ERROR; + for (i = 0; i < DIMS0; i++) + wbuf[i] = wbuf_data + (i * DIMS1); + /* Initialize the buffer */ for(i = 0; i < DIMS0;i++) for(j = 0;j < DIMS1;j++) - data[i][j] = k++; + wbuf[i][j] = k++; /* Write to the dataset */ - if(H5Dwrite(did1, tid1, sid, sid, H5P_DEFAULT, data) < 0) + if(H5Dwrite(did1, tid1, sid, sid, H5P_DEFAULT, wbuf_data) < 0) TEST_ERROR /* Flush the dataset */ @@ -1962,8 +1999,12 @@ test_dset_cork(hbool_t swmr, hbool_t new_format) if(corked) TEST_ERROR + /* Set up data array */ + if(NULL == (rbuf_data = (int *)HDcalloc(DIMS0 * DIMS1, sizeof(int)))) + TEST_ERROR; + /* Read from the dataset */ - if(H5Dread(did1, tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) + if(H5Dread(did1, tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf_data) < 0) TEST_ERROR /* Cork the dataset */ @@ -1993,7 +2034,7 @@ test_dset_cork(hbool_t swmr, hbool_t new_format) TEST_ERROR /* Write to the dataset */ - if(H5Dwrite(did1, tid1, sid, sid, H5P_DEFAULT, data) < 0) + if(H5Dwrite(did1, tid1, sid, sid, H5P_DEFAULT, wbuf_data) < 0) TEST_ERROR /* Refresh the dataset */ @@ -2106,6 +2147,10 @@ test_dset_cork(hbool_t swmr, hbool_t new_format) if(H5Pclose(dcpl) < 0) TEST_ERROR + HDfree(wbuf); + HDfree(wbuf_data); + HDfree(rbuf_data); + PASSED(); return 0; @@ -2121,6 +2166,11 @@ error: H5Pclose(fapl); H5Fclose(fid); } H5E_END_TRY; + + HDfree(wbuf); + HDfree(wbuf_data); + HDfree(rbuf_data); + return 1; } /* test_dset_cork() */ diff --git a/test/dsets.c b/test/dsets.c index 26a47f0..b866dfe 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -12776,20 +12776,23 @@ error: } /* end dls_01_write_data() */ static herr_t -dls_01_read_stuff( hid_t fid ) +dls_01_read_stuff(hid_t fid) { int status = 0; hid_t did = 0; H5O_info_t info; - did = H5Dopen2( fid, DLS_01_DATASET, H5P_DEFAULT ); - if ( did <= 0 ) TEST_ERROR + did = H5Dopen2(fid, DLS_01_DATASET, H5P_DEFAULT); + if(did <= 0) + TEST_ERROR - status = H5Oget_info2( did, &info, H5O_INFO_BASIC ); - if ( status != 0 ) TEST_ERROR + status = H5Oget_info2(did, &info, H5O_INFO_BASIC ); + if(status != 0) + TEST_ERROR - status = H5Dclose( did ); - if ( status != 0 ) TEST_ERROR + status = H5Dclose(did); + if(status != 0) + TEST_ERROR return SUCCEED; diff --git a/test/getname.c b/test/getname.c index 873ceb9..399f364 100644 --- a/test/getname.c +++ b/test/getname.c @@ -2380,7 +2380,7 @@ test_main(hid_t file_id, hid_t fapl) if((size = H5Iget_name(dtype, NULL, 0)) != 0) TEST_ERROR /* Create a link to the object */ - if( H5Olink(dtype, file2_id, "datatype", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if(H5Olink(dtype, file2_id, "datatype", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* Commit a second datatype with no links to it and commit it */ if((dtype_anon = H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR @@ -2405,17 +2405,17 @@ test_main(hid_t file_id, hid_t fapl) /* Check the H5Iget_name does not return an error for anon committed datatypes */ if((dtype_anon = H5Oopen_by_addr(file2_id, oinfo.addr)) < 0) TEST_ERROR - if((size = H5Iget_name(dtype_anon,NULL,0)) != 0) TEST_ERROR + if((size = H5Iget_name(dtype_anon, NULL, 0)) != 0) TEST_ERROR if(H5Tclose(dtype_anon) < 0) TEST_ERROR if(H5Fclose(file2_id) < 0) TEST_ERROR PASSED(); - return(0); + return 0; error: - return(1); + return 1; } static int diff --git a/test/links.c b/test/links.c index 5774f97..4dff1cf 100644 --- a/test/links.c +++ b/test/links.c @@ -31,10 +31,10 @@ #include "h5test.h" #include "H5srcdir.h" -#include "H5FDpkg.h" /* File drivers */ -#include "H5Gpkg.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Lprivate.h" /* Links */ +#include "H5FDpkg.h" /* File drivers */ +#include "H5Gpkg.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Lprivate.h" /* Links */ /* File for external link test. Created with gen_udlinks.c */ #define LINKED_FILE "be_extlink2.h5" @@ -537,9 +537,9 @@ cklinks(hid_t fapl, hbool_t new_format) status = H5Lexists(file, "no_grp1/hard", H5P_DEFAULT); } H5E_END_TRY; if(status >= 0) { - H5_FAILED(); - HDputs(" H5Lexists() should have failed for a path with missing components."); - TEST_ERROR + H5_FAILED(); + HDputs(" H5Lexists() should have failed for a path with missing components."); + TEST_ERROR } /* end if */ H5E_BEGIN_TRY { status = H5Lexists(file, "/no_grp1/hard", H5P_DEFAULT); @@ -635,7 +635,7 @@ cklinks(hid_t fapl, hbool_t new_format) error: return FAIL; -} +} /* end cklinks() */ /*------------------------------------------------------------------------- @@ -686,11 +686,11 @@ ck_new_links(hid_t fapl, hbool_t new_format) if(H5Fclose(file) < 0) TEST_ERROR PASSED(); - return SUCCEED; + return 0; error: - return FAIL; -} + return -1; +} /* end ck_new_links() */ /*------------------------------------------------------------------------- @@ -3456,33 +3456,58 @@ error: static int external_set_elink_fapl2(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1); /* Group IDs */ - hid_t core_fapl = -1, space = -1, dset = -1, did = -1, dapl_id = -1, dcpl = -1; - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE], - tmpname[NAME_BUF_SIZE], - cwdpath[NAME_BUF_SIZE]; - hsize_t dims[2]; - int points[NUM40][NUM40]; - int i, j, n; - h5_stat_size_t filesize, new_filesize; + hid_t fid = H5I_INVALID_HID; + hid_t gid = H5I_INVALID_HID; + hid_t core_fapl = H5I_INVALID_HID; + hid_t space = H5I_INVALID_HID; + hid_t dset = H5I_INVALID_HID; + hid_t did = H5I_INVALID_HID; + hid_t dapl_id = H5I_INVALID_HID; + hid_t dcpl = H5I_INVALID_HID; + char *filename1 = NULL; + char *filename2 = NULL; + char *tmpname = NULL; + char *cwdpath = NULL; + hsize_t dims[2]; + int **points = NULL; + int *points_data = NULL; + int i, j, n; + h5_stat_size_t filesize; + h5_stat_size_t new_filesize; if(new_format) TESTING("H5Pset/get_elink_fapl() with same physical layout (w/new group format)") else TESTING("H5Pset/get_elink_fapl() with same physical layout") + /* Set up file names and paths */ + if(NULL == (filename1 = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) + TEST_ERROR; + if(NULL == (filename2 = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) + TEST_ERROR; + if(NULL == (tmpname = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) + TEST_ERROR; + if(NULL == (cwdpath = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) + TEST_ERROR; + if((HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) || (NULL == HDgetcwd(cwdpath, (size_t)NAME_BUF_SIZE))) TEST_ERROR + /* Set up data array */ + if(NULL == (points_data = (int *)HDcalloc(NUM40 * NUM40, sizeof(int)))) + TEST_ERROR; + if(NULL == (points = (int **)HDcalloc(NUM40, sizeof(points_data)))) + TEST_ERROR; + for (i = 0; i < NUM40; i++) + points[i] = points_data + (i * NUM40); + /* * set up name for main file: * Linux: "/CWD/tmp_links/extlinks0" * Windows: "<cur drive>:/CWD/tmp_links/extlinks0" */ fix_ext_filename(tmpname, cwdpath, FILENAME[13]); - h5_fixname(tmpname, fapl, filename1, sizeof filename1); + h5_fixname(tmpname, fapl, filename1, NAME_BUF_SIZE); /* create fapl for the target file to be a "core" file */ core_fapl = h5_fileaccess(); @@ -3490,7 +3515,7 @@ external_set_elink_fapl2(hid_t fapl, hbool_t new_format) /* set up name for external linked target file: "extlinks17" */ /* set up name for target file: "extlinks17" */ - h5_fixname(FILENAME[39], core_fapl, filename2, sizeof filename2); + h5_fixname(FILENAME[39], core_fapl, filename2, NAME_BUF_SIZE); /* Create the target file to be a "core" file */ if((fid = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, core_fapl)) < 0) TEST_ERROR @@ -3505,7 +3530,8 @@ external_set_elink_fapl2(hid_t fapl, hbool_t new_format) dcpl = H5Pcreate(H5P_DATASET_CREATE); else dcpl = H5Pcopy(dcpl_g); - if (0 > dcpl) TEST_ERROR; + if (0 > dcpl) + TEST_ERROR; if(H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_LATE) < 0) TEST_ERROR; /* create "Dataset" in group "A" of target file */ @@ -3548,7 +3574,7 @@ external_set_elink_fapl2(hid_t fapl, hbool_t new_format) points[i][j] = n++; /* Write the data to the dataset */ - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, points) < 0) TEST_ERROR + if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, points_data) < 0) TEST_ERROR if(H5Pclose(dapl_id) < 0) TEST_ERROR if(H5Dclose(did) < 0) TEST_ERROR @@ -3561,6 +3587,14 @@ external_set_elink_fapl2(hid_t fapl, hbool_t new_format) if(H5Pclose(core_fapl) < 0) TEST_ERROR + HDfree(points); + HDfree(points_data); + + HDfree(filename1); + HDfree(filename2); + HDfree(tmpname); + HDfree(cwdpath); + PASSED(); return SUCCEED; @@ -3575,6 +3609,15 @@ error: H5Gclose(gid); H5Fclose(fid); } H5E_END_TRY; + + HDfree(points); + HDfree(points_data); + + HDfree(filename1); + HDfree(filename2); + HDfree(tmpname); + HDfree(cwdpath); + return FAIL; } /* end external_set_elink_fapl2() */ @@ -6059,19 +6102,26 @@ static int external_symlink(const char *env_h5_drvr, hid_t fapl, hbool_t new_format) { #ifdef H5_HAVE_SYMLINK - hid_t file1 = -1, file2 = -1, file3 = -1, file4 = -1, file5 = -1; - hid_t group2 = -1, group3 = -1, group4 = -1, group5 = -1; - char filename1[NAME_BUF_SIZE], - filename2a[NAME_BUF_SIZE], - filename2b[NAME_BUF_SIZE], - filename3a[NAME_BUF_SIZE], - filename3b[NAME_BUF_SIZE], - filename4a[NAME_BUF_SIZE], - filename4b[NAME_BUF_SIZE], - filename5a[NAME_BUF_SIZE], - filename5b[NAME_BUF_SIZE], - tmpname[NAME_BUF_SIZE], - cwdpath[NAME_BUF_SIZE]; + hid_t file1 = H5I_INVALID_HID; + hid_t file2 = H5I_INVALID_HID; + hid_t file3 = H5I_INVALID_HID; + hid_t file4 = H5I_INVALID_HID; + hid_t file5 = H5I_INVALID_HID; + hid_t group2 = H5I_INVALID_HID; + hid_t group3 = H5I_INVALID_HID; + hid_t group4 = H5I_INVALID_HID; + hid_t group5 = H5I_INVALID_HID; + char *filename1 = NULL; + char *filename2a = NULL; + char *filename2b = NULL; + char *filename3a = NULL; + char *filename3b = NULL; + char *filename4a = NULL; + char *filename4b = NULL; + char *filename5a = NULL; + char *filename5b = NULL; + char *tmpname = NULL; + char *cwdpath = NULL; hbool_t have_posix_compat_vfd; /* Whether VFD used is compatible w/POSIX I/O calls */ #endif /* H5_HAVE_SYMLINK */ @@ -6087,144 +6137,179 @@ external_symlink(const char *env_h5_drvr, hid_t fapl, hbool_t new_format) have_posix_compat_vfd = (hbool_t)(!HDstrcmp(env_h5_drvr, "sec2") || !HDstrcmp(env_h5_drvr, "core") || !HDstrcmp(env_h5_drvr, "nomatch")); - if(have_posix_compat_vfd) { - /* set up name for main file: "extlinks21A" */ - h5_fixname(FILENAME[45], fapl, filename1, sizeof(filename1)); + if(!have_posix_compat_vfd) { + SKIPPED(); + HDputs(" Current VFD doesn't support POSIX I/O calls"); + return SUCCEED; + } - /* create tmp_links directory and get current working directory path */ - if(HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) - TEST_ERROR - if(HDmkdir(TMPDIR2, (mode_t)0755) < 0 && errno != EEXIST) - TEST_ERROR - if(NULL == HDgetcwd(cwdpath, (size_t)NAME_BUF_SIZE)) - TEST_ERROR + if(NULL == (filename1 = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) + TEST_ERROR; + if(NULL == (filename2a = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) + TEST_ERROR; + if(NULL == (filename2b = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) + TEST_ERROR; + if(NULL == (filename3a = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) + TEST_ERROR; + if(NULL == (filename3b = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) + TEST_ERROR; + if(NULL == (filename4a = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) + TEST_ERROR; + if(NULL == (filename4b = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) + TEST_ERROR; + if(NULL == (filename5a = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) + TEST_ERROR; + if(NULL == (filename5b = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) + TEST_ERROR; + if(NULL == (tmpname = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) + TEST_ERROR; + if(NULL == (cwdpath = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) + TEST_ERROR; + + /* set up name for main file: "extlinks21A" */ + h5_fixname(FILENAME[45], fapl, filename1, NAME_BUF_SIZE); + + /* create tmp_links directory and get current working directory path */ + if(HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) + TEST_ERROR + if(HDmkdir(TMPDIR2, (mode_t)0755) < 0 && errno != EEXIST) + TEST_ERROR + if(NULL == HDgetcwd(cwdpath, (size_t)NAME_BUF_SIZE)) + TEST_ERROR - /* Set up names for files in the subdirectories */ + /* Set up names for files in the subdirectories */ - /* set up names for file #2 in temporary directory #2: "tmp2_links/extlinks21B" */ - h5_fixname(FILENAME[46], fapl, filename2a, sizeof(filename2a)); - fix_ext_filename(tmpname, cwdpath, FILENAME[46]); - h5_fixname(tmpname, fapl, filename2b, sizeof(filename2b)); + /* set up names for file #2 in temporary directory #2: "tmp2_links/extlinks21B" */ + h5_fixname(FILENAME[46], fapl, filename2a, NAME_BUF_SIZE); + fix_ext_filename(tmpname, cwdpath, FILENAME[46]); + h5_fixname(tmpname, fapl, filename2b, NAME_BUF_SIZE); - /* Create symbolic link #1 in temporary directory #1 to file #2 in temporary directory #2 */ - /* (i.e. tmp_links/sym1.h5 -> <full path to>/tmp2_links/extlinks21B.h5) */ - if(HDsymlink(filename2b, SYMLINK1) < 0 && errno != EEXIST) TEST_ERROR + /* Create symbolic link #1 in temporary directory #1 to file #2 in temporary directory #2 */ + /* (i.e. tmp_links/sym1.h5 -> <full path to>/tmp2_links/extlinks21B.h5) */ + if(HDsymlink(filename2b, SYMLINK1) < 0 && errno != EEXIST) TEST_ERROR - /* set up name for file #3 in temporary directory #2: "tmp2_links/extlinks21C" */ - h5_fixname(FILENAME[47], fapl, filename3a, sizeof(filename3a)); - h5_fixname(FILENAME[48], fapl, filename3b, sizeof(filename3b)); + /* set up name for file #3 in temporary directory #2: "tmp2_links/extlinks21C" */ + h5_fixname(FILENAME[47], fapl, filename3a, NAME_BUF_SIZE); + h5_fixname(FILENAME[48], fapl, filename3b, NAME_BUF_SIZE); - /* set up name for file #4 in temporary directory #1: "tmp_links/extlinks21D" */ - h5_fixname(FILENAME[49], fapl, filename4a, sizeof(filename4a)); - fix_ext_filename(tmpname, cwdpath, FILENAME[49]); - h5_fixname(tmpname, fapl, filename4b, sizeof(filename4b)); + /* set up name for file #4 in temporary directory #1: "tmp_links/extlinks21D" */ + h5_fixname(FILENAME[49], fapl, filename4a, NAME_BUF_SIZE); + fix_ext_filename(tmpname, cwdpath, FILENAME[49]); + h5_fixname(tmpname, fapl, filename4b, NAME_BUF_SIZE); - /* Create symbolic link #2 in temporary directory #2 to file #4 in temporary directory #1 */ - /* (i.e. tmp2_links/sym2.h5 -> <full path to>/tmp_links/extlinks21D.h5) */ - if(HDsymlink(filename4b, SYMLINK2) < 0 && errno != EEXIST) TEST_ERROR + /* Create symbolic link #2 in temporary directory #2 to file #4 in temporary directory #1 */ + /* (i.e. tmp2_links/sym2.h5 -> <full path to>/tmp_links/extlinks21D.h5) */ + if(HDsymlink(filename4b, SYMLINK2) < 0 && errno != EEXIST) TEST_ERROR - /* set up name for file #5 in temporary directory #1: "tmp_links/extlinks21E" */ - h5_fixname(FILENAME[50], fapl, filename5a, sizeof(filename5a)); - h5_fixname(FILENAME[51], fapl, filename5b, sizeof(filename5b)); + /* set up name for file #5 in temporary directory #1: "tmp_links/extlinks21E" */ + h5_fixname(FILENAME[50], fapl, filename5a, NAME_BUF_SIZE); + h5_fixname(FILENAME[51], fapl, filename5b, NAME_BUF_SIZE); - /* Create file #1 in current directory */ - if((file1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + /* Create file #1 in current directory */ + if((file1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - /* Create external link to file & object in temporary directory #2, using symlink #1 name */ - if(H5Lcreate_external(SYMLINK1, "group2", file1, "extlink2-sym", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + /* Create external link to file & object in temporary directory #2, using symlink #1 name */ + if(H5Lcreate_external(SYMLINK1, "group2", file1, "extlink2-sym", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - /* Close file #1 */ - if(H5Fclose(file1) < 0) TEST_ERROR + /* Close file #1 */ + if(H5Fclose(file1) < 0) TEST_ERROR + + /* Create file #2 in tmp_links directory #2 */ + if((file2 = H5Fcreate(filename2a, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if(H5Fclose(file2) < 0) TEST_ERROR - /* Create file #2 in tmp_links directory #2 */ - if((file2 = H5Fcreate(filename2a, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if(H5Fclose(file2) < 0) TEST_ERROR + /* Re-open file #2 in tmp_links directory through symlink */ + if((file2 = H5Fopen(SYMLINK1, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - /* Re-open file #2 in tmp_links directory through symlink */ - if((file2 = H5Fopen(SYMLINK1, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR + /* Create group in file #2 in temporary directory */ + if((group2 = H5Gcreate2(file2, "group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - /* Create group in file #2 in temporary directory */ - if((group2 = H5Gcreate2(file2, "group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + /* Create external link to file #3 & object in temporary directory #2 */ + if(H5Lcreate_external(filename3b, "group3", group2, "extlink3", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - /* Create external link to file #3 & object in temporary directory #2 */ - if(H5Lcreate_external(filename3b, "group3", group2, "extlink3", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + /* Close group in file #2 */ + if(H5Gclose(group2) < 0) TEST_ERROR - /* Close group in file #2 */ - if(H5Gclose(group2) < 0) TEST_ERROR + /* Close file #2 */ + if(H5Fclose(file2) < 0) TEST_ERROR - /* Close file #2 */ - if(H5Fclose(file2) < 0) TEST_ERROR + /* Create file #3 in temp. directory #2 */ + if((file3 = H5Fcreate(filename3a, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - /* Create file #3 in temp. directory #2 */ - if((file3 = H5Fcreate(filename3a, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + /* Create group in file #3 */ + if((group3 = H5Gcreate2(file3, "group3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - /* Create group in file #3 */ - if((group3 = H5Gcreate2(file3, "group3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + /* Create external link to file & object in temporary directory #1, using symlink #2 name */ + if(H5Lcreate_external(SYMLINK2, "group4", group3, "extlink4-sym", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - /* Create external link to file & object in temporary directory #1, using symlink #2 name */ - if(H5Lcreate_external(SYMLINK2, "group4", group3, "extlink4-sym", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + /* Close group in file #3 */ + if(H5Gclose(group3) < 0) TEST_ERROR - /* Close group in file #3 */ - if(H5Gclose(group3) < 0) TEST_ERROR + /* Close file #3 */ + if(H5Fclose(file3) < 0) TEST_ERROR - /* Close file #3 */ - if(H5Fclose(file3) < 0) TEST_ERROR + /* Create file #4 in temporary directory #1 */ + if((file4 = H5Fcreate(filename4b, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - /* Create file #4 in temporary directory #1 */ - if((file4 = H5Fcreate(filename4b, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + /* Create group in file #4 in 'temporary' directory */ + if((group4 = H5Gcreate2(file4, "group4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - /* Create group in file #4 in 'temporary' directory */ - if((group4 = H5Gcreate2(file4, "group4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + /* Create external link to file #5 & object in temporary directory #1 */ + if(H5Lcreate_external(filename5b, "group5", group4, "extlink5", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - /* Create external link to file #5 & object in temporary directory #1 */ - if(H5Lcreate_external(filename5b, "group5", group4, "extlink5", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + /* Close group in file #4 */ + if(H5Gclose(group4) < 0) TEST_ERROR - /* Close group in file #4 */ - if(H5Gclose(group4) < 0) TEST_ERROR + /* Close file #4 */ + if(H5Fclose(file4) < 0) TEST_ERROR - /* Close file #4 */ - if(H5Fclose(file4) < 0) TEST_ERROR + /* Create file #5 in temporary directory #1 */ + if((file5 = H5Fcreate(filename5a, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - /* Create file #5 in temporary directory #1 */ - if((file5 = H5Fcreate(filename5a, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + /* Create group in file #5 in 'temporary' directory #1 */ + if((group5 = H5Gcreate2(file5, "group5", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if(H5Gclose(group5) < 0) TEST_ERROR - /* Create group in file #5 in 'temporary' directory #1 */ - if((group5 = H5Gcreate2(file5, "group5", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(group5) < 0) TEST_ERROR + /* Close file #5 */ + if(H5Fclose(file5) < 0) TEST_ERROR - /* Close file #5 */ - if(H5Fclose(file5) < 0) TEST_ERROR + /* Actual tests... */ - /* Actual tests... */ + /* Reopen file #1 */ + if((file1 = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - /* Reopen file #1 */ - if((file1 = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR + /* Open group in file #2, through external link w/symlink */ + if((group2 = H5Gopen2(file1, "extlink2-sym", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if(H5Gclose(group2) < 0) TEST_ERROR - /* Open group in file #2, through external link w/symlink */ - if((group2 = H5Gopen2(file1, "extlink2-sym", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gclose(group2) < 0) TEST_ERROR + /* Open group in file #3, through external link w/symlink to external link */ + if((group3 = H5Gopen2(file1, "extlink2-sym/extlink3", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if(H5Gclose(group3) < 0) TEST_ERROR - /* Open group in file #3, through external link w/symlink to external link */ - if((group3 = H5Gopen2(file1, "extlink2-sym/extlink3", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gclose(group3) < 0) TEST_ERROR + /* Open group in file #4, through external link w/symlink to external link w/symlink */ + if((group4 = H5Gopen2(file1, "extlink2-sym/extlink3/extlink4-sym", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if(H5Gclose(group4) < 0) TEST_ERROR - /* Open group in file #4, through external link w/symlink to external link w/symlink */ - if((group4 = H5Gopen2(file1, "extlink2-sym/extlink3/extlink4-sym", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gclose(group4) < 0) TEST_ERROR + /* Open group in file #5, through external link w/symlink to external link w/symlink to external link */ + if((group5 = H5Gopen2(file1, "extlink2-sym/extlink3/extlink4-sym/extlink5", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if(H5Gclose(group5) < 0) TEST_ERROR - /* Open group in file #5, through external link w/symlink to external link w/symlink to external link */ - if((group5 = H5Gopen2(file1, "extlink2-sym/extlink3/extlink4-sym/extlink5", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gclose(group5) < 0) TEST_ERROR + /* Close file #1 */ + if(H5Fclose(file1) < 0) TEST_ERROR - /* Close file #1 */ - if(H5Fclose(file1) < 0) TEST_ERROR + HDfree(filename1); + HDfree(filename2a); + HDfree(filename2b); + HDfree(filename3a); + HDfree(filename3b); + HDfree(filename4a); + HDfree(filename4b); + HDfree(filename5a); + HDfree(filename5b); + HDfree(tmpname); + HDfree(cwdpath); - PASSED(); - } /* end if */ - else { - SKIPPED(); - HDputs(" Current VFD doesn't support POSIX I/O calls"); - } /* end else */ + PASSED(); return SUCCEED; @@ -6240,7 +6325,21 @@ error: H5Fclose(file2); H5Fclose(file1); } H5E_END_TRY; + + HDfree(filename1); + HDfree(filename2a); + HDfree(filename2b); + HDfree(filename3a); + HDfree(filename3b); + HDfree(filename4a); + HDfree(filename4b); + HDfree(filename5a); + HDfree(filename5b); + HDfree(tmpname); + HDfree(cwdpath); + return FAIL; + #else /* H5_HAVE_SYMLINK */ SKIPPED(); HDputs(" Current file system or operating system doesn't support symbolic links"); @@ -7081,7 +7180,7 @@ UD_hard_create(const char H5_ATTR_UNUSED * link_name, hid_t loc_group, const voi addr = *((const haddr_t *)udata); /* Open the object this link points to */ - target_obj= H5Oopen_by_addr(loc_group, addr); + target_obj = H5Oopen_by_addr(loc_group, addr); if(target_obj < 0) { ret_value = -1; goto done; @@ -7173,7 +7272,7 @@ UD_hard_delete(const char H5_ATTR_UNUSED * link_name, hid_t file, const void *ud addr = *((const haddr_t *) udata); /* Open the object this link points to */ - target_obj= H5Oopen_by_addr(file, addr); + target_obj = H5Oopen_by_addr(file, addr); if(target_obj < 0) { ret_value = -1; goto done; @@ -7371,7 +7470,7 @@ error: * Failure: -1 *------------------------------------------------------------------------- */ - /* A traversal function that ignores any udata and simply opens an object +/* A traversal function that ignores any udata and simply opens an object * in the current group named REREG_TARGET_NAME */ static hid_t @@ -7723,7 +7822,7 @@ ud_callbacks(hid_t fapl, hbool_t new_format) if(H5Gclose(gid) < 0) TEST_ERROR /* Query the link to test its query callback */ - if (H5Lget_info(fid, UD_CB_LINK_NAME, &li, H5P_DEFAULT) < 0) TEST_ERROR + if(H5Lget_info(fid, UD_CB_LINK_NAME, &li, H5P_DEFAULT) < 0) TEST_ERROR if(li.u.val_size != 16) TEST_ERROR if (UD_CB_TYPE != li.type) { H5_FAILED(); diff --git a/test/mount.c b/test/mount.c index b7d2858..72973ad 100644 --- a/test/mount.c +++ b/test/mount.c @@ -404,38 +404,41 @@ test_hide(hid_t fapl) char filename1[1024], filename2[1024]; TESTING("name hiding under mount point"); - h5_fixname(FILENAME[0], fapl, filename1, sizeof filename1); - h5_fixname(FILENAME[1], fapl, filename2, sizeof filename2); + h5_fixname(FILENAME[0], fapl, filename1, sizeof(filename1)); + h5_fixname(FILENAME[1], fapl, filename2, sizeof(filename2)); if((file1 = H5Fopen(filename1, H5F_ACC_RDONLY, fapl)) < 0 || (file2 = H5Fopen(filename2, H5F_ACC_RDONLY, fapl)) < 0) FAIL_STACK_ERROR /* Get information about file1:/mnt1/file1 for later */ - if(H5Oget_info_by_name2(file1, "/mnt1/file1", &oi1, H5O_INFO_BASIC, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if(H5Oget_info_by_name2(file1, "/mnt1/file1", &oi1, H5O_INFO_BASIC, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Build the virtual file */ - if(H5Fmount(file1, "/mnt1", file2, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if(H5Fmount(file1, "/mnt1", file2, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Original names under file1:/mnt1 should not be accessible */ H5E_BEGIN_TRY { - grp = H5Gopen2(file1, "/mnt1/file1", H5P_DEFAULT); + grp = H5Gopen2(file1, "/mnt1/file1", H5P_DEFAULT); } H5E_END_TRY; if(grp >= 0) { - H5_FAILED(); - HDputs(" Name is still accessible under mount point."); - TEST_ERROR + H5_FAILED(); + HDputs(" Name is still accessible under mount point."); + TEST_ERROR } /* end if */ /* * The original objects under file1:/mnt1 are still accessible by their * other names. This is a rather stupid test but demonstrates a point. */ - if(H5Oget_info_by_name2(file1, "/file1", &oi2, H5O_INFO_BASIC, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if(H5Oget_info_by_name2(file1, "/file1", &oi2, H5O_INFO_BASIC, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR if(oi1.fileno != oi2.fileno || H5F_addr_ne(oi1.addr, oi2.addr)) { - H5_FAILED(); - HDputs(" Hard link failed for hidden object."); - TEST_ERROR + H5_FAILED(); + HDputs(" Hard link failed for hidden object."); + TEST_ERROR } /* end if */ /* Unmount and close objects */ @@ -448,9 +451,9 @@ test_hide(hid_t fapl) error: H5E_BEGIN_TRY { - H5Gclose(grp); - H5Fclose(file1); - H5Fclose(file2); + H5Gclose(grp); + H5Fclose(file1); + H5Fclose(file2); } H5E_END_TRY; return 1; } /* end test_hide() */ @@ -490,20 +493,23 @@ test_assoc(hid_t fapl) FAIL_STACK_ERROR /* Get information about the root of file2 */ - if(H5Oget_info2(file2, &oi1, H5O_INFO_BASIC) < 0) FAIL_STACK_ERROR + if(H5Oget_info2(file2, &oi1, H5O_INFO_BASIC) < 0) + FAIL_STACK_ERROR /* Create the virtual file */ - if(H5Fmount(file1, "/mnt1", file2, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if(H5Fmount(file1, "/mnt1", file2, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* * Get info about the mount point -- should be the same as the root group * of file2. */ - if(H5Oget_info_by_name2(file1, "/mnt1", &oi2, H5O_INFO_BASIC, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if(H5Oget_info_by_name2(file1, "/mnt1", &oi2, H5O_INFO_BASIC, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR if(oi1.fileno != oi2.fileno || H5F_addr_ne(oi1.addr, oi2.addr)) { H5_FAILED(); - HDputs(" Association failed."); + HDputs(" Association failed."); TEST_ERROR } /* end if */ @@ -517,8 +523,8 @@ test_assoc(hid_t fapl) error: H5E_BEGIN_TRY { - H5Fclose(file2); - H5Fclose(file1); + H5Fclose(file2); + H5Fclose(file1); } H5E_END_TRY; return 1; } /* end test_assoc() */ diff --git a/test/mtime.c b/test/mtime.c index f7a441d..06f576b 100644 --- a/test/mtime.c +++ b/test/mtime.c @@ -39,9 +39,7 @@ const char *FILENAME[] = { * * Purpose: H5O_mtime_decode() test. * - * Return: Success: - * - * Failure: + * Return: EXIT_SUCCESS/EXIT_FAILURE * * Programmer: Robb Matzke * Thursday, July 30, 1998 @@ -188,10 +186,10 @@ main(void) /* All looks good */ HDputs("All modification time tests passed."); h5_cleanup(FILENAME, fapl); - return 0; + return EXIT_SUCCESS; /* Something broke */ error: - return 1; -} + return EXIT_FAILURE; +} /* end main() */ diff --git a/test/null_vol_connector.c b/test/null_vol_connector.c index 884bc65..985b576 100644 --- a/test/null_vol_connector.c +++ b/test/null_vol_connector.c @@ -28,105 +28,105 @@ /* The VOL class struct */ static const H5VL_class_t null_vol_g = { - 0, /* version */ - NULL_VOL_CONNECTOR_VALUE, /* value */ - NULL_VOL_CONNECTOR_NAME, /* name */ + 0, /* version */ + NULL_VOL_CONNECTOR_VALUE, /* value */ + NULL_VOL_CONNECTOR_NAME, /* name */ 0, /* capability flags */ - NULL, /* initialize */ - NULL, /* terminate */ + NULL, /* initialize */ + NULL, /* terminate */ { /* info_cls */ - (size_t)0, /* size */ - NULL, /* copy */ - NULL, /* compare */ - NULL, /* free */ - NULL, /* to_str */ - NULL, /* from_str */ + (size_t)0, /* size */ + NULL, /* copy */ + NULL, /* compare */ + NULL, /* free */ + NULL, /* to_str */ + NULL, /* from_str */ }, { /* wrap_cls */ - NULL, /* get_object */ - NULL, /* get_wrap_ctx */ - NULL, /* wrap_object */ - NULL, /* unwrap_object */ - NULL, /* free_wrap_ctx */ + NULL, /* get_object */ + NULL, /* get_wrap_ctx */ + NULL, /* wrap_object */ + NULL, /* unwrap_object */ + NULL, /* free_wrap_ctx */ }, { /* attribute_cls */ - NULL, /* create */ - NULL, /* open */ - NULL, /* read */ - NULL, /* write */ - NULL, /* get */ - NULL, /* specific */ - NULL, /* optional */ - NULL /* close */ + NULL, /* create */ + NULL, /* open */ + NULL, /* read */ + NULL, /* write */ + NULL, /* get */ + NULL, /* specific */ + NULL, /* optional */ + NULL /* close */ }, { /* dataset_cls */ - NULL, /* create */ - NULL, /* open */ - NULL, /* read */ - NULL, /* write */ - NULL, /* get */ - NULL, /* specific */ - NULL, /* optional */ - NULL /* close */ + NULL, /* create */ + NULL, /* open */ + NULL, /* read */ + NULL, /* write */ + NULL, /* get */ + NULL, /* specific */ + NULL, /* optional */ + NULL /* close */ }, { /* datatype_cls */ - NULL, /* commit */ - NULL, /* open */ - NULL, /* get_size */ - NULL, /* specific */ - NULL, /* optional */ - NULL /* close */ + NULL, /* commit */ + NULL, /* open */ + NULL, /* get_size */ + NULL, /* specific */ + NULL, /* optional */ + NULL /* close */ }, { /* file_cls */ - NULL, /* create */ - NULL, /* open */ - NULL, /* get */ - NULL, /* specific */ - NULL, /* optional */ - NULL /* close */ + NULL, /* create */ + NULL, /* open */ + NULL, /* get */ + NULL, /* specific */ + NULL, /* optional */ + NULL /* close */ }, { /* group_cls */ - NULL, /* create */ - NULL, /* open */ - NULL, /* get */ - NULL, /* specific */ - NULL, /* optional */ - NULL /* close */ + NULL, /* create */ + NULL, /* open */ + NULL, /* get */ + NULL, /* specific */ + NULL, /* optional */ + NULL /* close */ }, { /* link_cls */ - NULL, /* create */ - NULL, /* copy */ - NULL, /* move */ - NULL, /* get */ - NULL, /* specific */ - NULL /* optional */ + NULL, /* create */ + NULL, /* copy */ + NULL, /* move */ + NULL, /* get */ + NULL, /* specific */ + NULL /* optional */ }, { /* object_cls */ - NULL, /* open */ - NULL, /* copy */ - NULL, /* get */ - NULL, /* specific */ - NULL /* optional */ + NULL, /* open */ + NULL, /* copy */ + NULL, /* get */ + NULL, /* specific */ + NULL /* optional */ }, { /* introspect_cls */ - NULL, /* get_conn_cls */ - NULL, /* opt_query */ + NULL, /* get_conn_cls */ + NULL, /* opt_query */ }, { /* request_cls */ - NULL, /* wait */ - NULL, /* notify */ - NULL, /* cancel */ - NULL, /* specific */ - NULL, /* optional */ - NULL /* free */ + NULL, /* wait */ + NULL, /* notify */ + NULL, /* cancel */ + NULL, /* specific */ + NULL, /* optional */ + NULL /* free */ }, { /* blob_cls */ - NULL, /* put */ - NULL, /* get */ - NULL, /* specific */ - NULL /* optional */ + NULL, /* put */ + NULL, /* get */ + NULL, /* specific */ + NULL /* optional */ }, - NULL /* optional */ + NULL /* optional */ }; /* These two functions are necessary to load this plugin using diff --git a/test/objcopy.c b/test/objcopy.c index 751fe72..cabdbfd 100644 --- a/test/objcopy.c +++ b/test/objcopy.c @@ -157,6 +157,7 @@ const char *FILENAME[] = { #define NUM_SUB_GROUPS 20 #define NUM_WIDE_LOOP_GROUPS 10 #define NUM_DATASETS 10 +#define ATTR_CMPD_STRING "ThisIsAString" char src_obj_full_name[215]; /* the full path + name of the object to be copied */ @@ -194,9 +195,9 @@ compare_attribute_compound_vlstr(hid_t loc, hid_t loc2); * * Purpose: Add an address to the table. * - * Return: void + * Return: void * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Saturday, November 5, 2005 * *------------------------------------------------------------------------- @@ -228,11 +229,10 @@ addr_insert(H5O_info_t *oi) * * Purpose: Check if address has already been encountered * - * Return: Success: TRUE/FALSE - * - * Failure: (can't fail) + * Return: Success: TRUE/FALSE + * Failure: (can't fail) * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Saturday, November 5, 2005 * *------------------------------------------------------------------------- @@ -257,9 +257,9 @@ addr_lookup(H5O_info_t *oi) * * Purpose: Reset the address tracking data structures * - * Return: void + * Return: void * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Saturday, November 5, 2005 * *------------------------------------------------------------------------- @@ -5784,7 +5784,8 @@ attach_attribute_compound_vlstr(hid_t loc_id) int i; char *v; } s1; - s1 buf; /* Buffer */ + size_t len; + s1 buf = {0, NULL}; /* Buffer */ int ret_value = -1; /* Return value */ /* Create dataspace */ @@ -5814,8 +5815,11 @@ attach_attribute_compound_vlstr(hid_t loc_id) goto done; /* Write to the attribute */ + len = HDstrlen(ATTR_CMPD_STRING) + 1; buf.i = 9; - buf.v = "ThisIsAString"; + if(NULL == (buf.v = (char *)HDcalloc(len, sizeof(char)))) + goto done; + HDstrncpy(buf.v, ATTR_CMPD_STRING, len); if(H5Awrite(aid, cmpd_tid, &buf) < 0) goto done; @@ -5832,6 +5836,9 @@ done: H5Tclose(cmpd_tid); if(aid > 0) H5Aclose(aid); + + HDfree(buf.v); + return ret_value; } /* attach_attribute_compound_vlstr */ @@ -11464,8 +11471,8 @@ error: H5Tclose(f_tid); H5Tclose(g_tid); H5Tclose(anon_tid); - H5Pclose(ocpypl_id); - H5Aclose(aid); + H5Pclose(ocpypl_id); + H5Aclose(aid); H5Dclose(did); H5Sclose(sid); H5Gclose(gid); @@ -11704,14 +11711,14 @@ test_copy_cdt_merge_cdt(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t ds error: H5E_BEGIN_TRY { - H5Pclose(ocpypl_id); - H5Tclose(tid); - H5Tclose(tid1); - H5Tclose(tid2); - H5Tclose(tid3); - H5Tclose(tid4); - H5Tclose(tid5); - H5Aclose(aid); + H5Pclose(ocpypl_id); + H5Tclose(tid); + H5Tclose(tid1); + H5Tclose(tid2); + H5Tclose(tid3); + H5Tclose(tid4); + H5Tclose(tid5); + H5Aclose(aid); H5Sclose(sid); H5Fclose(fid_dst); H5Fclose(fid_src); diff --git a/test/objcopy_ref.c b/test/objcopy_ref.c index b539b8a..4637f23 100644 --- a/test/objcopy_ref.c +++ b/test/objcopy_ref.c @@ -44,53 +44,15 @@ const char *FILENAME[] = { #define CONFIG_DENSE 16 #define MAX_CONFIGURATION 31 -#define NAME_DATATYPE_SIMPLE "H5T_NATIVE_INT" -#define NAME_DATATYPE_SIMPLE2 "H5T_NATIVE_INT-2" -#define NAME_DATATYPE_VL "vlen of int" -#define NAME_DATATYPE_VL_VL "vlen of vlen of int" #define NAME_DATASET_SIMPLE "dataset_simple" -#define NAME_DATASET_SIMPLE2 "dataset_simple_copy" -#define NAME_DATASET_SIMPLE3 "dataset_simple_another_copy" -#define NAME_DATASET_COMPOUND "dataset_compound" -#define NAME_DATASET_CHUNKED "dataset_chunked" -#define NAME_DATASET_CHUNKED_SINGLE "dataset_chunked_single" -#define NAME_DATASET_CHUNKED2 "dataset_chunked2" -#define NAME_DATASET_CHUNKED2_SINGLE "dataset_chunked2_single" -#define NAME_DATASET_CHUNKED3 "dataset_chunked3" -#define NAME_DATASET_CHUNKED3_SINGLE "dataset_chunked3_single" -#define NAME_DATASET_CHUNKED4 "dataset_chunked4" -#define NAME_DATASET_CHUNKED4_SINGLE "dataset_chunked4_single" -#define NAME_DATASET_COMPACT "dataset_compact" -#define NAME_DATASET_EXTERNAL "dataset_ext" -#define NAME_DATASET_NAMED_DTYPE "dataset_named_dtype" -#define NAME_DATASET_NAMED_DTYPE2 "dataset_named_dtype2" -#define NAME_DATASET_MULTI_OHDR "dataset_multi_ohdr" -#define NAME_DATASET_MULTI_OHDR2 "dataset_multi_ohdr2" -#define NAME_DATASET_VL "dataset_vl" -#define NAME_DATASET_VL2 "dataset_vl2" -#define NAME_DATASET_VL_VL "dataset_vl_vl" -#define NAME_DATASET_VL_VL2 "dataset_vl_vl2" -#define NAME_DATASET_CMPD_VL "dataset_cmpd_vl" #define NAME_DATASET_SUB_SUB "/g0/g00/g000/dataset_simple" #define NAME_GROUP_UNCOPIED "/uncopied" -#define NAME_GROUP_EMPTY "/empty" #define NAME_GROUP_TOP "/g0" -#define NAME_GROUP_TOP2 "/g1" -#define NAME_GROUP_TOP3 "/g2" -#define NAME_GROUP_TOP4 "/g3" #define NAME_GROUP_SUB "/g0/g00" -#define NAME_GROUP_SUB_2 "/g0/g01" -#define NAME_GROUP_SUB_SUB "/g0/g00/g000" #define NAME_GROUP_SUB_SUB2 "g000" -#define NAME_GROUP_DATASET "/g0/dataset_simple" #define NAME_GROUP_LINK "/g_links" #define NAME_GROUP_LINK2 "/g_links2" -#define NAME_GROUP_LOOP "g_loop" -#define NAME_GROUP_LOOP2 "g_loop2" -#define NAME_GROUP_LOOP3 "g_loop3" #define NAME_GROUP_REF "ref_grp" -#define NAME_LINK_DATASET "/g_links/dataset_simple" -#define NAME_LINK_HARD "/g_links/hard_link_to_dataset_simple" #define NAME_LINK_SOFT "/g_links/soft_link_to_dataset_simple" #define NAME_LINK_SOFT2 "/g_links2/soft_link_to_dataset_simple" #define NAME_LINK_EXTERN "/g_links/external_link_to_dataset_simple" @@ -99,19 +61,11 @@ const char *FILENAME[] = { #define NAME_LINK_SOFT_DANGLE2 "/g_links2/soft_link_to_nowhere" #define NAME_LINK_EXTERN_DANGLE "/g_links/external_link_to_nowhere" #define NAME_LINK_EXTERN_DANGLE2 "/g_links2/external_link_to_nowhere" -#define NAME_OLD_FORMAT "/dset1" #define NAME_BUF_SIZE 1024 #define ATTR_NAME_LEN 80 #define DIM_SIZE_1 12 #define DIM_SIZE_2 6 -#define MAX_DIM_SIZE_1 100 -#define MAX_DIM_SIZE_2 80 -#define CHUNK_SIZE_1 5 /* Not an even fraction of dimension sizes, so we test copying partial chunks */ -#define CHUNK_SIZE_2 5 -#define NUM_SUB_GROUPS 20 -#define NUM_WIDE_LOOP_GROUPS 10 -#define NUM_DATASETS 10 unsigned num_attributes_g; /* Number of attributes created */ @@ -137,9 +91,9 @@ compare_groups(hid_t gid, hid_t gid2, hid_t pid, int depth, unsigned copy_flags) * * Purpose: Add an address to the table. * - * Return: void + * Return: void * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Saturday, November 5, 2005 * *------------------------------------------------------------------------- @@ -171,11 +125,10 @@ addr_insert(H5O_info_t *oi) * * Purpose: Check if address has already been encountered * - * Return: Success: TRUE/FALSE - * - * Failure: (can't fail) + * Return: Success: TRUE/FALSE + * Failure: (can't fail) * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Saturday, November 5, 2005 * *------------------------------------------------------------------------- @@ -200,9 +153,9 @@ addr_lookup(H5O_info_t *oi) * * Purpose: Reset the address tracking data structures * - * Return: void + * Return: void * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Saturday, November 5, 2005 * *------------------------------------------------------------------------- diff --git a/test/ohdr.c b/test/ohdr.c index 9d2d414..53d2f59 100644 --- a/test/ohdr.c +++ b/test/ohdr.c @@ -50,7 +50,8 @@ const char *FILENAME[] = { * To get this data file, define H5O_ENABLE_BOGUS in src/H5Oprivate, rebuild * the library and simply compile gen_bogus.c with that HDF5 library and run it. */ -#define FILE_BOGUS "tbogus.h5" +#define FILE_BOGUS "tbogus.h5" +#define TESTFILE_LEN 256 /* */ #define FILE_OHDR_SWMR "ohdr_swmr.h5" @@ -473,13 +474,13 @@ test_unknown(unsigned bogus_id, char *filename, hid_t fapl) hid_t fid_bogus = -1; /* bogus file ID */ hid_t gid_bogus = -1; /* bogus group ID */ hid_t loc_bogus = -1; /* location: bogus file or group ID */ - char testfile[256]; + char testfile[TESTFILE_LEN]; /* create a different name for a local copy of the data file to be opened with rd/wr file permissions in case build and test are done in the source directory. */ - HDstrncpy(testfile, FILE_BOGUS, HDstrlen(FILE_BOGUS)); - testfile[HDstrlen(FILE_BOGUS)]='\0'; + HDstrncpy(testfile, FILE_BOGUS, TESTFILE_LEN); + testfile[TESTFILE_LEN - 1]='\0'; HDstrncat(testfile, ".copy", 5); /* Make a copy of the data file from svn. */ @@ -759,7 +760,7 @@ count_attributes(hid_t dset_id) { H5O_info_t info; - if(H5Oget_info2(dset_id, &info, H5O_INFO_ALL) < 0) + if(H5Oget_info2(dset_id, &info, H5O_INFO_NUM_ATTRS) < 0) return -1; else return (int)info.num_attrs; /* should never exceed int bounds */ diff --git a/test/titerate.c b/test/titerate.c index 289a46c..669a094 100644 --- a/test/titerate.c +++ b/test/titerate.c @@ -1045,10 +1045,10 @@ test_iterate(void) /* These next tests use the same file */ for(new_format = FALSE; new_format <= TRUE; new_format++) { test_iter_group(new_format ? fapl2 : fapl, new_format); /* Test group iteration */ - test_iter_group_large(new_format ? fapl2 : fapl); /* Test group iteration for large # of objects */ + test_iter_group_large(new_format ? fapl2 : fapl); /* Test group iteration for large # of objects */ test_iter_attr(new_format ? fapl2 : fapl, new_format); /* Test attribute iteration */ - test_grp_memb_funcs(new_format ? fapl2 : fapl); /* Test group member information functions */ - test_links(new_format ? fapl2 : fapl); /* Test soft and hard link iteration */ + test_grp_memb_funcs(new_format ? fapl2 : fapl); /* Test group member information functions */ + test_links(new_format ? fapl2 : fapl); /* Test soft and hard link iteration */ } /* end for */ /* Test the fix for issue HDFFV-10588 */ diff --git a/test/trefer.c b/test/trefer.c index 04b34eb..dec049e 100644 --- a/test/trefer.c +++ b/test/trefer.c @@ -568,7 +568,7 @@ test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high) hsize_t high[SPACE2_RANK]; /* Selection bounds */ H5R_ref_t *wbuf, /* buffer to write to disk */ *rbuf; /* buffer read from disk */ - H5R_ref_t nvrbuf[3]={{{0}},{{101}},{{255}}}; /* buffer with non-valid refs */ + H5R_ref_t nvrbuf[3]={{{0}},{{101}},{{-128}}}; /* buffer with non-valid refs */ uint8_t *dwbuf, /* Buffer for writing numeric data to disk */ *drbuf; /* Buffer for reading numeric data from disk */ uint8_t *tu8; /* Temporary pointer to uint8 data */ diff --git a/test/trefer_deprec.c b/test/trefer_deprec.c index 272b866..6322894 100644 --- a/test/trefer_deprec.c +++ b/test/trefer_deprec.c @@ -517,7 +517,7 @@ test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high) hsize_t high[SPACE2_RANK]; /* Selection bounds */ hdset_reg_ref_t *wbuf, /* buffer to write to disk */ *rbuf; /* buffer read from disk */ - hdset_reg_ref_t nvrbuf[3]={{{0}},{{101}},{{255}}}; /* buffer with non-valid refs */ + hdset_reg_ref_t nvrbuf[3]={{{0}},{{101}},{{-128}}}; /* buffer with non-valid refs */ uint8_t *dwbuf, /* Buffer for writing numeric data to disk */ *drbuf; /* Buffer for reading numeric data from disk */ uint8_t *tu8; /* Temporary pointer to uint8 data */ diff --git a/test/unlink.c b/test/unlink.c index 6825dec..5199dcf 100644 --- a/test/unlink.c +++ b/test/unlink.c @@ -441,7 +441,7 @@ check_new_move(hid_t fapl) TESTING("check new move function"); /* Open file */ - h5_fixname(FILENAME[1], fapl, filename, sizeof filename); + h5_fixname(FILENAME[1], fapl, filename, sizeof(filename)); if((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) FAIL_STACK_ERROR @@ -458,7 +458,7 @@ check_new_move(hid_t fapl) FAIL_PUTS_ERROR(" Hard link test failed. Link seems not to point to the expected file location.") /* Check soft links */ - if(H5Lget_val(file, "group2/soft", linkval, sizeof linkval, H5P_DEFAULT) < 0) + if(H5Lget_val(file, "group2/soft", linkval, sizeof(linkval), H5P_DEFAULT) < 0) FAIL_STACK_ERROR if(HDstrcmp(linkval, "/group1/group_move")) FAIL_PUTS_ERROR(" Soft link test failed. Wrong link value") diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c index 7a184e6..84b8eb8 100644 --- a/tools/lib/h5tools.c +++ b/tools/lib/h5tools.c @@ -1804,10 +1804,10 @@ h5tools_is_zero(const void *_mem, size_t size) */ hbool_t h5tools_is_obj_same(hid_t loc_id1, const char *name1, - hid_t loc_id2, const char *name2) + hid_t loc_id2, const char *name2) { H5O_info_t oinfo1, oinfo2; - hbool_t ret_val = 0; + hbool_t ret_val = FALSE; if ( name1 && HDstrcmp(name1, ".")) H5Oget_info_by_name2(loc_id1, name1, &oinfo1, H5O_INFO_BASIC, H5P_DEFAULT); @@ -1820,7 +1820,7 @@ h5tools_is_obj_same(hid_t loc_id1, const char *name1, H5Oget_info2(loc_id2, &oinfo2, H5O_INFO_BASIC); if (oinfo1.fileno == oinfo2.fileno && oinfo1.addr==oinfo2.addr) - ret_val = 1; + ret_val = TRUE; return ret_val; } diff --git a/tools/src/h5dump/h5dump_xml.c b/tools/src/h5dump/h5dump_xml.c index b78cf00..b63e68d 100644 --- a/tools/src/h5dump/h5dump_xml.c +++ b/tools/src/h5dump/h5dump_xml.c @@ -610,7 +610,7 @@ xml_name_to_XID(const char *str , char *outstr, int outlen, int gen) HDsprintf(outstr, "xid_"H5_PRINTF_HADDR_FMT, objno); - return(0); + return 0; } static const char *quote = """; diff --git a/tools/src/h5stat/h5stat.c b/tools/src/h5stat/h5stat.c index 2ba95f2..9ce7327 100644 --- a/tools/src/h5stat/h5stat.c +++ b/tools/src/h5stat/h5stat.c @@ -399,7 +399,7 @@ attribute_stats(iter_t *iter, const H5O_info_t *oi) iter->attr_bins = (unsigned long *)HDrealloc(iter->attr_bins, (bin + 1) * sizeof(unsigned long)); HDassert(iter->attr_bins); - /* Initialize counts for intermediate bins */ + /* Initialize counts for intermediate bins */ while(iter->attr_nbins < bin) iter->attr_bins[iter->attr_nbins++] = 0; iter->attr_nbins++; |