diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2001-11-27 16:29:13 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2001-11-27 16:29:13 (GMT) |
commit | d456c2bb82be98bc2b7c1039927eb52258d1a0eb (patch) | |
tree | a7d8a65aef5d962c89b0965c86eb535917c023ad /tools/lib/h5tools_str.c | |
parent | 05264c88788f9bd9b04a58673ded246904210235 (diff) | |
download | hdf5-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/h5tools_str.c')
-rw-r--r-- | tools/lib/h5tools_str.c | 11 |
1 files changed, 7 insertions, 4 deletions
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, "[")); |