summaryrefslogtreecommitdiffstats
path: root/tools/lib
diff options
context:
space:
mode:
Diffstat (limited to 'tools/lib')
-rw-r--r--tools/lib/h5tools.c64
-rw-r--r--tools/lib/h5tools_error.h1
2 files changed, 34 insertions, 31 deletions
diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c
index 55075a0..8263909 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;
}
@@ -3290,10 +3292,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)
@@ -3301,6 +3305,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:
@@ -3308,21 +3313,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)
@@ -3390,7 +3392,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_ */
+