diff options
author | Allen Byrne <byrn@hdfgroup.org> | 2017-08-31 18:31:42 (GMT) |
---|---|---|
committer | Allen Byrne <byrn@hdfgroup.org> | 2017-08-31 18:31:42 (GMT) |
commit | f5275af71acecacbe2f1f132416986fabe1169c5 (patch) | |
tree | faf7f3ac42a3f86b3a3fc4ba43a434a0db4f86e6 /tools/lib/h5tools.c | |
parent | 289007567e6ab5e0893af787b1870f27f10644c7 (diff) | |
parent | 61bdee1ff77a5db47ce8a88ce7e3c83e58123236 (diff) | |
download | hdf5-f5275af71acecacbe2f1f132416986fabe1169c5.zip hdf5-f5275af71acecacbe2f1f132416986fabe1169c5.tar.gz hdf5-f5275af71acecacbe2f1f132416986fabe1169c5.tar.bz2 |
Merge pull request #644 in HDFFV/hdf5 from ~BYRN/hdf5_adb:develop to develop
* commit '61bdee1ff77a5db47ce8a88ce7e3c83e58123236':
HDFFV-10282 refactor out assert calls in tools
Diffstat (limited to 'tools/lib/h5tools.c')
-rw-r--r-- | tools/lib/h5tools.c | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c index 5031e44..344913a 100644 --- a/tools/lib/h5tools.c +++ b/tools/lib/h5tools.c @@ -1283,13 +1283,13 @@ init_acc_pos(h5tools_context_t *ctx, hsize_t *dims) int i; unsigned j; - HDassert(ctx->ndims); - - ctx->acc[ctx->ndims - 1] = 1; - for (i = ((int)ctx->ndims - 2); i >= 0; i--) - ctx->acc[i] = ctx->acc[i + 1] * dims[i + 1]; - for (j = 0; j < ctx->ndims; j++) - ctx->pos[j] = 0; + if(ctx->ndims > 0) { + ctx->acc[ctx->ndims - 1] = 1; + for (i = ((int)ctx->ndims - 2); i >= 0; i--) + ctx->acc[i] = ctx->acc[i + 1] * dims[i + 1]; + for (j = 0; j < ctx->ndims; j++) + ctx->pos[j] = 0; + } } /*------------------------------------------------------------------------- @@ -1410,13 +1410,17 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t memb = H5Tget_super(tid); ndims = H5Tget_array_ndims(tid); H5Tget_array_dims2(tid, dims); - HDassert(ndims >= 1 && ndims <= H5S_MAX_RANK); - - /* calculate the number of array elements */ - for (k = 0, nelmts = 1; k < ndims; k++) { - temp_nelmts = nelmts; - temp_nelmts *= dims[k]; - nelmts = (size_t) temp_nelmts; + if(ndims >= 1 && ndims <= H5S_MAX_RANK) { + /* calculate the number of array elements */ + for (k = 0, nelmts = 1; k < ndims; k++) { + temp_nelmts = nelmts; + temp_nelmts *= dims[k]; + nelmts = (size_t) temp_nelmts; + } + } + else { + H5Tclose(memb); + H5E_THROW(FAIL, H5E_tools_min_id_g, "calculate the number of array elements failed"); } for (block_index = 0; block_index < block_nelmts; block_index++) { @@ -1641,7 +1645,6 @@ render_bin_output_region_blocks(hid_t region_space, hid_t region_id, ndims = (unsigned)sndims; alloc_size = nblocks * ndims * 2 * sizeof(ptdata[0]); - HDassert(alloc_size == (hsize_t) ((size_t) alloc_size)); /*check for overflow*/ if((ptdata = (hsize_t*) HDmalloc((size_t) alloc_size)) == NULL) HGOTO_ERROR(FALSE, H5E_tools_min_id_g, "Could not allocate buffer for ptdata"); |