From c0958cb7547bbb7816582168b2f615ac293067e2 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Tue, 12 Apr 2011 12:58:28 -0500 Subject: [svn-r20481] Description: Bring r20480 from trunk to 1.8 branch: Remove global variable for the path name in the group traversal code. Also clean up a bunch of compiler warnings. Tested on: Mac OS X/32 10.6.7 (amazon) w/debug & production (h5committested on trunk) --- src/H5B2cache.c | 2 +- src/H5G.c | 3 --- src/H5Gpkg.h | 1 - src/H5Gtraverse.c | 74 +++++++++++++++++------------------------------------ src/H5Pdcpl.c | 2 +- src/H5detect.c | 2 +- test/dsets.c | 8 +++--- tools/lib/h5tools.c | 14 +++++++--- 8 files changed, 41 insertions(+), 65 deletions(-) diff --git a/src/H5B2cache.c b/src/H5B2cache.c index ba87eb9..bdb9868 100644 --- a/src/H5B2cache.c +++ b/src/H5B2cache.c @@ -830,7 +830,7 @@ H5B2_cache_internal_size(const H5F_t UNUSED *f, const H5B2_internal_t *internal, *------------------------------------------------------------------------- */ static H5B2_leaf_t * -H5B2_cache_leaf_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata) +H5B2_cache_leaf_load(H5F_t UNUSED *f, hid_t dxpl_id, haddr_t addr, void *_udata) { H5B2_leaf_cache_ud_t *udata = (H5B2_leaf_cache_ud_t *)_udata; H5B2_leaf_t *leaf = NULL; /* Pointer to lead node loaded */ diff --git a/src/H5G.c b/src/H5G.c index 2093329..5c7741c 100644 --- a/src/H5G.c +++ b/src/H5G.c @@ -843,9 +843,6 @@ H5G_term_interface(void) /* Destroy the group object id group */ H5I_dec_type_ref(H5I_GROUP); - /* Free the global component buffer */ - H5G_traverse_term_interface(); - /* Mark closed */ H5_interface_initialize_g = 0; n = 1; /*H5I*/ diff --git a/src/H5Gpkg.h b/src/H5Gpkg.h index 78e66d0..dfaf112 100644 --- a/src/H5Gpkg.h +++ b/src/H5Gpkg.h @@ -391,7 +391,6 @@ H5_DLL herr_t H5G_iterate(hid_t loc_id, const char *group_name, /* * Group hierarchy traversal routines */ -H5_DLL herr_t H5G_traverse_term_interface(void); H5_DLL herr_t H5G_traverse_special(const H5G_loc_t *grp_loc, const H5O_link_t *lnk, unsigned target, size_t *nlinks, hbool_t last_comp, H5G_loc_t *obj_loc, hbool_t *obj_exists, hid_t lapl_id, hid_t dxpl_id); diff --git a/src/H5Gtraverse.c b/src/H5Gtraverse.c index fadbaaa..3d82b6f 100644 --- a/src/H5Gtraverse.c +++ b/src/H5Gtraverse.c @@ -38,6 +38,7 @@ #include "H5Lprivate.h" /* Links */ #include "H5MMprivate.h" /* Memory management */ #include "H5Ppublic.h" /* Property Lists */ +#include "H5WBprivate.h" /* Wrapped Buffers */ /* Private typedefs */ @@ -54,8 +55,6 @@ typedef struct { /* Private macros */ /* Local variables */ -static char *H5G_comp_g = NULL; /*component buffer */ -static size_t H5G_comp_alloc_g = 0; /*sizeof component buffer */ /* PRIVATE PROTOTYPES */ static herr_t H5G_traverse_slink_cb(H5G_loc_t *grp_loc, const char *name, @@ -74,34 +73,6 @@ static herr_t H5G_traverse_real(const H5G_loc_t *loc, const char *name, /*------------------------------------------------------------------------- - * Function: H5G_traverse_term_interface - * - * Purpose: Terminates part of the H5G interface - free the global - * component buffer. - * - * Return: Success: Non-negative. - * - * Failure: Negative. - * - * Programmer: Quincey Koziol - * Monday, September 26, 2005 - * - *------------------------------------------------------------------------- - */ -herr_t -H5G_traverse_term_interface(void) -{ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_traverse_term_interface) - - /* Free the global component buffer */ - H5G_comp_g = (char *)H5MM_xfree(H5G_comp_g); - H5G_comp_alloc_g = 0; - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5G_traverse_term_interface() */ - - -/*------------------------------------------------------------------------- * Function: H5G_traverse_slink_cb * * Purpose: Callback for soft link traversal. This routine sets the @@ -570,8 +541,11 @@ H5G_traverse_real(const H5G_loc_t *_loc, const char *name, unsigned target, H5O_link_t lnk; /* Link information for object */ hbool_t link_valid = FALSE; /* Flag to indicate that the link information is valid */ hbool_t obj_loc_valid = FALSE; /* Flag to indicate that the object location is valid */ - H5G_own_loc_t own_loc=H5G_OWN_NONE; /* Enum to indicate whether callback took ownership of locations*/ + H5G_own_loc_t own_loc = H5G_OWN_NONE; /* Enum to indicate whether callback took ownership of locations*/ hbool_t group_copy = FALSE; /* Flag to indicate that the group entry is copied */ + char comp_buf[1024]; /* Temporary buffer for path components */ + char *comp; /* Pointer to buffer for path components */ + H5WB_t *wb = NULL; /* Wrapped buffer for temporary buffer */ hbool_t last_comp = FALSE; /* Flag to indicate that a component is the last component in the name */ herr_t ret_value = SUCCEED; /* Return value */ @@ -596,8 +570,8 @@ H5G_traverse_real(const H5G_loc_t *_loc, const char *name, unsigned target, HDassert(root_grp); /* Set the location entry to the root group's info */ - loc.oloc=&(root_grp->oloc); - loc.path=&(root_grp->path); + loc.oloc = &(root_grp->oloc); + loc.path = &(root_grp->path); } /* end if */ else { loc.oloc = _loc->oloc; @@ -625,17 +599,13 @@ H5G_traverse_real(const H5G_loc_t *_loc, const char *name, unsigned target, if(H5G_loc_reset(&obj_loc) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to reset location") - /* Check for needing a larger buffer for the individual path name components */ - if((HDstrlen(name) + 1) > H5G_comp_alloc_g) { - char *new_comp; /* New component buffer */ - size_t new_alloc; /* New component buffer size */ + /* Wrap the local buffer for serialized header info */ + if(NULL == (wb = H5WB_wrap(comp_buf, sizeof(comp_buf)))) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't wrap buffer") - new_alloc = MAX3(1024, (2 * H5G_comp_alloc_g), (HDstrlen(name) + 1)); - if(NULL == (new_comp = (char *)H5MM_realloc(H5G_comp_g, new_alloc))) - HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "unable to allocate component buffer") - H5G_comp_g = new_comp; - H5G_comp_alloc_g = new_alloc; - } /* end if */ + /* Get a pointer to a buffer that's large enough */ + if(NULL == (comp = (uint8_t *)H5WB_actual(wb, (HDstrlen(name) + 1)))) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't get actual buffer") /* Traverse the path */ while((name = H5G_component(name, &nchars)) && *name) { @@ -647,13 +617,13 @@ H5G_traverse_real(const H5G_loc_t *_loc, const char *name, unsigned target, * Copy the component name into a null-terminated buffer so * we can pass it down to the other symbol table functions. */ - HDmemcpy(H5G_comp_g, name, nchars); - H5G_comp_g[nchars] = '\0'; + HDmemcpy(comp, name, nchars); + comp[nchars] = '\0'; /* * The special name `.' is a no-op. */ - if('.' == H5G_comp_g[0] && !H5G_comp_g[1]) { + if('.' == comp[0] && !comp[1]) { name += nchars; continue; } /* end if */ @@ -669,7 +639,7 @@ H5G_traverse_real(const H5G_loc_t *_loc, const char *name, unsigned target, } /* end if */ /* Get information for object in current group */ - if((lookup_status = H5G_obj_lookup(grp_loc.oloc, H5G_comp_g, &lnk/*out*/, dxpl_id)) < 0) + if((lookup_status = H5G_obj_lookup(grp_loc.oloc, comp, &lnk/*out*/, dxpl_id)) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't look up component") obj_exists = FALSE; @@ -677,7 +647,7 @@ H5G_traverse_real(const H5G_loc_t *_loc, const char *name, unsigned target, if(lookup_status) { /* Sanity check link and indicate it's valid */ HDassert(lnk.type >= H5L_TYPE_HARD); - HDassert(!HDstrcmp(H5G_comp_g, lnk.name)); + HDassert(!HDstrcmp(comp, lnk.name)); link_valid = TRUE; /* Build object location from the link */ @@ -714,7 +684,7 @@ H5G_traverse_real(const H5G_loc_t *_loc, const char *name, unsigned target, } /* end else */ /* Call 'operator' routine */ - if((op)(&grp_loc, H5G_comp_g, cb_lnk, cb_loc, op_data, &own_loc) < 0) + if((op)(&grp_loc, comp, cb_lnk, cb_loc, op_data, &own_loc) < 0) HGOTO_ERROR(H5E_SYM, H5E_CALLBACK, FAIL, "traversal operator failed") HGOTO_DONE(SUCCEED) @@ -796,7 +766,7 @@ H5G_traverse_real(const H5G_loc_t *_loc, const char *name, unsigned target, HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group entry") /* Insert new group into current group's symbol table */ - if(H5G_loc_insert(&grp_loc, H5G_comp_g, &obj_loc, H5O_TYPE_GROUP, &gcrt_info, dxpl_id) < 0) + if(H5G_loc_insert(&grp_loc, comp, &obj_loc, H5O_TYPE_GROUP, &gcrt_info, dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "unable to insert intermediate group") /* Decrement refcount on intermediate group's object header in memory */ @@ -877,6 +847,10 @@ done: if(H5O_msg_reset(H5O_LINK_ID, &lnk) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to reset link message") + /* Release temporary component buffer */ + if(wb && H5WB_unwrap(wb) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't release wrapped buffer") + FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_traverse_real() */ diff --git a/src/H5Pdcpl.c b/src/H5Pdcpl.c index d2aa8d5..a06304c 100644 --- a/src/H5Pdcpl.c +++ b/src/H5Pdcpl.c @@ -52,7 +52,7 @@ /* Define default layout information */ #define H5D_DEF_STORAGE_COMPACT_INIT {(hbool_t)FALSE, (size_t)0, NULL} #define H5D_DEF_STORAGE_CONTIG_INIT {HADDR_UNDEF, (hsize_t)0} -#define H5D_DEF_STORAGE_CHUNK_INIT {H5D_CHUNK_BTREE, HADDR_UNDEF, NULL, {{NULL}}} +#define H5D_DEF_STORAGE_CHUNK_INIT {H5D_CHUNK_BTREE, HADDR_UNDEF, NULL, {{HADDR_UNDEF, NULL}}} #define H5D_DEF_LAYOUT_CHUNK_INIT {(unsigned)0, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, (uint32_t)0, (hsize_t)0, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}} #ifdef H5_HAVE_C99_DESIGNATED_INITIALIZER #define H5D_DEF_STORAGE_COMPACT {H5D_COMPACT, { .compact = H5D_DEF_STORAGE_COMPACT_INIT }} diff --git a/src/H5detect.c b/src/H5detect.c index 29955a1..0461cfd 100644 --- a/src/H5detect.c +++ b/src/H5detect.c @@ -739,7 +739,7 @@ H5TN_init_interface(void)\n\ done:\n\ if(ret_value < 0) {\n\ if(dt != NULL) {\n\ - H5FL_FREE(H5T_shared_t, dt->shared);\n\ + dt->shared = H5FL_FREE(H5T_shared_t, dt->shared);\n\ dt = H5FL_FREE(H5T_t, dt);\n\ } /* end if */\n\ } /* end if */\n\ diff --git a/test/dsets.c b/test/dsets.c index 682dfce..627fdae 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -4089,7 +4089,7 @@ test_nbit_int_size(hid_t file) */ if((precision = H5Tget_precision(datatype)) == 0) { H5_FAILED(); - printf(" Line %d: wrong precision size: %d\n",__LINE__, precision); + printf(" Line %d: wrong precision size: %zu\n",__LINE__, precision); goto error; } /* end if */ @@ -4099,7 +4099,7 @@ test_nbit_int_size(hid_t file) if((dset_size = H5Dget_storage_size(dataset)) < DSET_DIM1*DSET_DIM2*(precision/8) || dset_size > DSET_DIM1*DSET_DIM2*(precision/8) + 1*KB) { H5_FAILED(); - printf(" Line %d: wrong dataset size: %d\n",__LINE__, dset_size); + HDfprintf(stdout, " Line %d: wrong dataset size: %Hu\n",__LINE__, dset_size); goto error; } /* end if */ @@ -4296,7 +4296,7 @@ test_nbit_flt_size(hid_t file) */ if((precision = H5Tget_precision(datatype)) == 0) { H5_FAILED(); - printf(" Line %d: wrong precision size: %d\n",__LINE__, precision); + printf(" Line %d: wrong precision size: %zu\n",__LINE__, precision); goto error; } /* end if */ @@ -4306,7 +4306,7 @@ test_nbit_flt_size(hid_t file) if((dset_size = H5Dget_storage_size(dataset)) < DSET_DIM1*DSET_DIM2*(precision/8) || dset_size > DSET_DIM1*DSET_DIM2*(precision/8) + 1*KB) { H5_FAILED(); - printf(" Line %d: wrong dataset size: %d\n",__LINE__, dset_size); + HDfprintf(stdout, " Line %d: wrong dataset size: %Hu\n",__LINE__, dset_size); goto error; } /* end if */ diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c index 18d9035..730a1d5 100644 --- a/tools/lib/h5tools.c +++ b/tools/lib/h5tools.c @@ -2083,6 +2083,7 @@ h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_c size_t p_type_nbytes; /* size of memory type */ hsize_t sm_size[H5S_MAX_RANK]; /* stripmine size */ hsize_t sm_nbytes; /* bytes per stripmine */ + hssize_t ssm_nelmts; /* elements per stripmine*/ hsize_t sm_nelmts; /* elements per stripmine*/ unsigned char *sm_buf = NULL; /* buffer for raw data */ hid_t sm_space = -1; /* stripmine data space */ @@ -2125,8 +2126,9 @@ h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_c if(H5Sselect_hyperslab(f_space, H5S_SELECT_SET, temp_start, temp_stride, temp_count, temp_block) < 0) H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Sselect_hyperslab failed"); - if((sm_nelmts = H5Sget_select_npoints(f_space)) < 0) + if((ssm_nelmts = H5Sget_select_npoints(f_space)) < 0) H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Sget_select_npoints failed"); + sm_nelmts = (hsize_t)ssm_nelmts; if (sm_nelmts > 0) { /* @@ -2860,8 +2862,9 @@ h5tools_print_datatype(h5tools_str_t *buffer, const h5tool_format_t *info, HERR_INIT(int, SUCCEED) char *mname; hid_t mtype, str_type; + int snmembers; unsigned nmembers; - unsigned ndims; + int sndims; unsigned i; size_t size = 0; hsize_t dims[H5TOOLS_DUMP_MAX_RANK]; @@ -3205,8 +3208,9 @@ h5tools_print_datatype(h5tools_str_t *buffer, const h5tool_format_t *info, break; case H5T_COMPOUND: - if((nmembers = H5Tget_nmembers(type)) < 0) + if((snmembers = H5Tget_nmembers(type)) < 0) H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_nmembers failed"); + nmembers = (unsigned)snmembers; h5tools_str_append(buffer, "H5T_COMPOUND %s\n", h5tools_dump_header_format->structblockbegin); @@ -3282,7 +3286,9 @@ h5tools_print_datatype(h5tools_str_t *buffer, const h5tool_format_t *info, h5tools_str_append(buffer, "H5T_ARRAY { "); /* Get array information */ - if((ndims = H5Tget_array_ndims(type)) >= 0) { + if((sndims = H5Tget_array_ndims(type)) >= 0) { + unsigned ndims = (unsigned)sndims; + if(H5Tget_array_dims2(type, dims) >= 0) { /* Print array dimensions */ for (i = 0; i < ndims; i++) -- cgit v0.12