summaryrefslogtreecommitdiffstats
path: root/tools/lib/h5tools.c
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2017-09-06 17:36:26 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2017-09-06 17:36:26 (GMT)
commit0b070ae114172588756d2c8732ccb7c89eb08ab6 (patch)
treebc63dbf62358e0f49460c59bf77e32a031045d3c /tools/lib/h5tools.c
parenta57f039a6aae04b8f91955e92ddbaa74cc78fc2b (diff)
downloadhdf5-0b070ae114172588756d2c8732ccb7c89eb08ab6.zip
hdf5-0b070ae114172588756d2c8732ccb7c89eb08ab6.tar.gz
hdf5-0b070ae114172588756d2c8732ccb7c89eb08ab6.tar.bz2
HDFFV-10282 refactor out assert calls in tools
Diffstat (limited to 'tools/lib/h5tools.c')
-rw-r--r--tools/lib/h5tools.c41
1 files changed, 19 insertions, 22 deletions
diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c
index 159349a..62495f9 100644
--- a/tools/lib/h5tools.c
+++ b/tools/lib/h5tools.c
@@ -12,16 +12,10 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
- * Programmer: Robb Matzke <matzke@llnl.gov>
- * Thursday, July 23, 1998
- *
* Purpose: A library for displaying the values of a dataset in a human
* readable format.
*/
-#include <stdio.h>
-#include <stdlib.h>
-
#include "h5tools.h"
#include "h5tools_dump.h"
#include "h5tools_ref.h"
@@ -40,7 +34,7 @@ FILE *rawinstream = NULL; /* should initialize to stdin but gcc moa
FILE *rawoutstream = NULL; /* should initialize to stdout but gcc moans about it */
FILE *rawerrorstream = NULL; /* should initialize to stderr but gcc moans about it */
int bin_output; /* binary output */
-int bin_form; /* binary form */
+int bin_form = 0; /* binary form, default NATIVE */
int region_output; /* region output */
int oid_output; /* oid output */
int data_output; /* data output */
@@ -1289,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;
+ }
}
/*-------------------------------------------------------------------------
@@ -1416,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++) {
@@ -1647,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");