summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2020-03-09 18:55:40 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2020-03-09 18:55:40 (GMT)
commit049ade7a31078738f1a32914042af11da80e7de0 (patch)
tree6eb581ffeed9726f38c5533c4fb2f0ccb321470f
parent198109c48f223ce58738d8e6eca7fb2d0ada7eb7 (diff)
downloadhdf5-049ade7a31078738f1a32914042af11da80e7de0.zip
hdf5-049ade7a31078738f1a32914042af11da80e7de0.tar.gz
hdf5-049ade7a31078738f1a32914042af11da80e7de0.tar.bz2
Check sizeof type to use correct ref_type
-rw-r--r--tools/lib/h5tools_dump.c65
-rw-r--r--tools/src/h5ls/h5ls.c68
-rw-r--r--tools/src/h5repack/h5repack_refs.c11
3 files changed, 65 insertions, 79 deletions
diff --git a/tools/lib/h5tools_dump.c b/tools/lib/h5tools_dump.c
index 32db875..b10e0a7 100644
--- a/tools/lib/h5tools_dump.c
+++ b/tools/lib/h5tools_dump.c
@@ -3938,34 +3938,17 @@ h5tools_dump_data(FILE *stream, const h5tool_format_t *info, h5tools_context_t *
h5tools_str_sprint(&buffer, &outputformat, obj_id, f_type, memref, &datactx);
h5tools_render_element(stream, &outputformat, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
- if ((region_id = H5Rdereference2(obj_id, H5P_DEFAULT, H5R_OBJECT, memref)) >= 0) {
- datactx.indent_level++;
- h5tools_dump_data(stream, &outputformat, &datactx, region_id, TRUE);
- datactx.indent_level--;
- }
- else {
- if ((region_id = H5Rdereference2(obj_id, H5P_DEFAULT, H5R_DATASET_REGION, memref)) >= 0) {
- if ((region_space = H5Rget_region(obj_id, H5R_DATASET_REGION, memref)) >= 0) {
- if (h5tools_is_zero(memref, H5Tget_size(f_type))) {
- H5TOOLS_DEBUG("NULL H5R_DATASET_REGION");
-
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, " {");
- h5tools_render_element(stream, &outputformat, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
-
- datactx.need_prefix = TRUE;
- datactx.indent_level++;
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "NULL");
- h5tools_render_element(stream, &outputformat, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
- datactx.indent_level--;
- datactx.need_prefix = TRUE;
-
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "}");
- h5tools_render_element(stream, &outputformat, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
- }
- else {
+ if (!h5tools_is_zero(memref, H5Tget_size(f_type))) {
+ if (nsize == H5R_OBJ_REF_BUF_SIZE) {
+ if ((region_id = H5Rdereference2(obj_id, H5P_DEFAULT, H5R_OBJECT, memref)) >= 0) {
+ datactx.indent_level++;
+ h5tools_dump_data(stream, &outputformat, &datactx, region_id, TRUE);
+ datactx.indent_level--;
+ }
+ }
+ else {
+ if ((region_id = H5Rdereference2(obj_id, H5P_DEFAULT, H5R_DATASET_REGION, memref)) >= 0) {
+ if ((region_space = H5Rget_region(obj_id, H5R_DATASET_REGION, memref)) >= 0) {
H5S_sel_type region_type;
region_type = H5Sget_select_type(region_space);
@@ -3985,20 +3968,20 @@ h5tools_dump_data(FILE *stream, const h5tool_format_t *info, h5tools_context_t *
}
else
H5TOOLS_INFO("invalid region type");
- } /* end else to if (h5tools_is_zero(... */
- if(H5Sclose(region_space) < 0)
- H5TOOLS_INFO("H5Sclose H5R_DATASET_REGION failed");
- } /* end if (region_space >= 0) */
- else
- H5TOOLS_INFO("H5Rget_region H5R_DATASET_REGION failed");
- if(H5Dclose(region_id) < 0)
- H5TOOLS_INFO("H5Dclose H5R_DATASET_REGION failed");
- } /* if (region_id >= 0) */
- else {
- /* if (region_id < 0) - could mean that no reference was written do not throw failure */
- H5Epush2(H5tools_ERR_STACK_g, __FILE__, FUNC, __LINE__, H5tools_ERR_CLS_g, H5E_tools_g, H5E_tools_min_id_g, "H5Rdereference failed");
+ if(H5Sclose(region_space) < 0)
+ H5TOOLS_INFO("H5Sclose H5R_DATASET_REGION failed");
+ } /* end if (region_space >= 0) */
+ else
+ H5TOOLS_INFO("H5Rget_region H5R_DATASET_REGION failed");
+ if(H5Dclose(region_id) < 0)
+ H5TOOLS_INFO("H5Dclose H5R_DATASET_REGION failed");
+ } /* if (region_id >= 0) */
+ else {
+ /* if (region_id < 0) - could mean that no reference was written do not throw failure */
+ H5Epush2(H5tools_ERR_STACK_g, __FILE__, FUNC, __LINE__, H5tools_ERR_CLS_g, H5E_tools_g, H5E_tools_min_id_g, "H5Rdereference failed");
+ }
}
- }
+ } /* end else to if (h5tools_is_zero(... */
H5TOOLS_DEBUG("finished reference loop:%d",i);
} /* end for(i = 0; i < ndims; i++, datactx->cur_elmt++, elmt_counter++) */
diff --git a/tools/src/h5ls/h5ls.c b/tools/src/h5ls/h5ls.c
index f363b83..b75481a 100644
--- a/tools/src/h5ls/h5ls.c
+++ b/tools/src/h5ls/h5ls.c
@@ -1325,39 +1325,41 @@ dump_reference(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx
h5tools_render_element(stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)i, (hsize_t)ndims);
/* region data */
- if ((region_id = H5Rdereference2(container, H5P_DEFAULT, H5R_DATASET_REGION, memref)) >= 0) {
- if ((region_space = H5Rget_region(container, H5R_DATASET_REGION, memref)) >= 0) {
- H5S_sel_type region_type;
-
- region_type = H5Sget_select_type(region_space);
- if(region_type == H5S_SEL_POINTS) {
- /* Print point information */
- H5TOOLS_DEBUG("H5S_SEL_POINTS H5R_DATASET_REGION");
- h5tools_dump_region_data_points(
- region_space, region_id, stream, info, &datactx,
- &buffer, &curr_pos, ncols, (hsize_t)i, elmt_counter);
- }
- else if(region_type == H5S_SEL_HYPERSLABS) {
- /* Print block information */
- H5TOOLS_DEBUG("H5S_SEL_HYPERSLABS H5R_DATASET_REGION");
- h5tools_dump_region_data_blocks(
- region_space, region_id, stream, info, &datactx,
- &buffer, &curr_pos, ncols, (hsize_t)i, elmt_counter);
- }
- else
- H5TOOLS_INFO("invalid region type");
- if(H5Sclose(region_space) < 0)
- H5TOOLS_INFO("H5Sclose H5R_DATASET_REGION failed");
- } /* end if (region_space >= 0) */
- else
- H5TOOLS_INFO("H5Rget_region H5R_DATASET_REGION failed");
- if(H5Dclose(region_id) < 0)
- H5TOOLS_INFO("H5Dclose H5R_DATASET_REGION failed");
- } /* if (region_id >= 0) */
- else {
- /* if (region_id < 0) - could mean that no reference was written do not throw failure */
- H5Epush2(H5tools_ERR_STACK_g, __FILE__, FUNC, __LINE__, H5tools_ERR_CLS_g, H5E_tools_g, H5E_tools_min_id_g, "H5Rdereference failed");
- }
+ if (!h5tools_is_zero(memref, H5Tget_size(f_type))) {
+ if ((region_id = H5Rdereference2(container, H5P_DEFAULT, H5R_DATASET_REGION, memref)) >= 0) {
+ if ((region_space = H5Rget_region(container, H5R_DATASET_REGION, memref)) >= 0) {
+ H5S_sel_type region_type;
+
+ region_type = H5Sget_select_type(region_space);
+ if(region_type == H5S_SEL_POINTS) {
+ /* Print point information */
+ H5TOOLS_DEBUG("H5S_SEL_POINTS H5R_DATASET_REGION");
+ h5tools_dump_region_data_points(
+ region_space, region_id, stream, info, &datactx,
+ &buffer, &curr_pos, ncols, (hsize_t)i, elmt_counter);
+ }
+ else if(region_type == H5S_SEL_HYPERSLABS) {
+ /* Print block information */
+ H5TOOLS_DEBUG("H5S_SEL_HYPERSLABS H5R_DATASET_REGION");
+ h5tools_dump_region_data_blocks(
+ region_space, region_id, stream, info, &datactx,
+ &buffer, &curr_pos, ncols, (hsize_t)i, elmt_counter);
+ }
+ else
+ H5TOOLS_INFO("invalid region type");
+ if(H5Sclose(region_space) < 0)
+ H5TOOLS_INFO("H5Sclose H5R_DATASET_REGION failed");
+ } /* end if (region_space >= 0) */
+ else
+ H5TOOLS_INFO("H5Rget_region H5R_DATASET_REGION failed");
+ if(H5Dclose(region_id) < 0)
+ H5TOOLS_INFO("H5Dclose H5R_DATASET_REGION failed");
+ } /* if (region_id >= 0) */
+ else {
+ /* if (region_id < 0) - could mean that no reference was written do not throw failure */
+ H5Epush2(H5tools_ERR_STACK_g, __FILE__, FUNC, __LINE__, H5tools_ERR_CLS_g, H5E_tools_g, H5E_tools_min_id_g, "H5Rdereference failed");
+ }
+ } /* end else to if (h5tools_is_zero(... */
H5TOOLS_DEBUG("finished reference loop:%d",i);
} /* end for(i = 0; i < ndims; i++, ctx->cur_elmt++, elmt_counter++) */
diff --git a/tools/src/h5repack/h5repack_refs.c b/tools/src/h5repack/h5repack_refs.c
index 23dc8c2..04aea57 100644
--- a/tools/src/h5repack/h5repack_refs.c
+++ b/tools/src/h5repack/h5repack_refs.c
@@ -171,9 +171,10 @@ int do_copy_refobjs(hid_t fidin,
} /* end if */
for(u = 0; u < nelmts; u++) {
H5E_BEGIN_TRY {
- if((refobj_id = H5Rdereference2(dset_in, H5P_DEFAULT, H5R_OBJECT, &buf[u])) < 0)
- continue;
+ refobj_id = H5Rdereference2(dset_in, H5P_DEFAULT, H5R_OBJECT, &buf[u]);
} H5E_END_TRY;
+ if(refobj_id < 0)
+ continue;
/* get the name. a valid name could only occur
* in the second traversal of the file
@@ -252,9 +253,10 @@ int do_copy_refobjs(hid_t fidin,
for(u = 0; u < nelmts; u++) {
H5E_BEGIN_TRY {
- if((refobj_id = H5Rdereference2(dset_in, H5P_DEFAULT, H5R_DATASET_REGION, &buf[u])) < 0)
- continue;
+ refobj_id = H5Rdereference2(dset_in, H5P_DEFAULT, H5R_DATASET_REGION, &buf[u]);
} H5E_END_TRY;
+ if(refobj_id < 0)
+ continue;
/* get the name. a valid name could only occur
* in the second traversal of the file
@@ -538,7 +540,6 @@ static int copy_refs_attr(hid_t loc_in,
KY 2020-02-10
*/
is_ref_comp = (ref_comp_field_n > 0);
-
}