diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/H5V.c | 293 | ||||
-rw-r--r-- | src/H5Vprivate.h | 10 | ||||
-rwxr-xr-x | src/hdf5.lnt | 1 |
3 files changed, 167 insertions, 137 deletions
@@ -26,10 +26,27 @@ #include "H5Oprivate.h" #include "H5Vprivate.h" -#define H5V_HYPER_NDIMS H5O_LAYOUT_NDIMS +/* Interface initialization */ static int interface_initialize_g = 0; #define INTERFACE_INIT NULL +/* Local macros */ +#define H5V_HYPER_NDIMS H5O_LAYOUT_NDIMS + +/* Local prototypes */ +static void +H5V_stride_optimize1(unsigned *np/*in,out*/, hsize_t *elmt_size/*in,out*/, + const hsize_t *size, hssize_t *stride1); +static void +H5V_stride_optimize2(unsigned *np/*in,out*/, hsize_t *elmt_size/*in,out*/, + const hsize_t *size, hssize_t *stride1, hssize_t *stride2); +#ifdef LATER +static void +H5V_stride_copy2(hsize_t nelmts, hsize_t elmt_size, + unsigned dst_n, const hsize_t *dst_size, const hssize_t *dst_stride, void *_dst, + unsigned src_n, const hsize_t *src_size, const hssize_t *src_stride, const void *_src); +#endif /* LATER */ + /*------------------------------------------------------------------------- * Function: H5V_stride_optimize1 @@ -42,7 +59,7 @@ static int interface_initialize_g = 0; * All arguments are passed by reference and their values may be * modified by this function. * - * Return: Non-negative on success/Negative on failure + * Return: None * * Programmer: Robb Matzke * Saturday, October 11, 1997 @@ -51,13 +68,11 @@ static int interface_initialize_g = 0; * *------------------------------------------------------------------------- */ -herr_t +static void H5V_stride_optimize1(unsigned *np/*in,out*/, hsize_t *elmt_size/*in,out*/, - hsize_t *size, hssize_t *stride1) + const hsize_t *size, hssize_t *stride1) { - herr_t ret_value=SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(H5V_stride_optimize1, FAIL); + FUNC_ENTER_NOINIT(H5V_stride_optimize1); /* * This has to be true because if we optimize the dimensionality down to @@ -72,12 +87,12 @@ H5V_stride_optimize1(unsigned *np/*in,out*/, hsize_t *elmt_size/*in,out*/, (hsize_t)(stride1[*np-1])==*elmt_size) { *elmt_size *= size[*np-1]; if (--*np) { - stride1[*np-1] += size[*np] * stride1[*np]; + H5_CHECK_OVERFLOW(size[*np],hsize_t,hssize_t); + stride1[*np-1] += (hssize_t)size[*np] * stride1[*np]; } } -done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI_VOID } @@ -104,13 +119,11 @@ done: * *------------------------------------------------------------------------- */ -herr_t +static void H5V_stride_optimize2(unsigned *np/*in,out*/, hsize_t *elmt_size/*in,out*/, - hsize_t *size, hssize_t *stride1, hssize_t *stride2) + const hsize_t *size, hssize_t *stride1, hssize_t *stride2) { - herr_t ret_value=SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(H5V_stride_optimize2, FAIL); + FUNC_ENTER_NOINIT(H5V_stride_optimize2) /* * This has to be true because if we optimize the dimensionality down to @@ -138,8 +151,9 @@ H5V_stride_optimize2(unsigned *np/*in,out*/, hsize_t *elmt_size/*in,out*/, (hsize_t)(stride2[1]) == *elmt_size) { *elmt_size *= size[1]; --*np; /* *np decrements to a value of 1 now */ - stride1[0] += size[1] * stride1[1]; - stride2[0] += size[1] * stride2[1]; + H5_CHECK_OVERFLOW(size[1],hsize_t,hssize_t); + stride1[0] += (hssize_t)size[1] * stride1[1]; + stride2[0] += (hssize_t)size[1] * stride2[1]; if((hsize_t)(stride1[0]) == *elmt_size && (hsize_t)(stride2[0]) == *elmt_size) { @@ -154,15 +168,17 @@ H5V_stride_optimize2(unsigned *np/*in,out*/, hsize_t *elmt_size/*in,out*/, (hsize_t)(stride2[2]) == *elmt_size) { *elmt_size *= size[2]; --*np; /* *np decrements to a value of 2 now */ - stride1[1] += size[2] * stride1[2]; - stride2[1] += size[2] * stride2[2]; + H5_CHECK_OVERFLOW(size[2],hsize_t,hssize_t); + stride1[1] += (hssize_t)size[2] * stride1[2]; + stride2[1] += (hssize_t)size[2] * stride2[2]; if((hsize_t)(stride1[1]) == *elmt_size && (hsize_t)(stride2[1]) == *elmt_size) { *elmt_size *= size[1]; --*np; /* *np decrements to a value of 1 now */ - stride1[0] += size[1] * stride1[1]; - stride2[0] += size[1] * stride2[1]; + H5_CHECK_OVERFLOW(size[1],hsize_t,hssize_t); + stride1[0] += (hssize_t)size[1] * stride1[1]; + stride2[0] += (hssize_t)size[1] * stride2[1]; if((hsize_t)(stride1[0]) == *elmt_size && (hsize_t)(stride2[0]) == *elmt_size) { @@ -178,22 +194,25 @@ H5V_stride_optimize2(unsigned *np/*in,out*/, hsize_t *elmt_size/*in,out*/, (hsize_t)(stride2[3]) == *elmt_size) { *elmt_size *= size[3]; --*np; /* *np decrements to a value of 3 now */ - stride1[2] += size[3] * stride1[3]; - stride2[2] += size[3] * stride2[3]; + H5_CHECK_OVERFLOW(size[3],hsize_t,hssize_t); + stride1[2] += (hssize_t)size[3] * stride1[3]; + stride2[2] += (hssize_t)size[3] * stride2[3]; if((hsize_t)(stride1[2]) == *elmt_size && (hsize_t)(stride2[2]) == *elmt_size) { *elmt_size *= size[2]; --*np; /* *np decrements to a value of 2 now */ - stride1[1] += size[2] * stride1[2]; - stride2[1] += size[2] * stride2[2]; + H5_CHECK_OVERFLOW(size[2],hsize_t,hssize_t); + stride1[1] += (hssize_t)size[2] * stride1[2]; + stride2[1] += (hssize_t)size[2] * stride2[2]; if((hsize_t)(stride1[1]) == *elmt_size && (hsize_t)(stride2[1]) == *elmt_size) { *elmt_size *= size[1]; --*np; /* *np decrements to a value of 1 now */ - stride1[0] += size[1] * stride1[1]; - stride2[0] += size[1] * stride2[1]; + H5_CHECK_OVERFLOW(size[1],hsize_t,hssize_t); + stride1[0] += (hssize_t)size[1] * stride1[1]; + stride2[0] += (hssize_t)size[1] * stride2[1]; if((hsize_t)(stride1[0]) == *elmt_size && (hsize_t)(stride2[0]) == *elmt_size) { @@ -211,15 +230,15 @@ H5V_stride_optimize2(unsigned *np/*in,out*/, hsize_t *elmt_size/*in,out*/, (hsize_t)(stride2[*np-1]) == *elmt_size) { *elmt_size *= size[*np-1]; if (--*np) { - stride1[*np-1] += size[*np] * stride1[*np]; - stride2[*np-1] += size[*np] * stride2[*np]; + H5_CHECK_OVERFLOW(size[*np],hsize_t,hssize_t); + stride1[*np-1] += (hssize_t)size[*np] * stride1[*np]; + stride2[*np-1] += (hssize_t)size[*np] * stride2[*np]; } } break; } /* end switch */ -done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI_VOID } @@ -266,7 +285,7 @@ H5V_hyper_stride(unsigned n, const hsize_t *size, int i; /*counter */ hsize_t ret_value; /* Return value */ - FUNC_ENTER_NOAPI(H5V_hyper_stride, (HDabort(), 0)); + FUNC_ENTER_NOAPI(H5V_hyper_stride, (HDabort(), 0)) /*lint !e527 Don't worry about unreachable statement */ assert(n <= H5V_HYPER_NDIMS); assert(size); @@ -274,8 +293,9 @@ H5V_hyper_stride(unsigned n, const hsize_t *size, assert(stride); /* init */ + assert(n>0); stride[n-1] = 1; - skip = offset ? offset[n-1] : 0; + skip = offset ? (hsize_t)offset[n-1] : 0; switch(n) { case 2: /* 1-D dataset */ @@ -283,7 +303,7 @@ H5V_hyper_stride(unsigned n, const hsize_t *size, assert (tmp<((hsize_t)1<<(8*sizeof(hssize_t)-1))); stride[0] = (hssize_t)tmp; /*overflow checked*/ acc = total_size[1]; - skip += acc * (offset ? offset[0] : 0); + skip += acc * (offset ? (hsize_t)offset[0] : 0); break; case 3: /* 2-D dataset */ @@ -291,13 +311,13 @@ H5V_hyper_stride(unsigned n, const hsize_t *size, assert (tmp<((hsize_t)1<<(8*sizeof(hssize_t)-1))); stride[1] = (hssize_t)tmp; /*overflow checked*/ acc = total_size[2]; - skip += acc * (offset ? offset[1] : 0); + skip += acc * (offset ? (hsize_t)offset[1] : 0); tmp = acc * (total_size[1] - size[1]); assert (tmp<((hsize_t)1<<(8*sizeof(hssize_t)-1))); stride[0] = (hssize_t)tmp; /*overflow checked*/ acc *= total_size[1]; - skip += acc * (offset ? offset[0] : 0); + skip += acc * (offset ? (hsize_t)offset[0] : 0); break; case 4: /* 3-D dataset */ @@ -305,19 +325,19 @@ H5V_hyper_stride(unsigned n, const hsize_t *size, assert (tmp<((hsize_t)1<<(8*sizeof(hssize_t)-1))); stride[2] = (hssize_t)tmp; /*overflow checked*/ acc = total_size[3]; - skip += acc * (offset ? offset[2] : 0); + skip += acc * (offset ? (hsize_t)offset[2] : 0); tmp = acc * (total_size[2] - size[2]); assert (tmp<((hsize_t)1<<(8*sizeof(hssize_t)-1))); stride[1] = (hssize_t)tmp; /*overflow checked*/ acc *= total_size[2]; - skip += acc * (offset ? offset[1] : 0); + skip += acc * (offset ? (hsize_t)offset[1] : 0); tmp = acc * (total_size[1] - size[1]); assert (tmp<((hsize_t)1<<(8*sizeof(hssize_t)-1))); stride[0] = (hssize_t)tmp; /*overflow checked*/ acc *= total_size[1]; - skip += acc * (offset ? offset[0] : 0); + skip += acc * (offset ? (hsize_t)offset[0] : 0); break; default: @@ -327,7 +347,7 @@ H5V_hyper_stride(unsigned n, const hsize_t *size, assert (tmp<((hsize_t)1<<(8*sizeof(hssize_t)-1))); stride[i] = (hssize_t)tmp; /*overflow checked*/ acc *= total_size[i+1]; - skip += acc * (offset ? offset[i] : 0); + skip += acc * (offset ? (hsize_t)offset[i] : 0); } break; } /* end switch */ @@ -336,7 +356,7 @@ H5V_hyper_stride(unsigned n, const hsize_t *size, ret_value=skip; done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } @@ -373,23 +393,23 @@ H5V_hyper_eq(int n, htri_t ret_value=TRUE; /* Return value */ /* Use FUNC_ENTER_NOINIT here to avoid performance issues */ - FUNC_ENTER_NOINIT(H5V_hyper_eq); + FUNC_ENTER_NOINIT(H5V_hyper_eq) - if (n <= 0) HGOTO_DONE(TRUE); + if (n <= 0) HGOTO_DONE(TRUE) for (i=0; i<n; i++) { - if ((offset1 ? offset1[i] : 0) != (offset2 ? offset2[i] : 0)) { - HGOTO_DONE(FALSE); - } - if ((size1 ? size1[i] : 0) != (size2 ? size2[i] : 0)) { - HGOTO_DONE(FALSE); - } - if (0 == (nelmts1 *= (size1 ? size1[i] : 0))) HGOTO_DONE(FALSE); - if (0 == (nelmts2 *= (size2 ? size2[i] : 0))) HGOTO_DONE(FALSE); + if ((offset1 ? offset1[i] : 0) != (offset2 ? offset2[i] : 0)) + HGOTO_DONE(FALSE) + if ((size1 ? size1[i] : 0) != (size2 ? size2[i] : 0)) + HGOTO_DONE(FALSE) + if (0 == (nelmts1 *= (size1 ? size1[i] : 0))) + HGOTO_DONE(FALSE) + if (0 == (nelmts2 *= (size2 ? size2[i] : 0))) + HGOTO_DONE(FALSE) } done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } @@ -420,28 +440,27 @@ H5V_hyper_disjointp(unsigned n, htri_t ret_value=FALSE; /* Return value */ /* Use FUNC_ENTER_NOINIT here to avoid performance issues */ - FUNC_ENTER_NOINIT(H5V_hyper_disjointp); + FUNC_ENTER_NOINIT(H5V_hyper_disjointp) - if (!n || !size1 || !size2) HGOTO_DONE(TRUE); + if (!n || !size1 || !size2) HGOTO_DONE(TRUE) for (u=0; u<n; u++) { assert (size1[u]<HSSIZET_MAX); assert (size2[u]<HSSIZET_MAX); if (0==size1[u] || 0==size2[u]) - HGOTO_DONE(TRUE); + HGOTO_DONE(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)))) { - HGOTO_DONE(TRUE); - } + (offset1?offset1[u]:0)))) + HGOTO_DONE(TRUE) } done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } @@ -481,7 +500,7 @@ H5V_hyper_fill(unsigned n, const hsize_t *_size, unsigned u; #endif - FUNC_ENTER_NOAPI(H5V_hyper_fill, FAIL); + FUNC_ENTER_NOAPI(H5V_hyper_fill, FAIL) /* check args */ assert(n > 0 && n <= H5V_HYPER_NDIMS); @@ -507,7 +526,7 @@ H5V_hyper_fill(unsigned n, const hsize_t *_size, fill_value); done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } @@ -570,7 +589,7 @@ H5V_hyper_copy(unsigned n, const hsize_t *_size, unsigned u; #endif - FUNC_ENTER_NOAPI(H5V_hyper_copy, FAIL); + FUNC_ENTER_NOAPI(H5V_hyper_copy, FAIL) /* check args */ assert(n > 0 && n <= H5V_HYPER_NDIMS); @@ -602,10 +621,11 @@ H5V_hyper_copy(unsigned n, const hsize_t *_size, int ii; /*counter */ /* init */ + assert(n>0); dst_stride[n-1] = 1; src_stride[n-1] = 1; - dst_start = dst_offset ? dst_offset[n-1] : 0; - src_start = src_offset ? src_offset[n-1] : 0; + dst_start = dst_offset ? (hsize_t)dst_offset[n-1] : 0; + src_start = src_offset ? (hsize_t)src_offset[n-1] : 0; /* Unroll loop for common cases */ switch(n) { @@ -618,8 +638,8 @@ H5V_hyper_copy(unsigned n, const hsize_t *_size, src_stride[0] = (hssize_t)tmp2; /*overflow checked*/ dst_acc = dst_size[1]; src_acc = src_size[1]; - dst_start += dst_acc * (dst_offset ? dst_offset[0] : 0); - src_start += src_acc * (src_offset ? src_offset[0] : 0); + dst_start += dst_acc * (dst_offset ? (hsize_t)dst_offset[0] : 0); + src_start += src_acc * (src_offset ? (hsize_t)src_offset[0] : 0); break; case 3: @@ -631,8 +651,8 @@ H5V_hyper_copy(unsigned n, const hsize_t *_size, src_stride[1] = (hssize_t)tmp2; /*overflow checked*/ dst_acc = dst_size[2]; src_acc = src_size[2]; - dst_start += dst_acc * (dst_offset ? dst_offset[1] : 0); - src_start += src_acc * (src_offset ? src_offset[1] : 0); + dst_start += dst_acc * (dst_offset ? (hsize_t)dst_offset[1] : 0); + src_start += src_acc * (src_offset ? (hsize_t)src_offset[1] : 0); tmp1 = dst_acc * (dst_size[1] - size[1]); tmp2 = src_acc * (src_size[1] - size[1]); @@ -642,8 +662,8 @@ H5V_hyper_copy(unsigned n, const hsize_t *_size, src_stride[0] = (hssize_t)tmp2; /*overflow checked*/ dst_acc *= dst_size[1]; src_acc *= src_size[1]; - dst_start += dst_acc * (dst_offset ? dst_offset[0] : 0); - src_start += src_acc * (src_offset ? src_offset[0] : 0); + dst_start += dst_acc * (dst_offset ? (hsize_t)dst_offset[0] : 0); + src_start += src_acc * (src_offset ? (hsize_t)src_offset[0] : 0); break; case 4: @@ -655,8 +675,8 @@ H5V_hyper_copy(unsigned n, const hsize_t *_size, src_stride[2] = (hssize_t)tmp2; /*overflow checked*/ dst_acc = dst_size[3]; src_acc = src_size[3]; - dst_start += dst_acc * (dst_offset ? dst_offset[2] : 0); - src_start += src_acc * (src_offset ? src_offset[2] : 0); + dst_start += dst_acc * (dst_offset ? (hsize_t)dst_offset[2] : 0); + src_start += src_acc * (src_offset ? (hsize_t)src_offset[2] : 0); tmp1 = dst_acc * (dst_size[2] - size[2]); tmp2 = src_acc * (src_size[2] - size[2]); @@ -666,8 +686,8 @@ H5V_hyper_copy(unsigned n, const hsize_t *_size, src_stride[1] = (hssize_t)tmp2; /*overflow checked*/ dst_acc *= dst_size[2]; src_acc *= src_size[2]; - dst_start += dst_acc * (dst_offset ? dst_offset[1] : 0); - src_start += src_acc * (src_offset ? src_offset[1] : 0); + dst_start += dst_acc * (dst_offset ? (hsize_t)dst_offset[1] : 0); + src_start += src_acc * (src_offset ? (hsize_t)src_offset[1] : 0); tmp1 = dst_acc * (dst_size[1] - size[1]); tmp2 = src_acc * (src_size[1] - size[1]); @@ -677,8 +697,8 @@ H5V_hyper_copy(unsigned n, const hsize_t *_size, src_stride[0] = (hssize_t)tmp2; /*overflow checked*/ dst_acc *= dst_size[1]; src_acc *= src_size[1]; - dst_start += dst_acc * (dst_offset ? dst_offset[0] : 0); - src_start += src_acc * (src_offset ? src_offset[0] : 0); + dst_start += dst_acc * (dst_offset ? (hsize_t)dst_offset[0] : 0); + src_start += src_acc * (src_offset ? (hsize_t)src_offset[0] : 0); break; default: @@ -692,8 +712,8 @@ H5V_hyper_copy(unsigned n, const hsize_t *_size, src_stride[ii] = (hssize_t)tmp2; /*overflow checked*/ dst_acc *= dst_size[ii+1]; src_acc *= src_size[ii+1]; - dst_start += dst_acc * (dst_offset ? dst_offset[ii] : 0); - src_start += src_acc * (src_offset ? src_offset[ii] : 0); + dst_start += dst_acc * (dst_offset ? (hsize_t)dst_offset[ii] : 0); + src_start += src_acc * (src_offset ? (hsize_t)src_offset[ii] : 0); } break; } /* end switch */ @@ -708,7 +728,7 @@ H5V_hyper_copy(unsigned n, const hsize_t *_size, dst_stride, dst+dst_start, src_stride, src+src_start); done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } @@ -739,14 +759,15 @@ H5V_stride_fill(unsigned n, hsize_t elmt_size, const hsize_t *size, hbool_t carry; /*subtraction carray value */ herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5V_stride_fill, FAIL); + FUNC_ENTER_NOAPI(H5V_stride_fill, FAIL) assert (elmt_size < SIZET_MAX); 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); + H5_CHECK_OVERFLOW(elmt_size,hsize_t,size_t); + HDmemset(dst, (int)fill_value, (size_t)elmt_size); /*lint !e671 The elmt_size will be OK */ /* Decrement indices and advance pointer */ for (j=(int)(n-1), carry=TRUE; j>=0 && carry; --j) { @@ -754,13 +775,15 @@ H5V_stride_fill(unsigned n, hsize_t elmt_size, const hsize_t *size, if (--idx[j]) carry = FALSE; - else + else { + assert(size); idx[j] = size[j]; + } /* end else */ } } done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } @@ -799,7 +822,7 @@ H5V_stride_copy(unsigned n, hsize_t elmt_size, const hsize_t *size, hbool_t carry; /*carray for subtraction*/ herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5V_stride_copy, FAIL); + FUNC_ENTER_NOAPI(H5V_stride_copy, FAIL) assert (elmt_size<SIZET_MAX); if (n) { @@ -809,7 +832,7 @@ H5V_stride_copy(unsigned n, hsize_t elmt_size, const hsize_t *size, /* Copy an element */ H5_CHECK_OVERFLOW(elmt_size,hsize_t,size_t); - HDmemcpy(dst, src, (size_t)elmt_size); + HDmemcpy(dst, src, (size_t)elmt_size); /*lint !e671 The elmt_size will be OK */ /* Decrement indices and advance pointers */ for (j=(int)(n-1), carry=TRUE; j>=0 && carry; --j) { @@ -818,18 +841,22 @@ H5V_stride_copy(unsigned n, hsize_t elmt_size, const hsize_t *size, if (--idx[j]) carry = FALSE; - else + else { + assert(size); idx[j] = size[j]; + } } } } else { H5_CHECK_OVERFLOW(elmt_size,hsize_t,size_t); - HDmemcpy (dst, src, (size_t)elmt_size); + HDmemcpy (dst, src, (size_t)elmt_size); /*lint !e671 The elmt_size will be OK */ } done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } + +#ifdef LATER /*------------------------------------------------------------------------- * Function: H5V_stride_copy2 @@ -839,7 +866,7 @@ done: * we copy exactly NELMTS elements each of size ELMT_SIZE. The * size counters wrap if NELMTS is more than a size counter. * - * Return: Non-negative on success/Negative on failure + * Return: None * * Programmer: Robb Matzke * Saturday, October 11, 1997 @@ -848,16 +875,16 @@ done: * *------------------------------------------------------------------------- */ -herr_t +static void H5V_stride_copy2(hsize_t nelmts, hsize_t elmt_size, /* destination */ - int dst_n, const hsize_t *dst_size, + unsigned dst_n, const hsize_t *dst_size, const hssize_t *dst_stride, void *_dst, /* source */ - int src_n, const hsize_t *src_size, + unsigned src_n, const hsize_t *src_size, const hssize_t *src_stride, const void *_src) { @@ -865,14 +892,15 @@ H5V_stride_copy2(hsize_t nelmts, hsize_t elmt_size, const uint8_t *src = (const uint8_t *) _src; hsize_t dst_idx[H5V_HYPER_NDIMS]; hsize_t src_idx[H5V_HYPER_NDIMS]; - hsize_t i; - int j; + hsize_t i; /* Local index variable */ + int j; /* Local index variable */ hbool_t carry; - herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5V_stride_copy2, FAIL); + FUNC_ENTER_NOINIT(H5V_stride_copy2) assert (elmt_size < SIZET_MAX); + assert(dst_n>0); + assert(src_n>0); H5V_vector_cpy(dst_n, dst_idx, dst_size); H5V_vector_cpy(src_n, src_idx, src_size); @@ -880,28 +908,34 @@ H5V_stride_copy2(hsize_t nelmts, hsize_t elmt_size, for (i=0; i<nelmts; i++) { /* Copy an element */ - HDmemcpy(dst, src, (size_t)elmt_size); + H5_CHECK_OVERFLOW(elmt_size,hsize_t,size_t); + HDmemcpy(dst, src, (size_t)elmt_size); /*lint !e671 The elmt_size will be OK */ /* Decrement indices and advance pointers */ - for (j=dst_n-1, carry=TRUE; j>=0 && carry; --j) { + for (j=(int)(dst_n-1), carry=TRUE; j>=0 && carry; --j) { dst += dst_stride[j]; if (--dst_idx[j]) carry = FALSE; - else + else { + assert(dst_size); dst_idx[j] = dst_size[j]; + } /* end else */ } - for (j=src_n-1, carry=TRUE; j>=0 && carry; --j) { + for (j=(int)(src_n-1), carry=TRUE; j>=0 && carry; --j) { src += src_stride[j]; if (--src_idx[j]) carry = FALSE; - else + else { + assert(src_size); src_idx[j] = src_size[j]; + } /* end else */ } } -done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI_VOID } +#endif /* LATER */ + /*------------------------------------------------------------------------- * Function: H5V_array_fill @@ -928,7 +962,7 @@ H5V_array_fill(void *_dst, const void *src, size_t size, size_t count) uint8_t *dst=(uint8_t*)_dst;/* alias for pointer arithmetic */ herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5V_array_fill, FAIL); + FUNC_ENTER_NOAPI(H5V_array_fill, FAIL) assert (dst); assert (src); @@ -957,7 +991,7 @@ H5V_array_fill(void *_dst, const void *src, size_t size, size_t count) HDmemcpy(dst, _dst, items_left * size); done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* H5V_array_fill() */ @@ -985,7 +1019,7 @@ H5V_array_down(unsigned n, const hsize_t *total_size, hsize_t *down) int i; /*counter */ herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5V_array_down, FAIL); + FUNC_ENTER_NOAPI(H5V_array_down, FAIL) assert(n <= H5V_HYPER_NDIMS); assert(total_size); @@ -993,13 +1027,13 @@ H5V_array_down(unsigned n, const hsize_t *total_size, hsize_t *down) /* Build the sizes of each dimension in the array */ /* (From fastest to slowest) */ - for(i=n-1,acc=1; i>=0; i--) { + for(i=(int)(n-1),acc=1; i>=0; i--) { down[i]=acc; acc *= total_size[i]; } /* end for */ done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5V_array_down() */ @@ -1033,7 +1067,7 @@ H5V_array_offset_pre(unsigned n, const hsize_t *total_size, const hsize_t *acc, int i; /*counter */ hsize_t ret_value; /* Return value */ - FUNC_ENTER_NOAPI(H5V_array_offset_pre, (HDabort(), 0)); + FUNC_ENTER_NOAPI(H5V_array_offset_pre, (HDabort(), 0)) /*lint !e527 Don't worry about unreachable statement */ assert(n <= H5V_HYPER_NDIMS); assert(total_size); @@ -1041,14 +1075,16 @@ H5V_array_offset_pre(unsigned n, const hsize_t *total_size, const hsize_t *acc, assert(offset); /* Compute offset in array */ - for (i=(int)(n-1), skip=0; i>=0; --i) - skip += acc[i] * offset[i]; + for (i=(int)(n-1), skip=0; i>=0; --i) { + H5_CHECK_OVERFLOW(offset[i],hssize_t,hsize_t); + skip += acc[i] * (hsize_t)offset[i]; + } /* end for */ /* Set return value */ ret_value=skip; done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5V_array_offset_pre() */ @@ -1078,7 +1114,7 @@ H5V_array_offset(unsigned n, const hsize_t *total_size, const hssize_t *offset) hsize_t acc_arr[H5V_HYPER_NDIMS]; /* Accumulated size of down dimensions */ hsize_t ret_value; /* Return value */ - FUNC_ENTER_NOAPI(H5V_array_offset, (HDabort(), 0)); + FUNC_ENTER_NOAPI(H5V_array_offset, (HDabort(), 0)) /*lint !e527 Don't worry about unreachable statement */ assert(n <= H5V_HYPER_NDIMS); assert(total_size); @@ -1086,13 +1122,13 @@ H5V_array_offset(unsigned n, const hsize_t *total_size, const hssize_t *offset) /* Build the sizes of each dimension in the array */ if(H5V_array_down(n,total_size,acc_arr)<0) - HGOTO_ERROR(H5E_INTERNAL, H5E_BADVALUE, UFAIL, "can't compute down sizes"); + HGOTO_ERROR(H5E_INTERNAL, H5E_BADVALUE, UFAIL, "can't compute down sizes") /* Set return value */ ret_value=H5V_array_offset_pre(n,total_size,acc_arr,offset); done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5V_array_offset() */ @@ -1125,7 +1161,7 @@ H5V_array_calc(hsize_t offset, unsigned n, const hsize_t *total_size, hssize_t * int i; /* Local index variable */ herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5V_array_calc, FAIL); + FUNC_ENTER_NOAPI(H5V_array_calc, FAIL) /* Sanity check */ assert(n <= H5V_HYPER_NDIMS); @@ -1134,19 +1170,20 @@ H5V_array_calc(hsize_t offset, unsigned n, const hsize_t *total_size, hssize_t * /* Build the sizes of each dimension in the array */ /* (From fastest to slowest) */ - for(i=n-1,acc=1; i>=0; i--) { + for(i=(int)(n-1),acc=1; i>=0; i--) { idx[i]=acc; acc *= total_size[i]; } /* end for */ /* Compute the coordinates from the offset */ for(u=0; u<n; u++) { - coords[u]=offset/idx[u]; + H5_CHECK_OVERFLOW(offset/idx[u],hsize_t,hssize_t); /*lint !e771 idx will always be initialized */ + coords[u]=(hssize_t)(offset/idx[u]); offset %= idx[u]; } /* end for */ done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5V_array_calc() */ @@ -1200,7 +1237,7 @@ H5V_chunk_index(unsigned ndims, const hssize_t *coord, const hsize_t *chunk, unsigned u; /* Local index variable */ herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5V_chunk_index, FAIL); + FUNC_ENTER_NOAPI(H5V_chunk_index, FAIL) /* Sanity check */ assert(ndims <= H5V_HYPER_NDIMS); @@ -1210,14 +1247,16 @@ H5V_chunk_index(unsigned ndims, const hssize_t *coord, const hsize_t *chunk, assert(chunk_idx); /* Compute the scaled coordinates for actual coordinates */ - for(u=0; u<ndims; u++) - scaled_coord[u]=coord[u]/chunk[u]; + for(u=0; u<ndims; u++) { + H5_CHECK_OVERFLOW(chunk[u],hsize_t,hssize_t); + scaled_coord[u]=coord[u]/(hssize_t)chunk[u]; + } /* end for */ /* Compute the chunk index */ - *chunk_idx=H5V_array_offset_pre(ndims,nchunks,down_nchunks,scaled_coord); + *chunk_idx=H5V_array_offset_pre(ndims,nchunks,down_nchunks,scaled_coord); /*lint !e772 scaled_coord will always be initialized */ done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5V_chunk_index() */ @@ -1255,7 +1294,7 @@ H5V_memcpyvv(void *_dst, size_t u,v; /* Local index variables */ ssize_t ret_value=0; /* Return value */ - FUNC_ENTER_NOAPI(H5V_memcpyvv, FAIL); + FUNC_ENTER_NOAPI(H5V_memcpyvv, FAIL) /* Sanity check */ assert(_dst); @@ -1299,7 +1338,7 @@ H5V_memcpyvv(void *_dst, u++; /* Increment number of bytes copied */ - ret_value+=size; + ret_value+=(ssize_t)size; } /* end for */ /* Update current sequence vectors */ @@ -1307,6 +1346,6 @@ H5V_memcpyvv(void *_dst, *src_curr_seq=v; done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5V_memcpyvv() */ diff --git a/src/H5Vprivate.h b/src/H5Vprivate.h index a9a5507..607087c 100644 --- a/src/H5Vprivate.h +++ b/src/H5Vprivate.h @@ -71,16 +71,6 @@ H5_DLL herr_t H5V_stride_fill(unsigned n, hsize_t elmt_size, const hsize_t *size H5_DLL herr_t H5V_stride_copy(unsigned n, hsize_t elmt_size, const hsize_t *_size, const hssize_t *dst_stride, void *_dst, const hssize_t *src_stride, const void *_src); -H5_DLL herr_t H5V_stride_copy2(hsize_t nelmts, hsize_t elmt_size, int dst_n, - const hsize_t *dst_size, - const hssize_t *dst_stride, void *_dst, - int src_n, const hsize_t *src_size, - const hssize_t *src_stride, const void *_src); -H5_DLL herr_t H5V_stride_optimize1(unsigned *np, hsize_t *elmt_size, - hsize_t *size, hssize_t *stride1); -H5_DLL herr_t H5V_stride_optimize2(unsigned *np, hsize_t *elmt_size, - hsize_t *size, hssize_t *stride1, - hssize_t *stride2); H5_DLL herr_t H5V_array_fill(void *_dst, const void *src, size_t size, size_t count); H5_DLL herr_t H5V_array_down(unsigned n, const hsize_t *total_size, diff --git a/src/hdf5.lnt b/src/hdf5.lnt index 7ed29f0..f31c0a4 100755 --- a/src/hdf5.lnt +++ b/src/hdf5.lnt @@ -75,6 +75,7 @@ H5D.c H5Dio.c + H5V.c H5Z.c H5Zdeflate.c H5Zfletcher32.c |