diff options
author | Neil Fortner <nfortne2@hdfgroup.org> | 2015-08-07 16:15:39 (GMT) |
---|---|---|
committer | Neil Fortner <nfortne2@hdfgroup.org> | 2015-08-07 16:15:39 (GMT) |
commit | 98f947ceaedbae472efbebad505680d2ca62b403 (patch) | |
tree | 21146ddcd7fd224d9f68bccc9824aa082eb9c205 /src/H5Sselect.c | |
parent | bfd13897f6dcfddce253c6a5463cb9f53b927800 (diff) | |
download | hdf5-98f947ceaedbae472efbebad505680d2ca62b403.zip hdf5-98f947ceaedbae472efbebad505680d2ca62b403.tar.gz hdf5-98f947ceaedbae472efbebad505680d2ca62b403.tar.bz2 |
[svn-r27479] Add checking for invalid inputs to H5Dset_virtual: point selections, incorrect
numbers of elements selected, incorrect "slice" through limited dimensions,
incorrect number of printf substitutions.
Patch source selection space extent with bounds of selection if extent is
unknown before returning via H5Pget_virtual_srcspace.
Write updated VDS dataspace to file when it changes due to unlimited selections.
Other minor fixes/cleanup.
Tested: ummon
Diffstat (limited to 'src/H5Sselect.c')
-rw-r--r-- | src/H5Sselect.c | 53 |
1 files changed, 49 insertions, 4 deletions
diff --git a/src/H5Sselect.c b/src/H5Sselect.c index bb74b14..86a8c43 100644 --- a/src/H5Sselect.c +++ b/src/H5Sselect.c @@ -507,7 +507,7 @@ H5S_select_deserialize(const H5F_t *f, H5S_t **space, const uint8_t **p) /* Patch the rank of the allocated dataspace */ (void)HDmemset(dims, 0, (size_t)rank * sizeof(dims[0])); - if(H5S__set_extent_simple(tmp_space, rank, dims, NULL) < 0) + if(H5S_set_extent_simple(tmp_space, rank, dims, NULL) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't set dimensions") } /* end if */ else @@ -731,6 +731,51 @@ H5S_get_select_unlim_dim(const H5S_t *space) /*-------------------------------------------------------------------------- NAME + H5S_get_select_num_elem_non_unlim + PURPOSE + Gets the number of elements in the non-unlimited dimensions + USAGE + herr_t H5S_get_select_num_elem_non_unlim(space,num_elem_non_unlim) + H5S_t *space; IN: Dataspace pointer to check + hsize_t *num_elem_non_unlim; OUT: Number of elements in the non-unlimited dimensions + RETURNS + Non-negative on success/Negative on failure + DESCRIPTION + Returns the number of elements in a slice through the non-unlimited + dimensions of the selection. Fails if the selection has no unlimited + dimension. + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +herr_t +H5S_get_select_num_elem_non_unlim(const H5S_t *space, + hsize_t *num_elem_non_unlim) +{ + herr_t ret_value = SUCCEED; /* return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Check args */ + HDassert(space); + HDassert(num_elem_non_unlim); + + /* Check for selection callback */ + if(!space->select.type->num_elem_non_unlim) + HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "selection type has no num_elem_non_unlim callback") + + /* Make selection callback */ + if((*space->select.type->num_elem_non_unlim)(space, num_elem_non_unlim) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOUNT, FAIL, "can't get number of elements in non-unlimited dimension") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5S_get_select_unlim_dim() */ + + +/*-------------------------------------------------------------------------- + NAME H5S_select_is_contiguous PURPOSE Determines if a selection is contiguous in the dataspace @@ -2240,7 +2285,7 @@ H5S_select_project_intersection(const H5S_t *src_space, const H5S_t *dst_space, else if((src_intersect_space->select.type->type == H5S_SEL_POINTS) || (src_space->select.type->type == H5S_SEL_POINTS) || (dst_space->select.type->type == H5S_SEL_POINTS)) - HDassert(0 && "Not yet implemented...");//VDSINC + HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "point selections not currently supported") else { HDassert(src_intersect_space->select.type->type == H5S_SEL_HYPERSLABS); /* Intersecting space is hyperslab selection. Call the hyperslab @@ -2314,7 +2359,7 @@ H5S_select_subtract(H5S_t *space, H5S_t *subtract_space) /* Check for point selection in subtract_space, convert to * hyperslab */ if(subtract_space->select.type->type == H5S_SEL_POINTS) - HDassert(0 && "Not yet implemented...");//VDSINC + HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "point selections not currently supported") /* Check for point or all selection in space, convert to hyperslab */ @@ -2340,7 +2385,7 @@ H5S_select_subtract(H5S_t *space, H5S_t *subtract_space) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't convert selection") } /* end if */ else if(space->select.type->type == H5S_SEL_POINTS) - HDassert(0 && "Not yet implemented...");//VDSINC + HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "point selections not currently supported") HDassert(space->select.type->type == H5S_SEL_HYPERSLABS); HDassert(subtract_space->select.type->type == H5S_SEL_HYPERSLABS); |