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 /src/H5T.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 'src/H5T.c')
-rw-r--r-- | src/H5T.c | 14 |
1 files changed, 7 insertions, 7 deletions
@@ -3473,7 +3473,7 @@ H5Tget_ebias(hid_t type_id) } /* bias */ - ebias = dt->u.atomic.u.f.ebias; + H5_ASSIGN_OVERFLOW(ebias,dt->u.atomic.u.f.ebias,uint64_t,size_t); FUNC_LEAVE(ebias); } @@ -7765,7 +7765,7 @@ H5T_array_create(H5T_t *base, int ndims, const hsize_t dim[/* ndims */], { H5T_t *ret_value = NULL; /*new array data type */ int i; /* local index variable */ - + FUNC_ENTER(H5T_array_create, NULL); assert(base); @@ -7787,8 +7787,8 @@ H5T_array_create(H5T_t *base, int ndims, const hsize_t dim[/* ndims */], /* Copy the array dimensions & compute the # of elements in the array */ for(i=0, ret_value->u.array.nelem=1; i<ndims; i++) { - ret_value->u.array.dim[i] = dim[i]; - ret_value->u.array.nelem *= dim[i]; + H5_ASSIGN_OVERFLOW(ret_value->u.array.dim[i],dim[i],hsize_t,size_t); + ret_value->u.array.nelem *= (size_t)dim[i]; } /* end for */ /* Copy the dimension permutations */ @@ -8103,12 +8103,12 @@ H5T_debug(const H5T_t *dt, FILE *stream) (unsigned long) (dt->u.atomic.u.f.esize)); tmp = dt->u.atomic.u.f.ebias >> 32; if (tmp) { - size_t hi = tmp; - size_t lo = dt->u.atomic.u.f.ebias & 0xffffffff; + size_t hi=(size_t)tmp; + size_t lo =(size_t)(dt->u.atomic.u.f.ebias & 0xffffffff); fprintf(stream, " bias=0x%08lx%08lx", (unsigned long)hi, (unsigned long)lo); } else { - size_t lo = dt->u.atomic.u.f.ebias & 0xffffffff; + size_t lo = (size_t)(dt->u.atomic.u.f.ebias & 0xffffffff); fprintf(stream, " bias=0x%08lx", (unsigned long)lo); } break; |