diff options
Diffstat (limited to 'src/H5Tconv.c')
-rw-r--r-- | src/H5Tconv.c | 698 |
1 files changed, 349 insertions, 349 deletions
diff --git a/src/H5Tconv.c b/src/H5Tconv.c index cda9011..be09488 100644 --- a/src/H5Tconv.c +++ b/src/H5Tconv.c @@ -175,237 +175,237 @@ * */ #define H5T_CONV_xX_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ - *((DT*)D) = (DT)(*((ST*)S)); \ + *(D) = (DT)(*(S)); \ } #define H5T_CONV_xX_NOEX_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ - *((DT*)D) = (DT)(*((ST*)S)); \ + *(D) = (DT)(*(S)); \ } -/* Added a condition branch(else if (*((ST*)S) == (DT)(D_MAX))) which seems redundant. +/* Added a condition branch(else if (*(S) == (DT)(D_MAX))) which seems redundant. * It handles a special situation when the source is "float" and assigned the value * of "INT_MAX". A compiler may do roundup making this value "INT_MAX+1". However, - * when do comparison "if (*((ST*)S) > (DT)(D_MAX))", the compiler may consider them + * when do comparison "if (*(S) > (DT)(D_MAX))", the compiler may consider them * equal. In this case, do not return exception but make sure the maximum is assigned * to the destination. SLU - 2005/06/29 */ #define H5T_CONV_Xx_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ - if (*((ST*)S) > (DT)(D_MAX)) { \ + if (*(S) > (DT)(D_MAX)) { \ H5T_conv_ret_t except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, \ src_id, dst_id, S, D, cb_struct.user_data); \ if(except_ret == H5T_CONV_UNHANDLED) \ /* Let compiler convert if case is ignored by user handler*/ \ - *((DT*)D) = (DT)(D_MAX); \ + *(D) = (DT)(D_MAX); \ else if(except_ret == H5T_CONV_ABORT) \ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ - } else if (*((ST*)S) < (DT)(D_MIN)) { \ + } else if (*(S) < (DT)(D_MIN)) { \ H5T_conv_ret_t except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_LOW, \ src_id, dst_id, S, D, cb_struct.user_data); \ if(except_ret == H5T_CONV_UNHANDLED) \ /* Let compiler convert if case is ignored by user handler*/ \ - *((DT*)D) = (DT)(D_MIN); \ + *(D) = (DT)(D_MIN); \ else if(except_ret == H5T_CONV_ABORT) \ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ } else \ - *((DT*)D) = (DT)(*((ST*)S)); \ + *(D) = (DT)(*(S)); \ } #define H5T_CONV_Xx_NOEX_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ - if (*((ST*)S) > (DT)(D_MAX)) { \ - *((DT*)D) = (DT)(D_MAX); \ - } else if (*((ST*)S) < (DT)(D_MIN)) { \ - *((DT*)D) = (DT)(D_MIN); \ + if (*(S) > (DT)(D_MAX)) { \ + *(D) = (DT)(D_MAX); \ + } else if (*(S) < (DT)(D_MIN)) { \ + *(D) = (DT)(D_MIN); \ } else \ - *((DT*)D) = (DT)(*((ST*)S)); \ + *(D) = (DT)(*(S)); \ } #define H5T_CONV_Ux_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ - if (*((ST*)S) > (DT)(D_MAX)) { \ + if (*(S) > (DT)(D_MAX)) { \ H5T_conv_ret_t except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, \ src_id, dst_id, S, D, cb_struct.user_data); \ if(except_ret == H5T_CONV_UNHANDLED) \ /* Let compiler convert if case is ignored by user handler*/ \ - *((DT*)D) = (DT)(D_MAX); \ + *(D) = (DT)(D_MAX); \ else if(except_ret == H5T_CONV_ABORT) \ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ } else \ - *((DT*)D) = (DT)(*((ST*)S)); \ + *(D) = (DT)(*(S)); \ } #define H5T_CONV_Ux_NOEX_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ - if (*((ST*)S) > (DT)(D_MAX)) { \ - *((DT*)D) = (DT)(D_MAX); \ + if (*(S) > (DT)(D_MAX)) { \ + *(D) = (DT)(D_MAX); \ } else \ - *((DT*)D) = (DT)(*((ST*)S)); \ + *(D) = (DT)(*(S)); \ } #define H5T_CONV_sS(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ - assert(sizeof(ST)<=sizeof(DT)); \ + HDcompile_assert(sizeof(ST)<=sizeof(DT)); \ H5T_CONV(H5T_CONV_xX, long long, STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ } #define H5T_CONV_sU_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ - if (*((ST*)S) < 0) { \ + if (*(S) < 0) { \ H5T_conv_ret_t except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_LOW, \ src_id, dst_id, S, D, cb_struct.user_data); \ if(except_ret == H5T_CONV_UNHANDLED) \ /* Let compiler convert if case is ignored by user handler*/ \ - *((DT*)D) = 0; \ + *(D) = 0; \ else if(except_ret == H5T_CONV_ABORT) \ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ } else \ - *((DT*)D) = (DT)(*((ST*)S)); \ + *(D) = (DT)(*(S)); \ } #define H5T_CONV_sU_NOEX_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ - if (*((ST*)S) < 0) { \ - *((DT*)D) = 0; \ - } else \ - *((DT*)D) = (DT)(*((ST*)S)); \ + if(*(S) < 0) \ + *(D) = 0; \ + else \ + *(D) = (DT)(*(S)); \ } #define H5T_CONV_sU(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ - assert(sizeof(ST)<=sizeof(DT)); \ + HDcompile_assert(sizeof(ST)<=sizeof(DT)); \ H5T_CONV(H5T_CONV_sU, long long, STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ } #define H5T_CONV_uS_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ - if (sizeof(ST)==sizeof(DT) && *((ST*)S) > (DT)(D_MAX)) { \ + if(sizeof(ST) == sizeof(DT) && *(S) > (DT)(D_MAX)) { \ H5T_conv_ret_t except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, \ src_id, dst_id, S, D, cb_struct.user_data); \ if(except_ret == H5T_CONV_UNHANDLED) \ /* Let compiler convert if case is ignored by user handler*/ \ - *((DT*)D) = (DT)(D_MAX); \ + *(D) = (DT)(D_MAX); \ else if(except_ret == H5T_CONV_ABORT) \ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ } else \ - *((DT*)D) = (DT)(*((ST*)S)); \ + *(D) = (DT)(*(S)); \ } #define H5T_CONV_uS_NOEX_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ - if (sizeof(ST)==sizeof(DT) && *((ST*)S) > (D_MAX)) { \ - *((DT*)D) = (D_MAX); \ + if (sizeof(ST)==sizeof(DT) && *(S) > (D_MAX)) { \ + *(D) = (D_MAX); \ } else \ - *((DT*)D) = (DT)(*((ST*)S)); \ + *(D) = (DT)(*(S)); \ } #define H5T_CONV_uS(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ - assert(sizeof(ST)<=sizeof(DT)); \ + HDcompile_assert(sizeof(ST)<=sizeof(DT)); \ H5T_CONV(H5T_CONV_uS, long long, STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ } #define H5T_CONV_uU(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ - assert(sizeof(ST)<=sizeof(DT)); \ + HDcompile_assert(sizeof(ST)<=sizeof(DT)); \ H5T_CONV(H5T_CONV_xX, long long, STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ } #define H5T_CONV_Ss(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ - assert(sizeof(ST)>=sizeof(DT)); \ + HDcompile_assert(sizeof(ST)>=sizeof(DT)); \ H5T_CONV(H5T_CONV_Xx, long long, STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ } #define H5T_CONV_Su_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ - if (*((ST*)S) < 0) { \ + if(*(S) < 0) { \ H5T_conv_ret_t except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_LOW, \ src_id, dst_id, S, D, cb_struct.user_data); \ if(except_ret == H5T_CONV_UNHANDLED) \ /* Let compiler convert if case is ignored by user handler*/ \ - *((DT*)D) = 0; \ + *(D) = 0; \ else if(except_ret == H5T_CONV_ABORT) \ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ - } else if (sizeof(ST)>sizeof(DT) && *((ST*)S) > (DT)(D_MAX)) { \ + } else if (sizeof(ST)>sizeof(DT) && *(S) > (DT)(D_MAX)) { \ H5T_conv_ret_t except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, \ src_id, dst_id, S, D, cb_struct.user_data); \ if(except_ret == H5T_CONV_UNHANDLED) \ /* Let compiler convert if case is ignored by user handler*/ \ - *((DT*)D) = (DT)(D_MAX); \ + *(D) = (DT)(D_MAX); \ else if(except_ret == H5T_CONV_ABORT) \ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ } else \ - *((DT*)D) = (DT)(*((ST*)S)); \ + *(D) = (DT)(*(S)); \ } #define H5T_CONV_Su_NOEX_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ - if (*((ST*)S) < 0) { \ - *((DT*)D) = 0; \ - } else if (sizeof(ST)>sizeof(DT) && *((ST*)S) > (DT)(D_MAX)) { \ - *((DT*)D) = (DT)(D_MAX); \ - } else \ - *((DT*)D) = (DT)(*((ST*)S)); \ + if(*(S) < 0) \ + *(D) = 0; \ + else if (sizeof(ST)>sizeof(DT) && *(S) > (DT)(D_MAX)) \ + *(D) = (DT)(D_MAX); \ + else \ + *(D) = (DT)(*(S)); \ } #define H5T_CONV_Su(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ - assert(sizeof(ST)>=sizeof(DT)); \ + HDcompile_assert(sizeof(ST)>=sizeof(DT)); \ H5T_CONV(H5T_CONV_Su, long long, STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ } #define H5T_CONV_Us(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ - assert(sizeof(ST)>=sizeof(DT)); \ + HDcompile_assert(sizeof(ST)>=sizeof(DT)); \ H5T_CONV(H5T_CONV_Ux, long long, STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ } #define H5T_CONV_Uu(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ - assert(sizeof(ST)>=sizeof(DT)); \ + HDcompile_assert(sizeof(ST)>=sizeof(DT)); \ H5T_CONV(H5T_CONV_Ux, long long, STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ } #define H5T_CONV_su_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ /* Assumes memory format of unsigned & signed integers is same */ \ - if (*((ST*)S) < 0) { \ + if(*(S) < 0) { \ H5T_conv_ret_t except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_LOW, \ src_id, dst_id, S, D, cb_struct.user_data); \ if(except_ret == H5T_CONV_UNHANDLED) \ /* Let compiler convert if case is ignored by user handler*/ \ - *((DT*)D) = 0; \ + *(D) = 0; \ else if(except_ret == H5T_CONV_ABORT) \ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ } else \ - *((DT*)D) = (DT)(*((ST*)S)); \ + *(D) = (DT)(*(S)); \ } #define H5T_CONV_su_NOEX_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ /* Assumes memory format of unsigned & signed integers is same */ \ - if (*((ST*)S) < 0) { \ - *((DT*)D) = 0; \ - } else \ - *((DT*)D) = (DT)(*((ST*)S)); \ + if(*(S) < 0) \ + *(D) = 0; \ + else \ + *(D) = (DT)(*(S)); \ } #define H5T_CONV_su(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ - assert(sizeof(ST)==sizeof(DT)); \ + HDcompile_assert(sizeof(ST)==sizeof(DT)); \ H5T_CONV(H5T_CONV_su, long long, STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ } #define H5T_CONV_us_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ /* Assumes memory format of unsigned & signed integers is same */ \ - if (*((ST*)S) > (DT)(D_MAX)) { \ + if (*(S) > (DT)(D_MAX)) { \ H5T_conv_ret_t except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, \ src_id, dst_id, S, D, cb_struct.user_data); \ if(except_ret == H5T_CONV_UNHANDLED) \ /* Let compiler convert if case is ignored by user handler*/ \ - *((DT*)D) = (DT)(D_MAX); \ + *(D) = (DT)(D_MAX); \ else if(except_ret == H5T_CONV_ABORT) \ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ } else \ - *((DT*)D) = (DT)(*((ST*)S)); \ + *(D) = (DT)(*(S)); \ } #define H5T_CONV_us_NOEX_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ /* Assumes memory format of unsigned & signed integers is same */ \ - if (*((ST*)S) > (DT)(D_MAX)) { \ - *((DT*)D) = (DT)(D_MAX); \ - } else \ - *((DT*)D) = (DT)(*((ST*)S)); \ + if(*(S) > (DT)(D_MAX)) \ + *(D) = (DT)(D_MAX); \ + else \ + *(D) = (DT)(*(S)); \ } #define H5T_CONV_us(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ - assert(sizeof(ST)==sizeof(DT)); \ + HDcompile_assert(sizeof(ST)==sizeof(DT)); \ H5T_CONV(H5T_CONV_us, long long, STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ } #define H5T_CONV_fF(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ - assert(sizeof(ST)<=sizeof(DT)); \ + HDcompile_assert(sizeof(ST)<=sizeof(DT)); \ H5T_CONV(H5T_CONV_xX, long double, STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ } @@ -413,38 +413,38 @@ * when an overflow occurs, use the 'float' infinity values. */ #define H5T_CONV_Ff_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ - if (*((ST*)S) > (DT)(D_MAX)) { \ + if(*(S) > (DT)(D_MAX)) { \ H5T_conv_ret_t except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, \ src_id, dst_id, S, D, cb_struct.user_data); \ if(except_ret == H5T_CONV_UNHANDLED) \ /* Let compiler convert if case is ignored by user handler*/ \ - *((DT*)D) = (H5T_NATIVE_FLOAT_POS_INF_g); \ + *(D) = (H5T_NATIVE_FLOAT_POS_INF_g); \ else if(except_ret == H5T_CONV_ABORT) \ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ - } else if (*((ST*)S) < (DT)(D_MIN)) { \ + } else if (*(S) < (DT)(D_MIN)) { \ H5T_conv_ret_t except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_LOW, \ src_id, dst_id, S, D, cb_struct.user_data); \ if(except_ret == H5T_CONV_UNHANDLED) \ /* Let compiler convert if case is ignored by user handler*/ \ - *((DT*)D) = (H5T_NATIVE_FLOAT_NEG_INF_g); \ + *(D) = (H5T_NATIVE_FLOAT_NEG_INF_g); \ else if(except_ret == H5T_CONV_ABORT) \ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ } else \ - *((DT*)D) = (DT)(*((ST*)S)); \ + *(D) = (DT)(*(S)); \ } #define H5T_CONV_Ff_NOEX_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ - if (*((ST*)S) > (DT)(D_MAX)) { \ - *((DT*)D) = (H5T_NATIVE_FLOAT_POS_INF_g); \ - } else if (*((ST*)S) < (DT)(D_MIN)) { \ - *((DT*)D) = (H5T_NATIVE_FLOAT_NEG_INF_g); \ - } else \ - *((DT*)D) = (DT)(*((ST*)S)); \ + if(*(S) > (DT)(D_MAX)) \ + *(D) = (H5T_NATIVE_FLOAT_POS_INF_g); \ + else if (*(S) < (DT)(D_MIN)) \ + *(D) = (H5T_NATIVE_FLOAT_NEG_INF_g); \ + else \ + *(D) = (DT)(*(S)); \ } #define H5T_CONV_Ff(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ - assert(sizeof(ST)>=sizeof(DT)); \ + HDcompile_assert(sizeof(ST)>=sizeof(DT)); \ H5T_CONV(H5T_CONV_Ff, long double, STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ } @@ -512,7 +512,7 @@ unsigned low_bit_pos, high_bit_pos; \ \ /* Detect high & low bits set in source */ \ - H5T_HI_LO_BIT_SET(ST, *((ST*)S), low_bit_pos, high_bit_pos) \ + H5T_HI_LO_BIT_SET(ST, *(S), low_bit_pos, high_bit_pos) \ \ /* Check for more bits of precision in src than available in dst */ \ if((high_bit_pos - low_bit_pos) >= dprec) { \ @@ -520,73 +520,72 @@ src_id, dst_id, S, D, cb_struct.user_data); \ if(except_ret == H5T_CONV_UNHANDLED) \ /* Let compiler convert if case is ignored by user handler*/ \ - *((DT*)D) = (DT)(*((ST*)S)); \ + *(D) = (DT)(*(S)); \ else if(except_ret == H5T_CONV_ABORT) \ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ } \ else \ - *((DT*)D) = (DT)(*((ST*)S)); \ + *(D) = (DT)(*(S)); \ } \ else \ - *((DT*)D) = (DT)(*((ST*)S)); \ + *(D) = (DT)(*(S)); \ } #define H5T_CONV_xF_NOEX_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ - *((DT*)D) = (DT)(*((ST*)S)); \ + *(D) = (DT)(*(S)); \ } #define H5T_CONV_xF(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ H5T_CONV(H5T_CONV_xF, long double, STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ } -/* Quincey added the condition branch (else if (*((ST*)S) != (ST)((DT)(*((ST*)S))))). +/* Quincey added the condition branch (else if (*(S) != (ST)((DT)(*(S))))). * It handles a special situation when the source is "float" and assigned the value * of "INT_MAX". Compilers do roundup making this value "INT_MAX+1". This branch * is to check that situation and return exception for some compilers, mainly GCC. - * The branch if (*((ST*)S) > (DT)(D_MAX) || (sprec < dprec && *((ST*)S) == + * The branch if (*(S) > (DT)(D_MAX) || (sprec < dprec && *(S) == * (DT)(D_MAX))) is for some compilers like Sun, HP, IBM, and SGI where under * the same situation the "int" doesn't overflow. SLU - 2005/9/12 */ #define H5T_CONV_Fx_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ - if (*((ST*)S) > (DT)(D_MAX) || (sprec < dprec && *((ST*)S) == (DT)(D_MAX))) { \ + if(*(S) > (DT)(D_MAX) || (sprec < dprec && *(S) == (DT)(D_MAX))) { \ H5T_conv_ret_t except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, \ src_id, dst_id, S, D, cb_struct.user_data); \ if(except_ret == H5T_CONV_UNHANDLED) \ /* Let compiler convert if case is ignored by user handler*/ \ - *((DT*)D) = (DT)(D_MAX); \ + *(D) = (DT)(D_MAX); \ else if(except_ret == H5T_CONV_ABORT) \ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ - } else if (*((ST*)S) < (DT)(D_MIN)) { \ + } else if (*(S) < (DT)(D_MIN)) { \ H5T_conv_ret_t except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_LOW, \ src_id, dst_id, S, D, cb_struct.user_data); \ if(except_ret == H5T_CONV_UNHANDLED) \ /* Let compiler convert if case is ignored by user handler*/ \ - *((DT*)D) = (DT)(D_MIN); \ + *(D) = (DT)(D_MIN); \ else if(except_ret == H5T_CONV_ABORT) \ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ - } else if (*((ST*)S) != (ST)((DT)(*((ST*)S)))) { \ + } else if (*(S) != (ST)((DT)(*(S)))) { \ H5T_conv_ret_t except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_TRUNCATE, \ src_id, dst_id, S, D, cb_struct.user_data); \ if(except_ret == H5T_CONV_UNHANDLED) \ /* Let compiler convert if case is ignored by user handler*/ \ - *((DT*)D) = (DT)(*((ST*)S)); \ + *(D) = (DT)(*(S)); \ else if(except_ret == H5T_CONV_ABORT) \ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ } \ else \ - *((DT*)D) = (DT)(*((ST*)S)); \ + *(D) = (DT)(*(S)); \ } #define H5T_CONV_Fx_NOEX_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ - if (*((ST*)S) > (DT)(D_MAX)) { \ - *((DT*)D) = (DT)(D_MAX); \ - } else if (*((ST*)S) < (DT)(D_MIN)) { \ - *((DT*)D) = (DT)(D_MIN); \ - } \ + if(*(S) > (DT)(D_MAX)) \ + *(D) = (DT)(D_MAX); \ + else if(*(S) < (DT)(D_MIN)) \ + *(D) = (DT)(D_MIN); \ else \ - *((DT*)D) = (DT)(*((ST*)S)); \ + *(D) = (DT)(*(S)); \ } #define H5T_CONV_Fx(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ @@ -598,7 +597,7 @@ * to do them all. */ #define H5T_CONV_NO_EXCEPT_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ - *((DT*)D) = (DT)(*((ST*)S)); \ + *(D) = (DT)(*(S)); \ } /* The main part of every integer hardware conversion macro */ @@ -606,11 +605,14 @@ size_t elmtno; /*element number */ \ size_t sprec; /*source precision */ \ size_t dprec; /*destination precision */ \ - uint8_t *src, *s; /*source buffer */ \ - uint8_t *dst, *d; /*destination buffer */ \ + uint8_t *src_buf; /*'raw' source buffer */ \ + uint8_t *dst_buf; /*'raw' destination buffer */ \ + ST *src, *s; /*source buffer */ \ + DT *dst, *d; /*destination buffer */ \ H5T_class_t tclass; /*datatype's class */ \ H5T_t *st, *dt; /*datatype descriptors */ \ - ATYPE aligned; /*aligned type */ \ + ST src_aligned; /*source aligned type */ \ + DT dst_aligned; /*destination aligned type */ \ hbool_t s_mv, d_mv; /*move data to align it? */ \ ssize_t s_stride, d_stride; /*src and dst strides */ \ size_t safe; /*how many elements are safe to process in each pass */ \ @@ -641,7 +643,6 @@ if (buf_stride) { \ assert(buf_stride>=sizeof(ST)); \ assert(buf_stride>=sizeof(DT)); \ - H5_CHECK_OVERFLOW(buf_stride,size_t,ssize_t); \ s_stride = d_stride = (ssize_t)buf_stride; \ } else { \ s_stride = sizeof(ST); \ @@ -700,32 +701,33 @@ /* If we're down to the last few elements, just wrap up */ \ /* with a "real" reverse copy */ \ if(safe<2) { \ - src = (uint8_t*)buf+(nelmts-1)*s_stride; \ - dst = (uint8_t*)buf+(nelmts-1)*d_stride; \ + src = (ST *)(src_buf = (uint8_t*)buf+(nelmts-1)*s_stride); \ + dst = (DT *)(dst_buf = (uint8_t*)buf+(nelmts-1)*d_stride); \ s_stride = -s_stride; \ d_stride = -d_stride; \ \ safe=nelmts; \ } /* end if */ \ else { \ - src = (uint8_t*)buf+(nelmts-safe)*s_stride; \ - dst = (uint8_t*)buf+(nelmts-safe)*d_stride; \ + src = (ST *)(src_buf = (uint8_t*)buf+(nelmts-safe)*s_stride); \ + dst = (DT *)(dst_buf = (uint8_t*)buf+(nelmts-safe)*d_stride); \ } /* end else */ \ } /* end if */ \ else { \ /* Single forward pass over all data */ \ - src = dst = (uint8_t*)buf; \ + src = (ST *)(src_buf = (uint8_t*)buf); \ + dst = (DT *)(dst_buf = (uint8_t*)buf); \ safe=nelmts; \ } /* end else */ \ \ /* Perform loop over elements to convert */ \ if (s_mv && d_mv) { \ /* Alignment is required for both source and dest */ \ - s = (uint8_t*)&aligned; \ + s = &src_aligned; \ H5T_CONV_LOOP_OUTER(PRE_SALIGN,PRE_DALIGN,POST_SALIGN,POST_DALIGN,GUTS,s,d,ST,DT,D_MIN,D_MAX) \ } else if(s_mv) { \ /* Alignment is required only for source */ \ - s = (uint8_t*)&aligned; \ + s = &src_aligned; \ H5T_CONV_LOOP_OUTER(PRE_SALIGN,PRE_DNOALIGN,POST_SALIGN,POST_DNOALIGN,GUTS,s,dst,ST,DT,D_MIN,D_MAX) \ } else if(d_mv) { \ /* Alignment is required only for destination */ \ @@ -748,7 +750,7 @@ /* Macro defining action on source data which needs to be aligned (before main action) */ #define H5T_CONV_LOOP_PRE_SALIGN(ST) { \ - HDmemcpy(&aligned, src, sizeof(ST)); \ + HDmemcpy(&src_aligned, src, sizeof(ST)); \ } /* Macro defining action on source data which doesn't need to be aligned (before main action) */ @@ -757,7 +759,7 @@ /* Macro defining action on destination data which needs to be aligned (before main action) */ #define H5T_CONV_LOOP_PRE_DALIGN(DT) { \ - d = (uint8_t*)&aligned; \ + d = &dst_aligned; \ } /* Macro defining action on destination data which doesn't need to be aligned (before main action) */ @@ -774,7 +776,7 @@ /* Macro defining action on destination data which needs to be aligned (after main action) */ #define H5T_CONV_LOOP_POST_DALIGN(DT) { \ - HDmemcpy(dst, &aligned, sizeof(DT)); \ + HDmemcpy(dst, &dst_aligned, sizeof(DT)); \ } /* Macro defining action on destination data which doesn't need to be aligned (after main action) */ @@ -809,8 +811,10 @@ H5_GLUE(H5T_CONV_LOOP_,POST_DALIGN_GUTS)(DT) \ \ /* Advance pointers */ \ - src += s_stride; \ - dst += d_stride; \ + src_buf += s_stride; \ + src = (ST *)src_buf; \ + dst_buf += d_stride; \ + dst = (DT *)dst_buf; \ } /* Macro to call the actual "guts" of the type conversion, or call the "no exception" guts */ @@ -1037,8 +1041,8 @@ H5T_conv_order_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, switch(cdata->command) { case H5T_CONV_INIT: /* Capability query */ - if(NULL == (src = H5I_object(src_id)) || - NULL == (dst = H5I_object(dst_id))) + if(NULL == (src = (H5T_t *)H5I_object(src_id)) || + NULL == (dst = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") if(src->shared->size != dst->shared->size || 0 != src->shared->u.atomic.offset || @@ -1081,8 +1085,8 @@ H5T_conv_order_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, case H5T_CONV_CONV: /* The conversion */ - if(NULL == (src = H5I_object(src_id)) || - NULL == (dst = H5I_object(dst_id))) + if(NULL == (src = (H5T_t *)H5I_object(src_id)) || + NULL == (dst = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") /* Check for "no op" reference conversion */ @@ -1446,8 +1450,8 @@ H5T_conv_order(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, switch(cdata->command) { case H5T_CONV_INIT: /* Capability query */ - if(NULL == (src = H5I_object(src_id)) || - NULL == (dst = H5I_object(dst_id))) + if(NULL == (src = (H5T_t *)H5I_object(src_id)) || + NULL == (dst = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") if(src->shared->size != dst->shared->size || 0 != src->shared->u.atomic.offset || 0 != dst->shared->u.atomic.offset || @@ -1483,8 +1487,8 @@ H5T_conv_order(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, case H5T_CONV_CONV: /* The conversion */ - if(NULL == (src = H5I_object(src_id)) || - NULL == (dst = H5I_object(dst_id))) + if(NULL == (src = (H5T_t *)H5I_object(src_id)) || + NULL == (dst = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") buf_stride = buf_stride ? buf_stride : src->shared->size; @@ -1552,8 +1556,8 @@ H5T_conv_b_b(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, switch(cdata->command) { case H5T_CONV_INIT: /* Capability query */ - if(NULL == (src = H5I_object(src_id)) || - NULL == (dst = H5I_object(dst_id))) + if(NULL == (src = (H5T_t *)H5I_object(src_id)) || + NULL == (dst = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") if(H5T_ORDER_LE != src->shared->u.atomic.order && H5T_ORDER_BE != src->shared->u.atomic.order) @@ -1569,8 +1573,8 @@ H5T_conv_b_b(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, case H5T_CONV_CONV: /* Get the data types */ - if(NULL == (src = H5I_object(src_id)) || - NULL == (dst = H5I_object(dst_id))) + if(NULL == (src = (H5T_t *)H5I_object(src_id)) || + NULL == (dst = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") /* @@ -1789,7 +1793,7 @@ H5T_conv_struct_free(H5T_conv_struct_t *priv) H5MM_xfree(src_memb_id); H5MM_xfree(dst_memb_id); H5MM_xfree(priv->memb_path); - FUNC_LEAVE_NOAPI(H5MM_xfree(priv)); + FUNC_LEAVE_NOAPI((H5T_conv_struct_t *)H5MM_xfree(priv)); } @@ -1861,10 +1865,10 @@ H5T_conv_struct_init(H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata, hid_t dxpl_id) /* * Allocate private data structure and arrays. */ - if(NULL == (priv = cdata->priv=H5MM_calloc(sizeof(H5T_conv_struct_t))) || - NULL == (priv->src2dst = H5MM_malloc(src_nmembs * sizeof(int))) || - NULL == (priv->src_memb_id = H5MM_malloc(src_nmembs * sizeof(hid_t))) || - NULL == (priv->dst_memb_id = H5MM_malloc(dst_nmembs * sizeof(hid_t)))) + if(NULL == (priv = (H5T_conv_struct_t *)(cdata->priv=H5MM_calloc(sizeof(H5T_conv_struct_t)))) || + NULL == (priv->src2dst = (int *)H5MM_malloc(src_nmembs * sizeof(int))) || + NULL == (priv->src_memb_id = (hid_t *)H5MM_malloc(src_nmembs * sizeof(hid_t))) || + NULL == (priv->dst_memb_id = (hid_t *)H5MM_malloc(dst_nmembs * sizeof(hid_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") src2dst = priv->src2dst; priv->src_nmembs = src_nmembs; @@ -1891,7 +1895,7 @@ H5T_conv_struct_init(H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata, hid_t dxpl_id) src2dst[i] = -1; for(j = 0; j < dst_nmembs; j++) { if(!HDstrcmp(src->shared->u.compnd.memb[i].name, dst->shared->u.compnd.memb[j].name)) { - src2dst[i] = j; + H5_ASSIGN_OVERFLOW(src2dst[i],j,unsigned,int); break; } /* end if */ } /* end for */ @@ -1921,7 +1925,7 @@ H5T_conv_struct_init(H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata, hid_t dxpl_id) */ src2dst = priv->src2dst; H5MM_xfree(priv->memb_path); - if(NULL == (priv->memb_path = H5MM_malloc(src->shared->u.compnd.nmembs * sizeof(H5T_path_t*)))) + if(NULL == (priv->memb_path = (H5T_path_t **)H5MM_malloc(src->shared->u.compnd.nmembs * sizeof(H5T_path_t*)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") for(i = 0; i < src_nmembs; i++) { @@ -1945,7 +1949,7 @@ H5T_conv_struct_init(H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata, hid_t dxpl_id) * order or there's conversion between members, don't do the * optimization. */ - if(src2dst[i] != i || (src->shared->u.compnd.memb[i].offset != dst->shared->u.compnd.memb[i].offset) || (priv->memb_path[i])->is_noop == FALSE) { + if(src2dst[i] != (int)i || (src->shared->u.compnd.memb[i].offset != dst->shared->u.compnd.memb[i].offset) || (priv->memb_path[i])->is_noop == FALSE) { priv->subset_info.subset = H5T_SUBSET_FALSE; break; } /* end if */ @@ -1962,7 +1966,7 @@ H5T_conv_struct_init(H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata, hid_t dxpl_id) for(i = 0; i < dst_nmembs; i++) { /* If any of source members doesn't have counterpart in the same order or * there's conversion between members, don't do the optimization. */ - if(src2dst[i] != i || (src->shared->u.compnd.memb[i].offset != dst->shared->u.compnd.memb[i].offset) || (priv->memb_path[i])->is_noop == FALSE) { + if(src2dst[i] != (int)i || (src->shared->u.compnd.memb[i].offset != dst->shared->u.compnd.memb[i].offset) || (priv->memb_path[i])->is_noop == FALSE) { priv->subset_info.subset = H5T_SUBSET_FALSE; break; } @@ -1976,7 +1980,7 @@ H5T_conv_struct_init(H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata, hid_t dxpl_id) + dst->shared->u.compnd.memb[dst_nmembs-1].size; } else /* If the numbers of source and dest members are equal and no conversion is needed, * the case should have been handled as noop earlier in H5Dio.c. */ - ; + {;} cdata->recalc = FALSE; @@ -2067,8 +2071,7 @@ H5T_conv_struct_subset(const H5T_cdata_t *cdata) */ herr_t H5T_conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, void *_buf, void *_bkg, - hid_t dxpl_id) + size_t buf_stride, size_t bkg_stride, void *_buf, void *_bkg, hid_t dxpl_id) { uint8_t *buf = (uint8_t *)_buf; /*cast for pointer arithmetic */ uint8_t *bkg = (uint8_t *)_bkg; /*background pointer arithmetic */ @@ -2096,8 +2099,8 @@ H5T_conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * otherwise initialize the `priv' field of `cdata' with information * that remains (almost) constant for this conversion path. */ - if (NULL == (src = H5I_object(src_id)) || - NULL == (dst = H5I_object(dst_id))) + if (NULL == (src = (H5T_t *)H5I_object(src_id)) || + NULL == (dst = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype"); assert (H5T_COMPOUND==src->shared->type); assert (H5T_COMPOUND==dst->shared->type); @@ -2117,8 +2120,8 @@ H5T_conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, /* * Conversion. */ - if (NULL == (src = H5I_object(src_id)) || - NULL == (dst = H5I_object(dst_id))) + if (NULL == (src = (H5T_t *)H5I_object(src_id)) || + NULL == (dst = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype"); assert (priv); assert (bkg && cdata->need_bkg); @@ -2138,17 +2141,19 @@ H5T_conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, */ if (buf_stride) { src_delta = buf_stride; - if (!bkg_stride) - bkg_stride = dst->shared->size; - } else if (dst->shared->size <= src->shared->size) { + if(!bkg_stride) + bkg_stride = dst->shared->size; + } /* end if */ + else if(dst->shared->size <= src->shared->size) { src_delta = src->shared->size; - bkg_stride = dst->shared->size; - } else { + bkg_stride = dst->shared->size; + } /* end else-if */ + else { src_delta = -(int)src->shared->size; /*overflow shouldn't be possible*/ bkg_stride = -(int)dst->shared->size; /*overflow shouldn't be possible*/ - xbuf += (nelmts-1) * src->shared->size; - xbkg += (nelmts-1) * dst->shared->size; - } + xbuf += (nelmts - 1) * src->shared->size; + xbkg += (nelmts - 1) * dst->shared->size; + } /* end else */ /* Conversion loop... */ for (elmtno=0; elmtno<nelmts; elmtno++) { @@ -2318,17 +2323,17 @@ H5T_conv_struct_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, uint8_t *xbkg = NULL; /*temporary pointer into `bkg' */ H5T_t *src = NULL; /*source datatype */ H5T_t *dst = NULL; /*destination datatype */ - int *src2dst = NULL; /*maps src member to dst member */ + int *src2dst = NULL; /*maps src member to dst member */ H5T_cmemb_t *src_memb = NULL; /*source struct member descript.*/ H5T_cmemb_t *dst_memb = NULL; /*destination struct memb desc. */ size_t offset; /*byte offset wrt struct */ size_t elmtno; /*element counter */ size_t copy_size; /*size of element for copying */ - unsigned u; /*counters */ - int i; /*counters */ H5T_conv_struct_t *priv = NULL; /*private data */ hbool_t no_stride = FALSE; /*flag to indicate no stride */ - herr_t ret_value=SUCCEED; /* Return value */ + unsigned u; /*counters */ + int i; /*counters */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_struct_opt, FAIL) @@ -2340,15 +2345,14 @@ H5T_conv_struct_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * otherwise initialize the `priv' field of `cdata' with information * that remains (almost) constant for this conversion path. */ - if (NULL == (src = H5I_object(src_id)) || - NULL == (dst = H5I_object(dst_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype"); - assert (H5T_COMPOUND==src->shared->type); - assert (H5T_COMPOUND==dst->shared->type); + if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") + HDassert(H5T_COMPOUND == src->shared->type); + HDassert(H5T_COMPOUND == dst->shared->type); /* Initialize data which is relatively constant */ - if (H5T_conv_struct_init (src, dst, cdata, dxpl_id)<0) - HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to initialize conversion data"); + if(H5T_conv_struct_init(src, dst, cdata, dxpl_id) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to initialize conversion data") priv = (H5T_conv_struct_t *)(cdata->priv); src2dst = priv->src2dst; @@ -2362,29 +2366,29 @@ H5T_conv_struct_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * of loops as in the actual conversion except it checks that there * is room for each conversion instead of actually doing anything. */ - if (dst->shared->size > src->shared->size) { - for (u=0, offset=0; u<src->shared->u.compnd.nmembs; u++) { - if (src2dst[u]<0) + if(dst->shared->size > src->shared->size) { + for(u = 0, offset = 0; u < src->shared->u.compnd.nmembs; u++) { + if(src2dst[u] < 0) continue; src_memb = src->shared->u.compnd.memb + u; dst_memb = dst->shared->u.compnd.memb + src2dst[u]; - if (dst_memb->size > src_memb->size) + if(dst_memb->size > src_memb->size) offset += src_memb->size; - } - for (i=src->shared->u.compnd.nmembs-1; i>=0; --i) { - if (src2dst[i]<0) + } /* end for */ + for(i = src->shared->u.compnd.nmembs - 1; i >= 0; --i) { + if(src2dst[i] < 0) continue; src_memb = src->shared->u.compnd.memb + i; dst_memb = dst->shared->u.compnd.memb + src2dst[i]; - if (dst_memb->size > src_memb->size) { + if(dst_memb->size > src_memb->size) { offset -= src_memb->size; - if (dst_memb->size > src->shared->size-offset) { + if(dst_memb->size > src->shared->size-offset) { cdata->priv = priv = H5T_conv_struct_free(priv); - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "convertion is unsupported by this function"); - } - } - } - } + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "convertion is unsupported by this function") + } /* end if */ + } /* end if */ + } /* end for */ + } /* end if */ break; case H5T_CONV_FREE: @@ -2399,17 +2403,16 @@ H5T_conv_struct_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, /* * Conversion. */ - if (NULL == (src = H5I_object(src_id)) || - NULL == (dst = H5I_object(dst_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype"); + if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* Update cached data if necessary */ - if (cdata->recalc && H5T_conv_struct_init (src, dst, cdata, dxpl_id)<0) - HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to initialize conversion data"); + if(cdata->recalc && H5T_conv_struct_init(src, dst, cdata, dxpl_id)<0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to initialize conversion data") priv = (H5T_conv_struct_t *)(cdata->priv); src2dst = priv->src2dst; - assert(priv); - assert(bkg && cdata->need_bkg); + HDassert(priv); + HDassert(bkg && cdata->need_bkg); /* * Insure that members are sorted. @@ -2427,27 +2430,30 @@ H5T_conv_struct_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * background data into the BKG buffer at multiples of BKG_STRIDE; * otherwise assume BKG buffer is the packed destination datatype. */ - if (!buf_stride || !bkg_stride) bkg_stride = dst->shared->size; - if (!buf_stride) { + if(!buf_stride || !bkg_stride) + bkg_stride = dst->shared->size; + if(!buf_stride) { no_stride = TRUE; buf_stride = src->shared->size; - } + } /* end if */ if(priv->subset_info.subset == H5T_SUBSET_SRC || priv->subset_info.subset == H5T_SUBSET_DST) { /* If the optimization flag is set to indicate source members are a subset and - * in the top of the destination, simply copy the source members to background buffer. */ + * in the top of the destination, simply copy the source members to background buffer. + */ xbuf = buf; xbkg = bkg; copy_size = priv->subset_info.copy_size; - for (elmtno=0; elmtno<nelmts; elmtno++) { + for(elmtno = 0; elmtno < nelmts; elmtno++) { HDmemmove(xbkg, xbuf, copy_size); /* Update pointers */ xbuf += buf_stride; xbkg += bkg_stride; - } - } else { + } /* end for */ + } /* end if */ + else { /* * For each member where the destination is not larger than the * source, stride through all the elements converting only that member @@ -2455,33 +2461,33 @@ H5T_conv_struct_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * destination in the bkg buffer. Otherwise move the element as far * left as possible in the buffer. */ - for (u=0, offset=0; u<src->shared->u.compnd.nmembs; u++) { - if (src2dst[u]<0) continue; /*subsetting*/ + for(u = 0, offset = 0; u < src->shared->u.compnd.nmembs; u++) { + if(src2dst[u] < 0) + continue; /*subsetting*/ src_memb = src->shared->u.compnd.memb + u; dst_memb = dst->shared->u.compnd.memb + src2dst[u]; - if (dst_memb->size <= src_memb->size) { + if(dst_memb->size <= src_memb->size) { xbuf = buf + src_memb->offset; xbkg = bkg + dst_memb->offset; - if (H5T_convert(priv->memb_path[u], - priv->src_memb_id[u], + if(H5T_convert(priv->memb_path[u], priv->src_memb_id[u], priv->dst_memb_id[src2dst[u]], nelmts, - buf_stride, bkg_stride, xbuf, xbkg, dxpl_id)<0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to convert compound datatype member"); - for (elmtno=0; elmtno<nelmts; elmtno++) { + buf_stride, bkg_stride, xbuf, xbkg, dxpl_id) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to convert compound datatype member") + for(elmtno = 0; elmtno < nelmts; elmtno++) { HDmemmove(xbkg, xbuf, dst_memb->size); xbuf += buf_stride; xbkg += bkg_stride; - } - } else { - for (xbuf=buf, elmtno=0; elmtno<nelmts; elmtno++) { - HDmemmove(xbuf+offset, xbuf+src_memb->offset, - src_memb->size); + } /* end for */ + } /* end if */ + else { + for(xbuf = buf, elmtno = 0; elmtno < nelmts; elmtno++) { + HDmemmove(xbuf + offset, xbuf + src_memb->offset, src_memb->size); xbuf += buf_stride; - } + } /* end for */ offset += src_memb->size; - } - } + } /* end else */ + } /* end else */ /* * Work from right to left, converting those members that weren't @@ -2489,51 +2495,48 @@ H5T_conv_struct_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * is larger than the source) and them to their final position in the * bkg buffer. */ - for (i=src->shared->u.compnd.nmembs-1; i>=0; --i) { - if (src2dst[i]<0) + for(i = src->shared->u.compnd.nmembs - 1; i >= 0; --i) { + if(src2dst[i] < 0) continue; src_memb = src->shared->u.compnd.memb + i; dst_memb = dst->shared->u.compnd.memb + src2dst[i]; - if (dst_memb->size > src_memb->size) { + if(dst_memb->size > src_memb->size) { offset -= src_memb->size; xbuf = buf + offset; xbkg = bkg + dst_memb->offset; - if (H5T_convert(priv->memb_path[i], - priv->src_memb_id[i], - priv->dst_memb_id[src2dst[i]], nelmts, - buf_stride, - bkg_stride, xbuf, xbkg, - dxpl_id)<0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to convert compound datatype member"); - for (elmtno=0; elmtno<nelmts; elmtno++) { + if(H5T_convert(priv->memb_path[i], priv->src_memb_id[i], + priv->dst_memb_id[src2dst[i]], nelmts, + buf_stride, bkg_stride, xbuf, xbkg, dxpl_id) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to convert compound datatype member") + for(elmtno = 0; elmtno < nelmts; elmtno++) { HDmemmove(xbkg, xbuf, dst_memb->size); xbuf += buf_stride; xbkg += bkg_stride; - } - } - } - } + } /* end for */ + } /* end if */ + } /* end for */ + } /* end else */ if(no_stride) buf_stride = dst->shared->size; /* Move background buffer into result buffer */ - for (xbuf=buf, xbkg=bkg, elmtno=0; elmtno<nelmts; elmtno++) { + for(xbuf = buf, xbkg = bkg, elmtno = 0; elmtno < nelmts; elmtno++) { HDmemmove(xbuf, xbkg, dst->shared->size); xbuf += buf_stride; xbkg += bkg_stride; - } + } /* end for */ break; default: /* Some other command we don't know about yet.*/ - HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown conversion command"); - } + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown conversion command") + } /* end switch */ done: FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5T_conv_struct_opt() */ /*------------------------------------------------------------------------- @@ -2566,7 +2569,7 @@ H5T_conv_enum_init(H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata) FUNC_ENTER_NOAPI_NOINIT(H5T_conv_enum_init) cdata->need_bkg = H5T_BKG_NO; - if (NULL==(priv=cdata->priv=H5MM_calloc(sizeof(*priv)))) + if (NULL==(priv=(H5T_enum_struct_t *)(cdata->priv=H5MM_calloc(sizeof(*priv))))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); if (0==src->shared->u.enumer.nmembs) HGOTO_DONE(SUCCEED); @@ -2578,7 +2581,7 @@ H5T_conv_enum_init(H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata) */ H5T_sort_name(src, NULL); H5T_sort_name(dst, NULL); - if (NULL==(priv->src2dst=H5MM_malloc(src->shared->u.enumer.nmembs*sizeof(int)))) + if (NULL==(priv->src2dst=(int *)H5MM_malloc(src->shared->u.enumer.nmembs*sizeof(int)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");; for (i=0, j=0; i<src->shared->u.enumer.nmembs && j<dst->shared->u.enumer.nmembs; @@ -2630,7 +2633,7 @@ H5T_conv_enum_init(H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata) (double)length/src->shared->u.enumer.nmembs<1.2) { priv->base = domain[0]; priv->length = length; - if (NULL==(map=H5MM_malloc(length*sizeof(int)))) + if (NULL==(map=(int *)H5MM_malloc(length*sizeof(int)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); for (i=0; i<length; i++) map[i] = -1; /*entry unused*/ @@ -2719,8 +2722,8 @@ H5T_conv_enum(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * the `priv' field of `cdata' with information about the underlying * integer conversion. */ - if (NULL == (src = H5I_object(src_id)) || - NULL == (dst = H5I_object(dst_id))) + if (NULL == (src = (H5T_t *)H5I_object(src_id)) || + NULL == (dst = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype"); assert (H5T_ENUM==src->shared->type); assert (H5T_ENUM==dst->shared->type); @@ -2744,8 +2747,8 @@ H5T_conv_enum(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, break; case H5T_CONV_CONV: - if (NULL == (src = H5I_object(src_id)) || - NULL == (dst = H5I_object(dst_id))) + if (NULL == (src = (H5T_t *)H5I_object(src_id)) || + NULL == (dst = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype"); assert (H5T_ENUM==src->shared->type); assert (H5T_ENUM==dst->shared->type); @@ -2899,14 +2902,14 @@ H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dxpl_id) { H5T_vlen_alloc_info_t _vl_alloc_info; /* VL allocation info buffer */ - H5T_vlen_alloc_info_t *vl_alloc_info=&_vl_alloc_info; /* VL allocation info */ + H5T_vlen_alloc_info_t *vl_alloc_info = &_vl_alloc_info; /* VL allocation info */ H5T_path_t *tpath; /* Type conversion path */ - hbool_t noop_conv=FALSE; /* Flag to indicate a noop conversion */ - hbool_t write_to_file=FALSE; /* Flag to indicate writing to file */ + hbool_t noop_conv = FALSE; /* Flag to indicate a noop conversion */ + hbool_t write_to_file = FALSE; /* Flag to indicate writing to file */ hbool_t parent_is_vlen; /* Flag to indicate parent is vlen datatyp */ hid_t tsrc_id = -1, tdst_id = -1;/*temporary type atoms */ - H5T_t *src = NULL; /*source datatype */ - H5T_t *dst = NULL; /*destination datatype */ + H5T_t *src; /*source datatype */ + H5T_t *dst; /*destination datatype */ H5HG_t bg_hobjid, parent_hobjid; uint8_t *s; /*source buffer */ uint8_t *d; /*destination buffer */ @@ -2915,15 +2918,15 @@ H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, ssize_t b_stride; /*bkg stride */ size_t safe; /*how many elements are safe to process in each pass */ ssize_t seq_len; /*the number of elements in the current sequence*/ - size_t bg_seq_len=0; + size_t bg_seq_len = 0; size_t src_base_size, dst_base_size;/*source & destination base size*/ - void *conv_buf=NULL; /*temporary conversion buffer */ - size_t conv_buf_size=0; /*size of conversion buffer in bytes */ - void *tmp_buf=NULL; /*temporary background buffer */ - size_t tmp_buf_size=0; /*size of temporary bkg buffer */ - hbool_t nested=FALSE; /*flag of nested VL case */ + void *conv_buf = NULL; /*temporary conversion buffer */ + size_t conv_buf_size = 0; /*size of conversion buffer in bytes */ + void *tmp_buf = NULL; /*temporary background buffer */ + size_t tmp_buf_size = 0; /*size of temporary bkg buffer */ + hbool_t nested = FALSE; /*flag of nested VL case */ size_t elmtno; /*element number counter */ - herr_t ret_value=SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_vlen, FAIL) @@ -2936,7 +2939,7 @@ H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * information that remains (almost) constant for this * conversion path. */ - if(NULL == (src = H5I_object(src_id)) || NULL == (dst = H5I_object(dst_id))) + if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") HDassert(H5T_VLEN == src->shared->type); HDassert(H5T_VLEN == dst->shared->type); @@ -2954,7 +2957,7 @@ H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, /* * Conversion. */ - if(NULL == (src = H5I_object(src_id)) || NULL == (dst = H5I_object(dst_id))) + if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* Initialize source & destination strides */ @@ -2971,10 +2974,8 @@ H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, d_stride = (ssize_t)dst->shared->size; } /* end else */ if(bkg) { - if(bkg_stride) { - H5_CHECK_OVERFLOW(bkg_stride, size_t, ssize_t); + if(bkg_stride) b_stride = (ssize_t)bkg_stride; - } /* end if */ else b_stride = d_stride; } /* end if */ @@ -2992,20 +2993,21 @@ H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, if((tsrc_id = H5I_register(H5I_DATATYPE, H5T_copy(src->shared->parent, H5T_COPY_ALL), FALSE)) < 0 || (tdst_id = H5I_register(H5I_DATATYPE, H5T_copy(dst->shared->parent, H5T_COPY_ALL), FALSE)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register types for conversion") - } else + } /* end else-if */ + else noop_conv = TRUE; /* Check if we need a temporary buffer for this conversion */ parent_is_vlen = H5T_detect_class(dst->shared->parent, H5T_VLEN, FALSE); if(tpath->cdata.need_bkg || parent_is_vlen) { /* Set up initial background buffer */ - tmp_buf_size = MAX(src_base_size,dst_base_size); + tmp_buf_size = MAX(src_base_size, dst_base_size); if(NULL == (tmp_buf = H5FL_BLK_MALLOC(vlen_seq,tmp_buf_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion") } /* end if */ /* Get the allocation info */ - if(H5T_vlen_get_alloc_info(dxpl_id,&vl_alloc_info) < 0) + if(H5T_vlen_get_alloc_info(dxpl_id, &vl_alloc_info) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to retrieve VL allocation info") /* Set flags to indicate we are writing to or reading from the file */ @@ -3018,145 +3020,143 @@ H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, /* The outer loop of the type conversion macro, controlling which */ /* direction the buffer is walked */ - while (nelmts>0) { + while(nelmts > 0) { /* Check if we need to go backwards through the buffer */ - if(d_stride>s_stride) { + if(d_stride > s_stride) { /* Compute the number of "safe" destination elements at */ /* the end of the buffer (Those which don't overlap with */ /* any source elements at the beginning of the buffer) */ - safe=nelmts-(((nelmts*s_stride)+(d_stride-1))/d_stride); + safe = nelmts - (((nelmts * s_stride) + (d_stride - 1)) / d_stride); /* If we're down to the last few elements, just wrap up */ /* with a "real" reverse copy */ - if(safe<2) { - s = (uint8_t*)buf+(nelmts-1)*s_stride; - d = (uint8_t*)buf+(nelmts-1)*d_stride; - b = (uint8_t*)bkg+(nelmts-1)*b_stride; + if(safe < 2) { + s = (uint8_t *)buf + (nelmts - 1) * s_stride; + d = (uint8_t *)buf + (nelmts - 1) * d_stride; + b = (uint8_t *)bkg + (nelmts - 1) * b_stride; s_stride = -s_stride; d_stride = -d_stride; b_stride = -b_stride; - safe=nelmts; + safe = nelmts; } /* end if */ else { - s = (uint8_t*)buf+(nelmts-safe)*s_stride; - d = (uint8_t*)buf+(nelmts-safe)*d_stride; - b = (uint8_t*)bkg+(nelmts-safe)*b_stride; + s = (uint8_t *)buf + (nelmts - safe) * s_stride; + d = (uint8_t *)buf + (nelmts - safe) * d_stride; + b = (uint8_t *)bkg + (nelmts - safe) * b_stride; } /* end else */ } /* end if */ else { /* Single forward pass over all data */ - s = d = buf; - b = bkg; - safe=nelmts; + s = d = (uint8_t *)buf; + b = (uint8_t *)bkg; + safe = nelmts; } /* end else */ - for (elmtno=0; elmtno<safe; elmtno++) { + for(elmtno = 0; elmtno < safe; elmtno++) { /* Check for "nil" source sequence */ - if((*(src->shared->u.vlen.isnull))(src->shared->u.vlen.f,s)) { + if((*(src->shared->u.vlen.isnull))(src->shared->u.vlen.f, s)) { /* Write "nil" sequence to destination location */ - if((*(dst->shared->u.vlen.setnull))(dst->shared->u.vlen.f,dxpl_id,d,b)<0) - HGOTO_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL, "can't set VL data to 'nil'"); + if((*(dst->shared->u.vlen.setnull))(dst->shared->u.vlen.f, dxpl_id, d, b) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL, "can't set VL data to 'nil'") } /* end if */ else { /* Get length of element sequences */ - if((seq_len=(*(src->shared->u.vlen.getlen))(s))<0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "incorrect length"); + if((seq_len = (*(src->shared->u.vlen.getlen))(s)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "incorrect length") /* If we are reading from memory and there is no conversion, just get the pointer to sequence */ if(write_to_file && noop_conv) { /* Get direct pointer to sequence */ - if((conv_buf=(*(src->shared->u.vlen.getptr))(s))==NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid source pointer"); + if(NULL == (conv_buf = (*(src->shared->u.vlen.getptr))(s))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid source pointer") } /* end if */ else { size_t src_size, dst_size; /*source & destination total size in bytes*/ - src_size=seq_len*src_base_size; - dst_size=seq_len*dst_base_size; + src_size = seq_len * src_base_size; + dst_size = seq_len * dst_base_size; /* Check if conversion buffer is large enough, resize if - * necessary. If the SEQ_LEN is 0, allocate a minimal size buffer. */ + * necessary. If the SEQ_LEN is 0, allocate a minimal size buffer. + */ if(!seq_len && !conv_buf) { - conv_buf_size=((1/H5T_VLEN_MIN_CONF_BUF_SIZE)+1)*H5T_VLEN_MIN_CONF_BUF_SIZE; - if((conv_buf=H5FL_BLK_MALLOC(vlen_seq,conv_buf_size))==NULL) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion"); + conv_buf_size = ((1 / H5T_VLEN_MIN_CONF_BUF_SIZE) + 1) * H5T_VLEN_MIN_CONF_BUF_SIZE; + if(NULL == (conv_buf = H5FL_BLK_MALLOC(vlen_seq, conv_buf_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion") } - else if(conv_buf_size<MAX(src_size,dst_size)) { + else if(conv_buf_size < MAX(src_size, dst_size)) { /* Only allocate conversion buffer in H5T_VLEN_MIN_CONF_BUF_SIZE increments */ - conv_buf_size=((MAX(src_size,dst_size)/H5T_VLEN_MIN_CONF_BUF_SIZE)+1)*H5T_VLEN_MIN_CONF_BUF_SIZE; - if((conv_buf=H5FL_BLK_REALLOC(vlen_seq,conv_buf, conv_buf_size))==NULL) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion"); + conv_buf_size = ((MAX(src_size, dst_size) / H5T_VLEN_MIN_CONF_BUF_SIZE) + 1) * H5T_VLEN_MIN_CONF_BUF_SIZE; + if(NULL == (conv_buf = H5FL_BLK_REALLOC(vlen_seq, conv_buf, conv_buf_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion") } /* end if */ /* Read in VL sequence */ - if((*(src->shared->u.vlen.read))(src->shared->u.vlen.f,dxpl_id,s,conv_buf,src_size)<0) - HGOTO_ERROR(H5E_DATATYPE, H5E_READERROR, FAIL, "can't read VL data"); + if((*(src->shared->u.vlen.read))(src->shared->u.vlen.f, dxpl_id, s, conv_buf, src_size) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_READERROR, FAIL, "can't read VL data") } /* end else */ if(!noop_conv) { /* Check if temporary buffer is large enough, resize if necessary */ /* (Chain off the conversion buffer size) */ - if(tmp_buf && tmp_buf_size<conv_buf_size) { + if(tmp_buf && tmp_buf_size < conv_buf_size) { /* Set up initial background buffer */ - tmp_buf_size=conv_buf_size; - if((tmp_buf=H5FL_BLK_REALLOC(vlen_seq,tmp_buf,tmp_buf_size))==NULL) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion"); + tmp_buf_size = conv_buf_size; + if(NULL == (tmp_buf = H5FL_BLK_REALLOC(vlen_seq, tmp_buf, tmp_buf_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion") } /* end if */ /* If we are writing and there is a nested VL type, read * the sequence into the background buffer */ if(nested) { - uint8_t *tmp=b; - UINT32DECODE(tmp, bg_seq_len); + uint8_t *tmp = b; - if(bg_seq_len>0) { - if(tmp_buf_size<(bg_seq_len*MAX(src_base_size, dst_base_size))) { - tmp_buf_size=(bg_seq_len*MAX(src_base_size, dst_base_size)); - if((tmp_buf=H5FL_BLK_REALLOC(vlen_seq,tmp_buf, tmp_buf_size))==NULL) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion"); - } + UINT32DECODE(tmp, bg_seq_len); + if(bg_seq_len > 0) { + if(tmp_buf_size < (bg_seq_len * MAX(src_base_size, dst_base_size))) { + tmp_buf_size = (bg_seq_len * MAX(src_base_size, dst_base_size)); + if(NULL == (tmp_buf = H5FL_BLK_REALLOC(vlen_seq, tmp_buf, tmp_buf_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion") + } /* end if */ H5F_addr_decode(dst->shared->u.vlen.f, (const uint8_t **)&tmp, &(bg_hobjid.addr)); INT32DECODE(tmp, bg_hobjid.idx); - if(H5HG_read(dst->shared->u.vlen.f,dxpl_id,&bg_hobjid,tmp_buf, NULL)==NULL) - HGOTO_ERROR (H5E_DATATYPE, H5E_READERROR, FAIL, "can't read VL sequence into background buffer"); + if(NULL == H5HG_read(dst->shared->u.vlen.f, dxpl_id, &bg_hobjid, tmp_buf, NULL)) + HGOTO_ERROR(H5E_DATATYPE, H5E_READERROR, FAIL, "can't read VL sequence into background buffer") } /* end if */ /* If the sequence gets shorter, pad out the original sequence with zeros */ - H5_CHECK_OVERFLOW(bg_seq_len,size_t,ssize_t); - if((ssize_t)bg_seq_len<seq_len) { - HDmemset((uint8_t *)tmp_buf+dst_base_size*bg_seq_len,0,(seq_len-bg_seq_len)*dst_base_size); - } /* end if */ + if((ssize_t)bg_seq_len < seq_len) + HDmemset((uint8_t *)tmp_buf + dst_base_size * bg_seq_len, 0, (seq_len - bg_seq_len) * dst_base_size); } /* end if */ /* Convert VL sequence */ - H5_CHECK_OVERFLOW(seq_len,ssize_t,size_t); if(H5T_convert(tpath, tsrc_id, tdst_id, (size_t)seq_len, (size_t)0, (size_t)0, conv_buf, tmp_buf, dxpl_id) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "datatype conversion failed"); + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "datatype conversion failed") } /* end if */ /* Write sequence to destination location */ - if((*(dst->shared->u.vlen.write))(dst->shared->u.vlen.f,dxpl_id,vl_alloc_info,d,conv_buf, b, (size_t)seq_len, dst_base_size)<0) - HGOTO_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL, "can't write VL data"); + if((*(dst->shared->u.vlen.write))(dst->shared->u.vlen.f, dxpl_id, vl_alloc_info, d, conv_buf, b, (size_t)seq_len, dst_base_size) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL, "can't write VL data") if(!noop_conv) { /* For nested VL case, free leftover heap objects from the deeper level if the length of new data elements is shorter than the old data elements.*/ - H5_CHECK_OVERFLOW(bg_seq_len,size_t,ssize_t); - if(nested && seq_len<(ssize_t)bg_seq_len) { + if(nested && seq_len < (ssize_t)bg_seq_len) { size_t parent_seq_len; - size_t u; uint8_t *tmp_p; + size_t u; + /* TMP_P is reset each time in the loop because DST_BASE_SIZE may include some data in addition to VL info. - SLU */ - for(u=seq_len; u<bg_seq_len; u++) { - tmp_p = (uint8_t*)tmp_buf + u*dst_base_size; + for(u = seq_len; u < bg_seq_len; u++) { + tmp_p = (uint8_t*)tmp_buf + u * dst_base_size; UINT32DECODE(tmp_p, parent_seq_len); - if(parent_seq_len>0) { + if(parent_seq_len > 0) { H5F_addr_decode(dst->shared->u.vlen.f, (const uint8_t **)&tmp_p, &(parent_hobjid.addr)); INT32DECODE(tmp_p, parent_hobjid.idx); - if(H5HG_remove(dst->shared->u.vlen.f, dxpl_id,&parent_hobjid)<0) - HGOTO_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL, "Unable to remove heap object"); - } - } + if(H5HG_remove(dst->shared->u.vlen.f, dxpl_id, &parent_hobjid) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL, "Unable to remove heap object") + } /* end if */ + } /* end for */ } /* end if */ } /* end if */ } /* end else */ @@ -3168,18 +3168,18 @@ H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, } /* end for */ /* Decrement number of elements left to convert */ - nelmts-=safe; + nelmts -= safe; } /* end while */ /* Release the temporary datatype IDs used */ - if (tsrc_id >= 0) + if(tsrc_id >= 0) H5I_dec_ref(tsrc_id, FALSE); - if (tdst_id >= 0) + if(tdst_id >= 0) H5I_dec_ref(tdst_id, FALSE); break; default: /* Some other command we don't know about yet.*/ - HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown conversion command"); + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown conversion command") } /* end switch */ done: @@ -3194,7 +3194,7 @@ done: tmp_buf = H5FL_BLK_FREE(vlen_seq, tmp_buf); FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5T_conv_vlen() */ /*------------------------------------------------------------------------- @@ -3240,7 +3240,7 @@ H5T_conv_array(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * information that remains (almost) constant for this * conversion path. */ - if(NULL == (src = H5I_object(src_id)) || NULL == (dst = H5I_object(dst_id))) + if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") HDassert(H5T_ARRAY==src->shared->type); HDassert(H5T_ARRAY==dst->shared->type); @@ -3265,7 +3265,7 @@ H5T_conv_array(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, /* * Conversion. */ - if (NULL == (src = H5I_object(src_id)) || NULL == (dst = H5I_object(dst_id))) + if (NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* @@ -3398,8 +3398,8 @@ H5T_conv_i_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, switch (cdata->command) { case H5T_CONV_INIT: - if (NULL==(src=H5I_object(src_id)) || - NULL==(dst=H5I_object(dst_id))) + if (NULL==(src=(H5T_t *)H5I_object(src_id)) || + NULL==(dst=(H5T_t *)H5I_object(dst_id))) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype"); if (H5T_ORDER_LE!=src->shared->u.atomic.order && H5T_ORDER_BE!=src->shared->u.atomic.order) @@ -3417,8 +3417,8 @@ H5T_conv_i_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, case H5T_CONV_CONV: /* Get the datatypes */ - if (NULL==(src=H5I_object(src_id)) || - NULL==(dst=H5I_object(dst_id))) + if (NULL==(src=(H5T_t *)H5I_object(src_id)) || + NULL==(dst=(H5T_t *)H5I_object(dst_id))) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype"); /* @@ -3824,8 +3824,8 @@ H5T_conv_f_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, switch (cdata->command) { case H5T_CONV_INIT: - if (NULL==(src_p=H5I_object(src_id)) || - NULL==(dst_p=H5I_object(dst_id))) + if (NULL==(src_p=(H5T_t *)H5I_object(src_id)) || + NULL==(dst_p=(H5T_t *)H5I_object(dst_id))) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype"); src = src_p->shared->u.atomic; dst = dst_p->shared->u.atomic; @@ -3845,8 +3845,8 @@ H5T_conv_f_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, case H5T_CONV_CONV: /* Get the datatypes */ - if (NULL==(src_p=H5I_object(src_id)) || - NULL==(dst_p=H5I_object(dst_id))) + if (NULL==(src_p=(H5T_t *)H5I_object(src_id)) || + NULL==(dst_p=(H5T_t *)H5I_object(dst_id))) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype"); src = src_p->shared->u.atomic; dst = dst_p->shared->u.atomic; @@ -4367,8 +4367,8 @@ H5T_conv_s_s(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, switch (cdata->command) { case H5T_CONV_INIT: - if (NULL==(src=H5I_object(src_id)) || - NULL==(dst=H5I_object(dst_id))) + if (NULL==(src=(H5T_t *)H5I_object(src_id)) || + NULL==(dst=(H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype"); if (8*src->shared->size != src->shared->u.atomic.prec || 8*dst->shared->size != dst->shared->u.atomic.prec) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad precision"); @@ -4389,8 +4389,8 @@ H5T_conv_s_s(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, case H5T_CONV_CONV: /* Get the datatypes */ - if (NULL==(src=H5I_object(src_id)) || - NULL==(dst=H5I_object(dst_id))) + if (NULL==(src=(H5T_t *)H5I_object(src_id)) || + NULL==(dst=(H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype"); /* @@ -4422,7 +4422,7 @@ H5T_conv_s_s(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, } /* Allocate the overlap buffer */ - if (NULL==(dbuf=H5MM_malloc(dst->shared->size))) + if (NULL==(dbuf=(uint8_t *)H5MM_malloc(dst->shared->size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for string conversion"); /* The conversion loop. */ @@ -9808,18 +9808,18 @@ H5T_conv_f_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, int_buf = (uint8_t*)H5MM_calloc(buf_size); /* Get the plist structure. Do I need to close it? */ - if(NULL == (plist = H5P_object_verify(dxpl_id,H5P_DATASET_XFER))) + if(NULL == (plist = H5P_object_verify(dxpl_id, H5P_DATASET_XFER))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find property list for ID"); /* Get conversion exception callback property */ - if (H5P_get(plist,H5D_XFER_CONV_CB_NAME,&cb_struct)<0) + if(H5P_get(plist, H5D_XFER_CONV_CB_NAME, &cb_struct) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get conversion exception callback"); /* Allocate space for order-reversed source buffer */ src_rev = (uint8_t*)H5MM_calloc(src_p->shared->size); /* The conversion loop */ - for (elmtno=0; elmtno<nelmts; elmtno++) { + for(elmtno = 0; elmtno < nelmts; elmtno++) { /* Set these variables to default */ except_ret = H5T_CONV_UNHANDLED; truncated = FALSE; @@ -9829,7 +9829,7 @@ H5T_conv_f_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * If the source and destination buffers overlap then use a * temporary buffer for the destination. */ - if (direction>0) { + if(direction > 0) { s = sp; d = elmtno<olap ? dbuf : dp; } else { @@ -10038,8 +10038,8 @@ H5T_conv_f_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * Restore the implicit bit for mantissa if it's implied. * Equivalent to mantissa |= (hsize_t)1<<src.u.f.msize. */ - if (H5T_NORM_IMPLIED==src.u.f.norm) - H5T_bit_inc(int_buf, src.u.f.msize, 8*buf_size-src.u.f.msize); + if(H5T_NORM_IMPLIED == src.u.f.norm) + H5T_bit_inc(int_buf, src.u.f.msize, 8 * buf_size - src.u.f.msize); /* * Shift mantissa part by exponent minus mantissa size(right shift), @@ -10047,7 +10047,7 @@ H5T_conv_f_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * 10...010111, expo=20, expo-msize=-3. Right-shift the sequence, we get * 00010...10. The last three bits were dropped. */ - H5T_bit_shift(int_buf, (ssize_t)(expo-src.u.f.msize), (size_t)0, buf_size*8); + H5T_bit_shift(int_buf, (ssize_t)(expo-src.u.f.msize), (size_t)0, buf_size * 8); /* * If expo is less than mantissa size, the frantional value is dropped off |