summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/H5AC.c3
-rw-r--r--src/H5Aint.c33
-rw-r--r--src/H5B.c19
-rw-r--r--src/H5C.c6
-rw-r--r--src/H5Dbtree.c5
-rw-r--r--src/H5Dchunk.c19
-rw-r--r--src/H5Dcompact.c2
-rw-r--r--src/H5Dcontig.c2
-rw-r--r--src/H5Dfill.c4
-rw-r--r--src/H5Dint.c4
-rw-r--r--src/H5Dio.c6
-rw-r--r--src/H5F.c32
-rw-r--r--src/H5FDcore.c105
-rw-r--r--src/H5FDfamily.c6
-rw-r--r--src/H5FDsec2.c17
-rw-r--r--src/H5Fprivate.h3
-rw-r--r--src/H5Fsuper_cache.c11
-rw-r--r--src/H5Oattr.c15
-rw-r--r--src/H5Ofill.c2
-rw-r--r--src/H5Pfapl.c19
-rw-r--r--src/H5Pint.c2
-rw-r--r--src/H5Pprivate.h2
-rw-r--r--src/H5T.c135
-rw-r--r--src/H5Tcompound.c4
-rw-r--r--src/H5Tconv.c2
-rw-r--r--src/H5Tprivate.h2
-rw-r--r--src/H5Zdeflate.c5
-rw-r--r--src/H5Ztrans.c45
-rw-r--r--src/H5public.h4
29 files changed, 310 insertions, 204 deletions
diff --git a/src/H5AC.c b/src/H5AC.c
index 36527215..8e2ced6 100644
--- a/src/H5AC.c
+++ b/src/H5AC.c
@@ -3638,7 +3638,8 @@ H5AC_ext_config_2_int_config(H5AC_cache_config_t * ext_conf_ptr,
if ( ( ext_conf_ptr == NULL ) ||
( ext_conf_ptr->version != H5AC__CURR_CACHE_CONFIG_VERSION ) ||
( int_conf_ptr == NULL ) ) {
-
+ HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \
+ "Bad ext_conf_ptr or inf_conf_ptr on entry.")
}
int_conf_ptr->version = H5C__CURR_AUTO_SIZE_CTL_VER;
diff --git a/src/H5Aint.c b/src/H5Aint.c
index c50126a..a89c1c9 100644
--- a/src/H5Aint.c
+++ b/src/H5Aint.c
@@ -150,32 +150,21 @@ H5A_compact_build_table_cb(H5O_t UNUSED *oh, H5O_mesg_t *mesg/*in,out*/,
/* Re-allocate the table if necessary */
if(udata->curr_attr == udata->atable->nattrs) {
- size_t i;
- size_t n = MAX(1, 2 * udata->atable->nattrs);
- H5A_t **table = (H5A_t **)H5FL_SEQ_CALLOC(H5A_t_ptr, n);
-
- /* Use attribute functions for operation */
- for(i=0; i<udata->atable->nattrs; i++) {
- table[i] = (H5A_t *)H5FL_CALLOC(H5A_t);
- if(NULL == H5A_copy(table[i], udata->atable->attrs[i]))
- HGOTO_ERROR(H5E_ATTR, H5E_CANTCOPY, H5_ITER_ERROR, "can't copy attribute")
- if(H5A_close(udata->atable->attrs[i]) < 0)
- HGOTO_ERROR(H5E_ATTR, H5E_CANTCLOSEOBJ, H5_ITER_ERROR, "can't close attribute")
- }
-
- if(udata->atable->nattrs)
- udata->atable->attrs = (H5A_t **)H5FL_SEQ_FREE(H5A_t_ptr, udata->atable->attrs);
+ H5A_t **new_table; /* New table for attributes */
+ size_t new_table_size; /* Number of attributes in new table */
- if(!table)
+ /* Allocate larger table */
+ new_table_size = MAX(1, 2 * udata->atable->nattrs);
+ if(NULL == (new_table = (H5A_t **)H5FL_SEQ_REALLOC(H5A_t_ptr, udata->atable->attrs, new_table_size)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, H5_ITER_ERROR, "unable to extend attribute table")
- udata->atable->attrs = table;
- udata->atable->nattrs = n;
+
+ /* Update table information in user data */
+ udata->atable->attrs = new_table;
+ udata->atable->nattrs = new_table_size;
} /* end if */
/* Copy attribute into table */
- udata->atable->attrs[udata->curr_attr] = (H5A_t *)H5FL_CALLOC(H5A_t);
-
- if(NULL == H5A_copy(udata->atable->attrs[udata->curr_attr], (const H5A_t *)mesg->native))
+ if(NULL == (udata->atable->attrs[udata->curr_attr] = H5A_copy(NULL, (const H5A_t *)mesg->native)))
HGOTO_ERROR(H5E_ATTR, H5E_CANTCOPY, H5_ITER_ERROR, "can't copy attribute")
/* Assign [somewhat arbitrary] creation order value, if requested */
@@ -944,7 +933,7 @@ H5A_attr_copy_file(const H5A_t *attr_src, H5F_t *file_dst, hbool_t *recompute_si
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
/* Check if we need to convert data */
- if(H5T_detect_class(attr_src->shared->dt, H5T_VLEN) > 0) {
+ if(H5T_detect_class(attr_src->shared->dt, H5T_VLEN, FALSE) > 0) {
H5T_path_t *tpath_src_mem, *tpath_mem_dst; /* Datatype conversion paths */
H5T_t *dt_mem; /* Memory datatype */
size_t src_dt_size; /* Source datatype size */
diff --git a/src/H5B.c b/src/H5B.c
index 326d675..d915b01 100644
--- a/src/H5B.c
+++ b/src/H5B.c
@@ -1760,7 +1760,7 @@ done:
H5B_shared_t *
H5B_shared_new(const H5F_t *f, const H5B_class_t *type, size_t sizeof_rkey)
{
- H5B_shared_t *shared; /* New shared B-tree struct */
+ H5B_shared_t *shared = NULL; /* New shared B-tree struct */
size_t u; /* Local index variable */
H5B_shared_t *ret_value; /* Return value */
@@ -1772,8 +1772,8 @@ H5B_shared_new(const H5F_t *f, const H5B_class_t *type, size_t sizeof_rkey)
HDassert(type);
/* Allocate space for the shared structure */
- if(NULL == (shared = H5FL_MALLOC(H5B_shared_t)))
- HGOTO_ERROR(H5E_BTREE, H5E_NOSPACE, NULL, "memory allocation failed for shared B-tree info")
+ if(NULL == (shared = H5FL_CALLOC(H5B_shared_t)))
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "memory allocation failed for shared B-tree info")
/* Set up the "global" information for this file's groups */
shared->type = type;
@@ -1788,12 +1788,12 @@ H5B_shared_new(const H5F_t *f, const H5B_class_t *type, size_t sizeof_rkey)
/* Allocate shared buffers */
if(NULL == (shared->page = H5FL_BLK_MALLOC(page, shared->sizeof_rnode)))
- HGOTO_ERROR(H5E_BTREE, H5E_NOSPACE, NULL, "memory allocation failed for B-tree page")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "memory allocation failed for B-tree page")
#ifdef H5_CLEAR_MEMORY
HDmemset(shared->page, 0, shared->sizeof_rnode);
#endif /* H5_CLEAR_MEMORY */
if(NULL == (shared->nkey = H5FL_SEQ_MALLOC(size_t, (size_t)(shared->two_k + 1))))
- HGOTO_ERROR(H5E_BTREE, H5E_NOSPACE, NULL, "memory allocation failed for B-tree page")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "memory allocation failed for B-tree native keys")
/* Initialize the offsets into the native key buffer */
for(u = 0; u < (shared->two_k + 1); u++)
@@ -1803,6 +1803,15 @@ HDmemset(shared->page, 0, shared->sizeof_rnode);
ret_value = shared;
done:
+ if(NULL == ret_value)
+ if(shared) {
+ if(shared->page)
+ shared->page = H5FL_BLK_FREE(page, shared->page);
+ if(shared->nkey)
+ shared->nkey = H5FL_SEQ_FREE(size_t, shared->nkey);
+ shared = H5FL_FREE(H5B_shared_t, shared);
+ } /* end if */
+
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5B_shared_new() */
diff --git a/src/H5C.c b/src/H5C.c
index 7fc651b..ef58012 100644
--- a/src/H5C.c
+++ b/src/H5C.c
@@ -9814,12 +9814,8 @@ H5C__autoadjust__ageout__insert_new_marker(H5C_t * cache_ptr)
i++;
}
- HDassert( i < H5C__MAX_EPOCH_MARKERS );
-
- if ( (cache_ptr->epoch_marker_active)[i] != FALSE ) {
-
+ if(i >= H5C__MAX_EPOCH_MARKERS)
HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't find unused marker.")
- }
HDassert( ((cache_ptr->epoch_markers)[i]).addr == (haddr_t)i );
HDassert( ((cache_ptr->epoch_markers)[i]).next == NULL );
diff --git a/src/H5Dbtree.c b/src/H5Dbtree.c
index 2c13677..d9cde4b 100644
--- a/src/H5Dbtree.c
+++ b/src/H5Dbtree.c
@@ -1492,8 +1492,9 @@ done:
/* Free the raw B-tree node buffer */
if(NULL == storage.u.btree.shared)
HDONE_ERROR(H5E_IO, H5E_CANTFREE, FAIL, "ref-counted page nil")
- if(H5RC_DEC(storage.u.btree.shared) < 0)
- HDONE_ERROR(H5E_IO, H5E_CANTFREE, FAIL, "unable to decrement ref-counted page")
+ else
+ if(H5RC_DEC(storage.u.btree.shared) < 0)
+ HDONE_ERROR(H5E_IO, H5E_CANTFREE, FAIL, "unable to decrement ref-counted page")
} /* end if */
FUNC_LEAVE_NOAPI(ret_value)
diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c
index 5b1703a..95334af 100644
--- a/src/H5Dchunk.c
+++ b/src/H5Dchunk.c
@@ -2480,6 +2480,7 @@ H5D_chunk_flush_entry(const H5D_t *dset, hid_t dxpl_id, const H5D_dxpl_cache_t *
done:
/* Free the temp buffer only if it's different than the entry chunk */
if(buf != ent->chunk)
+ /* coverity["double_free"] */
H5MM_xfree(buf);
/*
@@ -4256,7 +4257,7 @@ H5D_chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata)
/* Check parameter for type conversion */
if(udata->do_convert) {
- if(H5T_detect_class(udata->dt_src, H5T_VLEN) > 0)
+ if(H5T_detect_class(udata->dt_src, H5T_VLEN, FALSE) > 0)
is_vlen = TRUE;
else if((H5T_get_class(udata->dt_src, FALSE) == H5T_REFERENCE) && (udata->file_src != udata->idx_info_dst->f))
fix_ref = TRUE;
@@ -4502,7 +4503,7 @@ H5D_chunk_copy(H5F_t *f_src, H5O_storage_chunk_t *storage_src,
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register source file datatype")
/* If there's a VLEN source datatype, set up type conversion information */
- if(H5T_detect_class(dt_src, H5T_VLEN) > 0) {
+ if(H5T_detect_class(dt_src, H5T_VLEN, FALSE) > 0) {
H5T_t *dt_dst; /* Destination datatype */
H5T_t *dt_mem; /* Memory datatype */
size_t mem_dt_size; /* Memory datatype size */
@@ -4514,16 +4515,22 @@ H5D_chunk_copy(H5F_t *f_src, H5O_storage_chunk_t *storage_src,
/* create a memory copy of the variable-length datatype */
if(NULL == (dt_mem = H5T_copy(dt_src, H5T_COPY_TRANSIENT)))
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy")
- if((tid_mem = H5I_register(H5I_DATATYPE, dt_mem, FALSE)) < 0)
+ if((tid_mem = H5I_register(H5I_DATATYPE, dt_mem, FALSE)) < 0) {
+ (void)H5T_close(dt_mem);
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register memory datatype")
+ } /* end if */
/* create variable-length datatype at the destinaton file */
if(NULL == (dt_dst = H5T_copy(dt_src, H5T_COPY_TRANSIENT)))
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy")
- if(H5T_set_loc(dt_dst, f_dst, H5T_LOC_DISK) < 0)
+ if(H5T_set_loc(dt_dst, f_dst, H5T_LOC_DISK) < 0) {
+ (void)H5T_close(dt_dst);
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "cannot mark datatype on disk")
- if((tid_dst = H5I_register(H5I_DATATYPE, dt_dst, FALSE)) < 0)
+ } /* end if */
+ if((tid_dst = H5I_register(H5I_DATATYPE, dt_dst, FALSE)) < 0) {
+ (void)H5T_close(dt_dst);
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register destination file datatype")
+ } /* end if */
/* Set up the conversion functions */
if(NULL == (tpath_src_mem = H5T_path_find(dt_src, dt_mem, NULL, NULL, dxpl_id, FALSE)))
@@ -4553,7 +4560,7 @@ H5D_chunk_copy(H5F_t *f_src, H5O_storage_chunk_t *storage_src,
/* Atomize */
if((sid_buf = H5I_register(H5I_DATASPACE, buf_space, FALSE)) < 0) {
- H5S_close(buf_space);
+ (void)H5S_close(buf_space);
HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace ID")
} /* end if */
diff --git a/src/H5Dcompact.c b/src/H5Dcompact.c
index f66e955..22f29e8 100644
--- a/src/H5Dcompact.c
+++ b/src/H5Dcompact.c
@@ -422,7 +422,7 @@ H5D_compact_copy(H5F_t *f_src, H5O_storage_compact_t *storage_src, H5F_t *f_dst,
HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register source file datatype")
/* If there's a VLEN source datatype, do type conversion information */
- if(H5T_detect_class(dt_src, H5T_VLEN) > 0) {
+ if(H5T_detect_class(dt_src, H5T_VLEN, FALSE) > 0) {
H5T_path_t *tpath_src_mem, *tpath_mem_dst; /* Datatype conversion paths */
H5T_t *dt_dst; /* Destination datatype */
H5T_t *dt_mem; /* Memory datatype */
diff --git a/src/H5Dcontig.c b/src/H5Dcontig.c
index 3e88be6..282cecb 100644
--- a/src/H5Dcontig.c
+++ b/src/H5Dcontig.c
@@ -1275,7 +1275,7 @@ H5D_contig_copy(H5F_t *f_src, const H5O_storage_contig_t *storage_src,
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register source file datatype")
/* If there's a VLEN source datatype, set up type conversion information */
- if(H5T_detect_class(dt_src, H5T_VLEN) > 0) {
+ if(H5T_detect_class(dt_src, H5T_VLEN, FALSE) > 0) {
/* create a memory copy of the variable-length datatype */
if(NULL == (dt_mem = H5T_copy(dt_src, H5T_COPY_TRANSIENT)))
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy")
diff --git a/src/H5Dfill.c b/src/H5Dfill.c
index bacaca2..2f3f112 100644
--- a/src/H5Dfill.c
+++ b/src/H5Dfill.c
@@ -240,7 +240,7 @@ H5D_fill(const void *fill, const H5T_t *fill_type, void *buf,
* then do conversion on each element so that each of them has a copy
* of the VL data.
*/
- if(TRUE == H5T_detect_class(fill_type, H5T_VLEN)) {
+ if(TRUE == H5T_detect_class(fill_type, H5T_VLEN, FALSE)) {
H5D_dxpl_cache_t _dxpl_cache; /* Data transfer property cache buffer */
H5D_dxpl_cache_t *dxpl_cache = &_dxpl_cache; /* Data transfer property cache */
H5S_sel_iter_t mem_iter; /* Memory selection iteration info */
@@ -397,7 +397,7 @@ H5D_fill_init(H5D_fill_buf_info_t *fb_info, void *caller_fill_buf,
htri_t has_vlen_type; /* Whether the datatype has a VL component */
/* Detect whether the datatype has a VL component */
- if((has_vlen_type = H5T_detect_class(dset_type, H5T_VLEN)) < 0)
+ if((has_vlen_type = H5T_detect_class(dset_type, H5T_VLEN, FALSE)) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "unable to detect vlen datatypes?")
fb_info->has_vlen_fill_type = (hbool_t)has_vlen_type;
diff --git a/src/H5Dint.c b/src/H5Dint.c
index 85d421a..f9329b6 100644
--- a/src/H5Dint.c
+++ b/src/H5Dint.c
@@ -736,7 +736,7 @@ H5D_update_oh_info(H5F_t *file, hid_t dxpl_id, H5D_t *dset, hid_t dapl_id)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't tell if fill value defined")
/* Special case handling for variable-length types */
- if(H5T_detect_class(type, H5T_VLEN)) {
+ if(H5T_detect_class(type, H5T_VLEN, FALSE)) {
/* If the default fill value is chosen for variable-length types, always write it */
if(fill_prop->fill_time == H5D_FILL_TIME_IFSET && fill_status == H5D_FILL_VALUE_DEFAULT) {
/* Update dataset creation property */
@@ -927,7 +927,7 @@ H5D_create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id,
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "datatype is not sensible")
/* Check if the datatype is/contains a VL-type */
- if(H5T_detect_class(type, H5T_VLEN))
+ if(H5T_detect_class(type, H5T_VLEN, FALSE))
has_vl_type = TRUE;
/* Check if the dataspace has an extent set (or is NULL) */
diff --git a/src/H5Dio.c b/src/H5Dio.c
index 62d2177..406b5ce 100644
--- a/src/H5Dio.c
+++ b/src/H5Dio.c
@@ -485,7 +485,7 @@ H5D_write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space,
/* If MPI based VFD is used, no VL datatype support yet. */
/* This is because they use the global heap in the file and we don't */
/* support parallel access of that yet */
- if(H5T_detect_class(type_info.mem_type, H5T_VLEN) > 0)
+ if(H5T_detect_class(type_info.mem_type, H5T_VLEN, FALSE) > 0)
HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "Parallel IO does not support writing VL datatypes yet")
/* If MPI based VFD is used, no VL datatype support yet. */
@@ -543,7 +543,7 @@ H5D_write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space,
HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "can't retrieve number of elements in file dataset")
/* Always allow fill values to be written if the dataset has a VL datatype */
- if(H5T_detect_class(dataset->shared->type, H5T_VLEN))
+ if(H5T_detect_class(dataset->shared->type, H5T_VLEN, FALSE))
full_overwrite = FALSE;
else
full_overwrite = (hbool_t)((hsize_t)file_nelmts == nelmts ? TRUE : FALSE);
@@ -751,7 +751,7 @@ H5D_typeinfo_init(const H5D_t *dset, const H5D_dxpl_cache_t *dxpl_cache,
type_info->cmpd_subset = H5T_path_compound_subset(type_info->tpath);
/* Check if we need a background buffer */
- if(do_write && H5T_detect_class(dset->shared->type, H5T_VLEN))
+ if(do_write && H5T_detect_class(dset->shared->type, H5T_VLEN, FALSE))
type_info->need_bkg = H5T_BKG_YES;
else {
H5T_bkg_t path_bkg; /* Type conversion's background info */
diff --git a/src/H5F.c b/src/H5F.c
index 68a5789..a4eedd5 100644
--- a/src/H5F.c
+++ b/src/H5F.c
@@ -69,6 +69,8 @@ static size_t H5F_get_objects(const H5F_t *f, unsigned types, size_t max_objs, h
static int H5F_get_objects_cb(void *obj_ptr, hid_t obj_id, void *key);
static H5F_t *H5F_new(H5F_file_t *shared, hid_t fcpl_id, hid_t fapl_id,
H5FD_t *lf);
+static herr_t H5F_build_actual_name(const H5F_t *f, const H5P_genplist_t *fapl,
+ const char *name, char ** /*out*/ actual_name);
static herr_t H5F_dest(H5F_t *f, hid_t dxpl_id);
static herr_t H5F_close(H5F_t *f);
@@ -1142,7 +1144,8 @@ H5F_dest(H5F_t *f, hid_t dxpl_id)
*-------------------------------------------------------------------------
*/
H5F_t *
-H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id)
+H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id,
+ hid_t dxpl_id)
{
H5F_t *file = NULL; /*the success return value */
H5F_file_t *shared = NULL; /*shared part of `file' */
@@ -1319,7 +1322,7 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t d
HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to build extpath")
/* Formulate the actual file name, after following symlinks, etc. */
- if(H5F_build_actual_name(file, name, &file->actual_name) < 0)
+ if(H5F_build_actual_name(file, a_plist, name, &file->actual_name) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to build actual name")
/* Success */
@@ -2170,15 +2173,18 @@ H5F_decr_nopen_objs(H5F_t *f)
*
*-------------------------------------------------------------------------
*/
-herr_t
-H5F_build_actual_name(const H5F_t *f, const char *name, char **actual_name/*out*/)
+static herr_t
+H5F_build_actual_name(const H5F_t *f, const H5P_genplist_t *fapl, const char *name,
+ char **actual_name/*out*/)
{
+ hid_t new_fapl_id = -1; /* ID for duplicated FAPL */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5F_build_actual_name)
/* Sanity check */
HDassert(f);
+ HDassert(fapl);
HDassert(name);
HDassert(actual_name);
@@ -2199,10 +2205,12 @@ H5F_build_actual_name(const H5F_t *f, const char *name, char **actual_name/*out*
/* Check for symbolic link */
if(S_IFLNK == (lst.st_mode & S_IFMT)) {
+ H5P_genplist_t *new_fapl; /* Duplicated FAPL */
int *fd; /* POSIX I/O file descriptor */
h5_stat_t st; /* Stat info from stat() call */
h5_stat_t fst; /* Stat info from fstat() call */
char realname[PATH_MAX]; /* Fully resolved path name of file */
+ hbool_t want_posix_fd; /* Flag for retrieving file descriptor from VFD */
/* Perform a sanity check that the file or link wasn't switched
* between when we opened it and when we called lstat(). This is
@@ -2210,8 +2218,19 @@ H5F_build_actual_name(const H5F_t *f, const char *name, char **actual_name/*out*
* here: https://www.securecoding.cert.org/confluence/display/seccode/POS35-C.+Avoid+race+conditions+while+checking+for+the+existence+of+a+symbolic+link
*/
+ /* Copy the FAPL object to modify */
+ if((new_fapl_id = H5P_copy_plist(fapl, FALSE)) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTCOPY, FAIL, "unable to copy file access property list")
+ if(NULL == (new_fapl = (H5P_genplist_t *)H5I_object(new_fapl_id)))
+ HGOTO_ERROR(H5E_FILE, H5E_CANTCREATE, FAIL, "can't get property list")
+
+ /* Set the character encoding on the new property list */
+ want_posix_fd = TRUE;
+ if(H5P_set(new_fapl, H5F_ACS_WANT_POSIX_FD_NAME, &want_posix_fd) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set character encoding")
+
/* Retrieve the file handle */
- if(H5F_get_vfd_handle(f, H5P_DEFAULT, (void **)&fd) < 0)
+ if(H5F_get_vfd_handle(f, new_fapl_id, (void **)&fd) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve POSIX file descriptor")
/* Stat the filename we're resolving */
@@ -2245,6 +2264,9 @@ H5F_build_actual_name(const H5F_t *f, const char *name, char **actual_name/*out*
} /* end else */
done:
+ if(new_fapl_id > 0 && H5Pclose(new_fapl_id) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, FAIL, "can't close duplicated FAPL")
+
FUNC_LEAVE_NOAPI(ret_value)
} /* H5F_build_actual_name() */
diff --git a/src/H5FDcore.c b/src/H5FDcore.c
index bd77199..15f4094 100644
--- a/src/H5FDcore.c
+++ b/src/H5FDcore.c
@@ -401,29 +401,29 @@ H5FD_core_open(const char *name, unsigned flags, hid_t fapl_id,
FUNC_ENTER_NOAPI(H5FD_core_open, NULL)
/* Check arguments */
- if (!name || !*name)
+ if(!name || !*name)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid file name")
- if (0==maxaddr || HADDR_UNDEF==maxaddr)
+ if(0 == maxaddr || HADDR_UNDEF == maxaddr)
HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "bogus maxaddr")
if(ADDR_OVERFLOW(maxaddr))
HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, NULL, "maxaddr overflow")
- assert(H5P_DEFAULT != fapl_id);
- if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list")
- fa = (H5FD_core_fapl_t *)H5P_get_driver_info(plist);
+ HDassert(H5P_DEFAULT != fapl_id);
+ if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list")
+ fa = (H5FD_core_fapl_t *)H5P_get_driver_info(plist);
/* Build the open flags */
o_flags = (H5F_ACC_RDWR & flags) ? O_RDWR : O_RDONLY;
- if (H5F_ACC_TRUNC & flags) o_flags |= O_TRUNC;
- if (H5F_ACC_CREAT & flags) o_flags |= O_CREAT;
- if (H5F_ACC_EXCL & flags) o_flags |= O_EXCL;
+ if(H5F_ACC_TRUNC & flags) o_flags |= O_TRUNC;
+ if(H5F_ACC_CREAT & flags) o_flags |= O_CREAT;
+ if(H5F_ACC_EXCL & flags) o_flags |= O_EXCL;
/* Open backing store. The only case that backing store is off is when
* the backing_store flag is off and H5F_ACC_CREAT is on. */
if(fa->backing_store || !(H5F_ACC_CREAT & flags)) {
- if (fa && (fd=HDopen(name, o_flags, 0666))<0)
+ if(fa && (fd = HDopen(name, o_flags, 0666)) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file")
- }
+ } /* end if */
/* Create the new file struct */
if(NULL == (file = (H5FD_core_t *)H5MM_calloc(sizeof(H5FD_core_t))))
@@ -444,39 +444,38 @@ H5FD_core_open(const char *name, unsigned flags, hid_t fapl_id,
/* If an existing file is opened, load the whole file into memory. */
if(!(H5F_ACC_CREAT & flags)) {
- unsigned char *x=NULL;
size_t size;
- if (HDfstat(file->fd, &sb)<0)
+ /* stat() file to retrieve its size */
+ if(HDfstat(file->fd, &sb) < 0)
HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, NULL, "unable to fstat file")
-
size = (size_t)sb.st_size;
+ /* Check if we should allocate the memory buffer and read in existing data */
if(size) {
- if (NULL==file->mem)
- x = (unsigned char*)H5MM_malloc(size);
-
- if (!x)
+ /* Allocate memory for the file's data */
+ if(NULL == (file->mem = (unsigned char*)H5MM_malloc(size)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate memory block")
- file->mem = x;
+ /* Set up data structures */
file->eof = size;
- if(HDread(file->fd, file->mem, size)<0)
+ /* Read in existing data */
+ if(HDread(file->fd, file->mem, size) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to read file")
- }
- }
+ } /* end if */
+ } /* end if */
/* Check for SWMR reader access */
if(flags & H5F_ACC_SWMR_READ)
file->swmr_read = TRUE;
/* Set return value */
- ret_value=(H5FD_t *)file;
+ ret_value = (H5FD_t *)file;
done:
FUNC_LEAVE_NOAPI(ret_value)
-}
+} /* end H5FD_core_open() */
/*-------------------------------------------------------------------------
@@ -583,13 +582,12 @@ done:
*
*-------------------------------------------------------------------------
*/
-/* ARGSUSED */
static herr_t
-H5FD_core_query(const H5FD_t UNUSED * _f, unsigned long *flags /* out */)
+H5FD_core_query(const H5FD_t * _file, unsigned long *flags /* out */)
{
- herr_t ret_value = SUCCEED; /* Return value */
+ const H5FD_core_t *file = (const H5FD_core_t*)_file;
- FUNC_ENTER_NOAPI(H5FD_core_query, FAIL)
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FD_core_query)
/* Set the VFL feature flags that this driver supports */
if(flags) {
@@ -598,10 +596,13 @@ H5FD_core_query(const H5FD_t UNUSED * _f, unsigned long *flags /* out */)
*flags |= H5FD_FEAT_ACCUMULATE_METADATA; /* OK to accumulate metadata for faster writes */
*flags |= H5FD_FEAT_DATA_SIEVE; /* OK to perform data sieving for faster raw data reads & writes */
*flags |= H5FD_FEAT_AGGREGATE_SMALLDATA; /* OK to aggregate "small" raw data allocations */
+
+ /* If the backing store is open, a POSIX file handle is available */
+ if(file->fd >= 0 && file->backing_store)
+ *flags |= H5FD_FEAT_POSIX_COMPAT_HANDLE; /* VFD handle is POSIX I/O call compatible */
} /* end if */
-done:
- FUNC_LEAVE_NOAPI(ret_value)
+ FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5FD_core_query() */
@@ -629,9 +630,8 @@ done:
static haddr_t
H5FD_core_get_eoa(const H5FD_t *_file, H5FD_mem_t UNUSED type)
{
- haddr_t ret_value; /* Return value */
-
const H5FD_core_t *file = (const H5FD_core_t*)_file;
+ haddr_t ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5FD_core_get_eoa, HADDR_UNDEF)
@@ -733,23 +733,52 @@ done:
*
*-------------------------------------------------------------------------
*/
-/* ARGSUSED */
static herr_t
-H5FD_core_get_handle(H5FD_t *_file, hid_t UNUSED fapl, void** file_handle)
+H5FD_core_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle)
{
- H5FD_core_t *file = (H5FD_core_t *)_file;
- herr_t ret_value = SUCCEED;
+ H5FD_core_t *file = (H5FD_core_t *)_file; /* core VFD info */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5FD_core_get_handle, FAIL)
+ /* Check args */
if(!file_handle)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file handle not valid")
- *file_handle = &(file->mem);
+ /* Check for non-default FAPL */
+ if(H5P_FILE_ACCESS_DEFAULT != fapl && H5P_DEFAULT != fapl) {
+ H5P_genplist_t *plist; /* Property list pointer */
+
+ /* Get the FAPL */
+ if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl)))
+ HGOTO_ERROR(H5E_VFL, H5E_BADTYPE, FAIL, "not a file access property list")
+
+ /* Check if private property for retrieving the backing store POSIX
+ * file descriptor is set. (This should not be set except within the
+ * library) QAK - 2009/12/04
+ */
+ if(H5P_exist_plist(plist, H5F_ACS_WANT_POSIX_FD_NAME) > 0) {
+ hbool_t want_posix_fd; /* Setting for retrieving file descriptor from core VFD */
+
+ /* Get property */
+ if(H5P_get(plist, H5F_ACS_WANT_POSIX_FD_NAME, &want_posix_fd) < 0)
+ HGOTO_ERROR(H5E_VFL, H5E_CANTGET, NULL, "can't get property of retrieving file descriptor")
+
+ /* If property is set, pass back the file descriptor instead of the memory address */
+ if(want_posix_fd)
+ *file_handle = &(file->fd);
+ else
+ *file_handle = &(file->mem);
+ } /* end if */
+ else
+ *file_handle = &(file->mem);
+ } /* end if */
+ else
+ *file_handle = &(file->mem);
done:
FUNC_LEAVE_NOAPI(ret_value)
-}
+} /* end H5FD_core_get_handle() */
/*-------------------------------------------------------------------------
diff --git a/src/H5FDfamily.c b/src/H5FDfamily.c
index 9817270..87e5e84 100644
--- a/src/H5FDfamily.c
+++ b/src/H5FDfamily.c
@@ -818,9 +818,11 @@ H5FD_family_open(const char *name, unsigned flags, hid_t fapl_id,
/* Enlarge member array */
if(file->nmembs >= file->amembs) {
unsigned n = MAX(64, 2 * file->amembs);
- H5FD_t **x = (H5FD_t **)H5MM_realloc(file->memb, n * sizeof(H5FD_t *));
+ H5FD_t **x;
- if(!x)
+ HDassert(n > 0);
+ /* coverity["freed_arg"] */
+ if(NULL == (x = (H5FD_t **)H5MM_realloc(file->memb, n * sizeof(H5FD_t *))))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to reallocate members")
file->amembs = n;
file->memb = x;
diff --git a/src/H5FDsec2.c b/src/H5FDsec2.c
index 324f489..ab2bc72 100644
--- a/src/H5FDsec2.c
+++ b/src/H5FDsec2.c
@@ -331,19 +331,18 @@ done:
*
*-------------------------------------------------------------------------
*/
-/* ARGSUSED */
static H5FD_t *
H5FD_sec2_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr)
{
- int o_flags;
- int fd=(-1);
- H5FD_sec2_t *file=NULL;
+ H5FD_sec2_t *file = NULL; /* sec2 VFD info */
+ int fd = (-1); /* File descriptor */
+ int o_flags; /* Flags for open() call */
#ifdef _WIN32
HFILE filehandle;
struct _BY_HANDLE_FILE_INFORMATION fileinfo;
#endif
h5_stat_t sb;
- H5FD_t *ret_value;
+ H5FD_t *ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5FD_sec2_open, NULL)
@@ -432,9 +431,11 @@ H5FD_sec2_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr)
ret_value = (H5FD_t*)file;
done:
- if(ret_value==NULL) {
- if(fd>=0)
+ if(NULL == ret_value) {
+ if(fd >= 0)
HDclose(fd);
+ if(file)
+ file = H5FL_FREE(H5FD_sec2_t, file);
} /* end if */
FUNC_LEAVE_NOAPI(ret_value)
@@ -471,7 +472,7 @@ H5FD_sec2_close(H5FD_t *_file)
HSYS_GOTO_ERROR(H5E_IO, H5E_CANTCLOSEFILE, FAIL, "unable to close file")
/* Release the file info */
- (void)H5FL_FREE(H5FD_sec2_t, file);
+ file = H5FL_FREE(H5FD_sec2_t, file);
done:
FUNC_LEAVE_NOAPI(ret_value)
diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h
index e86a99e..29f3aa7 100644
--- a/src/H5Fprivate.h
+++ b/src/H5Fprivate.h
@@ -380,6 +380,7 @@ typedef struct H5F_blk_aggr_t H5F_blk_aggr_t;
#define H5F_ACS_FAMILY_TO_SEC2_NAME "family_to_sec2" /* Whether to convert family to sec2 driver. (private property only used by h5repart) */
#define H5F_ACS_MULTI_TYPE_NAME "multi_type" /* Data type in multi file driver */
#define H5F_ACS_LATEST_FORMAT_NAME "latest_format" /* 'Use latest format version' flag */
+#define H5F_ACS_WANT_POSIX_FD_NAME "want_posix_fd" /* Internal: query the file descriptor from the core VFD, instead of the memory address */
/* ======================== File Mount properties ====================*/
#define H5F_MNT_SYM_LOCAL_NAME "local" /* Whether absolute symlinks local to file. */
@@ -475,8 +476,6 @@ H5_DLL H5F_t *H5F_open(const char *name, unsigned flags, hid_t fcpl_id,
H5_DLL herr_t H5F_try_close(H5F_t *f);
H5_DLL unsigned H5F_incr_nopen_objs(H5F_t *f);
H5_DLL unsigned H5F_decr_nopen_objs(H5F_t *f);
-H5_DLL herr_t H5F_build_actual_name(const H5F_t *f, const char *,
- char ** /*out*/ );
/* Functions than retrieve values from the file struct */
H5_DLL unsigned H5F_get_intent(const H5F_t *f);
diff --git a/src/H5Fsuper_cache.c b/src/H5Fsuper_cache.c
index 1f2de6d..f7a35b9 100644
--- a/src/H5Fsuper_cache.c
+++ b/src/H5Fsuper_cache.c
@@ -111,7 +111,8 @@ H5FL_EXTERN(H5F_super_t);
*-------------------------------------------------------------------------
*/
static H5F_super_t *
-H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED *udata1, void *udata2/*out*/)
+H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, const void UNUSED *udata1,
+ void *udata2/*out*/)
{
H5F_super_t *sblock = NULL; /* File's superblock */
haddr_t base_addr = HADDR_UNDEF; /* Base address of file */
@@ -609,6 +610,11 @@ H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED *udata1
ret_value = sblock;
done:
+ /* Release the [possibly partially initialized] superblock on errors */
+ if(!ret_value && sblock)
+ if(H5F_sblock_dest(f, sblock) < 0)
+ HDONE_ERROR(H5E_FILE, H5E_CANTFREE, NULL, "unable to destroy superblock data")
+
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5F_sblock_load() */
@@ -628,7 +634,8 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5F_sblock_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5F_super_t *sblock)
+H5F_sblock_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t UNUSED addr,
+ H5F_super_t *sblock)
{
herr_t ret_value = SUCCEED;
diff --git a/src/H5Oattr.c b/src/H5Oattr.c
index 971c514..ad068ad 100644
--- a/src/H5Oattr.c
+++ b/src/H5Oattr.c
@@ -234,6 +234,21 @@ H5O_attr_decode(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, unsigned UNUSED mesg_fl
ret_value = attr;
done:
+ if(NULL == ret_value) {
+ if(attr) {
+ if(attr->shared) {
+ /* Free any dynamicly allocated items */
+ if(H5A_free(attr) < 0)
+ HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, NULL, "can't release attribute info")
+
+ /* Destroy shared attribute struct */
+ attr->shared = H5FL_FREE(H5A_shared_t, attr->shared);
+ } /* end if */
+ } /* end if */
+
+ attr = H5FL_FREE(H5A_t, attr);
+ } /* end if */
+
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_attr_decode() */
diff --git a/src/H5Ofill.c b/src/H5Ofill.c
index 8cf901f..d133a0a 100644
--- a/src/H5Ofill.c
+++ b/src/H5Ofill.c
@@ -689,7 +689,7 @@ H5O_fill_reset_dyn(H5O_fill_t *fill)
HDassert(fill);
if(fill->buf) {
- if(fill->type && H5T_detect_class(fill->type, H5T_VLEN) > 0) {
+ if(fill->type && H5T_detect_class(fill->type, H5T_VLEN, FALSE) > 0) {
H5T_t *fill_type; /* Copy of fill value datatype */
H5S_t *fill_space; /* Scalar dataspace for fill value element */
diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c
index e082e9c..486bda3 100644
--- a/src/H5Pfapl.c
+++ b/src/H5Pfapl.c
@@ -101,18 +101,23 @@
#define H5F_ACS_FAMILY_OFFSET_DEF 0
/* Definition for new member size of family driver. It's private
* property only used by h5repart */
-#define H5F_ACS_FAMILY_NEWSIZE_SIZE sizeof(hsize_t)
-#define H5F_ACS_FAMILY_NEWSIZE_DEF 0
+#define H5F_ACS_FAMILY_NEWSIZE_SIZE sizeof(hsize_t)
+#define H5F_ACS_FAMILY_NEWSIZE_DEF 0
/* Definition for whether to convert family to sec2 driver. It's private
* property only used by h5repart */
-#define H5F_ACS_FAMILY_TO_SEC2_SIZE sizeof(hbool_t)
-#define H5F_ACS_FAMILY_TO_SEC2_DEF FALSE
+#define H5F_ACS_FAMILY_TO_SEC2_SIZE sizeof(hbool_t)
+#define H5F_ACS_FAMILY_TO_SEC2_DEF FALSE
/* Definition for data type in multi file driver */
#define H5F_ACS_MULTI_TYPE_SIZE sizeof(H5FD_mem_t)
#define H5F_ACS_MULTI_TYPE_DEF H5FD_MEM_DEFAULT
/* Definition for 'use latest format version' flag */
#define H5F_ACS_LATEST_FORMAT_SIZE sizeof(hbool_t)
#define H5F_ACS_LATEST_FORMAT_DEF FALSE
+/* Definition for whether to query the file descriptor from the core VFD
+ * instead of the memory address. (Private to library)
+ */
+#define H5F_ACS_WANT_POSIX_FD_SIZE sizeof(hbool_t)
+#define H5F_ACS_WANT_POSIX_FD_DEF FALSE
/******************/
@@ -204,6 +209,7 @@ H5P_facc_reg_prop(H5P_genclass_t *pclass)
hbool_t family_to_sec2 = H5F_ACS_FAMILY_TO_SEC2_DEF; /* Default ?? for family VFD */
H5FD_mem_t mem_type = H5F_ACS_MULTI_TYPE_DEF; /* Default file space type for multi VFD */
hbool_t latest_format = H5F_ACS_LATEST_FORMAT_DEF; /* Default setting for "use the latest version of the format" flag */
+ hbool_t want_posix_fd = H5F_ACS_WANT_POSIX_FD_DEF; /* Default setting for retrieving 'handle' from core VFD */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5P_facc_reg_prop)
@@ -280,6 +286,11 @@ H5P_facc_reg_prop(H5P_genclass_t *pclass)
if(H5P_register(pclass, H5F_ACS_LATEST_FORMAT_NAME, H5F_ACS_LATEST_FORMAT_SIZE, &latest_format, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
+ /* Register the private property of whether to retrieve the file descriptor from the core VFD */
+ /* (used internally to the library only) */
+ if(H5P_register(pclass, H5F_ACS_WANT_POSIX_FD_NAME, H5F_ACS_WANT_POSIX_FD_SIZE, &want_posix_fd, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
+
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5P_facc_reg_prop() */
diff --git a/src/H5Pint.c b/src/H5Pint.c
index 4da7f09..7111cba 100644
--- a/src/H5Pint.c
+++ b/src/H5Pint.c
@@ -619,7 +619,7 @@ done:
REVISION LOG
--------------------------------------------------------------------------*/
hid_t
-H5P_copy_plist(H5P_genplist_t *old_plist, hbool_t app_ref)
+H5P_copy_plist(const H5P_genplist_t *old_plist, hbool_t app_ref)
{
H5P_genclass_t *tclass; /* Temporary class pointer */
H5P_genplist_t *new_plist=NULL; /* New property list generated from copy */
diff --git a/src/H5Pprivate.h b/src/H5Pprivate.h
index 0b37938..f544dbc 100644
--- a/src/H5Pprivate.h
+++ b/src/H5Pprivate.h
@@ -58,7 +58,7 @@ H5_DLL herr_t H5P_init(void);
/* Internal versions of API routines */
H5_DLL herr_t H5P_close(void *_plist);
H5_DLL hid_t H5P_create_id(H5P_genclass_t *pclass, hbool_t app_ref);
-H5_DLL hid_t H5P_copy_plist(H5P_genplist_t *old_plist, hbool_t app_ref);
+H5_DLL hid_t H5P_copy_plist(const H5P_genplist_t *old_plist, hbool_t app_ref);
H5_DLL herr_t H5P_get(const H5P_genplist_t *plist, const char *name, void *value);
H5_DLL herr_t H5P_set(H5P_genplist_t *plist, const char *name, const void *value);
H5_DLL herr_t H5P_insert(H5P_genplist_t *plist, const char *name, size_t size,
diff --git a/src/H5T.c b/src/H5T.c
index 4041cd5..de917f6 100644
--- a/src/H5T.c
+++ b/src/H5T.c
@@ -1913,12 +1913,9 @@ H5Tdetect_class(hid_t type, H5T_class_t cls)
if(!(cls > H5T_NO_CLASS && cls < H5T_NCLASSES))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_NO_CLASS, "not a datatype class")
- /* Set return value. Consider VL string as a string for API, as a VL for
- * internal use. */
- if(H5T_IS_VL_STRING(dt->shared))
- ret_value = (H5T_STRING == cls);
- else
- ret_value = H5T_detect_class(dt, cls);
+ /* Set return value */
+ if((ret_value = H5T_detect_class(dt, cls, TRUE)) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, H5T_NO_CLASS, "can't get datatype class")
done:
FUNC_LEAVE_API(ret_value)
@@ -1937,11 +1934,18 @@ done:
* Wednesday, November 29, 2000
*
* Modifications:
- *
+ * Raymond Lu
+ * 4 December 2009
+ * Added a flag as a parameter to indicate whether the caller is
+ * H5Tdetect_class. I also added the check for VL string type
+ * just like the public function. Because we want to tell users
+ * VL string is a string type but we treat it as a VL type
+ * internally, H5T_detect_class needs to know where the caller
+ * is from.
*-------------------------------------------------------------------------
*/
htri_t
-H5T_detect_class (const H5T_t *dt, H5T_class_t cls)
+H5T_detect_class(const H5T_t *dt, H5T_class_t cls, hbool_t from_api)
{
unsigned i;
htri_t ret_value=FALSE; /* Return value */
@@ -1951,6 +1955,14 @@ H5T_detect_class (const H5T_t *dt, H5T_class_t cls)
assert(dt);
assert(cls>H5T_NO_CLASS && cls<H5T_NCLASSES);
+ /* Consider VL string as a string for API, as a VL for internal use. */
+ /* (note that this check must be performed before checking if the VL
+ * string belongs to the H5T_VLEN class, which would otherwise return
+ * true. -QAK)
+ */
+ if(from_api && H5T_IS_VL_STRING(dt->shared))
+ HGOTO_DONE(H5T_STRING == cls);
+
/* Check if this type is the correct type */
if(dt->shared->type==cls)
HGOTO_DONE(TRUE);
@@ -1967,7 +1979,7 @@ H5T_detect_class (const H5T_t *dt, H5T_class_t cls)
/* Recurse if it's VL, compound, enum or array */
if(H5T_IS_COMPLEX(dt->shared->u.compnd.memb[i].type->shared->type))
- if((nested_ret=H5T_detect_class(dt->shared->u.compnd.memb[i].type,cls))!=FALSE)
+ if((nested_ret=H5T_detect_class(dt->shared->u.compnd.memb[i].type, cls, from_api))!=FALSE)
HGOTO_DONE(nested_ret);
} /* end for */
break;
@@ -1975,7 +1987,7 @@ H5T_detect_class (const H5T_t *dt, H5T_class_t cls)
case H5T_ARRAY:
case H5T_VLEN:
case H5T_ENUM:
- HGOTO_DONE(H5T_detect_class(dt->shared->parent,cls));
+ HGOTO_DONE(H5T_detect_class(dt->shared->parent, cls, from_api));
default:
break;
@@ -3816,84 +3828,85 @@ H5T_get_size(const H5T_t *dt)
* Programmer: Robb Matzke
* Wednesday, December 10, 1997
*
- * Modifications:
- * Robb Matzke, 22 Dec 1998
- * Able to compare enumeration data types.
- *
- * Robb Matzke, 20 May 1999
- * Compares bitfields and opaque types.
- *
- * Quincey Koziol, 19 Mar 2005
- * Allow an enumerated datatypes to compare equal, if the "superset"
- * flag is set and dt2 has a superset of the enumerated values in dt1
*-------------------------------------------------------------------------
*/
int
H5T_cmp(const H5T_t *dt1, const H5T_t *dt2, hbool_t superset)
{
unsigned *idx1 = NULL, *idx2 = NULL;
- int ret_value = 0;
+ size_t base_size;
+ hbool_t swapped;
int i, j;
unsigned u;
int tmp;
- hbool_t swapped;
- size_t base_size;
+ int ret_value = 0;
- FUNC_ENTER_NOAPI(H5T_cmp, 0);
+ FUNC_ENTER_NOAPI(H5T_cmp, 0)
+ /* Sanity check */
+ HDassert(dt1);
+ HDassert(dt2);
+
/* the easy case */
- if (dt1 == dt2) HGOTO_DONE(0);
- assert(dt1);
- assert(dt2);
+ if(dt1 == dt2)
+ HGOTO_DONE(0);
/* compare */
- if (dt1->shared->type < dt2->shared->type) HGOTO_DONE(-1);
- if (dt1->shared->type > dt2->shared->type) HGOTO_DONE(1);
-
- if (dt1->shared->size < dt2->shared->size) HGOTO_DONE(-1);
- if (dt1->shared->size > dt2->shared->size) HGOTO_DONE(1);
-
- if (dt1->shared->parent && !dt2->shared->parent) HGOTO_DONE(-1);
- if (!dt1->shared->parent && dt2->shared->parent) HGOTO_DONE(1);
- if (dt1->shared->parent) {
+ if(dt1->shared->type < dt2->shared->type)
+ HGOTO_DONE(-1);
+ if(dt1->shared->type > dt2->shared->type)
+ HGOTO_DONE(1);
+
+ if(dt1->shared->size < dt2->shared->size)
+ HGOTO_DONE(-1);
+ if(dt1->shared->size > dt2->shared->size)
+ HGOTO_DONE(1);
+
+ if(dt1->shared->parent && !dt2->shared->parent)
+ HGOTO_DONE(-1);
+ if(!dt1->shared->parent && dt2->shared->parent)
+ HGOTO_DONE(1);
+ if(dt1->shared->parent) {
tmp = H5T_cmp(dt1->shared->parent, dt2->shared->parent, superset);
- if (tmp<0) HGOTO_DONE(-1);
- if (tmp>0) HGOTO_DONE(1);
- }
+ if(tmp < 0)
+ HGOTO_DONE(-1);
+ if(tmp > 0)
+ HGOTO_DONE(1);
+ } /* end if */
switch(dt1->shared->type) {
case H5T_COMPOUND:
/*
* Compound data types...
*/
- if (dt1->shared->u.compnd.nmembs < dt2->shared->u.compnd.nmembs)
+ if(dt1->shared->u.compnd.nmembs < dt2->shared->u.compnd.nmembs)
HGOTO_DONE(-1);
- if (dt1->shared->u.compnd.nmembs > dt2->shared->u.compnd.nmembs)
+ if(dt1->shared->u.compnd.nmembs > dt2->shared->u.compnd.nmembs)
HGOTO_DONE(1);
/* Build an index for each type so the names are sorted */
- if (NULL==(idx1 = H5MM_malloc(dt1->shared->u.compnd.nmembs * sizeof(unsigned))) ||
- NULL==(idx2 = H5MM_malloc(dt2->shared->u.compnd.nmembs * sizeof(unsigned))))
+ if(NULL == (idx1 = H5MM_malloc(dt1->shared->u.compnd.nmembs * sizeof(unsigned))) ||
+ NULL == (idx2 = H5MM_malloc(dt2->shared->u.compnd.nmembs * sizeof(unsigned))))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed");
- for (u=0; u<dt1->shared->u.compnd.nmembs; u++)
+ for(u = 0; u < dt1->shared->u.compnd.nmembs; u++)
idx1[u] = idx2[u] = u;
if(dt1->shared->u.enumer.nmembs > 1) {
- for (i=dt1->shared->u.compnd.nmembs-1, swapped=TRUE; swapped && i>=0; --i)
- for (j=0, swapped=FALSE; j<i; j++)
- if (HDstrcmp(dt1->shared->u.compnd.memb[idx1[j]].name,
- dt1->shared->u.compnd.memb[idx1[j+1]].name) > 0) {
+ for(i = dt1->shared->u.compnd.nmembs - 1, swapped = TRUE; swapped && i >= 0; --i)
+ for(j = 0, swapped=FALSE; j < i; j++)
+ if(HDstrcmp(dt1->shared->u.compnd.memb[idx1[j]].name,
+ dt1->shared->u.compnd.memb[idx1[j + 1]].name) > 0) {
tmp = idx1[j];
- idx1[j] = idx1[j+1];
- idx1[j+1] = tmp;
+ idx1[j] = idx1[j + 1];
+ idx1[j + 1] = tmp;
swapped = TRUE;
}
- for (i=dt2->shared->u.compnd.nmembs-1, swapped=TRUE; swapped && i>=0; --i)
- for (j=0, swapped=FALSE; j<i; j++)
- if (HDstrcmp(dt2->shared->u.compnd.memb[idx2[j]].name,
- dt2->shared->u.compnd.memb[idx2[j+1]].name) > 0) {
+ for(i = dt2->shared->u.compnd.nmembs - 1, swapped = TRUE; swapped && i >= 0; --i)
+ for(j = 0, swapped = FALSE; j<i; j++)
+ if(HDstrcmp(dt2->shared->u.compnd.memb[idx2[j]].name,
+ dt2->shared->u.compnd.memb[idx2[j + 1]].name) > 0) {
tmp = idx2[j];
- idx2[j] = idx2[j+1];
- idx2[j+1] = tmp;
+ idx2[j] = idx2[j + 1];
+ idx2[j + 1] = tmp;
swapped = TRUE;
}
} /* end if */
@@ -4212,13 +4225,13 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2, hbool_t superset)
} /* end switch */
done:
- if(idx1!=NULL)
+ if(NULL != idx1)
H5MM_xfree(idx1);
- if(idx2!=NULL)
+ if(NULL != idx2)
H5MM_xfree(idx2);
- FUNC_LEAVE_NOAPI(ret_value);
-}
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5T_cmp() */
/*-------------------------------------------------------------------------
@@ -5124,7 +5137,7 @@ H5T_is_relocatable(const H5T_t *dt)
HDassert(dt);
/* VL and reference datatypes are relocatable */
- if(H5T_detect_class(dt, H5T_VLEN) || H5T_detect_class(dt, H5T_REFERENCE))
+ if(H5T_detect_class(dt, H5T_VLEN, FALSE) || H5T_detect_class(dt, H5T_REFERENCE, FALSE))
ret_value = TRUE;
done:
diff --git a/src/H5Tcompound.c b/src/H5Tcompound.c
index db7a701b..48192d2 100644
--- a/src/H5Tcompound.c
+++ b/src/H5Tcompound.c
@@ -403,7 +403,7 @@ H5Tpack(hid_t type_id)
H5TRACE1("e", "i", type_id);
/* Check args */
- if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)) || H5T_detect_class(dt, H5T_COMPOUND) <= 0)
+ if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)) || H5T_detect_class(dt, H5T_COMPOUND, TRUE) <= 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a compound datatype")
/* Pack */
@@ -534,7 +534,7 @@ H5T_pack(const H5T_t *dt)
HDassert(dt);
- if(H5T_detect_class(dt, H5T_COMPOUND) > 0) {
+ if(H5T_detect_class(dt, H5T_COMPOUND, FALSE) > 0) {
/* If datatype has been packed, skip packing it and indicate success */
if(TRUE == H5T_is_packed(dt))
HGOTO_DONE(SUCCEED)
diff --git a/src/H5Tconv.c b/src/H5Tconv.c
index ab9e703..ecf93e1 100644
--- a/src/H5Tconv.c
+++ b/src/H5Tconv.c
@@ -2996,7 +2996,7 @@ H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
noop_conv = TRUE;
/* Check if we need a temporary buffer for this conversion */
- parent_is_vlen = H5T_detect_class(dst->shared->parent, H5T_VLEN);
+ parent_is_vlen = H5T_detect_class(dst->shared->parent, H5T_VLEN, FALSE);
if(tpath->cdata.need_bkg || parent_is_vlen) {
/* Set up initial background buffer */
tmp_buf_size = MAX(src_base_size,dst_base_size);
diff --git a/src/H5Tprivate.h b/src/H5Tprivate.h
index 9189f04..afa6ceb 100644
--- a/src/H5Tprivate.h
+++ b/src/H5Tprivate.h
@@ -111,7 +111,7 @@ H5_DLL herr_t H5T_lock(H5T_t *dt, hbool_t immutable);
H5_DLL herr_t H5T_close(H5T_t *dt);
H5_DLL H5T_t *H5T_get_super(const H5T_t *dt);
H5_DLL H5T_class_t H5T_get_class(const H5T_t *dt, htri_t internal);
-H5_DLL htri_t H5T_detect_class(const H5T_t *dt, H5T_class_t cls);
+H5_DLL htri_t H5T_detect_class(const H5T_t *dt, H5T_class_t cls, hbool_t from_api);
H5_DLL size_t H5T_get_size(const H5T_t *dt);
H5_DLL int H5T_cmp(const H5T_t *dt1, const H5T_t *dt2, hbool_t superset);
H5_DLL herr_t H5T_debug(const H5T_t *dt, FILE * stream);
diff --git a/src/H5Zdeflate.c b/src/H5Zdeflate.c
index c0bcd70..c490720 100644
--- a/src/H5Zdeflate.c
+++ b/src/H5Zdeflate.c
@@ -78,6 +78,11 @@ H5Z_filter_deflate (unsigned flags, size_t cd_nelmts,
FUNC_ENTER_NOAPI(H5Z_filter_deflate, 0)
+ /* Sanity check */
+ HDassert(*buf_size > 0);
+ HDassert(buf);
+ HDassert(*buf);
+
/* Check arguments */
if (cd_nelmts!=1 || cd_values[0]>9)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, 0, "invalid deflate aggression level")
diff --git a/src/H5Ztrans.c b/src/H5Ztrans.c
index 2b35786..1a6988f 100644
--- a/src/H5Ztrans.c
+++ b/src/H5Ztrans.c
@@ -335,29 +335,29 @@ H5Z_unget_token(H5Z_token *current)
/*-------------------------------------------------------------------------
* Function: H5Z_get_token
+ *
* Purpose: Determine what the next valid H5Z_token is in the expression
* string. The current position within the H5Z_token string is
* kept internal to the H5Z_token and handled by this and the
* unget_H5Z_token function.
+ *
* Return: Succeess: The passed in H5Z_token with a valid tok_type
* field.
* Failure: The passed in H5Z_token but with the tok_type
* field set to ERROR.
+ *
* Programmer: Bill Wendling
* 26. August 2003
- * Modifications:
- * Leon Arber: Added FUNC_ENTER / FUNC_LEAVE pairs
+ *
*-------------------------------------------------------------------------
*/
static H5Z_token *
H5Z_get_token(H5Z_token *current)
{
-
- void* ret_value=current;
+ void *ret_value = current;
FUNC_ENTER_NOAPI(H5Z_get_token, NULL)
-
/* check args */
assert(current);
@@ -463,11 +463,11 @@ H5Z_get_token(H5Z_token *current)
if (current->tok_begin[0] == '\0')
current->tok_type = H5Z_XFORM_END;
- HGOTO_DONE(current);
+ /* Set return value */
+ ret_value = (void *)current;
done:
FUNC_LEAVE_NOAPI(ret_value)
-
}
@@ -498,17 +498,17 @@ H5Z_xform_destroy_parse_tree(H5Z_node *tree)
FUNC_LEAVE_NOAPI_VOID
}
-
/*-------------------------------------------------------------------------
* Function: H5Z_parse
+ *
* Purpose: Entry function for parsing the expression string.
+ *
* Return: Success: Valid H5Z_node ptr to an expression tree.
* NULLure: NULL
+ *
* Programmer: Bill Wendling
* 26. August 2003
- * Modifications:
- * Leon Arber: Added FUNC_ENTER / FUNC_LEAVE pairs
*
*-------------------------------------------------------------------------
*/
@@ -518,11 +518,10 @@ H5Z_xform_parse(const char *expression, H5Z_datval_ptrs* dat_val_pointers)
H5Z_token tok;
void* ret_value;
- FUNC_ENTER_NOAPI_NOFUNC(H5Z_xform_parse)
-
- if (!expression)
- HGOTO_DONE(NULL)
+ FUNC_ENTER_NOAPI(H5Z_xform_parse, NULL)
+ if(!expression)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "No expression provided?")
/* Set up the initial H5Z_token for parsing */
tok.tok_expr = tok.tok_begin = tok.tok_end = expression;
@@ -573,7 +572,7 @@ H5Z_parse_expression(H5Z_token *current, H5Z_datval_ptrs* dat_val_pointers)
if (!new_node) {
H5Z_xform_destroy_parse_tree(expr);
- HGOTO_DONE(expr)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "Unable to allocate new node")
}
new_node->lchild = expr;
@@ -592,7 +591,7 @@ H5Z_parse_expression(H5Z_token *current, H5Z_datval_ptrs* dat_val_pointers)
if (!new_node) {
H5Z_xform_destroy_parse_tree(expr);
- HGOTO_DONE(expr)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "Unable to allocate new node")
}
new_node->lchild = expr;
@@ -643,7 +642,7 @@ static H5Z_node *
H5Z_parse_term(H5Z_token *current, H5Z_datval_ptrs* dat_val_pointers)
{
H5Z_node *term = NULL;
- void* ret_value;
+ H5Z_node *ret_value;
FUNC_ENTER_NOAPI(H5Z_parse_term, NULL);
term = H5Z_parse_factor(current, dat_val_pointers);
@@ -659,7 +658,7 @@ H5Z_parse_term(H5Z_token *current, H5Z_datval_ptrs* dat_val_pointers)
if (!new_node) {
H5Z_xform_destroy_parse_tree(term);
- HGOTO_DONE(term)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "Unable to allocate new node")
}
new_node->lchild = term;
@@ -678,7 +677,7 @@ H5Z_parse_term(H5Z_token *current, H5Z_datval_ptrs* dat_val_pointers)
if (!new_node) {
H5Z_xform_destroy_parse_tree(term);
- HGOTO_DONE(term)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "Unable to allocate new node")
}
new_node->lchild = term;
@@ -744,7 +743,7 @@ H5Z_parse_factor(H5Z_token *current, H5Z_datval_ptrs* dat_val_pointers)
factor = H5Z_new_node(H5Z_XFORM_INTEGER);
if (!factor)
- HGOTO_DONE(factor)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "Unable to allocate new node")
sscanf(current->tok_begin, "%ld", &factor->value.int_val);
break;
@@ -752,7 +751,7 @@ H5Z_parse_factor(H5Z_token *current, H5Z_datval_ptrs* dat_val_pointers)
factor = H5Z_new_node(H5Z_XFORM_FLOAT);
if (!factor)
- HGOTO_DONE(factor)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "Unable to allocate new node")
sscanf(current->tok_begin, "%lf", &factor->value.float_val);
break;
@@ -760,7 +759,7 @@ H5Z_parse_factor(H5Z_token *current, H5Z_datval_ptrs* dat_val_pointers)
factor = H5Z_new_node(H5Z_XFORM_SYMBOL);
if (!factor)
- HGOTO_DONE(factor)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "Unable to allocate new node")
factor->value.dat_val = &(dat_val_pointers->ptr_dat_val[dat_val_pointers->num_ptrs]);
dat_val_pointers->num_ptrs++;
@@ -770,7 +769,7 @@ H5Z_parse_factor(H5Z_token *current, H5Z_datval_ptrs* dat_val_pointers)
factor = H5Z_parse_expression(current, dat_val_pointers);
if (!factor)
- HGOTO_DONE(factor)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "Unable to allocate new node")
current = H5Z_get_token(current);
diff --git a/src/H5public.h b/src/H5public.h
index 7a9c948..3244800 100644
--- a/src/H5public.h
+++ b/src/H5public.h
@@ -71,10 +71,10 @@ extern "C" {
/* Version numbers */
#define H5_VERS_MAJOR 1 /* For major interface/format changes */
#define H5_VERS_MINOR 9 /* For minor interface/format changes */
-#define H5_VERS_RELEASE 52 /* For tweaks, bug-fixes, or development */
+#define H5_VERS_RELEASE 54 /* For tweaks, bug-fixes, or development */
#define H5_VERS_SUBRELEASE "FA_a4" /* For pre-releases like snap0 */
/* Empty string for real releases. */
-#define H5_VERS_INFO "HDF5 library version: 1.9.52-FA_a4" /* Full version string */
+#define H5_VERS_INFO "HDF5 library version: 1.9.54-FA_a4" /* Full version string */
#define H5check() H5check_version(H5_VERS_MAJOR,H5_VERS_MINOR, \
H5_VERS_RELEASE)