summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/h5dump/h5dump.c39
-rw-r--r--tools/h5stat/h5stat.c10
-rw-r--r--tools/lib/h5tools.c64
-rw-r--r--tools/lib/h5tools_error.h1
4 files changed, 62 insertions, 52 deletions
diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c
index a1f78b1..a6c1f77 100644
--- a/tools/h5dump/h5dump.c
+++ b/tools/h5dump/h5dump.c
@@ -2710,11 +2710,12 @@ dump_dcpl(hid_t dcpl_id,hid_t type_id, hid_t obj_id)
int i, next;
unsigned j;
- storage_size=H5Dget_storage_size(obj_id);
+ storage_size = H5Dget_storage_size(obj_id);
nfilters = H5Pget_nfilters(dcpl_id);
- ioffset=H5Dget_offset(obj_id);
- next=H5Pget_external_count(dcpl_id);
- strcpy(f_name,"\0");
+ ioffset = H5Dget_offset(obj_id);
+ next = H5Pget_external_count(dcpl_id);
+ HDassert(next >= 0);
+ HDstrcpy(f_name,"\0");
/*-------------------------------------------------------------------------
* STORAGE_LAYOUT
@@ -4510,14 +4511,16 @@ print_enum(hid_t type)
unsigned char *value = NULL; /*value array */
unsigned char *copy = NULL; /*a pointer to value array */
unsigned nmembs; /*number of members */
+ int snmembs;
int nchars; /*number of output characters */
hid_t super; /*enum base integer type */
hid_t native = -1; /*native integer datatype */
size_t dst_size; /*destination value type size */
unsigned i;
- nmembs = H5Tget_nmembers(type);
- assert(nmembs>0);
+ snmembs = H5Tget_nmembers(type);
+ HDassert(snmembs >= 0);
+ nmembs = (unsigned)snmembs;
super = H5Tget_super(type);
/*
@@ -4527,17 +4530,16 @@ print_enum(hid_t type)
* 2. unsigned long long -- the largest native unsigned integer
* 3. raw format
*/
- if (H5Tget_size(type) <= sizeof(long long)) {
- dst_size = sizeof(long long);
+ if(H5Tget_size(type) <= sizeof(long long)) {
+ dst_size = sizeof(long long);
- if (H5T_SGN_NONE == H5Tget_sign(type)) {
- native = H5T_NATIVE_ULLONG;
- } else {
- native = H5T_NATIVE_LLONG;
- }
- } else {
- dst_size = H5Tget_size(type);
- }
+ if(H5T_SGN_NONE == H5Tget_sign(type))
+ native = H5T_NATIVE_ULLONG;
+ else
+ native = H5T_NATIVE_LLONG;
+ } /* end if */
+ else
+ dst_size = H5Tget_size(type);
/* Get the names and raw values of all members */
name = calloc(nmembs, sizeof(char *));
@@ -6691,13 +6693,16 @@ xml_print_enum(hid_t type)
char **name = NULL; /*member names */
unsigned char *value = NULL; /*value array */
unsigned nmembs; /*number of members */
+ int snmembs;
hid_t super; /*enum base integer type */
hid_t native = -1; /*native integer datatype */
size_t dst_size; /*destination value type size */
unsigned i; /*miscellaneous counters */
size_t j;
- nmembs = H5Tget_nmembers(type);
+ snmembs = H5Tget_nmembers(type);
+ HDassert(snmembs >= 0);
+ nmembs = (unsigned)snmembs;
super = H5Tget_super(type);
indentation(indent);
diff --git a/tools/h5stat/h5stat.c b/tools/h5stat/h5stat.c
index f5537e1..2e6acc2 100644
--- a/tools/h5stat/h5stat.c
+++ b/tools/h5stat/h5stat.c
@@ -527,10 +527,12 @@ dataset_stats(iter_t *iter, const char *name, const H5O_info_t *oi)
iter->dset_comptype[0]++;
for(u = 0; u < (unsigned)nfltr; u++) {
fltr = H5Pget_filter2(dcpl, u, 0, 0, 0, 0, 0, NULL);
- if(fltr < (H5_NFILTERS_IMPL - 1))
- iter->dset_comptype[fltr]++;
- else
- iter->dset_comptype[H5_NFILTERS_IMPL - 1]++; /*other filters*/
+ if(fltr >= 0) {
+ if(fltr < (H5_NFILTERS_IMPL - 1))
+ iter->dset_comptype[fltr]++;
+ else
+ iter->dset_comptype[H5_NFILTERS_IMPL - 1]++; /*other filters*/
+ } /* end if */
} /* end for */
} /* endif nfltr */
diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c
index 80016b2..4761ab9 100644
--- a/tools/lib/h5tools.c
+++ b/tools/lib/h5tools.c
@@ -2000,10 +2000,10 @@ h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_c
/* calculate the potential number of elements we're going to print */
if(H5Sselect_hyperslab(f_space, H5S_SELECT_SET, temp_start, temp_stride, temp_count, temp_block) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sselect_hyperslab failed");
+ H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Sselect_hyperslab failed");
if((sm_nelmts = H5Sget_select_npoints(f_space)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sget_select_npoints failed");
+ H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Sget_select_npoints failed");
if (sm_nelmts > 0) {
/*
@@ -2011,7 +2011,7 @@ h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_c
* a hyperslab whose size is manageable.
*/
if((sm_nbytes = p_type_nbytes = H5Tget_size(p_type)) == 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_size failed");
+ H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_size failed");
if (ctx->ndims > 0)
for (i = ctx->ndims; i > 0; --i) {
@@ -2025,18 +2025,17 @@ h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_c
assert(sm_nbytes == (hsize_t) ((size_t) sm_nbytes)); /*check for overflow*/
if((sm_buf = HDmalloc((size_t) sm_nelmts * p_type_nbytes)) == NULL)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for strip-mine");
+ H5E_THROW(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for strip-mine");
if((sm_space = H5Screate_simple(1, &sm_nelmts, NULL)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Screate_simple failed");
+ H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Screate_simple failed");
if(H5Sselect_hyperslab(sm_space, H5S_SELECT_SET, &zero, NULL, &sm_nelmts, NULL) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sselect_hyperslab failed");
+ H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Sselect_hyperslab failed");
/* read the data */
- if (H5Dread(dset, p_type, sm_space, f_space, H5P_DEFAULT, sm_buf) < 0) {
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dread failed");
- }
+ if(H5Dread(dset, p_type, sm_space, f_space, H5P_DEFAULT, sm_buf) < 0)
+ H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Dread failed");
/* print the data */
flags = START_OF_DATA;
@@ -2050,7 +2049,7 @@ h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_c
/* print array indices. get the lower bound of the hyperslab and calulate
the element position at the start of hyperslab */
if(H5Sget_select_bounds(f_space, low, high) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sget_select_bounds failed");
+ H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Sget_select_bounds failed");
elmtno = 0;
for (i = 0; i < (size_t) ctx->ndims - 1; i++) {
@@ -2066,10 +2065,11 @@ h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_c
ctx->sm_pos = elmtno;
h5tools_dump_simple_data(stream, info, dset, ctx, flags, sm_nelmts, p_type, sm_buf);
-done:
+
if(H5Sclose(sm_space) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed");
- HDfree(sm_buf);
+ H5E_THROW(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed");
+ if(sm_buf)
+ HDfree(sm_buf);
}
else
H5E_THROW(SUCCEED, H5E_tools_min_id_g, "nothing to print");
@@ -2272,7 +2272,8 @@ h5tools_dump_simple_subset(FILE *stream, const h5tool_format_t *info, hid_t dset
hid_t p_type, struct subset_t *sset, int indentlevel)
{
HERR_INIT(herr_t, SUCCEED)
- hid_t f_space; /* file data space */
+ int sndims;
+ hid_t f_space = -1; /* file data space */
size_t i; /* counters */
hsize_t total_size[H5S_MAX_RANK];/* total size of dataset*/
h5tools_context_t ctx; /* print context */
@@ -2288,8 +2289,9 @@ h5tools_dump_simple_subset(FILE *stream, const h5tool_format_t *info, hid_t dset
memset(&ctx, 0, sizeof(ctx));
ctx.indent_level = indentlevel;
ctx.need_prefix = 1;
- if((ctx.ndims = H5Sget_simple_extent_ndims(f_space)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed");
+ if((sndims = H5Sget_simple_extent_ndims(f_space)) < 0)
+ H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed");
+ ctx.ndims = (unsigned)sndims;
/* assume entire data space to be printed */
if (ctx.ndims > 0)
@@ -2297,10 +2299,11 @@ h5tools_dump_simple_subset(FILE *stream, const h5tool_format_t *info, hid_t dset
ctx.p_min_idx[i] = 0;
if(H5Sget_simple_extent_dims(f_space, total_size, NULL) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed");
+ H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed");
ctx.size_last_dim = total_size[ctx.ndims - 1];
h5tools_display_simple_subset(stream, info, &ctx, dset, p_type, sset, f_space, total_size);
+
/* Terminate the output */
if (ctx.cur_column) {
fputs(OPT(info->line_suf, ""), stream);
@@ -2308,11 +2311,10 @@ h5tools_dump_simple_subset(FILE *stream, const h5tool_format_t *info, hid_t dset
fputs(OPT(info->line_sep, ""), stream);
}
-done:
- if(H5Sclose(f_space) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed");
-
CATCH
+ if(f_space >= 0 && H5Sclose(f_space) < 0)
+ H5E_THROW(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed");
+
return ret_value;
}
@@ -3291,10 +3293,12 @@ h5tools_print_enum(h5tools_str_t *buffer, hid_t type)
H5T_sign_t sign_type; /*sign of value type */
size_t type_size; /*value type size */
size_t dst_size; /*destination value type size */
+ int snmembs;
unsigned i;
- if((nmembs = H5Tget_nmembers(type)) < 0)
+ if((snmembs = H5Tget_nmembers(type)) < 0)
H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_nmembers failed");
+ nmembs = (unsigned)snmembs;
assert(nmembs > 0);
if((super = H5Tget_super(type)) < 0)
@@ -3302,6 +3306,7 @@ h5tools_print_enum(h5tools_str_t *buffer, hid_t type)
if((type_size = H5Tget_size(type)) <= 0)
H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_size(type) failed");
+
/*
* Determine what datatype to use for the native values. To simplify
* things we entertain three possibilities:
@@ -3309,21 +3314,18 @@ h5tools_print_enum(h5tools_str_t *buffer, hid_t type)
* 2. unsigned long long -- the largest native unsigned integer
* 3. raw format
*/
- if (type_size <= sizeof(long long)) {
+ if(type_size <= sizeof(long long)) {
dst_size = sizeof(long long);
if((sign_type = H5Tget_sign(type))<0)
H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_sign failed");
- if (H5T_SGN_NONE == sign_type) {
+ if(H5T_SGN_NONE == sign_type)
native = H5T_NATIVE_ULLONG;
- }
- else {
+ else
native = H5T_NATIVE_LLONG;
- }
- }
- else {
+ } /* end if */
+ else
dst_size = type_size;
- }
/* Get the names and raw values of all members */
if((name = calloc(nmembs, sizeof(char *))) == NULL)
@@ -3391,7 +3393,7 @@ CATCH
free(value);
if(super >= 0 && H5Tclose(super) < 0)
- H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tclose failed");
+ H5E_THROW(FAIL, H5E_tools_min_id_g, "Could not close datatype's super class");
if (0 == nmembs)
h5tools_str_append(buffer, "\n<empty>");
diff --git a/tools/lib/h5tools_error.h b/tools/lib/h5tools_error.h
index 9efe223..da8f03c 100644
--- a/tools/lib/h5tools_error.h
+++ b/tools/lib/h5tools_error.h
@@ -116,3 +116,4 @@ extern hid_t H5E_tools_min_id_g;
#define HGOTO_DONE(ret_val) {ret_value = ret_val; goto done;}
#endif /* H5TOOLS_ERROR_H_ */
+