diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2001-01-09 21:22:30 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2001-01-09 21:22:30 (GMT) |
commit | 35bc545296209684a5c46db0cde11beb9403a4dc (patch) | |
tree | 98b5a037ed928085b98abc1fee71fc62f81073c1 /src/H5V.c | |
parent | 1290c4808d3e9890c765b1445f66b823c9026734 (diff) | |
download | hdf5-35bc545296209684a5c46db0cde11beb9403a4dc.zip hdf5-35bc545296209684a5c46db0cde11beb9403a4dc.tar.gz hdf5-35bc545296209684a5c46db0cde11beb9403a4dc.tar.bz2 |
[svn-r3252] Purpose:
Code cleanup.
Description:
Fixed _lots_ (I mean _tons_) of warnings spit out by the gcc with the
extra warnings. Including a few show-stoppers for compression on IRIX
machines.
Solution:
Changed lots of variables' types to more sensible and consistent types,
more range-checking, more variable typecasts, etc.
Platforms tested:
FreeBSD 4.2 (hawkwind), IRIX64-64 (modi4)
Diffstat (limited to 'src/H5V.c')
-rw-r--r-- | src/H5V.c | 160 |
1 files changed, 81 insertions, 79 deletions
@@ -38,7 +38,7 @@ static intn interface_initialize_g = 0; *------------------------------------------------------------------------- */ herr_t -H5V_stride_optimize1(intn *np/*in,out*/, hsize_t *elmt_size/*in,out*/, +H5V_stride_optimize1(uintn *np/*in,out*/, hsize_t *elmt_size/*in,out*/, hsize_t *size, hssize_t *stride1) { FUNC_ENTER(H5V_stride_optimize1, FAIL); @@ -52,13 +52,12 @@ H5V_stride_optimize1(intn *np/*in,out*/, hsize_t *elmt_size/*in,out*/, /* * Combine adjacent memory accesses */ - while (*np && - stride1[*np-1]>0 && - (hsize_t)(stride1[*np-1])==*elmt_size) { - *elmt_size *= size[*np-1]; - if (--*np) { - stride1[*np-1] += size[*np] * stride1[*np]; - } + while (*np && stride1[*np-1]>0 && + (hsize_t)(stride1[*np-1])==*elmt_size) { + *elmt_size *= size[*np-1]; + if (--*np) { + stride1[*np-1] += size[*np] * stride1[*np]; + } } FUNC_LEAVE(SUCCEED); @@ -85,7 +84,7 @@ H5V_stride_optimize1(intn *np/*in,out*/, hsize_t *elmt_size/*in,out*/, *------------------------------------------------------------------------- */ herr_t -H5V_stride_optimize2(intn *np/*in,out*/, hsize_t *elmt_size/*in,out*/, +H5V_stride_optimize2(uintn *np/*in,out*/, hsize_t *elmt_size/*in,out*/, hsize_t *size, hssize_t *stride1, hssize_t *stride2) { FUNC_ENTER(H5V_stride_optimize2, FAIL); @@ -196,7 +195,6 @@ H5V_stride_optimize2(intn *np/*in,out*/, hsize_t *elmt_size/*in,out*/, break; } /* end switch */ - FUNC_LEAVE(SUCCEED); } @@ -230,18 +228,18 @@ H5V_stride_optimize2(intn *np/*in,out*/, hsize_t *elmt_size/*in,out*/, *------------------------------------------------------------------------- */ hsize_t -H5V_hyper_stride(intn n, const hsize_t *size, +H5V_hyper_stride(uintn n, const hsize_t *size, const hsize_t *total_size, const hssize_t *offset, hssize_t *stride/*out*/) { hsize_t skip; /*starting point byte offset */ hsize_t acc; /*accumulator */ hsize_t tmp; - int i; /*counter */ + intn i; /*counter */ FUNC_ENTER(H5V_hyper_stride, (HDabort(), 0)); - assert(n >= 0 && n <= H5V_HYPER_NDIMS); + assert(n <= H5V_HYPER_NDIMS); assert(size); assert(total_size); assert(stride); @@ -295,7 +293,7 @@ H5V_hyper_stride(intn n, const hsize_t *size, default: /* others */ - for (i=n-2, acc=1; i>=0; --i) { + for (i=(intn)(n-2), acc=1; i>=0; --i) { hsize_t tmp = acc * (total_size[i+1] - size[i+1]); assert (tmp<((hsize_t)1<<(8*sizeof(hssize_t)-1))); stride[i] = (hssize_t)tmp; /*overflow checked*/ @@ -374,27 +372,28 @@ H5V_hyper_eq(intn n, *------------------------------------------------------------------------- */ htri_t -H5V_hyper_disjointp(intn n, +H5V_hyper_disjointp(uintn n, const hssize_t *offset1, const hsize_t *size1, const hssize_t *offset2, const hsize_t *size2) { - intn i; + uintn u; if (!n || !size1 || !size2) return TRUE; - for (i=0; i<n; i++) { - assert (size1[i]<HSSIZET_MAX); - assert (size2[i]<HSSIZET_MAX); - - if (0==size1[i] || 0==size2[i]) return TRUE; - if (((offset1?offset1[i]:0) < (offset2?offset2[i]:0) && - ((offset1?offset1[i]:0) + (hssize_t)size1[i] <= - (offset2?offset2[i]:0))) || - ((offset2?offset2[i]:0) < (offset1?offset1[i]:0) && - ((offset2?offset2[i]:0) + (hssize_t)size2[i] <= - (offset1?offset1[i]:0)))) { - return TRUE; - } + for (u=0; u<n; u++) { + assert (size1[u]<HSSIZET_MAX); + assert (size2[u]<HSSIZET_MAX); + + if (0==size1[u] || 0==size2[u]) + return TRUE; + if (((offset1?offset1[u]:0) < (offset2?offset2[u]:0) && + ((offset1?offset1[u]:0) + (hssize_t)size1[u] <= + (offset2?offset2[u]:0))) || + ((offset2?offset2[u]:0) < (offset1?offset1[u]:0) && + ((offset2?offset2[u]:0) + (hssize_t)size2[u] <= + (offset1?offset1[u]:0)))) { + return TRUE; + } } return FALSE; } @@ -421,7 +420,7 @@ H5V_hyper_disjointp(intn n, *------------------------------------------------------------------------- */ herr_t -H5V_hyper_fill(intn n, const hsize_t *_size, +H5V_hyper_fill(uintn n, const hsize_t *_size, const hsize_t *total_size, const hssize_t *offset, void *_dst, uintn fill_value) { @@ -432,7 +431,7 @@ H5V_hyper_fill(intn n, const hsize_t *_size, hsize_t elmt_size = 1; /*bytes per element */ herr_t status; /*function return status */ #ifndef NDEBUG - int i; + uintn u; #endif FUNC_ENTER(H5V_hyper_fill, FAIL); @@ -443,9 +442,9 @@ H5V_hyper_fill(intn n, const hsize_t *_size, assert(total_size); assert(dst); #ifndef NDEBUG - for (i = 0; i < n; i++) { - assert(_size[i] > 0); - assert(total_size[i] > 0); + for (u = 0; u < n; u++) { + assert(_size[u] > 0); + assert(total_size[u] > 0); } #endif @@ -496,7 +495,7 @@ H5V_hyper_fill(intn n, const hsize_t *_size, *------------------------------------------------------------------------- */ herr_t -H5V_hyper_copy(intn n, const hsize_t *_size, +H5V_hyper_copy(uintn n, const hsize_t *_size, /*destination*/ const hsize_t *dst_size, const hssize_t *dst_offset, @@ -517,7 +516,7 @@ H5V_hyper_copy(intn n, const hsize_t *_size, hsize_t tmp2; herr_t status; /*return status */ #ifndef NDEBUG - intn i; + uintn u; #endif FUNC_ENTER(H5V_hyper_copy, FAIL); @@ -530,10 +529,10 @@ H5V_hyper_copy(intn n, const hsize_t *_size, assert(dst); assert(src); #ifndef NDEBUG - for (i = 0; i < n; i++) { - assert(_size[i] > 0); - assert(dst_size[i] > 0); - assert(src_size[i] > 0); + for (u = 0; u < n; u++) { + assert(_size[u] > 0); + assert(dst_size[u] > 0); + assert(src_size[u] > 0); } #endif @@ -549,7 +548,7 @@ H5V_hyper_copy(intn n, const hsize_t *_size, { hsize_t dst_acc; /*accumulator */ hsize_t src_acc; /*accumulator */ - int ii; /*counter */ + intn ii; /*counter */ /* init */ dst_stride[n-1] = 1; @@ -633,7 +632,7 @@ H5V_hyper_copy(intn n, const hsize_t *_size, default: /* others */ - for (ii=n-2, dst_acc=1, src_acc=1; ii>=0; --ii) { + for (ii=(intn)(n-2), dst_acc=1, src_acc=1; ii>=0; --ii) { hsize_t tmp1 = dst_acc * (dst_size[ii+1] - size[ii+1]); hsize_t tmp2 = src_acc * (src_size[ii+1] - size[ii+1]); assert (tmp1<((hsize_t)1<<(8*sizeof(hssize_t)-1))); @@ -655,8 +654,7 @@ H5V_hyper_copy(intn n, const hsize_t *_size, /* Perform the copy in terms of stride */ status = H5V_stride_copy(n, elmt_size, size, - dst_stride, dst+dst_start, - src_stride, src+src_start); + dst_stride, dst+dst_start, src_stride, src+src_start); FUNC_LEAVE(status); } @@ -677,7 +675,7 @@ H5V_hyper_copy(intn n, const hsize_t *_size, *------------------------------------------------------------------------- */ herr_t -H5V_stride_fill(intn n, hsize_t elmt_size, const hsize_t *size, +H5V_stride_fill(uintn n, hsize_t elmt_size, const hsize_t *size, const hssize_t *stride, void *_dst, uintn fill_value) { uint8_t *dst = (uint8_t*)_dst; /*cast for ptr arithmetic */ @@ -693,17 +691,18 @@ H5V_stride_fill(intn n, hsize_t elmt_size, const hsize_t *size, H5V_vector_cpy(n, idx, size); nelmts = H5V_vector_reduce_product(n, size); for (i=0; i<nelmts; i++) { - - /* Copy an element */ - HDmemset(dst, (signed)fill_value, (size_t)elmt_size); - - /* Decrement indices and advance pointer */ - for (j=n-1, carry=TRUE; j>=0 && carry; --j) { - dst += stride[j]; - - if (--idx[j]) carry = FALSE; - else idx[j] = size[j]; - } + /* Copy an element */ + HDmemset(dst, (signed)fill_value, (size_t)elmt_size); + + /* Decrement indices and advance pointer */ + for (j=(intn)(n-1), carry=TRUE; j>=0 && carry; --j) { + dst += stride[j]; + + if (--idx[j]) + carry = FALSE; + else + idx[j] = size[j]; + } } FUNC_LEAVE(SUCCEED); @@ -731,7 +730,7 @@ H5V_stride_fill(intn n, hsize_t elmt_size, const hsize_t *size, *------------------------------------------------------------------------- */ herr_t -H5V_stride_copy(int n, hsize_t elmt_size, const hsize_t *size, +H5V_stride_copy(uintn n, hsize_t elmt_size, const hsize_t *size, const hssize_t *dst_stride, void *_dst, const hssize_t *src_stride, const void *_src) { @@ -747,25 +746,28 @@ H5V_stride_copy(int n, hsize_t elmt_size, const hsize_t *size, assert (elmt_size<SIZET_MAX); if (n) { - H5V_vector_cpy(n, idx, size); - nelmts = H5V_vector_reduce_product(n, size); - for (i=0; i<nelmts; i++) { - - /* Copy an element */ - HDmemcpy(dst, src, (size_t)elmt_size); - - /* Decrement indices and advance pointers */ - for (j=n-1, carry=TRUE; j>=0 && carry; --j) { - src += src_stride[j]; - dst += dst_stride[j]; - - if (--idx[j]) carry = FALSE; - else idx[j] = size[j]; - } - } + H5V_vector_cpy(n, idx, size); + nelmts = H5V_vector_reduce_product(n, size); + for (i=0; i<nelmts; i++) { + + /* Copy an element */ + HDmemcpy(dst, src, (size_t)elmt_size); + + /* Decrement indices and advance pointers */ + for (j=(intn)(n-1), carry=TRUE; j>=0 && carry; --j) { + src += src_stride[j]; + dst += dst_stride[j]; + + if (--idx[j]) + carry = FALSE; + else + idx[j] = size[j]; + } + } } else { - HDmemcpy (dst, src, (size_t)elmt_size); - HRETURN (SUCCEED); + assert(elmt_size==(hsize_t)((size_t)elmt_size)); /*check for overflow*/ + HDmemcpy (dst, src, (size_t)elmt_size); + HRETURN (SUCCEED); } @@ -915,20 +917,20 @@ H5V_array_fill(void *_dst, const void *src, size_t size, size_t count) *------------------------------------------------------------------------- */ hsize_t -H5V_array_offset(intn n, const hsize_t *total_size, const hssize_t *offset) +H5V_array_offset(uintn n, const hsize_t *total_size, const hssize_t *offset) { hsize_t skip; /*starting point byte offset */ hsize_t acc; /*accumulator */ - int i; /*counter */ + intn i; /*counter */ FUNC_ENTER(H5V_array_stride, (HDabort(), 0)); - assert(n >= 0 && n <= H5V_HYPER_NDIMS); + assert(n <= H5V_HYPER_NDIMS); assert(total_size); assert(offset); /* others */ - for (i=n-1, acc=1, skip=0; i>=0; --i) { + for (i=(intn)(n-1), acc=1, skip=0; i>=0; --i) { skip += acc * offset[i]; acc *= total_size[i]; } |