summaryrefslogtreecommitdiffstats
path: root/tools/lib
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2001-11-27 16:29:13 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2001-11-27 16:29:13 (GMT)
commitd456c2bb82be98bc2b7c1039927eb52258d1a0eb (patch)
treea7d8a65aef5d962c89b0965c86eb535917c023ad /tools/lib
parent05264c88788f9bd9b04a58673ded246904210235 (diff)
downloadhdf5-d456c2bb82be98bc2b7c1039927eb52258d1a0eb.zip
hdf5-d456c2bb82be98bc2b7c1039927eb52258d1a0eb.tar.gz
hdf5-d456c2bb82be98bc2b7c1039927eb52258d1a0eb.tar.bz2
[svn-r4643] Purpose:
Code cleanup Description: Windows is generating hundreds of warnings from some of the practices in the library. Mostly, they are because size_t is 32-bit and hsize_t is 64-bit on Windows and we were carelessly casting the larger values down to the smaller ones without checking for overflow. Also, some other small code cleanups,etc. Solution: Re-worked some algorithms to eliminate the casts and also added more overflow checking for assignments and function parameters which needed casts. Kent did most of the work, I just went over his changes and fit them into the the library code a bit better. Platforms tested: FreeBSD 4.4 (hawkwind)
Diffstat (limited to 'tools/lib')
-rw-r--r--tools/lib/h5tools.c12
-rw-r--r--tools/lib/h5tools_str.c11
2 files changed, 15 insertions, 8 deletions
diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c
index 569fe2f..c97914a 100644
--- a/tools/lib/h5tools.c
+++ b/tools/lib/h5tools.c
@@ -649,7 +649,8 @@ h5tools_dump_simple_subset(FILE *stream, const h5dump_t *info, hid_t dset,
ctx.p_min_idx[i] = 0;
H5Sget_simple_extent_dims(f_space, total_size, NULL);
- ctx.size_last_dim = total_size[ctx.ndims - 1];
+ assert(total_size[ctx.ndims - 1]==(hsize_t)((int)(total_size[ctx.ndims - 1])));
+ ctx.size_last_dim = (int)(total_size[ctx.ndims - 1]);
count = sset->count[ctx.ndims - 1];
sset->count[ctx.ndims - 1] = 1;
@@ -819,7 +820,10 @@ h5tools_dump_simple_dset(FILE *stream, const h5dump_t *info, hid_t dset,
ctx.p_min_idx[i] = 0;
H5Sget_simple_extent_dims(f_space, total_size, NULL);
- ctx.size_last_dim = total_size[ctx.ndims - 1];
+ /* printf("total_size[ctx.ndims-1]%d\n",total_size[ctx.ndims-1]);
+ printf("total_size cast %d\n",(int)(total_size[ctx.ndims-1])); */
+ /*assert(total_size[ctx.ndims - 1]==(hsize_t)((int)(total_size[ctx.ndims - 1])));*/
+ ctx.size_last_dim = (total_size[ctx.ndims - 1]);
/* calculate the number of elements we're going to print */
p_nelmts = 1;
@@ -975,8 +979,8 @@ h5tools_dump_simple_mem(FILE *stream, const h5dump_t *info, hid_t obj_id,
if (nelmts == 0)
return SUCCEED; /*nothing to print*/
-
- ctx.size_last_dim = ctx.p_max_idx[ctx.ndims - 1];
+ assert(ctx.p_max_idx[ctx.ndims - 1]==(hsize_t)((int)ctx.p_max_idx[ctx.ndims - 1]));
+ ctx.size_last_dim = (int)(ctx.p_max_idx[ctx.ndims - 1]);
/* Print it */
h5tools_dump_simple_data(stream, info, obj_id, &ctx,
diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c
index 0e3c5c7..2bc6305 100644
--- a/tools/lib/h5tools_str.c
+++ b/tools/lib/h5tools_str.c
@@ -786,7 +786,7 @@ h5tools_str_sprint(h5tools_str_t *str, const h5dump_t *info, hid_t container,
}
} else if (H5Tget_class(type) == H5T_ARRAY) {
int k, ndims;
- hsize_t i, dims[H5S_MAX_RANK];
+ hsize_t i, dims[H5S_MAX_RANK],temp_nelmts;
/* Get the array's base datatype for each element */
memb = H5Tget_super(type);
@@ -796,9 +796,12 @@ h5tools_str_sprint(h5tools_str_t *str, const h5dump_t *info, hid_t container,
assert(ndims >= 1 && ndims <= H5S_MAX_RANK);
/* Calculate the number of array elements */
- for (k = 0, nelmts = 1; k < ndims; k++)
- nelmts *= dims[k];
-
+ for (k = 0, nelmts = 1; k < ndims; k++){
+ temp_nelmts = nelmts;
+ temp_nelmts *= dims[k];
+ assert(temp_nelmts==(hsize_t)((size_t)temp_nelmts));
+ nelmts = (size_t)temp_nelmts;
+ }
/* Print the opening bracket */
h5tools_str_append(str, "%s", OPT(info->arr_pre, "["));