diff options
-rw-r--r-- | config/gnu-flags | 20 | ||||
-rw-r--r-- | config/pgi-flags | 17 | ||||
-rwxr-xr-x | configure | 47 | ||||
-rw-r--r-- | configure.in | 2 | ||||
-rw-r--r-- | src/H5Aint.c | 2 | ||||
-rw-r--r-- | src/H5B.c | 2 | ||||
-rw-r--r-- | src/H5B2.c | 6 | ||||
-rw-r--r-- | src/H5B2int.c | 110 | ||||
-rw-r--r-- | src/H5B2pkg.h | 2 | ||||
-rw-r--r-- | src/H5C.c | 14 | ||||
-rw-r--r-- | src/H5Dchunk.c | 8 | ||||
-rw-r--r-- | src/H5Dcompact.c | 9 | ||||
-rw-r--r-- | src/H5Defl.c | 64 | ||||
-rw-r--r-- | src/H5F.c | 4 | ||||
-rw-r--r-- | src/H5Fsuper.c | 4 | ||||
-rw-r--r-- | src/H5Fsuper_cache.c | 2 | ||||
-rw-r--r-- | src/H5Tbit.c | 512 | ||||
-rw-r--r-- | src/H5Tconv.c | 698 | ||||
-rw-r--r-- | src/H5Tpkg.h | 2 | ||||
-rw-r--r-- | src/H5Zscaleoffset.c | 753 | ||||
-rw-r--r-- | src/H5config.h.in | 6 | ||||
-rw-r--r-- | src/H5detect.c | 24 | ||||
-rw-r--r-- | src/H5overflow.h | 558 | ||||
-rw-r--r-- | src/H5overflow.txt | 2 | ||||
-rw-r--r-- | test/dt_arith.c | 11 | ||||
-rw-r--r-- | test/fheap.c | 3 |
26 files changed, 1795 insertions, 1087 deletions
diff --git a/config/gnu-flags b/config/gnu-flags index 427b839..96db51d 100644 --- a/config/gnu-flags +++ b/config/gnu-flags @@ -147,23 +147,11 @@ case "$cc_vendor-$cc_version" in gcc-2.95.[34]) PROD_CFLAGS="-O3" ;; - gcc-4.[345]*) - # The optimization level is reduced for gcc 4.[345] due to problems - # with code generation for src/H5Tconv.c with the -O (same -O1) - # optimization levels (which shows up as failures for long double - # types -> signed char conversion in the test/dt_arith test). - # There's either a bug in gcc or our code. Need further investigation. - # Turn off all optimizations to allow the tests to pass for now. - # - AKC - 2009/04/19 - PROD_CFLAGS="-O0" + gcc-3.*) + PROD_CFLAGS="-O3" ;; - gcc-3.[0-4]*|gcc-4.[012]*) - # The optimization level is reduced for gcc 3.* and 4.* due to problems - # with code generation for src/H5Tconv.c with the -O2 & -O3 - # optimization levels (which shows up as failures for various integer - # types -> long long conversions in the test/dtypes test). Perhaps - # later versions of gcc will fix this bug... - QAK - 2003/10/20 - PROD_CFLAGS="-O" + gcc-4.*) + PROD_CFLAGS="-O3" ;; *) PROD_CFLAGS="-O" diff --git a/config/pgi-flags b/config/pgi-flags index 2b03f3d..664b37b 100644 --- a/config/pgi-flags +++ b/config/pgi-flags @@ -68,15 +68,18 @@ if test "X-pgcc" = "X-$cc_vendor"; then #esac # General - H5_CFLAGS="$H5_CFLAGS $arch -Minform,warn" + H5_CFLAGS="$H5_CFLAGS $arch -c99 -Minform=inform" # Production - # Check for MPI wrapper being used and tweak down compiler options - if test "X-" == "X-$is_mpi"; then - PROD_CFLAGS="-fast -s -Mnoframe" - else - PROD_CFLAGS="-O2 -s" - fi + case "$cc_vendor-$cc_version" in + # Tweak down compiler optimizations for v9.x + pgcc-9.*) + PROD_CFLAGS="-O1 -s" + ;; + *) + PROD_CFLAGS="-fast -s" + ;; + esac PROD_CPPFLAGS= # Debug @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Id: configure.in 18534 2010-04-08 15:30:10Z koziol . +# From configure.in Id: configure.in 18589 2010-04-18 13:59:45Z hdftest . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.65 for HDF5 1.9.68-FA_a4. # @@ -21347,6 +21347,17 @@ _ACEOF fi +ac_fn_c_check_type "$LINENO" "ptrdiff_t" "ac_cv_type_ptrdiff_t" "$ac_includes_default" +if test "x$ac_cv_type_ptrdiff_t" = x""yes; then : + +else + +cat >>confdefs.h <<_ACEOF +#define ptrdiff_t long +_ACEOF + +fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5 $as_echo_n "checking whether byte ordering is bigendian... " >&6; } if test "${ac_cv_c_bigendian+set}" = set; then : @@ -22933,6 +22944,40 @@ cat >>confdefs.h <<_ACEOF _ACEOF +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of ptrdiff_t" >&5 +$as_echo_n "checking size of ptrdiff_t... " >&6; } +if test "${ac_cv_sizeof_ptrdiff_t+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (ptrdiff_t))" "ac_cv_sizeof_ptrdiff_t" "$ac_includes_default"; then : + +else + if test "$ac_cv_type_ptrdiff_t" = yes; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +{ as_fn_set_status 77 +as_fn_error "cannot compute sizeof (ptrdiff_t) +See \`config.log' for more details." "$LINENO" 5; }; } + else + ac_cv_sizeof_ptrdiff_t=0 + fi +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_ptrdiff_t" >&5 +$as_echo "$ac_cv_sizeof_ptrdiff_t" >&6; } + + + +cat >>confdefs.h <<_ACEOF +#define SIZEOF_PTRDIFF_T $ac_cv_sizeof_ptrdiff_t +_ACEOF + + cat >>confdefs.h <<\EOF #include <sys/types.h> /*for off_t definition*/ diff --git a/configure.in b/configure.in index dbffabf..309e46e 100644 --- a/configure.in +++ b/configure.in @@ -1333,6 +1333,7 @@ dnl AC_TYPE_OFF_T AC_CHECK_TYPE([size_t], [unsigned long]) AC_CHECK_TYPE([ssize_t], [long]) +AC_CHECK_TYPE([ptrdiff_t], [long]) AC_C_BIGENDIAN AC_CHECK_SIZEOF([char], [1]) AC_CHECK_SIZEOF([short], [2]) @@ -1389,6 +1390,7 @@ AC_CHECK_SIZEOF( uint_fast64_t, [8]) AC_CHECK_SIZEOF([size_t], [4]) AC_CHECK_SIZEOF([ssize_t], [4]) +AC_CHECK_SIZEOF([ptrdiff_t], [4]) cat >>confdefs.h <<\EOF #include <sys/types.h> /*for off_t definition*/ diff --git a/src/H5Aint.c b/src/H5Aint.c index 613ea77..81b5c60 100644 --- a/src/H5Aint.c +++ b/src/H5Aint.c @@ -920,7 +920,7 @@ H5A_attr_copy_file(const H5A_t *attr_src, H5F_t *file_dst, hbool_t *recompute_si *recompute_size = TRUE; /* Compute the size of the data */ - H5_ASSIGN_OVERFLOW(attr_dst->shared->data_size, H5S_GET_EXTENT_NPOINTS(attr_dst->shared->ds) * H5T_get_size(attr_dst->shared->dt), hsize_t, size_t); + H5_ASSIGN_OVERFLOW(attr_dst->shared->data_size, H5S_GET_EXTENT_NPOINTS(attr_dst->shared->ds) * H5T_get_size(attr_dst->shared->dt), hssize_t, size_t); /* Copy (& convert) the data, if necessary */ if(attr_src->shared->data) { @@ -1718,7 +1718,7 @@ H5B_shared_new(const H5F_t *f, const H5B_class_t *type, size_t sizeof_rkey) shared->sizeof_rkey = sizeof_rkey; HDassert(shared->sizeof_rkey); shared->sizeof_keys = (shared->two_k + 1) * type->sizeof_nkey; - shared->sizeof_rnode = (H5B_SIZEOF_HDR(f) + /*node header */ + shared->sizeof_rnode = ((size_t)H5B_SIZEOF_HDR(f) + /*node header */ shared->two_k * H5F_SIZEOF_ADDR(f) + /*child pointers */ (shared->two_k + 1) * shared->sizeof_rkey); /*keys */ HDassert(shared->sizeof_rnode); @@ -743,7 +743,8 @@ H5B2_remove(H5B2_t *bt2, hid_t dxpl_id, void *udata, H5B2_remove_t op, if(H5FL_fac_term(hdr->node_info[hdr->depth].node_ptr_fac) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't destroy node's node pointer block factory") - hdr->depth -= (uint16_t)depth_decreased; + HDassert((uint16_t)(hdr->depth - depth_decreased) < hdr->depth); + hdr->depth = (uint16_t)(hdr->depth - depth_decreased); } /* end for */ } /* end if */ else { @@ -824,7 +825,8 @@ H5B2_remove_by_idx(H5B2_t *bt2, hid_t dxpl_id, H5_iter_order_t order, if(H5FL_fac_term(hdr->node_info[hdr->depth].node_ptr_fac) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't destroy node's node pointer block factory") - hdr->depth -= (uint16_t)depth_decreased; + HDassert((uint16_t)(hdr->depth - depth_decreased) < hdr->depth); + hdr->depth = (uint16_t)(hdr->depth - depth_decreased); } /* end for */ } /* end if */ else { diff --git a/src/H5B2int.c b/src/H5B2int.c index 5423bf7..17922fd 100644 --- a/src/H5B2int.c +++ b/src/H5B2int.c @@ -271,14 +271,14 @@ H5B2_split1(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth, H5B2_node_ptr_t *cur /* Copy "upper half" of node pointers, if the node is an internal node */ if(depth > 1) HDmemcpy(&(right_node_ptrs[0]), &(left_node_ptrs[mid_record + (unsigned)1]), - sizeof(H5B2_node_ptr_t) * (old_node_nrec - mid_record)); + sizeof(H5B2_node_ptr_t) * (size_t)(old_node_nrec - mid_record)); /* Copy "middle" record to internal node */ HDmemcpy(H5B2_INT_NREC(internal, hdr, idx), H5B2_NAT_NREC(left_native, hdr, mid_record), hdr->cls->nrec_size); /* Update record counts in child nodes */ internal->node_ptrs[idx].node_nrec = *left_nrec = mid_record; - internal->node_ptrs[idx + 1].node_nrec = *right_nrec = old_node_nrec - (mid_record + (unsigned)1); + internal->node_ptrs[idx + 1].node_nrec = *right_nrec = (uint16_t)(old_node_nrec - (mid_record + 1)); /* Determine total number of records in new child nodes */ if(depth > 1) { @@ -516,15 +516,15 @@ H5B2_redistribute2(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth, if(*left_nrec < *right_nrec) { /* Moving record from right node to left */ - uint16_t new_right_nrec = (*left_nrec + *right_nrec) / 2; /* New number of records for right child */ - uint16_t move_nrec = *right_nrec - new_right_nrec; /* Number of records to move from right node to left */ + uint16_t new_right_nrec = (uint16_t)(*left_nrec + *right_nrec) / 2; /* New number of records for right child */ + uint16_t move_nrec = (uint16_t)(*right_nrec - new_right_nrec); /* Number of records to move from right node to left */ /* Copy record from parent node down into left child */ HDmemcpy(H5B2_NAT_NREC(left_native, hdr, *left_nrec), H5B2_INT_NREC(internal, hdr, idx), hdr->cls->nrec_size); /* See if we need to move records from right node */ if(move_nrec > 1) - HDmemcpy(H5B2_NAT_NREC(left_native, hdr, (*left_nrec + 1)), H5B2_NAT_NREC(right_native, hdr, 0), hdr->cls->nrec_size * (move_nrec - 1)); + HDmemcpy(H5B2_NAT_NREC(left_native, hdr, (*left_nrec + 1)), H5B2_NAT_NREC(right_native, hdr, 0), hdr->cls->nrec_size * (size_t)(move_nrec - 1)); /* Move record from right node into parent node */ HDmemcpy(H5B2_INT_NREC(internal, hdr, idx), H5B2_NAT_NREC(right_native, hdr, (move_nrec - 1)), hdr->cls->nrec_size); @@ -551,14 +551,14 @@ H5B2_redistribute2(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth, } /* end if */ /* Update number of records in child nodes */ - *left_nrec += move_nrec; + *left_nrec = (uint16_t)(*left_nrec + move_nrec); *right_nrec = new_right_nrec; } /* end if */ else { /* Moving record from left node to right */ - uint16_t new_left_nrec = (*left_nrec + *right_nrec) / 2; /* New number of records for left child */ - uint16_t move_nrec = *left_nrec - new_left_nrec; /* Number of records to move from left node to right */ + uint16_t new_left_nrec = (uint16_t)(*left_nrec + *right_nrec) / 2; /* New number of records for left child */ + uint16_t move_nrec = (uint16_t)(*left_nrec - new_left_nrec); /* Number of records to move from left node to right */ /* Slide records in right node up */ HDmemmove(H5B2_NAT_NREC(right_native, hdr, move_nrec), @@ -570,7 +570,7 @@ H5B2_redistribute2(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth, /* See if we need to move records from left node */ if(move_nrec > 1) - HDmemcpy(H5B2_NAT_NREC(right_native, hdr, 0), H5B2_NAT_NREC(left_native, hdr, ((*left_nrec - move_nrec) + 1)), hdr->cls->nrec_size * (move_nrec - 1)); + HDmemcpy(H5B2_NAT_NREC(right_native, hdr, 0), H5B2_NAT_NREC(left_native, hdr, ((*left_nrec - move_nrec) + 1)), hdr->cls->nrec_size * (size_t)(move_nrec - 1)); /* Move record from left node into parent node */ HDmemcpy(H5B2_INT_NREC(internal, hdr, idx), H5B2_NAT_NREC(left_native, hdr, (*left_nrec - move_nrec)), hdr->cls->nrec_size); @@ -581,7 +581,7 @@ H5B2_redistribute2(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth, unsigned u; /* Local index variable */ /* Slide node pointers in right node up */ - HDmemmove(&(right_node_ptrs[move_nrec]), &(right_node_ptrs[0]), sizeof(H5B2_node_ptr_t) * (*right_nrec + 1)); + HDmemmove(&(right_node_ptrs[move_nrec]), &(right_node_ptrs[0]), sizeof(H5B2_node_ptr_t) * (size_t)(*right_nrec + 1)); /* Copy node pointers from left node to right */ HDmemcpy(&(right_node_ptrs[0]), &(left_node_ptrs[new_left_nrec + 1]), sizeof(H5B2_node_ptr_t) * move_nrec); @@ -595,7 +595,7 @@ H5B2_redistribute2(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth, /* Update number of records in child nodes */ *left_nrec = new_left_nrec; - *right_nrec += move_nrec; + *right_nrec = (uint16_t)(*right_nrec + move_nrec); } /* end else */ /* Update # of records in child nodes */ @@ -604,8 +604,8 @@ H5B2_redistribute2(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth, /* Update total # of records in child B-trees */ if(depth > 1) { - internal->node_ptrs[idx].all_nrec += left_moved_nrec; - internal->node_ptrs[idx + 1].all_nrec += right_moved_nrec; + internal->node_ptrs[idx].all_nrec = (hsize_t)((hssize_t)internal->node_ptrs[idx].all_nrec + left_moved_nrec); + internal->node_ptrs[idx + 1].all_nrec = (hsize_t)((hssize_t)internal->node_ptrs[idx + 1].all_nrec + right_moved_nrec); } /* end if */ else { internal->node_ptrs[idx].all_nrec = internal->node_ptrs[idx].node_nrec; @@ -743,10 +743,10 @@ H5B2_redistribute3(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth, /* Redistribute records */ { /* Compute new # of records in each node */ - unsigned total_nrec = *left_nrec + *middle_nrec + *right_nrec + 2; - uint16_t new_middle_nrec = (total_nrec - 2) / 3; - uint16_t new_left_nrec = ((total_nrec - 2) - new_middle_nrec) / 2; - uint16_t new_right_nrec = (total_nrec - 2) - (new_left_nrec + new_middle_nrec); + unsigned total_nrec = (unsigned)(*left_nrec + *middle_nrec + *right_nrec + 2); + uint16_t new_middle_nrec = (uint16_t)(total_nrec - 2) / 3; + uint16_t new_left_nrec = (uint16_t)((total_nrec - 2) - new_middle_nrec) / 2; + uint16_t new_right_nrec = (uint16_t)((total_nrec - 2) - (unsigned)(new_left_nrec + new_middle_nrec)); uint16_t curr_middle_nrec = *middle_nrec; /* Sanity check rounding */ @@ -762,7 +762,7 @@ H5B2_redistribute3(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth, /* Move records from middle node into left node */ if((new_left_nrec - 1) > *left_nrec) { - moved_middle_nrec = new_left_nrec - (*left_nrec + 1); + moved_middle_nrec = (uint16_t)(new_left_nrec - (*left_nrec + 1)); HDmemcpy(H5B2_NAT_NREC(left_native, hdr, *left_nrec + 1), H5B2_NAT_NREC(middle_native, hdr, 0), hdr->cls->nrec_size * moved_middle_nrec); } /* end if */ @@ -771,7 +771,7 @@ H5B2_redistribute3(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth, moved_middle_nrec++; /* Slide records in middle node down */ - HDmemmove(H5B2_NAT_NREC(middle_native, hdr, 0), H5B2_NAT_NREC(middle_native, hdr, moved_middle_nrec), hdr->cls->nrec_size * (*middle_nrec - moved_middle_nrec)); + HDmemmove(H5B2_NAT_NREC(middle_native, hdr, 0), H5B2_NAT_NREC(middle_native, hdr, moved_middle_nrec), hdr->cls->nrec_size * (size_t)(*middle_nrec - moved_middle_nrec)); /* Move node pointers also if this is an internal node */ if(depth > 1) { @@ -780,26 +780,26 @@ H5B2_redistribute3(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth, unsigned u; /* Local index variable */ /* Move middle node pointers into left node */ - move_nptrs = new_left_nrec - *left_nrec; + move_nptrs = (unsigned)(new_left_nrec - *left_nrec); HDmemcpy(&(left_node_ptrs[*left_nrec + 1]), &(middle_node_ptrs[0]), sizeof(H5B2_node_ptr_t)*move_nptrs); /* Count the number of records being moved into the left node */ for(u = 0, moved_nrec = 0; u < move_nptrs; u++) moved_nrec += middle_node_ptrs[u].all_nrec; - left_moved_nrec = moved_nrec + move_nptrs; - middle_moved_nrec -= moved_nrec + move_nptrs; + left_moved_nrec = (hssize_t)(moved_nrec + move_nptrs); + middle_moved_nrec -= (hssize_t)(moved_nrec + move_nptrs); /* Slide the node pointers in middle node down */ HDmemmove(&(middle_node_ptrs[0]), &(middle_node_ptrs[move_nptrs]), sizeof(H5B2_node_ptr_t) * ((*middle_nrec - move_nptrs) + 1)); } /* end if */ /* Update the current number of records in middle node */ - curr_middle_nrec -= moved_middle_nrec; + curr_middle_nrec = (uint16_t)(curr_middle_nrec - moved_middle_nrec); } /* end if */ /* Move records into right node */ if(new_right_nrec > *right_nrec) { - unsigned right_nrec_move = new_right_nrec - *right_nrec; /* Number of records to move out of right node */ + unsigned right_nrec_move = (unsigned)(new_right_nrec - *right_nrec); /* Number of records to move out of right node */ /* Slide records in right node up */ HDmemmove(H5B2_NAT_NREC(right_native, hdr, right_nrec_move), H5B2_NAT_NREC(right_native, hdr, 0), hdr->cls->nrec_size * (*right_nrec)); @@ -820,7 +820,7 @@ H5B2_redistribute3(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth, unsigned u; /* Local index variable */ /* Slide the node pointers in right node up */ - HDmemmove(&(right_node_ptrs[right_nrec_move]), &(right_node_ptrs[0]), sizeof(H5B2_node_ptr_t) * (*right_nrec + 1)); + HDmemmove(&(right_node_ptrs[right_nrec_move]), &(right_node_ptrs[0]), sizeof(H5B2_node_ptr_t) * (size_t)(*right_nrec + 1)); /* Move middle node pointers into right node */ HDmemcpy(&(right_node_ptrs[0]), &(middle_node_ptrs[(curr_middle_nrec - right_nrec_move) + 1]), sizeof(H5B2_node_ptr_t) * right_nrec_move); @@ -828,17 +828,17 @@ H5B2_redistribute3(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth, /* Count the number of records being moved into the right node */ for(u = 0, moved_nrec = 0; u < right_nrec_move; u++) moved_nrec += right_node_ptrs[u].all_nrec; - right_moved_nrec = moved_nrec + right_nrec_move; - middle_moved_nrec -= moved_nrec + right_nrec_move; + right_moved_nrec = (hssize_t)(moved_nrec + right_nrec_move); + middle_moved_nrec -= (hssize_t)(moved_nrec + right_nrec_move); } /* end if */ /* Update the current number of records in middle node */ - curr_middle_nrec -= right_nrec_move; + curr_middle_nrec = (uint16_t)(curr_middle_nrec - right_nrec_move); } /* end if */ /* Move records out of left node */ if(new_left_nrec < *left_nrec) { - unsigned left_nrec_move = *left_nrec - new_left_nrec; /* Number of records to move out of left node */ + unsigned left_nrec_move = (unsigned)(*left_nrec - new_left_nrec); /* Number of records to move out of left node */ /* Slide middle records up */ HDmemmove(H5B2_NAT_NREC(middle_native, hdr, left_nrec_move), H5B2_NAT_NREC(middle_native, hdr, 0), hdr->cls->nrec_size * curr_middle_nrec); @@ -859,7 +859,7 @@ H5B2_redistribute3(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth, unsigned u; /* Local index variable */ /* Slide the node pointers in middle node up */ - HDmemmove(&(middle_node_ptrs[left_nrec_move]), &(middle_node_ptrs[0]), sizeof(H5B2_node_ptr_t) * (curr_middle_nrec + 1)); + HDmemmove(&(middle_node_ptrs[left_nrec_move]), &(middle_node_ptrs[0]), sizeof(H5B2_node_ptr_t) * (size_t)(curr_middle_nrec + 1)); /* Move left node pointers into middle node */ HDmemcpy(&(middle_node_ptrs[0]), &(left_node_ptrs[new_left_nrec + 1]), sizeof(H5B2_node_ptr_t) * left_nrec_move); @@ -867,17 +867,17 @@ H5B2_redistribute3(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth, /* Count the number of records being moved into the left node */ for(u = 0, moved_nrec = 0; u < left_nrec_move; u++) moved_nrec += middle_node_ptrs[u].all_nrec; - left_moved_nrec -= moved_nrec + left_nrec_move; - middle_moved_nrec += moved_nrec + left_nrec_move; + left_moved_nrec -= (hssize_t)(moved_nrec + left_nrec_move); + middle_moved_nrec += (hssize_t)(moved_nrec + left_nrec_move); } /* end if */ /* Update the current number of records in middle node */ - curr_middle_nrec += left_nrec_move; + curr_middle_nrec = (uint16_t)(curr_middle_nrec + left_nrec_move); } /* end if */ /* Move records out of right node */ if(new_right_nrec < *right_nrec) { - unsigned right_nrec_move = *right_nrec - new_right_nrec; /* Number of records to move out of right node */ + unsigned right_nrec_move = (unsigned)(*right_nrec - new_right_nrec); /* Number of records to move out of right node */ /* Move right parent record down to middle node */ HDmemcpy(H5B2_NAT_NREC(middle_native, hdr, curr_middle_nrec), H5B2_INT_NREC(internal, hdr, idx), hdr->cls->nrec_size); @@ -902,11 +902,11 @@ H5B2_redistribute3(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth, /* Count the number of records being moved into the right node */ for(u = 0, moved_nrec = 0; u < right_nrec_move; u++) moved_nrec += right_node_ptrs[u].all_nrec; - right_moved_nrec -= moved_nrec + right_nrec_move; - middle_moved_nrec += moved_nrec + right_nrec_move; + right_moved_nrec -= (hssize_t)(moved_nrec + right_nrec_move); + middle_moved_nrec += (hssize_t)(moved_nrec + right_nrec_move); /* Slide the node pointers in right node down */ - HDmemmove(&(right_node_ptrs[0]), &(right_node_ptrs[right_nrec_move]), sizeof(H5B2_node_ptr_t) * (new_right_nrec + 1)); + HDmemmove(&(right_node_ptrs[0]), &(right_node_ptrs[right_nrec_move]), sizeof(H5B2_node_ptr_t) * (size_t)(new_right_nrec + 1)); } /* end if */ } /* end if */ @@ -923,9 +923,9 @@ H5B2_redistribute3(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth, /* Update total # of records in child B-trees */ if(depth > 1) { - internal->node_ptrs[idx - 1].all_nrec += left_moved_nrec; - internal->node_ptrs[idx].all_nrec += middle_moved_nrec; - internal->node_ptrs[idx + 1].all_nrec += right_moved_nrec; + internal->node_ptrs[idx - 1].all_nrec = (hsize_t)((hssize_t)internal->node_ptrs[idx - 1].all_nrec + left_moved_nrec); + internal->node_ptrs[idx].all_nrec = (hsize_t)((hssize_t)internal->node_ptrs[idx].all_nrec + middle_moved_nrec); + internal->node_ptrs[idx + 1].all_nrec = (hsize_t)((hssize_t)internal->node_ptrs[idx + 1].all_nrec + right_moved_nrec); } /* end if */ else { internal->node_ptrs[idx - 1].all_nrec = internal->node_ptrs[idx - 1].node_nrec; @@ -1100,10 +1100,10 @@ H5B2_merge2(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth, /* Copy node pointers from right node into left node */ if(depth > 1) - HDmemcpy(&(left_node_ptrs[*left_nrec + 1]), &(right_node_ptrs[0]), sizeof(H5B2_node_ptr_t) * (*right_nrec + 1)); + HDmemcpy(&(left_node_ptrs[*left_nrec + 1]), &(right_node_ptrs[0]), sizeof(H5B2_node_ptr_t) * (size_t)(*right_nrec + 1)); /* Update # of records in left node */ - *left_nrec += *right_nrec + 1; + *left_nrec = (uint16_t)(*left_nrec + *right_nrec + 1); } /* end block */ /* Update # of records in child nodes */ @@ -1261,7 +1261,7 @@ H5B2_merge3(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth, /* Redistribute records into left node */ { - unsigned total_nrec = *left_nrec + *middle_nrec + *right_nrec + 2; + unsigned total_nrec = (unsigned)(*left_nrec + *middle_nrec + *right_nrec + 2); unsigned middle_nrec_move = ((total_nrec - 1) / 2) - *left_nrec; /* Set the base number of records moved from middle node */ @@ -1291,12 +1291,12 @@ H5B2_merge3(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth, middle_moved_nrec += middle_node_ptrs[u].all_nrec; /* Slide the node pointers in right node down */ - HDmemmove(&(middle_node_ptrs[0]), &(middle_node_ptrs[middle_nrec_move]), sizeof(H5B2_node_ptr_t) * ((*middle_nrec + 1) - middle_nrec_move)); + HDmemmove(&(middle_node_ptrs[0]), &(middle_node_ptrs[middle_nrec_move]), sizeof(H5B2_node_ptr_t) * (size_t)((unsigned)(*middle_nrec + 1) - middle_nrec_move)); } /* end if */ /* Update # of records in left & middle nodes */ - *left_nrec += middle_nrec_move; - *middle_nrec -= middle_nrec_move; + *left_nrec = (uint16_t)(*left_nrec + middle_nrec_move); + *middle_nrec = (uint16_t)(*middle_nrec - middle_nrec_move); } /* end block */ /* Redistribute records into middle node */ @@ -1310,10 +1310,10 @@ H5B2_merge3(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth, /* Move node pointers also if this is an internal node */ if(depth > 1) /* Copy node pointers from middle node into left node */ - HDmemcpy(&(middle_node_ptrs[*middle_nrec + 1]), &(right_node_ptrs[0]), sizeof(H5B2_node_ptr_t) * (*right_nrec + 1)); + HDmemcpy(&(middle_node_ptrs[*middle_nrec + 1]), &(right_node_ptrs[0]), sizeof(H5B2_node_ptr_t) * (size_t)(*right_nrec + 1)); /* Update # of records in middle node */ - *middle_nrec += *right_nrec + 1; + *middle_nrec = (uint16_t)(*middle_nrec + (*right_nrec + 1)); } /* end block */ /* Update # of records in child nodes */ @@ -1796,7 +1796,7 @@ HDmemset(internal->node_ptrs, 0, sizeof(H5B2_node_ptr_t) * (hdr->node_info[depth /* Set number of records & depth of the node */ internal->nrec = 0; - internal->depth = depth; + internal->depth = (uint16_t)depth; /* Allocate space on disk for the internal node */ if(HADDR_UNDEF == (node_ptr->addr = H5MF_alloc(hdr->f, H5FD_MEM_BTREE, dxpl_id, (hsize_t)hdr->node_size))) @@ -1846,8 +1846,8 @@ H5B2_protect_internal(H5B2_hdr_t *hdr, hid_t dxpl_id, haddr_t addr, /* Set up user data for callback */ udata.hdr = hdr; - udata.nrec = nrec; - udata.depth = depth; + H5_ASSIGN_OVERFLOW(/* To: */ udata.nrec, /* From: */ nrec, /* From: */ unsigned, /* To: */ uint16_t) + H5_ASSIGN_OVERFLOW(/* To: */ udata.depth, /* From: */ depth, /* From: */ unsigned, /* To: */ uint16_t) /* Protect the internal node */ if(NULL == (ret_value = (H5B2_internal_t *)H5AC_protect(hdr->f, dxpl_id, H5AC_BT2_INT, addr, &udata, NULL, rw))) @@ -1912,7 +1912,7 @@ H5B2_iterate_node(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth, HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree internal node pointers") /* Copy the node pointers */ - HDmemcpy(node_ptrs, internal->node_ptrs, (sizeof(H5B2_node_ptr_t) * (curr_node->node_nrec + 1))); + HDmemcpy(node_ptrs, internal->node_ptrs, (sizeof(H5B2_node_ptr_t) * (size_t)(curr_node->node_nrec + 1))); } /* end if */ else { H5B2_leaf_t *leaf; /* Pointer to leaf node */ @@ -2800,7 +2800,7 @@ H5B2_delete_node(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth, native = internal->int_native; /* Descend into children */ - for(u = 0; u < internal->nrec + 1; u++) + for(u = 0; u < internal->nrec + (unsigned)1; u++) if(H5B2_delete_node(hdr, dxpl_id, depth - 1, &(internal->node_ptrs[u]), op, op_data) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTLIST, FAIL, "node descent failed") } /* end if */ @@ -2875,12 +2875,12 @@ H5B2_node_size(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth, unsigned u; /* Local index */ /* Descend into children */ - for(u = 0; u < internal->nrec + 1; u++) + for(u = 0; u < internal->nrec + (unsigned)1; u++) if(H5B2_node_size(hdr, dxpl_id, (depth - 1), &(internal->node_ptrs[u]), btree_size) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTLIST, FAIL, "node iteration failed") } /* end if */ else /* depth is 1: count all the leaf nodes from this node */ - *btree_size += (internal->nrec + 1) * hdr->node_size; + *btree_size += (hsize_t)(internal->nrec + 1) * hdr->node_size; /* Count this node */ *btree_size += hdr->node_size; diff --git a/src/H5B2pkg.h b/src/H5B2pkg.h index dd8f67b..f2f4e61 100644 --- a/src/H5B2pkg.h +++ b/src/H5B2pkg.h @@ -53,7 +53,7 @@ /* Size of a internal node pointer (on disk) */ #define H5B2_INT_POINTER_SIZE(h, d) ( \ - (h)->sizeof_addr /* Address of child node */ \ + (unsigned)(h)->sizeof_addr /* Address of child node */ \ + (h)->max_nrec_size /* # of records in child node */ \ + (h)->node_info[(d) - 1].cum_max_nrec_size /* Total # of records in child & below */ \ ) @@ -157,7 +157,7 @@ static herr_t H5C__flash_increase_cache_size(H5C_t * cache_ptr, size_t old_entry_size, size_t new_entry_size); -static herr_t H5C_flush_single_entry(const H5F_t * f, +static herr_t H5C_flush_single_entry(H5F_t * f, hid_t primary_dxpl_id, hid_t secondary_dxpl_id, const H5C_class_t * type_ptr, @@ -166,7 +166,7 @@ static herr_t H5C_flush_single_entry(const H5F_t * f, hbool_t * first_flush_ptr, hbool_t del_entry_from_slist_on_destroy); -static herr_t H5C_flush_invalidate_cache(const H5F_t * f, +static herr_t H5C_flush_invalidate_cache(H5F_t * f, hid_t primary_dxpl_id, hid_t secondary_dxpl_id, unsigned flags); @@ -726,6 +726,12 @@ H5C_def_auto_resize_rpt_fcn(H5C_t * cache_ptr, switch ( (cache_ptr->resize_ctl).decr_mode ) { + case H5C_decr__off: + HDfprintf(stdout, + "%sAuto cache resize -- decrease off. HR = %lf\n", + cache_ptr->prefix, hit_rate); + break; + case H5C_decr__threshold: HDassert( hit_rate > (cache_ptr->resize_ctl).upper_hr_threshold ); @@ -7551,7 +7557,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5C_flush_invalidate_cache(const H5F_t * f, +H5C_flush_invalidate_cache(H5F_t * f, hid_t primary_dxpl_id, hid_t secondary_dxpl_id, unsigned flags) @@ -8158,7 +8164,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5C_flush_single_entry(const H5F_t * f, +H5C_flush_single_entry(H5F_t * f, hid_t primary_dxpl_id, hid_t secondary_dxpl_id, const H5C_class_t * type_ptr, diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index 7087166..c7baa65 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -406,7 +406,7 @@ H5D_chunk_construct(H5F_t UNUSED *f, H5D_t *dset) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "external storage not supported with chunked layout") /* Set the last dimension of the chunk size to the size of the datatype */ - dset->shared->layout.u.chunk.dim[dset->shared->layout.u.chunk.ndims - 1] = H5T_GET_SIZE(type); + dset->shared->layout.u.chunk.dim[dset->shared->layout.u.chunk.ndims - 1] = (uint32_t)H5T_GET_SIZE(type); /* Get local copy of dataset dimensions (for sanity checking) */ if(H5S_get_simple_extent_dims(dset->shared->space, NULL, max_dim) < 0) @@ -1740,7 +1740,8 @@ H5D_chunk_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, io_info->store->chunk.index = chunk_info->index; /* Compute # of bytes accessed in chunk */ - src_accessed_bytes = chunk_info->chunk_points * type_info->src_type_size; + H5_CHECK_OVERFLOW(type_info->src_type_size, /*From:*/ size_t, /*To:*/ uint32_t); + src_accessed_bytes = chunk_info->chunk_points * (uint32_t)type_info->src_type_size; /* Lock the chunk into the cache */ if(NULL == (chunk = H5D_chunk_lock(io_info, &udata, FALSE, &idx_hint))) @@ -1872,7 +1873,8 @@ H5D_chunk_write(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, io_info->store->chunk.index = chunk_info->index; /* Compute # of bytes accessed in chunk */ - dst_accessed_bytes = chunk_info->chunk_points * type_info->dst_type_size; + H5_CHECK_OVERFLOW(type_info->dst_type_size, /*From:*/ size_t, /*To:*/ uint32_t); + dst_accessed_bytes = chunk_info->chunk_points * (uint32_t)type_info->dst_type_size; /* Determine if we will access all the data in the chunk */ if(dst_accessed_bytes != ctg_store.contig.dset_size || diff --git a/src/H5Dcompact.c b/src/H5Dcompact.c index 5018ca1..b12eb3d 100644 --- a/src/H5Dcompact.c +++ b/src/H5Dcompact.c @@ -172,7 +172,8 @@ done: static herr_t H5D_compact_construct(H5F_t *f, H5D_t *dset) { - hssize_t tmp_size; /* Temporary holder for raw data size */ + hssize_t stmp_size; /* Temporary holder for raw data size */ + hsize_t tmp_size; /* Temporary holder for raw data size */ hsize_t max_comp_data_size; /* Max. allowed size of compact data */ herr_t ret_value = SUCCEED; /* Return value */ @@ -186,7 +187,11 @@ H5D_compact_construct(H5F_t *f, H5D_t *dset) * Compact dataset is stored in dataset object header message of * layout. */ - tmp_size = H5S_GET_EXTENT_NPOINTS(dset->shared->space) * H5T_get_size(dset->shared->type); + stmp_size = H5S_GET_EXTENT_NPOINTS(dset->shared->space); + HDassert(stmp_size >= 0); + tmp_size = H5T_get_size(dset->shared->type); + HDassert(tmp_size > 0); + tmp_size = tmp_size * (hsize_t)stmp_size; H5_ASSIGN_OVERFLOW(dset->shared->layout.storage.u.compact.size, tmp_size, hssize_t, size_t); /* Verify data size is smaller than maximum header message size diff --git a/src/H5Defl.c b/src/H5Defl.c index 18750c8..b0233d4 100644 --- a/src/H5Defl.c +++ b/src/H5Defl.c @@ -115,7 +115,8 @@ H5D_efl_construct(H5F_t *f, H5D_t *dset) size_t dt_size; /* Size of datatype */ hsize_t dim[H5O_LAYOUT_NDIMS]; /* Current size of data in elements */ hsize_t max_dim[H5O_LAYOUT_NDIMS]; /* Maximum size of data in elements */ - hssize_t tmp_size; /* Temporary holder for raw data size */ + hssize_t stmp_size; /* Temporary holder for raw data size */ + hsize_t tmp_size; /* Temporary holder for raw data size */ hsize_t max_points; /* Maximum elements */ hsize_t max_storage; /* Maximum storage size */ int ndims; /* Rank of dataspace */ @@ -158,7 +159,9 @@ H5D_efl_construct(H5F_t *f, H5D_t *dset) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "dataspace size exceeds external storage size") /* Compute the total size of dataset */ - tmp_size = H5S_GET_EXTENT_NPOINTS(dset->shared->space) * dt_size; + stmp_size = H5S_GET_EXTENT_NPOINTS(dset->shared->space); + HDassert(stmp_size >= 0); + tmp_size = (hsize_t)stmp_size * dt_size; H5_ASSIGN_OVERFLOW(dset->shared->layout.storage.u.contig.size, tmp_size, hssize_t, hsize_t); /* Get the sieve buffer size for this dataset */ @@ -340,59 +343,58 @@ H5D_efl_write(const H5O_efl_t *efl, haddr_t addr, size_t size, const uint8_t *bu FUNC_ENTER_NOAPI_NOINIT(H5D_efl_write) /* Check args */ - HDassert(efl && efl->nused>0); + HDassert(efl && efl->nused > 0); HDassert(H5F_addr_defined(addr)); HDassert(size < SIZET_MAX); HDassert(buf || 0 == size); /* Find the first efl member in which to write */ - for (u=0, cur=0; u<efl->nused; u++) { - if (H5O_EFL_UNLIMITED==efl->slot[u].size || addr < cur+efl->slot[u].size) { + for(u = 0, cur = 0; u < efl->nused; u++) { + if(H5O_EFL_UNLIMITED == efl->slot[u].size || addr < cur + efl->slot[u].size) { skip = addr - cur; break; - } + } /* end if */ cur += efl->slot[u].size; - } + } /* end for */ /* Write the data */ - while (size) { - assert(buf); - if (u>=efl->nused) - HGOTO_ERROR (H5E_EFL, H5E_OVERFLOW, FAIL, "write past logical end of file") - if (H5F_OVERFLOW_HSIZET2OFFT (efl->slot[u].offset+skip)) - HGOTO_ERROR (H5E_EFL, H5E_OVERFLOW, FAIL, "external file address overflowed") - if ((fd=HDopen (efl->slot[u].name, O_CREAT|O_RDWR, 0666))<0) { - if (HDaccess (efl->slot[u].name, F_OK)<0) { - HGOTO_ERROR (H5E_EFL, H5E_CANTOPENFILE, FAIL, "external raw data file does not exist") - } else { - HGOTO_ERROR (H5E_EFL, H5E_CANTOPENFILE, FAIL, "unable to open external raw data file") - } - } - if (HDlseek (fd, (off_t)(efl->slot[u].offset+skip), SEEK_SET)<0) - HGOTO_ERROR (H5E_EFL, H5E_SEEKERROR, FAIL, "unable to seek in external raw data file") + while(size) { + HDassert(buf); + if(u >= efl->nused) + HGOTO_ERROR(H5E_EFL, H5E_OVERFLOW, FAIL, "write past logical end of file") + if(H5F_OVERFLOW_HSIZET2OFFT(efl->slot[u].offset + skip)) + HGOTO_ERROR(H5E_EFL, H5E_OVERFLOW, FAIL, "external file address overflowed") + if((fd = HDopen(efl->slot[u].name, O_CREAT|O_RDWR, 0666)) < 0) { + if(HDaccess(efl->slot[u].name, F_OK) < 0) + HGOTO_ERROR(H5E_EFL, H5E_CANTOPENFILE, FAIL, "external raw data file does not exist") + else + HGOTO_ERROR(H5E_EFL, H5E_CANTOPENFILE, FAIL, "unable to open external raw data file") + } /* end if */ + if(HDlseek(fd, (off_t)(efl->slot[u].offset + skip), SEEK_SET) < 0) + HGOTO_ERROR(H5E_EFL, H5E_SEEKERROR, FAIL, "unable to seek in external raw data file") #ifndef NDEBUG - tempto_write = MIN(efl->slot[u].size-skip,(hsize_t)size); - H5_CHECK_OVERFLOW(tempto_write,hsize_t,size_t); + tempto_write = MIN(efl->slot[u].size - skip, (hsize_t)size); + H5_CHECK_OVERFLOW(tempto_write, hsize_t, size_t); to_write = (size_t)tempto_write; #else /* NDEBUG */ - to_write = MIN((size_t)(efl->slot[u].size-skip), size); + to_write = MIN((size_t)(efl->slot[u].size - skip), size); #endif /* NDEBUG */ - if ((size_t)HDwrite (fd, buf, to_write)!=to_write) - HGOTO_ERROR (H5E_EFL, H5E_READERROR, FAIL, "write error in external raw data file") + if((size_t)HDwrite(fd, buf, to_write)!=to_write) + HGOTO_ERROR(H5E_EFL, H5E_READERROR, FAIL, "write error in external raw data file") HDclose (fd); fd = -1; size -= to_write; buf += to_write; skip = 0; u++; - } + } /* end while */ done: - if (fd>=0) - HDclose (fd); + if(fd >= 0) + HDclose(fd); FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5D_efl_write() */ /*------------------------------------------------------------------------- @@ -1865,9 +1865,9 @@ H5F_try_close(H5F_t *f) /* Forced close of all opened objects in this file */ if(f->nopen_objs > 0) { - unsigned obj_count; /* # of open objects */ + size_t obj_count; /* # of open objects */ hid_t objs[128]; /* Array of objects to close */ - unsigned u; /* Local index variable */ + size_t u; /* Local index variable */ /* Get the list of IDs of open dataset, group, & attribute objects */ while((obj_count = H5F_get_obj_ids(f, H5F_OBJ_LOCAL|H5F_OBJ_DATASET|H5F_OBJ_GROUP|H5F_OBJ_ATTR, (int)(sizeof(objs)/sizeof(objs[0])), objs, FALSE)) != 0) { diff --git a/src/H5Fsuper.c b/src/H5Fsuper.c index 7698654..f6aa1ac 100644 --- a/src/H5Fsuper.c +++ b/src/H5Fsuper.c @@ -459,7 +459,7 @@ H5F_super_init(H5F_t *f, hid_t dxpl_id) sblock->super_vers = super_vers; /* Compute the size of the superblock */ - superblock_size = (size_t)H5F_SUPERBLOCK_SIZE(super_vers, f); + superblock_size = (hsize_t)H5F_SUPERBLOCK_SIZE(super_vers, f); /* Compute the size of the driver information block */ H5_ASSIGN_OVERFLOW(driver_size, H5FD_sb_size(f->shared->lf), hsize_t, size_t); @@ -723,7 +723,7 @@ H5F_super_size(H5F_t *f, hid_t dxpl_id, hsize_t *super_size, hsize_t *super_ext_ /* Set the superblock size */ if(super_size) - *super_size = (size_t)H5F_SUPERBLOCK_SIZE(f->shared->sblock->super_vers, f); + *super_size = (hsize_t)H5F_SUPERBLOCK_SIZE(f->shared->sblock->super_vers, f); /* Set the superblock extension size */ if(super_ext_size) { diff --git a/src/H5Fsuper_cache.c b/src/H5Fsuper_cache.c index 78cb3565..cb74322 100644 --- a/src/H5Fsuper_cache.c +++ b/src/H5Fsuper_cache.c @@ -763,7 +763,7 @@ H5F_sblock_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t UNUSED addr, } /* end else */ /* Retrieve the total size of the superblock info */ - H5_ASSIGN_OVERFLOW(superblock_size, (p - buf), int, size_t); + H5_ASSIGN_OVERFLOW(superblock_size, (p - buf), ptrdiff_t, size_t); /* Double check we didn't overrun the block (unlikely) */ HDassert(superblock_size <= sizeof(buf)); diff --git a/src/H5Tbit.c b/src/H5Tbit.c index a5340a6..2c289b0 100644 --- a/src/H5Tbit.c +++ b/src/H5Tbit.c @@ -24,9 +24,10 @@ #include "H5private.h" /*generic functions */ #include "H5Eprivate.h" /*error handling */ -#include "H5Iprivate.h" /*ID functions */ #include "H5MMprivate.h" /* Memory management */ #include "H5Tpkg.h" /*data-type functions */ +#include "H5WBprivate.h" /* Wrapped Buffers */ + /*------------------------------------------------------------------------- @@ -39,24 +40,22 @@ * Programmer: Robb Matzke * Wednesday, June 10, 1998 * - * Modifications: - * *------------------------------------------------------------------------- */ void -H5T_bit_copy (uint8_t *dst, size_t dst_offset, const uint8_t *src, - size_t src_offset, size_t size) +H5T_bit_copy(uint8_t *dst, size_t dst_offset, const uint8_t *src, + size_t src_offset, size_t size) { - int shift; - unsigned mask_lo, mask_hi; - int s_idx, d_idx; + unsigned shift; + unsigned mask_lo, mask_hi; + unsigned s_idx, d_idx; /* * Normalize the offset to be a byte number and a bit offset within that * byte. */ - s_idx = (int)src_offset / 8; - d_idx = (int)dst_offset / 8; + s_idx = src_offset / 8; + d_idx = dst_offset / 8; src_offset %= 8; dst_offset %= 8; @@ -76,25 +75,27 @@ H5T_bit_copy (uint8_t *dst, size_t dst_offset, const uint8_t *src, * ...+---------------+---------------+ * dst[d_idx+1] dst[d_idx] */ - while (src_offset && size>0) { - unsigned nbits = (unsigned)MIN3 (size, 8-dst_offset, 8-src_offset); - unsigned mask = (1<<nbits) - 1; + while(src_offset && size > 0) { + unsigned nbits = MIN3(size, 8 - dst_offset, 8 - src_offset); + unsigned mask = ((unsigned)1 << nbits) - 1; - dst[d_idx] &= ~(mask<<dst_offset); - dst[d_idx] |= ((src[s_idx]>>src_offset)&mask) << dst_offset; + dst[d_idx] &= (uint8_t)~(mask << dst_offset); + dst[d_idx] |= (uint8_t)(((src[s_idx] >> src_offset) & (uint8_t)mask) << dst_offset); src_offset += nbits; - if (src_offset>=8) { + if(src_offset >= 8) { s_idx++; src_offset %= 8; - } + } /* end if */ + dst_offset += nbits; - if (dst_offset>=8) { + if(dst_offset >= 8) { d_idx++; dst_offset %= 8; - } + } /* end if */ + size -= nbits; - } + } /* end while */ /* * The middle bits. We are aligned on a source byte which needs to be @@ -117,42 +118,44 @@ H5T_bit_copy (uint8_t *dst, size_t dst_offset, const uint8_t *src, * bits). SHIFT is three since the source must be shifted right three bits * to line up with the destination. */ - shift = (int)dst_offset; - mask_lo = (1<<(8-shift))-1; + shift = dst_offset; + mask_lo = ((unsigned)1 << (8 - shift)) - 1; mask_hi = (~mask_lo) & 0xff; - for (/*void*/; size>8; size-=8, d_idx++, s_idx++) { - if (shift) { - dst[d_idx+0] &= ~(mask_lo<<shift); - dst[d_idx+0] |= (src[s_idx] & mask_lo) << shift; - dst[d_idx+1] &= ~(mask_hi>>(8-shift)); - dst[d_idx+1] |= (src[s_idx] & mask_hi) >> (8-shift); - } else { + for(/*void*/; size > 8; size -= 8, d_idx++, s_idx++) { + if(shift) { + dst[d_idx + 0] &= (uint8_t)(~(mask_lo << shift)); + dst[d_idx + 0] |= (uint8_t)((src[s_idx] & mask_lo) << shift); + dst[d_idx + 1] &= (uint8_t)(~(mask_hi >> (8 - shift))); + dst[d_idx + 1] |= (uint8_t)((src[s_idx] & mask_hi) >> (8 - shift)); + } /* end if */ + else dst[d_idx] = src[s_idx]; - } - } + } /* end for */ /* Finish up */ - while (size>0) { - unsigned nbits = (unsigned)MIN3 (size, 8-dst_offset, 8-src_offset); - unsigned mask = (1<<nbits) - 1; + while(size > 0) { + unsigned nbits = (unsigned)MIN3 (size, 8 - dst_offset, 8 - src_offset); + unsigned mask = ((unsigned)1 << nbits) - 1; - dst[d_idx] &= ~(mask<<dst_offset); - dst[d_idx] |= ((src[s_idx]>>src_offset)&mask) << dst_offset; + dst[d_idx] &= (uint8_t)(~(mask << dst_offset)); + dst[d_idx] |= (uint8_t)(((src[s_idx] >> src_offset) & (uint8_t)mask) << dst_offset); src_offset += nbits; - if (src_offset>=8) { + if(src_offset >= 8) { s_idx++; src_offset %= 8; - } + } /* end if */ + dst_offset += nbits; - if (dst_offset>=8) { + if(dst_offset >= 8) { d_idx++; dst_offset %= 8; - } + } /* end if */ + size -= nbits; - } -} + } /* end while */ +} /* end H5T_bit_copy() */ /*------------------------------------------------------------------------- @@ -173,54 +176,64 @@ H5T_bit_copy (uint8_t *dst, size_t dst_offset, const uint8_t *src, * Programmer: Raymond Lu * Monday, April 12, 2004 * - * Modifications: - * *------------------------------------------------------------------------- */ -void -H5T_bit_shift (uint8_t *buf, ssize_t shift_dist, size_t offset, size_t size) +herr_t +H5T_bit_shift(uint8_t *buf, ssize_t shift_dist, size_t offset, size_t size) { - uint8_t *tmp_buf; + uint8_t tmp_buf[512]; /* Temporary buffer */ + H5WB_t *wb = NULL; /* Wrapped buffer for temporary buffer */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5T_bit_shift); + FUNC_ENTER_NOAPI(H5T_bit_shift, FAIL) /* Sanity check */ - assert(buf); - assert(size); - - if(!shift_dist) - goto done; - if((size_t)ABS(shift_dist) >= size) { - H5T_bit_set(buf, offset, size, 0); - goto done; - } - - tmp_buf = (uint8_t*)H5MM_calloc(size/8+1); - assert(tmp_buf); - - /* Shift vector by making copies */ - if(shift_dist > 0) { /* left shift */ - /* Copy part to be shifted to a temporary buffer */ - H5T_bit_copy(tmp_buf, (size_t)0, buf, offset, (size_t)(size - shift_dist)); - - /* Copy it back to the original buffer */ - H5T_bit_copy(buf, offset + shift_dist, tmp_buf, (size_t)0, (size_t)(size - shift_dist)); - - /* Zero-set the left part*/ - H5T_bit_set(buf, offset, (size_t)shift_dist, 0); - } else { /* right shift */ - shift_dist = - shift_dist; - H5T_bit_copy(tmp_buf, (size_t)0, buf, offset + shift_dist, (size_t)(size - shift_dist)); - H5T_bit_copy (buf, offset, tmp_buf, (size_t)0, (size_t)(size - shift_dist)); - H5T_bit_set(buf, offset + size - shift_dist, (size_t)shift_dist, 0); - } - - /* Free temporary buffer */ - H5MM_xfree(tmp_buf); + HDassert(buf); + HDassert(size); + + if(shift_dist) { + size_t abs_shift_dist = (size_t)ABS(shift_dist); + + if(abs_shift_dist >= size) + H5T_bit_set(buf, offset, size, 0); + else { + size_t buf_size = (size / 8) + 1; /* Size of shift buffer needed */ + uint8_t *shift_buf; /* Pointer to shift buffer */ + + /* Wrap the local buffer for serialized header info */ + if(NULL == (wb = H5WB_wrap(tmp_buf, sizeof(tmp_buf)))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "can't wrap buffer") + + /* Get a pointer to a buffer that's large enough */ + if(NULL == (shift_buf = (uint8_t *)H5WB_actual(wb, buf_size))) + HGOTO_ERROR(H5E_DATATYPE, H5E_NOSPACE, FAIL, "can't get actual buffer") + + /* Shift vector by making copies */ + if(shift_dist > 0) { /* left shift */ + /* Copy part to be shifted to a temporary buffer */ + H5T_bit_copy(shift_buf, (size_t)0, buf, offset, size - abs_shift_dist); + + /* Copy it back to the original buffer */ + H5T_bit_copy(buf, offset + abs_shift_dist, shift_buf, (size_t)0, size - abs_shift_dist); + + /* Zero-set the left part*/ + H5T_bit_set(buf, offset, abs_shift_dist, 0); + } /* end if */ + else { /* right shift */ + H5T_bit_copy(shift_buf, (size_t)0, buf, offset + abs_shift_dist, size - abs_shift_dist); + H5T_bit_copy(buf, offset, shift_buf, (size_t)0, size - abs_shift_dist); + H5T_bit_set(buf, offset + size - abs_shift_dist, abs_shift_dist, 0); + } /* end else */ + } /* end else */ + } /* end if */ done: - FUNC_LEAVE_NOAPI_VOID -} + /* Release resources */ + if(wb && H5WB_unwrap(wb) < 0) + HDONE_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "can't close wrapped buffer") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5T_bit_shift() */ /*------------------------------------------------------------------------- @@ -237,20 +250,18 @@ done: * Programmer: Robb Matzke * Tuesday, June 23, 1998 * - * Modifications: - * *------------------------------------------------------------------------- */ uint64_t -H5T_bit_get_d (uint8_t *buf, size_t offset, size_t size) +H5T_bit_get_d(uint8_t *buf, size_t offset, size_t size) { - uint64_t val=0; + uint64_t val = 0; size_t i, hs; uint64_t ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOFUNC(H5T_bit_get_d) - assert (8*sizeof(val)>=size); + HDassert(8 * sizeof(val) >= size); H5T_bit_copy((uint8_t*)&val, (size_t)0, buf, offset, size); switch(H5T_native_order_g) { @@ -262,20 +273,23 @@ H5T_bit_get_d (uint8_t *buf, size_t offset, size_t size) uint8_t tmp = ((uint8_t*)&val)[i]; ((uint8_t*)&val)[i] = ((uint8_t*)&val)[sizeof(val) - (i + 1)]; ((uint8_t*)&val)[sizeof(val) - (i + 1)] = tmp; - } + } /* end for */ break; + case H5T_ORDER_ERROR: + case H5T_ORDER_VAX: + case H5T_ORDER_NONE: default: /* Unknown endianness. Bail out. */ HGOTO_DONE(UFAIL) - } + } /* end switch */ /* Set return value */ ret_value = val; done: FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5T_bit_get_d() */ /*------------------------------------------------------------------------- @@ -288,35 +302,36 @@ done: * Programmer: Robb Matzke * Wednesday, June 24, 1998 * - * Modifications: - * *------------------------------------------------------------------------- */ void -H5T_bit_set_d (uint8_t *buf, size_t offset, size_t size, uint64_t val) +H5T_bit_set_d(uint8_t *buf, size_t offset, size_t size, uint64_t val) { size_t i, hs; - assert (8*sizeof(val)>=size); + HDassert(8 * sizeof(val) >= size); - switch (H5T_native_order_g) { + switch(H5T_native_order_g) { case H5T_ORDER_LE: break; case H5T_ORDER_BE: - for (i=0, hs=sizeof(val)/2; i<hs; i++) { - uint8_t tmp = ((uint8_t*)&val)[i]; - ((uint8_t*)&val)[i] = ((uint8_t*)&val)[sizeof(val)-(i+1)]; - ((uint8_t*)&val)[sizeof(val)-(i+1)] = tmp; - } + for(i = 0, hs = sizeof(val) / 2; i < hs; i++) { + uint8_t tmp = ((uint8_t *)&val)[i]; + ((uint8_t *)&val)[i] = ((uint8_t *)&val)[sizeof(val) - (i + 1)]; + ((uint8_t *)&val)[sizeof(val) - (i + 1)] = tmp; + } /* end for */ break; + case H5T_ORDER_ERROR: + case H5T_ORDER_VAX: + case H5T_ORDER_NONE: default: - HDabort (); - } + HDabort(); + } /* end switch */ H5T_bit_copy(buf, offset, (uint8_t*)&val, (size_t)0, size); -} +} /* end H5T_bit_set_d() */ /*------------------------------------------------------------------------- @@ -335,7 +350,7 @@ H5T_bit_set_d (uint8_t *buf, size_t offset, size_t size, uint64_t val) *------------------------------------------------------------------------- */ void -H5T_bit_set (uint8_t *buf, size_t offset, size_t size, hbool_t value) +H5T_bit_set(uint8_t *buf, size_t offset, size_t size, hbool_t value) { int idx; @@ -344,32 +359,31 @@ H5T_bit_set (uint8_t *buf, size_t offset, size_t size, hbool_t value) offset %= 8; /* The first partial byte */ - if (size && offset%8) { - size_t nbits = MIN (size, 8-offset); - unsigned mask = (1<<nbits)-1; - if (value) { - buf[idx++] |= mask << offset; - } else { - buf[idx++] &= ~(mask << offset); - } + if(size && offset % 8) { + size_t nbits = MIN(size, 8 - offset); + unsigned mask = ((unsigned)1 << nbits) - 1; + + if(value) + buf[idx++] |= (uint8_t)(mask << offset); + else + buf[idx++] &= (uint8_t)(~(mask << offset)); size -= nbits; - } + } /* end if */ /* The middle bytes */ - while (size>=8) { + while(size >= 8) { buf[idx++] = value ? 0xff : 0x00; size -= 8; - } + } /* end while */ /* The last partial byte */ - if (size) { - if (value) { - buf[idx] |= (1<<size)-1; - } else { - buf[idx] &= ~((1<<size)-1); - } - } -} + if(size) { + if(value) + buf[idx] |= (uint8_t)(((unsigned)1 << size) - 1); + else + buf[idx] &= (uint8_t)(~(((unsigned)1 << size) - 1)); + } /* end if */ +} /* end H5T_bit_set() */ /*------------------------------------------------------------------------- @@ -390,8 +404,6 @@ H5T_bit_set (uint8_t *buf, size_t offset, size_t size, hbool_t value) * Programmer: Robb Matzke * Wednesday, June 10, 1998 * - * Modifications: - * *------------------------------------------------------------------------- */ ssize_t @@ -401,10 +413,10 @@ H5T_bit_find(uint8_t *buf, size_t offset, size_t size, H5T_sdir_t direction, ssize_t base = (ssize_t)offset; ssize_t idx, i; size_t iu; - ssize_t ret_value=(-1); /* Return value */ + ssize_t ret_value = (-1); /* Return value */ /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5T_bit_find); + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5T_bit_find) /* Some functions call this with value=TRUE */ HDassert(TRUE == 1); @@ -416,63 +428,64 @@ H5T_bit_find(uint8_t *buf, size_t offset, size_t size, H5T_sdir_t direction, offset %= 8; /* Beginning */ - if (offset) { - for (iu=offset; iu<8 && size>0; iu++, size--) { - if (value==(hbool_t)((buf[idx]>>iu) & 0x01)) - HGOTO_DONE(8*idx+(ssize_t)iu - base); - } + if(offset) { + for(iu = offset; iu < 8 && size > 0; iu++, size--) + if(value == (hbool_t)((buf[idx] >> iu) & 0x01)) + HGOTO_DONE(8 * idx + (ssize_t)iu - base); + offset = 0; idx++; - } + } /* end if */ + /* Middle */ - while (size>=8) { - if ((value?0x00:0xff)!=buf[idx]) { - for (i=0; i<8; i++) { - if (value==(hbool_t)((buf[idx]>>i) & 0x01)) - HGOTO_DONE(8*idx+i - base); - } - } + while(size >= 8) { + if((value ? 0x00 : 0xff) != buf[idx]) + for(i = 0; i < 8; i++) + if(value == (hbool_t)((buf[idx] >> i) & 0x01)) + HGOTO_DONE(8 * idx + i - base); + size -= 8; idx++; - } + } /* end while */ + /* End */ - for (i=0; i<(ssize_t)size; i++) { - if (value==(hbool_t)((buf[idx]>>i) & 0x01)) - HGOTO_DONE(8*idx+i - base); - } + for(i = 0; i < (ssize_t)size; i++) + if(value == (hbool_t)((buf[idx] >> i) & 0x01)) + HGOTO_DONE(8 * idx + i - base); break; case H5T_BIT_MSB: /* Calculate index */ - idx = (ssize_t)((offset+size-1) / 8); + idx = (ssize_t)((offset + size - 1) / 8); offset %= 8; /* Beginning */ - if (size>8-offset && (offset+size)%8) { - for (iu=(offset+size)%8; iu>0; --iu, --size) { - if (value==(hbool_t)((buf[idx]>>(iu-1)) & 0x01)) - HGOTO_DONE(8*idx+(ssize_t)(iu-1) - base); - } + if(size > 8 - offset && (offset + size) % 8) { + for(iu = (offset + size) % 8; iu > 0; --iu, --size) + if(value == (hbool_t)((buf[idx] >> (iu - 1)) & 0x01)) + HGOTO_DONE(8 * idx + (ssize_t)(iu - 1) - base); + --idx; - } + } /* end if */ + /* Middle */ - while (size>=8) { - if ((value?0x00:0xff)!=buf[idx]) { - for (i=7; i>=0; --i) { - if (value==(hbool_t)((buf[idx]>>i) & 0x01)) - HGOTO_DONE(8*idx+i - base); - } - } + while(size >= 8) { + if((value ? 0x00 : 0xff) != buf[idx]) { + for(i = 7; i >= 0; --i) + if(value == (hbool_t)((buf[idx] >> i) & 0x01)) + HGOTO_DONE(8 * idx + i - base); + } /* end if */ + size -= 8; --idx; - } + } /* end while */ + /* End */ - if (size>0) { - for (iu=offset+size; iu>offset; --iu) { - if (value==(hbool_t)((buf[idx]>>(iu-1)) & 0x01)) - HGOTO_DONE(8*idx+(ssize_t)(iu-1) - base); - } - } + if(size > 0) { + for(iu = offset + size; iu > offset; --iu) + if(value == (hbool_t)((buf[idx] >> (iu - 1)) & 0x01)) + HGOTO_DONE(8 * idx + (ssize_t)(iu - 1) - base); + } /* end if */ break; default: @@ -480,7 +493,7 @@ H5T_bit_find(uint8_t *buf, size_t offset, size_t size, H5T_sdir_t direction, } /* end switch */ done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_bit_find() */ @@ -498,8 +511,6 @@ done: * Programmer: Robb Matzke * Friday, June 26, 1998 * - * Modifications: - * *------------------------------------------------------------------------- */ htri_t @@ -510,47 +521,50 @@ H5T_bit_inc(uint8_t *buf, size_t start, size_t size) unsigned acc, mask; /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5T_bit_inc); + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5T_bit_inc) + + HDassert(buf); - assert(buf); start %= 8; /* The first partial byte */ - if (start) { - if (size+start<8) mask = (1<<size)-1; - else mask = (1<<(8-start))-1; - acc = (buf[idx]>>start) & mask; + if(start) { + if(size + start < 8) + mask = ((unsigned)1 << size) - 1; + else + mask = ((unsigned)1 << (8 - start)) - 1; + acc = ((unsigned)buf[idx] >> start) & mask; acc += 1; - carry = acc & (1<<MIN(size, 8-start)); - buf[idx] &= ~(mask<<start); - buf[idx] |= (acc & mask) << start; - size -= MIN(size, 8-start); - start=0; + carry = acc & ((unsigned)1 << MIN(size, 8 - start)); + buf[idx] &= (uint8_t)(~(mask << start)); + buf[idx] |= (uint8_t)((acc & mask) << start); + size -= MIN(size, 8 - start); + start = 0; idx++; - } + } /* end if */ /* The middle */ - while (carry && size>=8) { + while(carry && size >= 8) { acc = buf[idx]; acc += 1; carry = acc & 0x100; buf[idx] = acc & 0xff; idx++; size -= 8; - } + } /* end while */ /* The last bits */ - if (carry && size>0) { - mask = (1<<size)-1; + if(carry && size > 0) { + mask = ((unsigned)1 << size) - 1; acc = buf[idx] & mask; acc += 1; - carry = acc & (1<<size); - buf[idx] &= ~mask; - buf[idx] |= acc & mask; - } + carry = acc & ((unsigned)1 << size); + buf[idx] &= (uint8_t)(~mask); + buf[idx] |= (uint8_t)(acc & mask); + } /* end if */ - FUNC_LEAVE_NOAPI(carry ? TRUE : FALSE); -} + FUNC_LEAVE_NOAPI(carry ? TRUE : FALSE) +} /* end H5T_bit_inc() */ /*------------------------------------------------------------------------- @@ -567,8 +581,6 @@ H5T_bit_inc(uint8_t *buf, size_t start, size_t size) * Programmer: Raymond Lu * March 17, 2004 * - * Modifications: - * *------------------------------------------------------------------------- */ htri_t @@ -580,13 +592,13 @@ H5T_bit_dec(uint8_t *buf, size_t start, size_t size) unsigned borrow = 0; /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5T_bit_dec); + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5T_bit_dec) - assert(buf); - assert(size); + HDassert(buf); + HDassert(size); /* The first partial byte */ - if ((size+start-1)/8 > idx) { /*bit sequence doesn't end in the same byte as starts*/ + if((size + start - 1) / 8 > idx) { /*bit sequence doesn't end in the same byte as starts*/ /* Example: a sequence like 11000100 and start = 3. We substract 00001000 from * it and get 10111100. If a sequence is 00000111, we do right shift for START * bits and get 00000000. So we need to borrow from higher byte when we substract @@ -597,42 +609,41 @@ H5T_bit_dec(uint8_t *buf, size_t start, size_t size) buf[idx] -= 1 << pos; idx++; size -= (8 - pos); - } else { /* bit sequence ends in the same byte as starts */ + + /* The middle bytes */ + while(borrow && size >= 8) { + if(buf[idx]) + borrow = 0; + buf[idx] -= 1; + + idx++; + size -= 8; + } /* end while */ + + /* The last partial byte */ + if(borrow && size > 0) { + /* Similar to the first byte case, where sequence ends in the same byte as starts */ + tmp = buf[idx]; + buf[idx] -= 1; + if((buf[idx] >> size) != tmp >> size) + buf[idx] += 1 << size; + } /* end if */ + } /* end if */ + else { /* bit sequence ends in the same byte as starts */ /* Example: a sequence like 11000100 and pos=3, size=3. We substract 00001000 * and get 10111100. A bit is borrowed from 6th bit(buf[idx]>>6=00000010, tmp>>6=00000011, * not equal). We need to put this bit back by increment 1000000. */ tmp = buf[idx]; buf[idx] -= 1 << pos; - if((buf[idx] >> (pos+size)) != tmp >> (pos+size)) { - buf[idx] += 1 << (pos+size); + if((buf[idx] >> (pos + size)) != tmp >> (pos + size)) { + buf[idx] += 1 << (pos + size); borrow = 1; - } - goto done; - } + } /* end if */ + } /* end else */ - /* The middle bytes */ - while (borrow && size>=8) { - if(buf[idx]) - borrow = 0; - buf[idx] -= 1; - - idx++; - size -= 8; - } - - /* The last partial byte */ - if (borrow && size>0) { - /* Similar to the first byte case, where sequence ends in the same byte as starts */ - tmp = buf[idx]; - buf[idx] -= 1; - if((buf[idx] >> size) != tmp >> size) - buf[idx] += 1 << size; - } - -done: - FUNC_LEAVE_NOAPI(borrow ? TRUE : FALSE); -} + FUNC_LEAVE_NOAPI(borrow ? TRUE : FALSE) +} /* end H5T_bit_dec() */ /*------------------------------------------------------------------------- @@ -646,8 +657,6 @@ done: * Programmer: Raymond Lu * March 19, 2004 * - * Modifications: - * *------------------------------------------------------------------------- */ void @@ -660,38 +669,37 @@ H5T_bit_neg(uint8_t *buf, size_t start, size_t size) /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5T_bit_neg); - assert(buf); - assert(size); + HDassert(buf); + HDassert(size); /* The first partial byte */ tmp = buf[idx]; - tmp = ~tmp; + tmp = (uint8_t)~tmp; /* Simply copy the negated bit field back to the original byte */ - if((size+start-1)/8 > idx) { /*bit sequence doesn't end in the same byte as starts*/ - H5T_bit_copy (&(buf[idx]), pos, &tmp, pos, (8-pos)); + if((size + start - 1) / 8 > idx) { /*bit sequence doesn't end in the same byte as starts*/ + H5T_bit_copy(&(buf[idx]), pos, &tmp, pos, (8-pos)); idx++; size -= (8 - pos); - } else { /* bit sequence ends in the same byte as starts */ - H5T_bit_copy (&(buf[idx]), pos, &tmp, pos, size); - goto done; - } - - /* The middle bytes */ - while (size>=8) { - buf[idx] = ~(buf[idx]); - idx++; - size -= 8; - } - /* The last partial byte */ - if(size > 0) { - /* Similar to the first byte case, where sequence ends in the same byte as starts */ - tmp = buf[idx]; - tmp = ~tmp; - H5T_bit_copy(&(buf[idx]), (size_t)0, &tmp, (size_t)0, size); - } + /* The middle bytes */ + while(size >= 8) { + buf[idx] = (uint8_t)~(buf[idx]); + idx++; + size -= 8; + } /* end while */ + + /* The last partial byte */ + if(size > 0) { + /* Similar to the first byte case, where sequence ends in the same byte as starts */ + tmp = buf[idx]; + tmp = (uint8_t)~tmp; + H5T_bit_copy(&(buf[idx]), (size_t)0, &tmp, (size_t)0, size); + } /* end if */ + } /* end if */ + else /* bit sequence ends in the same byte as starts */ + H5T_bit_copy(&(buf[idx]), pos, &tmp, pos, size); -done: FUNC_LEAVE_NOAPI_VOID -} +} /* end H5T_bit_neg() */ + 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 diff --git a/src/H5Tpkg.h b/src/H5Tpkg.h index 45b0e7f..0ec9632 100644 --- a/src/H5Tpkg.h +++ b/src/H5Tpkg.h @@ -1363,7 +1363,7 @@ H5_DLL herr_t H5T_conv_ldouble_ullong(hid_t src_id, hid_t dst_id, /* Bit twiddling functions */ H5_DLL void H5T_bit_copy(uint8_t *dst, size_t dst_offset, const uint8_t *src, size_t src_offset, size_t size); -H5_DLL void H5T_bit_shift(uint8_t *buf, ssize_t shift_dist, size_t offset, size_t size); +H5_DLL herr_t H5T_bit_shift(uint8_t *buf, ssize_t shift_dist, size_t offset, size_t size); H5_DLL void H5T_bit_set(uint8_t *buf, size_t offset, size_t size, hbool_t value); H5_DLL uint64_t H5T_bit_get_d(uint8_t *buf, size_t offset, size_t size); diff --git a/src/H5Zscaleoffset.c b/src/H5Zscaleoffset.c index 5927713..5737702 100644 --- a/src/H5Zscaleoffset.c +++ b/src/H5Zscaleoffset.c @@ -35,17 +35,17 @@ typedef struct { unsigned mem_order; /* current memory endianness order */ } parms_atomic; -enum H5Z_scaleoffset_type {t_bad=0, t_uchar=1, t_ushort, t_uint, t_ulong, t_ulong_long, +enum H5Z_scaleoffset_t {t_bad=0, t_uchar=1, t_ushort, t_uint, t_ulong, t_ulong_long, t_schar, t_short, t_int, t_long, t_long_long, t_float, t_double}; /* Local function prototypes */ static double H5Z_scaleoffset_rnd(double val); static herr_t H5Z_can_apply_scaleoffset(hid_t dcpl_id, hid_t type_id, hid_t space_id); -static enum H5Z_scaleoffset_type H5Z_scaleoffset_get_type(unsigned dtype_class, +static enum H5Z_scaleoffset_t H5Z_scaleoffset_get_type(unsigned dtype_class, unsigned dtype_size, unsigned dtype_sign); static herr_t H5Z_scaleoffset_set_parms_fillval(H5P_genplist_t *dcpl_plist, - const H5T_t *type, enum H5Z_scaleoffset_type scale_type, unsigned cd_values[], + const H5T_t *type, enum H5Z_scaleoffset_t scale_type, unsigned cd_values[], int need_convert, hid_t dxpl_id); static herr_t H5Z_set_local_scaleoffset(hid_t dcpl_id, hid_t type_id, hid_t space_id); static size_t H5Z_filter_scaleoffset(unsigned flags, size_t cd_nelmts, @@ -53,32 +53,32 @@ static size_t H5Z_filter_scaleoffset(unsigned flags, size_t cd_nelmts, static void H5Z_scaleoffset_convert(void *buf, unsigned d_nelmts, size_t dtype_size); static unsigned H5Z_scaleoffset_log2(unsigned long long num); static void H5Z_scaleoffset_precompress_i(void *data, unsigned d_nelmts, - enum H5Z_scaleoffset_type type, unsigned filavail, const void *filval_buf, + enum H5Z_scaleoffset_t type, unsigned filavail, const void *filval_buf, uint32_t *minbits, unsigned long long *minval); static void H5Z_scaleoffset_postdecompress_i(void *data, unsigned d_nelmts, - enum H5Z_scaleoffset_type type, unsigned filavail, const void *filval_buf, + enum H5Z_scaleoffset_t type, unsigned filavail, const void *filval_buf, uint32_t minbits, unsigned long long minval); static herr_t H5Z_scaleoffset_precompress_fd(void *data, unsigned d_nelmts, - enum H5Z_scaleoffset_type type, unsigned filavail, const void *filval_buf, + enum H5Z_scaleoffset_t type, unsigned filavail, const void *filval_buf, uint32_t *minbits, unsigned long long *minval, double D_val); static herr_t H5Z_scaleoffset_postdecompress_fd(void *data, unsigned d_nelmts, - enum H5Z_scaleoffset_type type, unsigned filavail, const void *filval_buf, + enum H5Z_scaleoffset_t type, unsigned filavail, const void *filval_buf, uint32_t minbits, unsigned long long minval, double D_val); -static void H5Z_scaleoffset_next_byte(size_t *j, int *buf_len); +static void H5Z_scaleoffset_next_byte(size_t *j, unsigned *buf_len); static void H5Z_scaleoffset_decompress_one_byte(unsigned char *data, size_t data_offset, - int k, int begin_i, unsigned char *buffer, size_t *j, int *buf_len, - parms_atomic p, int dtype_len); + unsigned k, unsigned begin_i, unsigned char *buffer, size_t *j, unsigned *buf_len, + parms_atomic p, unsigned dtype_len); static void H5Z_scaleoffset_compress_one_byte(unsigned char *data, size_t data_offset, - int k, int begin_i, unsigned char *buffer, size_t *j, int *buf_len, - parms_atomic p, int dtype_len); + unsigned k, unsigned begin_i, unsigned char *buffer, size_t *j, unsigned *buf_len, + parms_atomic p, unsigned dtype_len); static void H5Z_scaleoffset_decompress_one_atomic(unsigned char *data, size_t data_offset, - unsigned char *buffer, size_t *j, int *buf_len, parms_atomic p); + unsigned char *buffer, size_t *j, unsigned *buf_len, parms_atomic p); static void H5Z_scaleoffset_compress_one_atomic(unsigned char *data, size_t data_offset, - unsigned char *buffer, size_t *j, int *buf_len, parms_atomic p); + unsigned char *buffer, size_t *j, unsigned *buf_len, parms_atomic p); static void H5Z_scaleoffset_decompress(unsigned char *data, unsigned d_nelmts, - unsigned char *buffer, parms_atomic p); + unsigned char *buffer, parms_atomic p); static void H5Z_scaleoffset_compress(unsigned char *data, unsigned d_nelmts, unsigned char *buffer, - size_t buffer_size, parms_atomic p); + size_t buffer_size, parms_atomic p); /* This message derives from H5Z */ H5Z_class2_t H5Z_SCALEOFFSET[1] = {{ @@ -119,15 +119,25 @@ H5Z_class2_t H5Z_SCALEOFFSET[1] = {{ /* Store fill value in cd_values[] */ #define H5Z_scaleoffset_save_filval(type, cd_values, fill_val) \ { \ - unsigned i; /* index */ \ + unsigned char *fill_parm; /* Pointer to fill value parameter */ \ \ /* Store the fill value as the last entry in cd_values[] \ * Store byte by byte from least significant byte to most significant byte \ * Plenty of space left for the fill value (from index 8 to 19) \ */ \ - for(i = 0; i < sizeof(type); i++) \ - ((unsigned char *)&cd_values[H5Z_SCALEOFFSET_PARM_FILVAL])[i] = \ - (unsigned char)((fill_val & ((type)0xff << i * 8)) >> i * 8); \ + fill_parm = (unsigned char *)&cd_values[H5Z_SCALEOFFSET_PARM_FILVAL]; \ + if(H5T_native_order_g == H5T_ORDER_LE) \ + HDmemcpy(fill_parm, &fill_val, sizeof(type)); \ + else { \ + unsigned char *fill_buf; /* Pointer to fill value in memory */ \ + unsigned u; /* index */ \ + \ + HDassert(H5T_native_order_g == H5T_ORDER_BE); \ + \ + fill_buf = (unsigned char *)&fill_val; \ + for(u = 0; u < sizeof(type); u++) \ + fill_parm[u] = fill_buf[sizeof(type) - (u + 1)]; \ + } /* end else */ \ } /* Set the fill value parameter in cd_values[] for unsigned integer type */ @@ -170,57 +180,54 @@ H5Z_class2_t H5Z_SCALEOFFSET[1] = {{ HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "unable to get fill value") \ \ /* Store the fill value as the last entry in cd_values[] */ \ - ((unsigned char *)&cd_values[H5Z_SCALEOFFSET_PARM_FILVAL])[0] = fill_val; \ + ((unsigned char *)&cd_values[H5Z_SCALEOFFSET_PARM_FILVAL])[0] = (unsigned char)fill_val; \ } /* Set the fill value parameter in cd_values[] for floating-point type */ #define H5Z_scaleoffset_set_filval_4(type, dcpl_plist, dt, cd_values, need_convert, dxpl_id)\ -{ \ - type fill_val; \ - \ - /* Get dataset fill value */ \ - if(H5P_get_fill_value(dcpl_plist, dt, &fill_val, dxpl_id) < 0) \ - HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "unable to get fill value") \ - \ - if(need_convert) \ - H5Z_scaleoffset_convert(&fill_val, 1, sizeof(type)); \ - \ - if(sizeof(type) == sizeof(int)) \ - H5Z_scaleoffset_save_filval(unsigned int, cd_values, *(int *)&fill_val) \ - else if(sizeof(type) == sizeof(long)) \ - H5Z_scaleoffset_save_filval(unsigned long, cd_values, *(long *)&fill_val) \ - else if(sizeof(type) == sizeof(long long)) \ - H5Z_scaleoffset_save_filval(unsigned long long, cd_values, *(long long *)&fill_val)\ - else \ - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer dataype")\ +{ \ + type fill_val; \ + \ + /* Get dataset fill value */ \ + if(H5P_get_fill_value(dcpl_plist, dt, &fill_val, dxpl_id) < 0) \ + HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "unable to get fill value") \ + \ + if(need_convert) \ + H5Z_scaleoffset_convert(&fill_val, 1, sizeof(type)); \ + \ + H5Z_scaleoffset_save_filval(type, cd_values, fill_val) \ } /* Get the fill value for integer type */ -#define H5Z_scaleoffset_get_filval_1(i, type, filval_buf, filval) \ +#define H5Z_scaleoffset_get_filval_1(type, filval_buf, filval) \ { \ - type filval_mask; \ + const unsigned char *fill_parm; /* Pointer to fill value parameter */ \ + \ + /* retrieve fill value from corresponding positions of cd_values[] \ + * retrieve them corresponding to how they are stored \ + */ \ + fill_parm = (const unsigned char *)filval_buf; \ + if(H5T_native_order_g == H5T_ORDER_LE) \ + HDmemcpy(&filval, fill_parm, sizeof(type)); \ + else { \ + unsigned char *fill_buf; /* Pointer to fill value in memory */ \ + unsigned u; /* index */ \ + \ + HDassert(H5T_native_order_g == H5T_ORDER_BE); \ \ - /* retrieve fill value from corresponding positions of cd_values[] \ - * retrieve them corresponding to how they are stored \ - */ \ - for(i = 0; i < sizeof(type); i++) { \ - filval_mask = ((const unsigned char *)filval_buf)[i]; \ - filval_mask <<= i*8; \ - filval |= filval_mask; \ - } \ + fill_buf = (unsigned char *)&filval; \ + for(u = 0; u < sizeof(type); u++) \ + fill_buf[u] = fill_parm[sizeof(type) - (u + 1)]; \ + } /* end else */ \ } /* Get the fill value for floating-point type */ -#define H5Z_scaleoffset_get_filval_2(i, type, filval_buf, filval) \ -{ \ - if(sizeof(type)==sizeof(int)) \ - H5Z_scaleoffset_get_filval_1(i, int, filval_buf, *(int *)&filval) \ - else if(sizeof(type)==sizeof(long)) \ - H5Z_scaleoffset_get_filval_1(i, long, filval_buf, *(long *)&filval) \ - else if(sizeof(type)==sizeof(long long)) \ - H5Z_scaleoffset_get_filval_1(i, long long, filval_buf, *(long long *)&filval) \ - else \ - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer dataype")\ +#define H5Z_scaleoffset_get_filval_2(type, filval_buf, filval) \ +{ \ + if(sizeof(type) <= sizeof(long long)) \ + H5Z_scaleoffset_get_filval_1(type, filval_buf, filval) \ + else \ + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer dataype") \ } /* Find maximum and minimum values of a buffer with fill value defined for integer type */ @@ -315,65 +322,68 @@ H5Z_class2_t H5Z_SCALEOFFSET[1] = {{ /* Precompress for unsigned integer type */ #define H5Z_scaleoffset_precompress_1(type, data, d_nelmts, filavail, filval_buf, minbits, minval)\ -{ \ - type *buf = data, min = 0, max = 0, span, filval = 0; unsigned i; \ - \ - if(filavail == H5Z_SCALEOFFSET_FILL_DEFINED) { /* fill value defined */ \ - H5Z_scaleoffset_get_filval_1(i, type, filval_buf, filval) \ - if(*minbits == H5Z_SO_INT_MINBITS_DEFAULT ) { /* minbits not set yet, calculate max, min, and minbits */\ - H5Z_scaleoffset_max_min_1(i, d_nelmts, buf, filval, max, min) \ - H5Z_scaleoffset_check_1(type, max, min, minbits) \ - span = max - min + 1; \ - *minbits = H5Z_scaleoffset_log2((unsigned long long)(span+1)); \ - } else /* minbits already set, only calculate min */ \ - H5Z_scaleoffset_min_1(i, d_nelmts, buf, filval, min) \ - if(*minbits != sizeof(type)*8) /* change values if minbits != full precision */ \ - for(i = 0; i < d_nelmts; i++) \ - buf[i] = (buf[i] == filval)?(((type)1 << *minbits) - 1):(buf[i] - min); \ - } else { /* fill value undefined */ \ - if(*minbits == H5Z_SO_INT_MINBITS_DEFAULT ) { /* minbits not set yet, calculate max, min, and minbits */\ - H5Z_scaleoffset_max_min_2(i, d_nelmts, buf, max, min) \ - H5Z_scaleoffset_check_1(type, max, min, minbits) \ - span = max - min + 1; \ - *minbits = H5Z_scaleoffset_log2((unsigned long long)span); \ - } else /* minbits already set, only calculate min */ \ - H5Z_scaleoffset_min_2(i, d_nelmts, buf, min) \ - if(*minbits != sizeof(type)*8) /* change values if minbits != full precision */ \ - for(i = 0; i < d_nelmts; i++) buf[i] -= min; \ - } \ - *minval = min; \ +{ \ + type *buf = (type *)data, min = 0, max = 0, span, filval = 0; \ + unsigned i; \ + \ + if(filavail == H5Z_SCALEOFFSET_FILL_DEFINED) { /* fill value defined */ \ + H5Z_scaleoffset_get_filval_1(type, filval_buf, filval) \ + if(*minbits == H5Z_SO_INT_MINBITS_DEFAULT) { /* minbits not set yet, calculate max, min, and minbits */ \ + H5Z_scaleoffset_max_min_1(i, d_nelmts, buf, filval, max, min) \ + H5Z_scaleoffset_check_1(type, max, min, minbits) \ + span = (type)(max - min + 1); \ + *minbits = H5Z_scaleoffset_log2((unsigned long long)(span+1)); \ + } else /* minbits already set, only calculate min */ \ + H5Z_scaleoffset_min_1(i, d_nelmts, buf, filval, min) \ + if(*minbits != sizeof(type)*8) /* change values if minbits != full precision */ \ + for(i = 0; i < d_nelmts; i++) \ + buf[i] = (type)((buf[i] == filval) ? (((type)1 << *minbits) - 1) : (buf[i] - min)); \ + } else { /* fill value undefined */ \ + if(*minbits == H5Z_SO_INT_MINBITS_DEFAULT ) { /* minbits not set yet, calculate max, min, and minbits */ \ + H5Z_scaleoffset_max_min_2(i, d_nelmts, buf, max, min) \ + H5Z_scaleoffset_check_1(type, max, min, minbits) \ + span = (type)(max - min + 1); \ + *minbits = H5Z_scaleoffset_log2((unsigned long long)span); \ + } else /* minbits already set, only calculate min */ \ + H5Z_scaleoffset_min_2(i, d_nelmts, buf, min) \ + if(*minbits != sizeof(type)*8) /* change values if minbits != full precision */ \ + for(i = 0; i < d_nelmts; i++) \ + buf[i] = (type)(buf[i] - min); \ + } \ + *minval = min; \ } /* Precompress for signed integer type */ #define H5Z_scaleoffset_precompress_2(type, data, d_nelmts, filavail, filval_buf, minbits, minval)\ { \ - type *buf = data, min = 0, max = 0, filval = 0; \ + type *buf = (type *)data, min = 0, max = 0, filval = 0; \ unsigned type span; unsigned i; \ \ if(filavail == H5Z_SCALEOFFSET_FILL_DEFINED) { /* fill value defined */ \ - H5Z_scaleoffset_get_filval_1(i, type, filval_buf, filval) \ - if(*minbits == H5Z_SO_INT_MINBITS_DEFAULT ) { /* minbits not set yet, calculate max, min, and minbits */\ + H5Z_scaleoffset_get_filval_1(type, filval_buf, filval) \ + if(*minbits == H5Z_SO_INT_MINBITS_DEFAULT) { /* minbits not set yet, calculate max, min, and minbits */ \ H5Z_scaleoffset_max_min_1(i, d_nelmts, buf, filval, max, min) \ H5Z_scaleoffset_check_2(type, max, min, minbits) \ - span = max - min + 1; \ - *minbits = H5Z_scaleoffset_log2((unsigned long long)(span+1)); \ + span = (unsigned type)(max - min + 1); \ + *minbits = H5Z_scaleoffset_log2((unsigned long long)(span + 1)); \ } else /* minbits already set, only calculate min */ \ H5Z_scaleoffset_min_1(i, d_nelmts, buf, filval, min) \ - if(*minbits != sizeof(type)*8) /* change values if minbits != full precision */ \ + if(*minbits != sizeof(type) * 8) /* change values if minbits != full precision */ \ for(i = 0; i < d_nelmts; i++) \ - buf[i] = (buf[i] == filval) ? (type)(((unsigned type)1 << *minbits) - 1) : (buf[i] - min); \ + buf[i] = (type)((buf[i] == filval) ? (type)(((unsigned type)1 << *minbits) - 1) : (buf[i] - min)); \ } else { /* fill value undefined */ \ if(*minbits == H5Z_SO_INT_MINBITS_DEFAULT ) { /* minbits not set yet, calculate max, min, and minbits */\ H5Z_scaleoffset_max_min_2(i, d_nelmts, buf, max, min) \ H5Z_scaleoffset_check_2(type, max, min, minbits) \ - span = max - min + 1; \ + span = (unsigned type)(max - min + 1); \ *minbits = H5Z_scaleoffset_log2((unsigned long long)span); \ } else /* minbits already set, only calculate min */ \ H5Z_scaleoffset_min_2(i, d_nelmts, buf, min) \ - if(*minbits != sizeof(type)*8) /* change values if minbits != full precision */ \ - for(i = 0; i < d_nelmts; i++) buf[i] -= min; \ + if(*minbits != sizeof(type) * 8) /* change values if minbits != full precision */ \ + for(i = 0; i < d_nelmts; i++) \ + buf[i] = (type)(buf[i] - min); \ } \ - *minval = min; \ + *minval = (unsigned long long)min; \ } /* Modify values of data in precompression if fill value defined for floating-point type */ @@ -381,27 +391,27 @@ H5Z_class2_t H5Z_SCALEOFFSET[1] = {{ { \ if(sizeof(type)==sizeof(int)) \ for(i = 0; i < d_nelmts; i++) { \ - if(HDfabs(buf[i] - filval) < HDpow(10.0, -D_val)) \ - *(int *)&buf[i] = ((unsigned int)1 << *minbits) - 1; \ + if(HDfabs(buf[i] - filval) < HDpow(10.0, -D_val)) \ + *(int *)&buf[i] = (int)(((unsigned int)1 << *minbits) - 1); \ else \ *(int *)&buf[i] = H5Z_scaleoffset_rnd( \ - buf[i]*HDpow(10.0, D_val) - min*HDpow(10.0, D_val)); \ + buf[i]*HDpow(10.0, D_val) - min*HDpow(10.0, D_val)); \ } \ else if(sizeof(type)==sizeof(long)) \ for(i = 0; i < d_nelmts; i++) { \ - if(HDfabs(buf[i] - filval) < HDpow(10.0, -D_val)) \ - *(long *)&buf[i] = ((unsigned long)1 << *minbits) - 1; \ + if(HDfabs(buf[i] - filval) < HDpow(10.0, -D_val)) \ + *(long *)&buf[i] = (long)(((unsigned long)1 << *minbits) - 1); \ else \ *(long *)&buf[i] = H5Z_scaleoffset_rnd( \ - buf[i]*HDpow(10.0, D_val) - min*HDpow(10.0, D_val)); \ + buf[i]*HDpow(10.0, D_val) - min*HDpow(10.0, D_val)); \ } \ else if(sizeof(type)==sizeof(long long)) \ for(i = 0; i < d_nelmts; i++) { \ - if(HDfabs(buf[i] - filval) < HDpow(10.0, -D_val)) \ - *(long long *)&buf[i] = ((unsigned long long)1 << *minbits) - 1; \ + if(HDfabs(buf[i] - filval) < HDpow(10.0, -D_val)) \ + *(long long *)&buf[i] = (long long)(((unsigned long long)1 << *minbits) - 1); \ else \ *(long long *)&buf[i] = H5Z_scaleoffset_rnd( \ - buf[i]*HDpow(10.0, D_val) - min*HDpow(10.0, D_val)); \ + buf[i]*HDpow(10.0, D_val) - min*HDpow(10.0, D_val)); \ } \ else \ HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer dataype")\ @@ -429,40 +439,50 @@ H5Z_class2_t H5Z_SCALEOFFSET[1] = {{ /* Save the minimum value for floating-point type */ #define H5Z_scaleoffset_save_min(i, type, minval, min) \ { \ - if(sizeof(type)==sizeof(int)) \ - for(i = 0; i < sizeof(int); i++) \ - ((unsigned char *)minval)[i] = (unsigned char)((*(int *)&min & ((int)0xff << i*8)) >> i*8); \ - else if(sizeof(type)==sizeof(long)) \ - for(i = 0; i < sizeof(long); i++) \ - ((unsigned char *)minval)[i] = (unsigned char)((*(long *)&min & ((long)0xff << i*8)) >> i*8); \ - else if(sizeof(type)==sizeof(long long)) \ - for(i = 0; i < sizeof(long long); i++) \ - ((unsigned char *)minval)[i] = (unsigned char)((*(long long *)&min & ((long long)0xff << i*8)) >> i*8);\ - else \ - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer dataype")\ + if(sizeof(type) <= sizeof(long long)) { \ + unsigned char *min_parm; /* Pointer to min value parameter */ \ + \ + min_parm = (unsigned char *)minval; \ + if(H5T_native_order_g == H5T_ORDER_LE) \ + HDmemcpy(min_parm, &min, sizeof(type)); \ + else { \ + unsigned char *min_buf; /* Pointer to min value in memory */ \ + unsigned u; /* index */ \ + \ + HDassert(H5T_native_order_g == H5T_ORDER_BE); \ + \ + min_buf = (unsigned char *)&min; \ + for(u = 0; u < sizeof(type); u++) \ + min_parm[u] = min_buf[sizeof(type) - (u + 1)]; \ + } /* end else */ \ + } /* end if */ \ + else \ + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer dataype") \ } /* Precompress for floating-point type using variable-minimum-bits method */ #define H5Z_scaleoffset_precompress_3(type, data, d_nelmts, filavail, filval_buf, \ minbits, minval, D_val) \ { \ - type *buf = data, min = 0, max = 0, filval = 0; \ - unsigned long long span; unsigned i; *minval = 0; \ + type *buf = (type *)data, min = 0, max = 0, filval = 0; \ + unsigned long long span; \ + unsigned i; \ \ + *minval = 0; \ if(filavail == H5Z_SCALEOFFSET_FILL_DEFINED) { /* fill value defined */ \ - H5Z_scaleoffset_get_filval_2(i, type, filval_buf, filval) \ + H5Z_scaleoffset_get_filval_2(type, filval_buf, filval) \ H5Z_scaleoffset_max_min_3(i, d_nelmts, buf, filval, max, min, D_val) \ H5Z_scaleoffset_check_3(i, type, max, min, minbits, D_val) \ - span = H5Z_scaleoffset_rnd(max*HDpow(10.0,D_val) - min*HDpow(10.0,D_val)) + 1; \ - *minbits = H5Z_scaleoffset_log2((unsigned long long)(span+1)); \ - if(*minbits != sizeof(type)*8) /* change values if minbits != full precision */ \ + span = H5Z_scaleoffset_rnd(max * HDpow(10.0, D_val) - min * HDpow(10.0, D_val)) + 1; \ + *minbits = H5Z_scaleoffset_log2((unsigned long long)(span + 1)); \ + if(*minbits != sizeof(type) * 8) /* change values if minbits != full precision */ \ H5Z_scaleoffset_modify_1(i, type, buf, d_nelmts, filval, minbits, min, D_val) \ } else { /* fill value undefined */ \ H5Z_scaleoffset_max_min_2(i, d_nelmts, buf, max, min) \ H5Z_scaleoffset_check_3(i, type, max, min, minbits, D_val) \ - span = H5Z_scaleoffset_rnd(max*HDpow(10.0,D_val) - min*HDpow(10.0,D_val)) + 1; \ + span = H5Z_scaleoffset_rnd(max * HDpow(10.0, D_val) - min * HDpow(10.0, D_val)) + 1; \ *minbits = H5Z_scaleoffset_log2((unsigned long long)span); \ - if(*minbits != sizeof(type)*8) /* change values if minbits != full precision */ \ + if(*minbits != sizeof(type) * 8) /* change values if minbits != full precision */ \ H5Z_scaleoffset_modify_2(i, type, buf, d_nelmts, min, D_val) \ } \ H5Z_scaleoffset_save_min(i, type, minval, min) \ @@ -471,49 +491,56 @@ H5Z_class2_t H5Z_SCALEOFFSET[1] = {{ /* Postdecompress for unsigned integer type */ #define H5Z_scaleoffset_postdecompress_1(type, data, d_nelmts, filavail, filval_buf, minbits, minval)\ { \ - type *buf = data, filval = 0; unsigned i; \ + type *buf = (type *)data, filval = 0; unsigned i; \ \ if(filavail == H5Z_SCALEOFFSET_FILL_DEFINED) { /* fill value defined */ \ - H5Z_scaleoffset_get_filval_1(i, type, filval_buf, filval) \ + H5Z_scaleoffset_get_filval_1(type, filval_buf, filval) \ for(i = 0; i < d_nelmts; i++) \ - buf[i] = (type)((buf[i] == (((type)1 << minbits) - 1))?filval:(buf[i] + minval));\ + buf[i] = (type)((buf[i] == (((type)1 << minbits) - 1)) ? filval : (buf[i] + minval)); \ } else /* fill value undefined */ \ - for(i = 0; i < d_nelmts; i++) buf[i] += (type)(minval); \ + for(i = 0; i < d_nelmts; i++) buf[i] = (type)(buf[i] + (type)(minval)); \ } /* Postdecompress for signed integer type */ #define H5Z_scaleoffset_postdecompress_2(type, data, d_nelmts, filavail, filval_buf, minbits, minval)\ { \ - type *buf = data, filval = 0; unsigned i; \ + type *buf = (type *)data, filval = 0; \ + unsigned i; \ \ if(filavail == H5Z_SCALEOFFSET_FILL_DEFINED) { /* fill value defined */ \ - H5Z_scaleoffset_get_filval_1(i, type, filval_buf, filval) \ + H5Z_scaleoffset_get_filval_1(type, filval_buf, filval) \ for(i = 0; i < d_nelmts; i++) \ buf[i] = (type)(((unsigned type)buf[i] == (((unsigned type)1 << minbits) - 1)) ? filval : (buf[i] + minval));\ } else /* fill value undefined */ \ - for(i = 0; i < d_nelmts; i++) buf[i] += (type)(minval); \ + for(i = 0; i < d_nelmts; i++) \ + buf[i] = (type)(buf[i] + (type)(minval)); \ } /* Retrive minimum value of floating-point type */ -#define H5Z_scaleoffset_get_min(i, type, minval, min) \ -{ \ - if(sizeof(type)==sizeof(int)) { \ - int mask; \ - for(i = 0; i < sizeof(int); i++) { \ - mask = ((unsigned char *)&minval)[i]; mask <<= i*8; *(int *)&min |= mask; \ - } \ - } else if(sizeof(type)==sizeof(long)) { \ - long mask; \ - for(i = 0; i < sizeof(long); i++) { \ - mask = ((unsigned char *)&minval)[i]; mask <<= i*8; *(long *)&min |= mask; \ - } \ - } else if(sizeof(type)==sizeof(long long)) { \ - long long mask; \ - for(i = 0; i < sizeof(long long); i++) { \ - mask = ((unsigned char *)&minval)[i]; mask <<= i*8; *(long long *)&min |= mask;\ - } \ - } else \ - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer dataype")\ +#define H5Z_scaleoffset_get_min(type, minval, min) \ +{ \ + if(sizeof(type) <= sizeof(long long)) { \ + const unsigned char *min_parm; /* Pointer to min value parameter */ \ + \ + /* retrieve min value from corresponding positions \ + * retrieve them corresponding to how they are stored \ + */ \ + min_parm = (const unsigned char *)&minval; \ + if(H5T_native_order_g == H5T_ORDER_LE) \ + HDmemcpy(&min, min_parm, sizeof(type)); \ + else { \ + unsigned char *min_buf; /* Pointer to min value in memory */ \ + unsigned u; /* index */ \ + \ + HDassert(H5T_native_order_g == H5T_ORDER_BE); \ + \ + min_buf = (unsigned char *)&min; \ + for(u = 0; u < sizeof(type); u++) \ + min_buf[u] = min_parm[sizeof(type) - (u + 1)]; \ + } /* end else */ \ + } /* end if */ \ + else \ + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer dataype") \ } /* Modify values of data in postdecompression if fill value defined for floating-point type */ @@ -521,16 +548,16 @@ H5Z_class2_t H5Z_SCALEOFFSET[1] = {{ { \ if(sizeof(type)==sizeof(int)) \ for(i = 0; i < d_nelmts; i++) \ - buf[i] = (*(int *)&buf[i]==(((unsigned int)1 << minbits) - 1))? \ - filval:(*(int *)&buf[i])/HDpow(10.0, D_val) + min; \ + buf[i] = (type)((*(int *)&buf[i] == (int)(((unsigned int)1 << minbits) - 1)) ? \ + filval : (double)(*(int *)&buf[i]) / HDpow(10.0, D_val) + min); \ else if(sizeof(type)==sizeof(long)) \ for(i = 0; i < d_nelmts; i++) \ - buf[i] = (*(long *)&buf[i]==(((unsigned long)1 << minbits) - 1))? \ - filval:(*(long *)&buf[i])/HDpow(10.0, D_val) + min; \ + buf[i] = (type)((*(long *)&buf[i] == (long)(((unsigned long)1 << minbits) - 1)) ? \ + filval : (double)(*(long *)&buf[i]) / HDpow(10.0, D_val) + min); \ else if(sizeof(type)==sizeof(long long)) \ for(i = 0; i < d_nelmts; i++) \ - buf[i] = (*(long long *)&buf[i]==(((unsigned long long)1 << minbits) - 1))? \ - filval:(*(long long *)&buf[i])/HDpow(10.0, D_val) + min; \ + buf[i] = (type)((*(long long *)&buf[i] == (long long)(((unsigned long long)1 << minbits) - 1)) ? \ + filval : (double)(*(long long *)&buf[i]) / HDpow(10.0, D_val) + min); \ else \ HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer dataype") \ } @@ -540,13 +567,13 @@ H5Z_class2_t H5Z_SCALEOFFSET[1] = {{ { \ if(sizeof(type)==sizeof(int)) \ for(i = 0; i < d_nelmts; i++) \ - buf[i] = (*(int *)&buf[i])/HDpow(10.0, D_val) + min; \ + buf[i] = (type)((double)(*(int *)&buf[i]) / HDpow(10.0, D_val) + min); \ else if(sizeof(type)==sizeof(long)) \ for(i = 0; i < d_nelmts; i++) \ - buf[i] = (*(long *)&buf[i])/HDpow(10.0, D_val) + min; \ + buf[i] = (type)((double)(*(long *)&buf[i]) / HDpow(10.0, D_val) + min); \ else if(sizeof(type)==sizeof(long long)) \ for(i = 0; i < d_nelmts; i++) \ - buf[i] = (*(long long *)&buf[i])/HDpow(10.0, D_val) + min; \ + buf[i] = (type)((double)(*(long long *)&buf[i]) / HDpow(10.0, D_val) + min); \ else \ HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer dataype") \ } @@ -555,19 +582,19 @@ H5Z_class2_t H5Z_SCALEOFFSET[1] = {{ #define H5Z_scaleoffset_postdecompress_3(type, data, d_nelmts, filavail, filval_buf, \ minbits, minval, D_val) \ { \ - type *buf = data, filval = 0, min = 0; unsigned i; \ + type *buf = (type *)data, filval = 0, min = 0; \ + unsigned i; \ \ - H5Z_scaleoffset_get_min(i, type, minval, min) \ + H5Z_scaleoffset_get_min(type, minval, min) \ \ if(filavail == H5Z_SCALEOFFSET_FILL_DEFINED) { /* fill value defined */ \ - H5Z_scaleoffset_get_filval_2(i, type, filval_buf, filval) \ + H5Z_scaleoffset_get_filval_2(type, filval_buf, filval) \ H5Z_scaleoffset_modify_3(i, type, buf, d_nelmts, filval, minbits, min, D_val) \ } else /* fill value undefined */ \ H5Z_scaleoffset_modify_4(i, type, buf, d_nelmts, min, D_val) \ } - /*------------------------------------------------------------------------- * Function: H5Z_can_apply_scaleoffset * @@ -595,7 +622,7 @@ H5Z_can_apply_scaleoffset(hid_t UNUSED dcpl_id, hid_t type_id, hid_t UNUSED spac FUNC_ENTER_NOAPI(H5Z_can_apply_scaleoffset, FAIL) /* Get datatype */ - if(NULL == (type = H5I_object_verify(type_id, H5I_DATATYPE))) + if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* Get datatype's class, for checking the "datatype class" */ @@ -638,11 +665,11 @@ done: * *------------------------------------------------------------------------- */ -static enum H5Z_scaleoffset_type +static enum H5Z_scaleoffset_t H5Z_scaleoffset_get_type(unsigned dtype_class, unsigned dtype_size, unsigned dtype_sign) { - enum H5Z_scaleoffset_type type = t_bad; /* integer type */ - enum H5Z_scaleoffset_type ret_value; /* return value */ + enum H5Z_scaleoffset_t type = t_bad; /* integer type */ + enum H5Z_scaleoffset_t ret_value; /* return value */ FUNC_ENTER_NOAPI_NOINIT(H5Z_scaleoffset_get_type) @@ -698,7 +725,7 @@ done: */ static herr_t H5Z_scaleoffset_set_parms_fillval(H5P_genplist_t *dcpl_plist, - const H5T_t *type, enum H5Z_scaleoffset_type scale_type, + const H5T_t *type, enum H5Z_scaleoffset_t scale_type, unsigned cd_values[], int need_convert, hid_t dxpl_id) { herr_t ret_value = SUCCEED; /* Return value */ @@ -763,10 +790,9 @@ H5Z_set_local_scaleoffset(hid_t dcpl_id, hid_t type_id, hid_t space_id) hssize_t npoints; /* Number of points in the dataspace */ H5T_class_t dtype_class; /* Datatype's class */ H5T_order_t dtype_order; /* Datatype's endianness order */ - int need_convert = FALSE; /* Flag indicating convertion of byte order */ size_t dtype_size; /* Datatype's size (in bytes) */ H5T_sign_t dtype_sign; /* Datatype's sign */ - enum H5Z_scaleoffset_type scale_type; /* Specific datatype */ + enum H5Z_scaleoffset_t scale_type; /* Specific datatype */ H5D_fill_value_t status; /* Status of fill value in property list */ herr_t ret_value = SUCCEED; /* Return value */ @@ -777,7 +803,7 @@ H5Z_set_local_scaleoffset(hid_t dcpl_id, hid_t type_id, hid_t space_id) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get datatype */ - if(NULL == (type = H5I_object_verify(type_id, H5I_DATATYPE))) + if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* Get the filter's current parameters */ @@ -809,6 +835,17 @@ H5Z_set_local_scaleoffset(hid_t dcpl_id, hid_t type_id, hid_t space_id) cd_values[H5Z_SCALEOFFSET_PARM_CLASS] = H5Z_SCALEOFFSET_CLS_FLOAT; break; + case H5T_NO_CLASS: + case H5T_TIME: + case H5T_STRING: + case H5T_BITFIELD: + case H5T_OPAQUE: + case H5T_COMPOUND: + case H5T_REFERENCE: + case H5T_ENUM: + case H5T_VLEN: + case H5T_ARRAY: + case H5T_NCLASSES: default: HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "datatype class not supported by scaleoffset") } /* end switch */ @@ -835,6 +872,8 @@ H5Z_set_local_scaleoffset(hid_t dcpl_id, hid_t type_id, hid_t space_id) cd_values[H5Z_SCALEOFFSET_PARM_SIGN] = H5Z_SCALEOFFSET_SGN_2; break; + case H5T_SGN_ERROR: + case H5T_NSGN: default: HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad integer sign") } /* end switch */ @@ -854,6 +893,9 @@ H5Z_set_local_scaleoffset(hid_t dcpl_id, hid_t type_id, hid_t space_id) cd_values[H5Z_SCALEOFFSET_PARM_ORDER] = H5Z_SCALEOFFSET_ORDER_BE; break; + case H5T_ORDER_ERROR: + case H5T_ORDER_VAX: + case H5T_ORDER_NONE: default: HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype endianness order") } /* end switch */ @@ -866,6 +908,8 @@ H5Z_set_local_scaleoffset(hid_t dcpl_id, hid_t type_id, hid_t space_id) if(status == H5D_FILL_VALUE_UNDEFINED) cd_values[H5Z_SCALEOFFSET_PARM_FILAVAIL] = H5Z_SCALEOFFSET_FILL_UNDEFINED; else { + int need_convert = FALSE; /* Flag indicating convertion of byte order */ + cd_values[H5Z_SCALEOFFSET_PARM_FILAVAIL] = H5Z_SCALEOFFSET_FILL_DEFINED; /* Check if memory byte order matches dataset datatype byte order */ @@ -908,8 +952,8 @@ done: *------------------------------------------------------------------------- */ static size_t -H5Z_filter_scaleoffset (unsigned flags, size_t cd_nelmts, const unsigned cd_values[], - size_t nbytes, size_t *buf_size, void **buf) +H5Z_filter_scaleoffset(unsigned flags, size_t cd_nelmts, const unsigned cd_values[], + size_t nbytes, size_t *buf_size, void **buf) { size_t ret_value = 0; /* return value */ size_t size_out = 0; /* size of output buffer */ @@ -922,7 +966,7 @@ H5Z_filter_scaleoffset (unsigned flags, size_t cd_nelmts, const unsigned cd_valu double D_val = 0.0; /* decimal scale factor */ uint32_t minbits = 0; /* minimum number of bits to store values */ unsigned long long minval= 0; /* minimum value of input buffer */ - enum H5Z_scaleoffset_type type; /* memory type corresponding to dataset datatype */ + enum H5Z_scaleoffset_t type; /* memory type corresponding to dataset datatype */ int need_convert = FALSE; /* flag indicating convertion of byte order */ unsigned char *outbuf = NULL; /* pointer to new output buffer */ unsigned buf_offset = 21; /* buffer offset because of parameters stored in file */ @@ -947,6 +991,9 @@ H5Z_filter_scaleoffset (unsigned flags, size_t cd_nelmts, const unsigned cd_valu need_convert = TRUE; break; + case H5T_ORDER_ERROR: + case H5T_ORDER_VAX: + case H5T_ORDER_NONE: default: HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, 0, "bad H5T_NATIVE_INT endianness order") } /* end switch */ @@ -997,7 +1044,7 @@ H5Z_filter_scaleoffset (unsigned flags, size_t cd_nelmts, const unsigned cd_valu ret_value = *buf_size; goto done; } - minbits = scale_factor; + minbits = (uint32_t)scale_factor; } /* prepare paramters to pass to compress/decompress functions */ @@ -1040,7 +1087,7 @@ H5Z_filter_scaleoffset (unsigned flags, size_t cd_nelmts, const unsigned cd_valu size_out = d_nelmts * p.size; /* allocate memory space for decompressed buffer */ - if(NULL==(outbuf = H5MM_malloc(size_out))) + if(NULL == (outbuf = (unsigned char *)H5MM_malloc(size_out))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed for scaleoffset decompression") /* special case: minbits equal to full precision */ @@ -1088,7 +1135,7 @@ H5Z_filter_scaleoffset (unsigned flags, size_t cd_nelmts, const unsigned cd_valu } /* output; compress */ else { - assert(nbytes == d_nelmts * p.size); + HDassert(nbytes == d_nelmts * p.size); /* before preprocess, convert to memory endianness order if needed */ if(need_convert) @@ -1119,7 +1166,7 @@ H5Z_filter_scaleoffset (unsigned flags, size_t cd_nelmts, const unsigned cd_valu size_out = buf_offset + nbytes * p.minbits / (p.size * 8) + 1; /* may be 1 larger */ /* allocate memory space for compressed buffer */ - if(NULL==(outbuf = H5MM_malloc(size_out))) + if(NULL == (outbuf = (unsigned char *)H5MM_malloc(size_out))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed for scaleoffset compression") /* store minbits and minval in the front of output compressed buffer @@ -1128,7 +1175,7 @@ H5Z_filter_scaleoffset (unsigned flags, size_t cd_nelmts, const unsigned cd_valu * 4 bytes for minbits, 1 byte for size of minval, 16 bytes for minval */ for(i = 0; i < 4; i++) - ((unsigned char *)outbuf)[i] = (minbits & ((uint32_t)0xff << i*8)) >> i*8; + ((unsigned char *)outbuf)[i] = (unsigned char)((minbits & ((uint32_t)0xff << i*8)) >> i*8); ((unsigned char *)outbuf)[4] = sizeof(unsigned long long); @@ -1137,11 +1184,11 @@ H5Z_filter_scaleoffset (unsigned flags, size_t cd_nelmts, const unsigned cd_valu /* special case: minbits equal to full precision */ if(minbits == p.size * 8) { - HDmemcpy(outbuf+buf_offset, *buf, nbytes); + HDmemcpy(outbuf + buf_offset, *buf, nbytes); *buf = outbuf; outbuf = NULL; *buf_size = size_out; - ret_value = buf_offset+nbytes; + ret_value = buf_offset + nbytes; goto done; } @@ -1150,7 +1197,7 @@ H5Z_filter_scaleoffset (unsigned flags, size_t cd_nelmts, const unsigned cd_valu * all data elements have the same value */ if(minbits != 0) - H5Z_scaleoffset_compress(*buf, d_nelmts, outbuf+buf_offset, size_out-buf_offset, p); + H5Z_scaleoffset_compress((unsigned char *)*buf, d_nelmts, outbuf + buf_offset, size_out - buf_offset, p); } /* free the input buffer */ @@ -1187,124 +1234,140 @@ H5Z_scaleoffset_convert(void *buf, unsigned d_nelmts, size_t dtype_size) unsigned i, j; unsigned char *buffer, temp; - buffer = buf; + buffer = (unsigned char *)buf; for(i = 0; i < d_nelmts * dtype_size; i += dtype_size) - for(j = 0; j < dtype_size/2; j++) { + for(j = 0; j < dtype_size / 2; j++) { /* swap pair of bytes */ - temp = buffer[i+j]; - buffer[i+j] = buffer[i+dtype_size-1-j]; - buffer[i+dtype_size-1-j] = temp; - } + temp = buffer[i + j]; + buffer[i + j] = buffer[i + dtype_size - 1 - j]; + buffer[i + dtype_size - 1 - j] = temp; + } /* end for */ } /* end if */ -} +} /* end H5Z_scaleoffset_convert() */ /* Round a floating-point value to the nearest integer value 4/19/05 */ /* rounding to the bigger absolute value if val is in the middle, 0.5 -> 1, -0.5 ->-1 5/9/05, KY */ -static double H5Z_scaleoffset_rnd(double val) +static double +H5Z_scaleoffset_rnd(double val) { - double u_val, l_val; + double u_val, l_val; - u_val = HDceil(val); - l_val = HDfloor(val); + u_val = HDceil(val); + l_val = HDfloor(val); - if(val > 0) { - if((u_val - val)<=(val - l_val)) return u_val; - else return l_val; - } - else { - if((val - l_val)<=(u_val - val)) return l_val; - else return u_val; - } -} + if(val > 0) { + if((u_val - val) <= (val - l_val)) + return u_val; + else + return l_val; + } /* end if */ + else { + if((val - l_val) <= (u_val - val)) + return l_val; + else + return u_val; + } +} /* H5Z_scaleoffset_rnd() */ /* return ceiling of floating-point log2 function * receive unsigned integer as argument 3/10/2005 */ -static unsigned H5Z_scaleoffset_log2(unsigned long long num) +static unsigned +H5Z_scaleoffset_log2(unsigned long long num) { unsigned v = 0; unsigned long long lower_bound = 1; /* is power of 2, largest value <= num */ unsigned long long val = num; - while(val >>= 1) { v++; lower_bound <<= 1; } + while(val >>= 1) { + v++; + lower_bound <<= 1; + } - if(num == lower_bound) return v; - else return v+1; + if(num == lower_bound) + return v; + else + return v + 1; } /* precompress for integer type */ static void -H5Z_scaleoffset_precompress_i(void *data, unsigned d_nelmts, enum H5Z_scaleoffset_type type, - unsigned filavail, const void *filval_buf, uint32_t *minbits, unsigned long long *minval) +H5Z_scaleoffset_precompress_i(void *data, unsigned d_nelmts, enum H5Z_scaleoffset_t type, + unsigned filavail, const void *filval_buf, uint32_t *minbits, unsigned long long *minval) { - if(type == t_uchar) - H5Z_scaleoffset_precompress_1(unsigned char, data, d_nelmts, + if(type == t_uchar) + H5Z_scaleoffset_precompress_1(unsigned char, data, d_nelmts, filavail, filval_buf, minbits, minval) - else if(type == t_ushort) - H5Z_scaleoffset_precompress_1(unsigned short, data, d_nelmts, + else if(type == t_ushort) + H5Z_scaleoffset_precompress_1(unsigned short, data, d_nelmts, filavail, filval_buf, minbits, minval) - else if(type == t_uint) - H5Z_scaleoffset_precompress_1(unsigned int, data, d_nelmts, + else if(type == t_uint) + H5Z_scaleoffset_precompress_1(unsigned int, data, d_nelmts, filavail, filval_buf, minbits, minval) - else if(type == t_ulong) - H5Z_scaleoffset_precompress_1(unsigned long, data, d_nelmts, + else if(type == t_ulong) + H5Z_scaleoffset_precompress_1(unsigned long, data, d_nelmts, filavail, filval_buf, minbits, minval) - else if(type == t_ulong_long) - H5Z_scaleoffset_precompress_1(unsigned long long, data, d_nelmts, + else if(type == t_ulong_long) + H5Z_scaleoffset_precompress_1(unsigned long long, data, d_nelmts, filavail, filval_buf, minbits, minval) - else if(type == t_schar) { - signed char *buf = data, min = 0, max = 0, filval = 0; - unsigned char span; unsigned i; - - if(filavail == H5Z_SCALEOFFSET_FILL_DEFINED) { /* fill value defined */ - H5Z_scaleoffset_get_filval_1(i, signed char, filval_buf, filval); - if(*minbits == H5Z_SO_INT_MINBITS_DEFAULT ) { /* minbits not set yet, calculate max, min, and minbits */ - H5Z_scaleoffset_max_min_1(i, d_nelmts, buf, filval, max, min) - if((unsigned char)(max - min) > (unsigned char)(~(unsigned char)0 - 2)) - { *minbits = sizeof(signed char)*8; return; } - span = max - min + 1; - *minbits = H5Z_scaleoffset_log2((unsigned long long)(span+1)); - } else /* minbits already set, only calculate min */ - H5Z_scaleoffset_min_1(i, d_nelmts, buf, filval, min) - if(*minbits != sizeof(signed char)*8) /* change values if minbits != full precision */ - for(i = 0; i < d_nelmts; i++) - buf[i] = (buf[i] == filval)?(((unsigned char)1 << *minbits) - 1):(buf[i] - min); - } else { /* fill value undefined */ - if(*minbits == H5Z_SO_INT_MINBITS_DEFAULT ) { /* minbits not set yet, calculate max, min, and minbits */ - H5Z_scaleoffset_max_min_2(i, d_nelmts, buf, max, min) - if((unsigned char)(max - min) > (unsigned char)(~(unsigned char)0 - 2)) { - *minbits = sizeof(signed char)*8; - *minval = min; return; - } - span = max - min + 1; - *minbits = H5Z_scaleoffset_log2((unsigned long long)span); - } else /* minbits already set, only calculate min */ - H5Z_scaleoffset_min_2(i, d_nelmts, buf, min) - if(*minbits != sizeof(signed char)*8) /* change values if minbits != full precision */ - for(i = 0; i < d_nelmts; i++) buf[i] -= min; - } - *minval = min; - } - else if(type == t_short) - H5Z_scaleoffset_precompress_2(short, data, d_nelmts, + else if(type == t_schar) { + signed char *buf = (signed char *)data, min = 0, max = 0, filval = 0; + unsigned char span; + unsigned i; + + if(filavail == H5Z_SCALEOFFSET_FILL_DEFINED) { /* fill value defined */ + H5Z_scaleoffset_get_filval_1(signed char, filval_buf, filval); + if(*minbits == H5Z_SO_INT_MINBITS_DEFAULT) { /* minbits not set yet, calculate max, min, and minbits */ + H5Z_scaleoffset_max_min_1(i, d_nelmts, buf, filval, max, min) + if((unsigned char)(max - min) > (unsigned char)(~(unsigned char)0 - 2)) { + *minbits = sizeof(signed char)*8; + return; + } + span = (unsigned char)(max - min + 1); + *minbits = H5Z_scaleoffset_log2((unsigned long long)(span+1)); + } else /* minbits already set, only calculate min */ + H5Z_scaleoffset_min_1(i, d_nelmts, buf, filval, min) + if(*minbits != sizeof(signed char)*8) /* change values if minbits != full precision */ + for(i = 0; i < d_nelmts; i++) + buf[i] = (signed char)((buf[i] == filval) ? (((unsigned char)1 << *minbits) - 1) : (buf[i] - min)); + } else { /* fill value undefined */ + if(*minbits == H5Z_SO_INT_MINBITS_DEFAULT) { /* minbits not set yet, calculate max, min, and minbits */ + H5Z_scaleoffset_max_min_2(i, d_nelmts, buf, max, min) + if((unsigned char)(max - min) > (unsigned char)(~(unsigned char)0 - 2)) { + *minbits = sizeof(signed char)*8; + *minval = (unsigned long long)min; + return; + } + span = (unsigned char)(max - min + 1); + *minbits = H5Z_scaleoffset_log2((unsigned long long)span); + } else /* minbits already set, only calculate min */ + H5Z_scaleoffset_min_2(i, d_nelmts, buf, min) + if(*minbits != sizeof(signed char) * 8) /* change values if minbits != full precision */ + for(i = 0; i < d_nelmts; i++) + buf[i] = (signed char)(buf[i] - min); + } + *minval = (unsigned long long)min; + } + else if(type == t_short) + H5Z_scaleoffset_precompress_2(short, data, d_nelmts, filavail, filval_buf, minbits, minval) - else if(type == t_int) - H5Z_scaleoffset_precompress_2(int, data, d_nelmts, + else if(type == t_int) + H5Z_scaleoffset_precompress_2(int, data, d_nelmts, filavail, filval_buf, minbits, minval) - else if(type == t_long) - H5Z_scaleoffset_precompress_2(long, data, d_nelmts, + else if(type == t_long) + H5Z_scaleoffset_precompress_2(long, data, d_nelmts, filavail, filval_buf, minbits, minval) - else if(type == t_long_long) - H5Z_scaleoffset_precompress_2(long long, data, d_nelmts, + else if(type == t_long_long) + H5Z_scaleoffset_precompress_2(long long, data, d_nelmts, filavail, filval_buf, minbits, minval) } /* postdecompress for integer type */ static void -H5Z_scaleoffset_postdecompress_i(void *data, unsigned d_nelmts, enum H5Z_scaleoffset_type type, - unsigned filavail, const void *filval_buf, uint32_t minbits, unsigned long long minval) +H5Z_scaleoffset_postdecompress_i(void *data, unsigned d_nelmts, enum H5Z_scaleoffset_t type, + unsigned filavail, const void *filval_buf, uint32_t minbits, unsigned long long minval) { long long sminval = *(long long*)&minval; /* for signed integer types */ @@ -1324,14 +1387,16 @@ H5Z_scaleoffset_postdecompress_i(void *data, unsigned d_nelmts, enum H5Z_scaleof H5Z_scaleoffset_postdecompress_1(unsigned long long, data, d_nelmts, filavail, filval_buf, minbits, minval) else if(type == t_schar) { - signed char *buf = data, filval = 0; unsigned i; + signed char *buf = (signed char *)data, filval = 0; + unsigned i; if(filavail == H5Z_SCALEOFFSET_FILL_DEFINED) { /* fill value defined */ - H5Z_scaleoffset_get_filval_1(i, signed char, filval_buf, filval) + H5Z_scaleoffset_get_filval_1(signed char, filval_buf, filval) for(i = 0; i < d_nelmts; i++) - buf[i] = (buf[i] == (((unsigned char)1 << minbits) - 1))?filval:(buf[i] + sminval); + buf[i] = (signed char)((buf[i] == (((unsigned char)1 << minbits) - 1)) ? filval : (buf[i] + sminval)); } else /* fill value undefined */ - for(i = 0; i < d_nelmts; i++) buf[i] += sminval; + for(i = 0; i < d_nelmts; i++) + buf[i] = (signed char)(buf[i] + sminval); } else if(type == t_short) H5Z_scaleoffset_postdecompress_2(short, data, d_nelmts, filavail, @@ -1350,8 +1415,9 @@ H5Z_scaleoffset_postdecompress_i(void *data, unsigned d_nelmts, enum H5Z_scaleof /* precompress for floating-point type, variable-minimum-bits method success: non-negative, failure: negative 4/15/05 */ static herr_t -H5Z_scaleoffset_precompress_fd(void *data, unsigned d_nelmts, enum H5Z_scaleoffset_type type, -unsigned filavail, const void *filval_buf, uint32_t *minbits, unsigned long long *minval, double D_val) +H5Z_scaleoffset_precompress_fd(void *data, unsigned d_nelmts, enum H5Z_scaleoffset_t type, + unsigned filavail, const void *filval_buf, uint32_t *minbits, + unsigned long long *minval, double D_val) { herr_t ret_value=SUCCEED; /* Return value */ @@ -1371,10 +1437,11 @@ done: /* postdecompress for floating-point type, variable-minimum-bits method success: non-negative, failure: negative 4/15/05 */ static herr_t -H5Z_scaleoffset_postdecompress_fd(void *data, unsigned d_nelmts, enum H5Z_scaleoffset_type type, -unsigned filavail, const void *filval_buf, uint32_t minbits, unsigned long long minval, double D_val) +H5Z_scaleoffset_postdecompress_fd(void *data, unsigned d_nelmts, enum H5Z_scaleoffset_t type, + unsigned filavail, const void *filval_buf, uint32_t minbits, + unsigned long long minval, double D_val) { - long long sminval = *(long long*)&minval; /* for signed integer types */ + long long sminval = (long long)minval; /* for signed integer types */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5Z_scaleoffset_postdecompress_fd, FAIL) @@ -1390,16 +1457,20 @@ done: FUNC_LEAVE_NOAPI(ret_value) } -static void H5Z_scaleoffset_next_byte(size_t *j, int *buf_len) +static void +H5Z_scaleoffset_next_byte(size_t *j, unsigned *buf_len) { - ++(*j); *buf_len = 8 * sizeof(unsigned char); + ++(*j); + *buf_len = 8 * sizeof(unsigned char); } -static void H5Z_scaleoffset_decompress_one_byte(unsigned char *data, size_t data_offset, int k, -int begin_i, unsigned char *buffer, size_t *j, int *buf_len, parms_atomic p, int dtype_len) +static void +H5Z_scaleoffset_decompress_one_byte(unsigned char *data, size_t data_offset, + unsigned k, unsigned begin_i, unsigned char *buffer, size_t *j, unsigned *buf_len, + parms_atomic p, unsigned dtype_len) { - int dat_len; /* dat_len is the number of bits to be copied in each data byte */ - unsigned char val; /* value to be copied in each data byte */ + unsigned dat_len; /* dat_len is the number of bits to be copied in each data byte */ + unsigned char val; /* value to be copied in each data byte */ /* initialize value and bits of unsigned char to be copied */ val = buffer[*j]; @@ -1409,75 +1480,82 @@ int begin_i, unsigned char *buffer, size_t *j, int *buf_len, parms_atomic p, int dat_len = 8; if(*buf_len > dat_len) { - data[data_offset + k] = - ((val >> (*buf_len - dat_len)) & ~(~0 << dat_len)); + data[data_offset + k] = (unsigned char)((val >> (*buf_len - dat_len)) & ~(~0 << dat_len)); *buf_len -= dat_len; - } else { - data[data_offset + k] = - ((val & ~(~0 << *buf_len)) << (dat_len - *buf_len)); + } /* end if */ + else { + data[data_offset + k] = (unsigned char)((val & ~(~0 << *buf_len)) << (dat_len - *buf_len)); dat_len -= *buf_len; H5Z_scaleoffset_next_byte(j, buf_len); - if(dat_len == 0) return; + if(dat_len == 0) + return; val = buffer[*j]; - data[data_offset + k] |= - ((val >> (*buf_len - dat_len)) & ~(~0 << dat_len)); + data[data_offset + k] |= (unsigned char)((val >> (*buf_len - dat_len)) & ~(~0 << dat_len)); *buf_len -= dat_len; - } + } /* end else */ } -static void H5Z_scaleoffset_decompress_one_atomic(unsigned char *data, size_t data_offset, - unsigned char *buffer, size_t *j, int *buf_len, parms_atomic p) +static void +H5Z_scaleoffset_decompress_one_atomic(unsigned char *data, size_t data_offset, + unsigned char *buffer, size_t *j, unsigned *buf_len, parms_atomic p) { /* begin_i: the index of byte having first significant bit */ - int k, begin_i, dtype_len; + unsigned begin_i; + unsigned dtype_len; + int k; - assert(p.minbits > 0); + HDassert(p.minbits > 0); dtype_len = p.size * 8; if(p.mem_order == H5Z_SCALEOFFSET_ORDER_LE) { /* little endian */ begin_i = p.size - 1 - (dtype_len - p.minbits) / 8; - for(k = begin_i; k >= 0; k--) - H5Z_scaleoffset_decompress_one_byte(data, data_offset, k, begin_i, + for(k = (int)begin_i; k >= 0; k--) + H5Z_scaleoffset_decompress_one_byte(data, data_offset, (unsigned)k, begin_i, buffer, j, buf_len, p, dtype_len); } + else { /* big endian */ + HDassert(p.mem_order == H5Z_SCALEOFFSET_ORDER_BE); - if(p.mem_order == H5Z_SCALEOFFSET_ORDER_BE) { /* big endian */ begin_i = (dtype_len - p.minbits) / 8; - for(k = begin_i; k <= p.size - 1; k++) - H5Z_scaleoffset_decompress_one_byte(data, data_offset, k, begin_i, + for(k = (int)begin_i; k <= (int)(p.size - 1); k++) + H5Z_scaleoffset_decompress_one_byte(data, data_offset, (unsigned)k, begin_i, buffer, j, buf_len, p, dtype_len); } } -static void H5Z_scaleoffset_decompress(unsigned char *data, unsigned d_nelmts, - unsigned char *buffer, parms_atomic p) +static void +H5Z_scaleoffset_decompress(unsigned char *data, unsigned d_nelmts, + unsigned char *buffer, parms_atomic p) { - /* i: index of data, j: index of buffer, - buf_len: number of bits to be filled in current byte */ - size_t i, j; - int buf_len; - - /* must initialize to zeros */ - for(i = 0; i < d_nelmts*p.size; i++) data[i] = 0; - - /* initialization before the loop */ - j = 0; - buf_len = sizeof(unsigned char) * 8; - - /* decompress */ - for(i = 0; i < d_nelmts; i++) - H5Z_scaleoffset_decompress_one_atomic(data, i*p.size, buffer, &j, &buf_len, p); + /* i: index of data, j: index of buffer, + buf_len: number of bits to be filled in current byte */ + size_t i, j; + unsigned buf_len; + + /* must initialize to zeros */ + for(i = 0; i < d_nelmts*p.size; i++) + data[i] = 0; + + /* initialization before the loop */ + j = 0; + buf_len = sizeof(unsigned char) * 8; + + /* decompress */ + for(i = 0; i < d_nelmts; i++) + H5Z_scaleoffset_decompress_one_atomic(data, i * p.size, buffer, &j, &buf_len, p); } -static void H5Z_scaleoffset_compress_one_byte(unsigned char *data, size_t data_offset, int k, -int begin_i, unsigned char *buffer, size_t *j, int *buf_len, parms_atomic p, int dtype_len) +static void +H5Z_scaleoffset_compress_one_byte(unsigned char *data, size_t data_offset, + unsigned k, unsigned begin_i, unsigned char *buffer, size_t *j, unsigned *buf_len, + parms_atomic p, unsigned dtype_len) { - int dat_len; /* dat_len is the number of bits to be copied in each data byte */ - unsigned char val; /* value to be copied in each data byte */ + unsigned dat_len; /* dat_len is the number of bits to be copied in each data byte */ + unsigned char val; /* value to be copied in each data byte */ /* initialize value and bits of unsigned char to be copied */ val = data[data_offset + k]; @@ -1487,53 +1565,58 @@ int begin_i, unsigned char *buffer, size_t *j, int *buf_len, parms_atomic p, int dat_len = 8; if(*buf_len > dat_len) { - buffer[*j] |= (val & ~(~0 << dat_len)) << (*buf_len - dat_len); + buffer[*j] |= (unsigned char)((val & ~(~0 << dat_len)) << (*buf_len - dat_len)); *buf_len -= dat_len; } else { - buffer[*j] |= (val >> (dat_len - *buf_len)) & ~(~0 << *buf_len); + buffer[*j] |= (unsigned char)((val >> (dat_len - *buf_len)) & ~(~0 << *buf_len)); dat_len -= *buf_len; H5Z_scaleoffset_next_byte(j, buf_len); - if(dat_len == 0) return; + if(dat_len == 0) + return; - buffer[*j] = (val & ~(~0 << dat_len)) << (*buf_len - dat_len); + buffer[*j] = (unsigned char)((val & ~(~0 << dat_len)) << (*buf_len - dat_len)); *buf_len -= dat_len; - } + } /* end else */ } -static void H5Z_scaleoffset_compress_one_atomic(unsigned char *data, size_t data_offset, - unsigned char *buffer, size_t *j, int *buf_len, parms_atomic p) +static void +H5Z_scaleoffset_compress_one_atomic(unsigned char *data, size_t data_offset, + unsigned char *buffer, size_t *j, unsigned *buf_len, parms_atomic p) { /* begin_i: the index of byte having first significant bit */ - int k, begin_i, dtype_len; + unsigned begin_i; + unsigned dtype_len; + int k; - assert(p.minbits > 0); + HDassert(p.minbits > 0); dtype_len = p.size * 8; if(p.mem_order == H5Z_SCALEOFFSET_ORDER_LE) { /* little endian */ begin_i = p.size - 1 - (dtype_len - p.minbits) / 8; - for(k = begin_i; k >= 0; k--) - H5Z_scaleoffset_compress_one_byte(data, data_offset, k, begin_i, + for(k = (int)begin_i; k >= 0; k--) + H5Z_scaleoffset_compress_one_byte(data, data_offset, (unsigned)k, begin_i, buffer, j, buf_len, p, dtype_len); } - - if(p.mem_order == H5Z_SCALEOFFSET_ORDER_BE) { /* big endian */ + else { /* big endian */ + HDassert(p.mem_order == H5Z_SCALEOFFSET_ORDER_BE); begin_i = (dtype_len - p.minbits) / 8; - for(k = begin_i; k <= p.size - 1; k++) - H5Z_scaleoffset_compress_one_byte(data, data_offset, k, begin_i, + for(k = (int)begin_i; k <= (int)(p.size - 1); k++) + H5Z_scaleoffset_compress_one_byte(data, data_offset, (unsigned)k, begin_i, buffer, j, buf_len, p, dtype_len); } } -static void H5Z_scaleoffset_compress(unsigned char *data, unsigned d_nelmts, unsigned char *buffer, - size_t buffer_size, parms_atomic p) +static void +H5Z_scaleoffset_compress(unsigned char *data, unsigned d_nelmts, + unsigned char *buffer, size_t buffer_size, parms_atomic p) { /* i: index of data, j: index of buffer, buf_len: number of bits to be filled in current byte */ size_t i, j; - int buf_len; + unsigned buf_len; /* must initialize buffer to be zeros */ for(j = 0; j < buffer_size; j++) @@ -1545,7 +1628,7 @@ static void H5Z_scaleoffset_compress(unsigned char *data, unsigned d_nelmts, uns /* compress */ for(i = 0; i < d_nelmts; i++) - H5Z_scaleoffset_compress_one_atomic(data, i*p.size, buffer, &j, &buf_len, p); + H5Z_scaleoffset_compress_one_atomic(data, i * p.size, buffer, &j, &buf_len, p); } #endif /* H5_HAVE_FILTER_SCALEOFFSET */ diff --git a/src/H5config.h.in b/src/H5config.h.in index 90d1361..ef072de 100644 --- a/src/H5config.h.in +++ b/src/H5config.h.in @@ -548,6 +548,9 @@ /* The size of `off_t', as computed by sizeof. */ #undef SIZEOF_OFF_T +/* The size of `ptrdiff_t', as computed by sizeof. */ +#undef SIZEOF_PTRDIFF_T + /* The size of `short', as computed by sizeof. */ #undef SIZEOF_SHORT @@ -676,6 +679,9 @@ /* Define to `long int' if <sys/types.h> does not define. */ #undef off_t +/* Define to `long' if <sys/types.h> does not define. */ +#undef ptrdiff_t + /* Define to `unsigned long' if <sys/types.h> does not define. */ #undef size_t diff --git a/src/H5detect.c b/src/H5detect.c index 50b36fd..ac1185f 100644 --- a/src/H5detect.c +++ b/src/H5detect.c @@ -92,7 +92,7 @@ static volatile int nd_g = 0, na_g = 0; static void print_results(int nd, detected_t *d, int na, malign_t *m); static void iprint(detected_t *); -static int byte_cmp(int, void *, void *); +static int byte_cmp(int, const void *, const void *); static int bit_cmp(int, int *, void *, void *); static void fix_order(int, int, int, int *, const char **); static int imp_bit(int, int *, void *, void *); @@ -250,19 +250,10 @@ precision (detected_t *d) * matzke@llnl.gov * Jun 12 1996 * - * Modifications: - * - * Robb Matzke, 14 Aug 1996 - * The byte order detection has been changed because on the Cray - * the last pass causes a rounding to occur that causes the least - * significant mantissa byte to change unexpectedly. - * - * Robb Matzke, 5 Nov 1996 - * Removed HFILE and CFILE arguments. *------------------------------------------------------------------------- */ #define DETECT_F(TYPE,VAR,INFO) { \ - TYPE _v1, _v2, _v3; \ + volatile TYPE _v1, _v2, _v3; \ int _i, _j, _first=(-1), _last=(-1); \ char *_mesg; \ \ @@ -279,7 +270,8 @@ precision (detected_t *d) /* Byte Order */ \ for (_i=0,_v1=0.0,_v2=1.0; _i<(signed)sizeof(TYPE); _i++) { \ _v3 = _v1; _v1 += _v2; _v2 /= 256.0; \ - if ((_j=byte_cmp(sizeof(TYPE), &_v3, &_v1))>=0) { \ + _j=byte_cmp(sizeof(TYPE), &_v3, &_v1); \ + if(_j>=0) { \ if (0==_i || INFO.perm[_i-1]!=_j) { \ INFO.perm[_i] = _j; \ _last = _i; \ @@ -831,11 +823,11 @@ iprint(detected_t *d) *------------------------------------------------------------------------- */ static int -byte_cmp(int n, void *_a, void *_b) +byte_cmp(int n, const void *_a, const void *_b) { - register int i; - unsigned char *a = (unsigned char *) _a; - unsigned char *b = (unsigned char *) _b; + int i; + const unsigned char *a = (const unsigned char *) _a; + const unsigned char *b = (const unsigned char *) _b; for (i = 0; i < n; i++) if (a[i] != b[i]) return i; return -1; diff --git a/src/H5overflow.h b/src/H5overflow.h index 1c00acf..f4064f4 100644 --- a/src/H5overflow.h +++ b/src/H5overflow.h @@ -51,6 +51,18 @@ ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) #endif /* src: unsigned dst: uint8_t */ +/* src: unsigned, dst: uint16_t */ +#if H5_SIZEOF_UNSIGNED < H5_SIZEOF_UINT16_T + #define ASSIGN_unsigned_TO_uint16_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_UNSIGNED > H5_SIZEOF_UINT16_T + #define ASSIGN_unsigned_TO_uint16_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_UNSIGNED == H5_SIZEOF_UINT16_T */ + #define ASSIGN_unsigned_TO_uint16_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: unsigned dst: uint16_t */ + /* src: unsigned, dst: uint32_t */ #if H5_SIZEOF_UNSIGNED < H5_SIZEOF_UINT32_T #define ASSIGN_unsigned_TO_uint32_t(dst, dsttype, src, srctype) \ @@ -75,6 +87,18 @@ ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) #endif /* src: unsigned dst: uint64_t */ +/* src: unsigned, dst: ptrdiff_t */ +#if H5_SIZEOF_UNSIGNED < H5_SIZEOF_PTRDIFF_T + #define ASSIGN_unsigned_TO_ptrdiff_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_UNSIGNED > H5_SIZEOF_PTRDIFF_T + #define ASSIGN_unsigned_TO_ptrdiff_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_UNSIGNED == H5_SIZEOF_PTRDIFF_T */ + #define ASSIGN_unsigned_TO_ptrdiff_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#endif /* src: unsigned dst: ptrdiff_t */ + /* src: unsigned, dst: size_t */ #if H5_SIZEOF_UNSIGNED < H5_SIZEOF_SIZE_T #define ASSIGN_unsigned_TO_size_t(dst, dsttype, src, srctype) \ @@ -174,6 +198,18 @@ ASSIGN_TO_SAME_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) #endif /* src: int dst: uint8_t */ +/* src: int, dst: uint16_t */ +#if H5_SIZEOF_INT < H5_SIZEOF_UINT16_T + #define ASSIGN_int_TO_uint16_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_INT > H5_SIZEOF_UINT16_T + #define ASSIGN_int_TO_uint16_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_INT == H5_SIZEOF_UINT16_T */ + #define ASSIGN_int_TO_uint16_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#endif /* src: int dst: uint16_t */ + /* src: int, dst: uint32_t */ #if H5_SIZEOF_INT < H5_SIZEOF_UINT32_T #define ASSIGN_int_TO_uint32_t(dst, dsttype, src, srctype) \ @@ -198,6 +234,18 @@ ASSIGN_TO_SAME_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) #endif /* src: int dst: uint64_t */ +/* src: int, dst: ptrdiff_t */ +#if H5_SIZEOF_INT < H5_SIZEOF_PTRDIFF_T + #define ASSIGN_int_TO_ptrdiff_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_INT > H5_SIZEOF_PTRDIFF_T + #define ASSIGN_int_TO_ptrdiff_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_INT == H5_SIZEOF_PTRDIFF_T */ + #define ASSIGN_int_TO_ptrdiff_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: int dst: ptrdiff_t */ + /* src: int, dst: size_t */ #if H5_SIZEOF_INT < H5_SIZEOF_SIZE_T #define ASSIGN_int_TO_size_t(dst, dsttype, src, srctype) \ @@ -297,6 +345,18 @@ ASSIGN_TO_SAME_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) #endif /* src: uint8_t dst: int */ +/* src: uint8_t, dst: uint16_t */ +#if H5_SIZEOF_UINT8_T < H5_SIZEOF_UINT16_T + #define ASSIGN_uint8_t_TO_uint16_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_UINT8_T > H5_SIZEOF_UINT16_T + #define ASSIGN_uint8_t_TO_uint16_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_UINT8_T == H5_SIZEOF_UINT16_T */ + #define ASSIGN_uint8_t_TO_uint16_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: uint8_t dst: uint16_t */ + /* src: uint8_t, dst: uint32_t */ #if H5_SIZEOF_UINT8_T < H5_SIZEOF_UINT32_T #define ASSIGN_uint8_t_TO_uint32_t(dst, dsttype, src, srctype) \ @@ -321,6 +381,18 @@ ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) #endif /* src: uint8_t dst: uint64_t */ +/* src: uint8_t, dst: ptrdiff_t */ +#if H5_SIZEOF_UINT8_T < H5_SIZEOF_PTRDIFF_T + #define ASSIGN_uint8_t_TO_ptrdiff_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_UINT8_T > H5_SIZEOF_PTRDIFF_T + #define ASSIGN_uint8_t_TO_ptrdiff_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_UINT8_T == H5_SIZEOF_PTRDIFF_T */ + #define ASSIGN_uint8_t_TO_ptrdiff_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#endif /* src: uint8_t dst: ptrdiff_t */ + /* src: uint8_t, dst: size_t */ #if H5_SIZEOF_UINT8_T < H5_SIZEOF_SIZE_T #define ASSIGN_uint8_t_TO_size_t(dst, dsttype, src, srctype) \ @@ -394,6 +466,153 @@ #endif /* src: uint8_t dst: h5_stat_size_t */ +/* Assignment checks for uint16_t */ + +/* src: uint16_t, dst: unsigned */ +#if H5_SIZEOF_UINT16_T < H5_SIZEOF_UNSIGNED + #define ASSIGN_uint16_t_TO_unsigned(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_UINT16_T > H5_SIZEOF_UNSIGNED + #define ASSIGN_uint16_t_TO_unsigned(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_UINT16_T == H5_SIZEOF_UNSIGNED */ + #define ASSIGN_uint16_t_TO_unsigned(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: uint16_t dst: unsigned */ + +/* src: uint16_t, dst: int */ +#if H5_SIZEOF_UINT16_T < H5_SIZEOF_INT + #define ASSIGN_uint16_t_TO_int(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_UINT16_T > H5_SIZEOF_INT + #define ASSIGN_uint16_t_TO_int(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_UINT16_T == H5_SIZEOF_INT */ + #define ASSIGN_uint16_t_TO_int(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#endif /* src: uint16_t dst: int */ + +/* src: uint16_t, dst: uint8_t */ +#if H5_SIZEOF_UINT16_T < H5_SIZEOF_UINT8_T + #define ASSIGN_uint16_t_TO_uint8_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_UINT16_T > H5_SIZEOF_UINT8_T + #define ASSIGN_uint16_t_TO_uint8_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_UINT16_T == H5_SIZEOF_UINT8_T */ + #define ASSIGN_uint16_t_TO_uint8_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: uint16_t dst: uint8_t */ + +/* src: uint16_t, dst: uint32_t */ +#if H5_SIZEOF_UINT16_T < H5_SIZEOF_UINT32_T + #define ASSIGN_uint16_t_TO_uint32_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_UINT16_T > H5_SIZEOF_UINT32_T + #define ASSIGN_uint16_t_TO_uint32_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_UINT16_T == H5_SIZEOF_UINT32_T */ + #define ASSIGN_uint16_t_TO_uint32_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: uint16_t dst: uint32_t */ + +/* src: uint16_t, dst: uint64_t */ +#if H5_SIZEOF_UINT16_T < H5_SIZEOF_UINT64_T + #define ASSIGN_uint16_t_TO_uint64_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_UINT16_T > H5_SIZEOF_UINT64_T + #define ASSIGN_uint16_t_TO_uint64_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_UINT16_T == H5_SIZEOF_UINT64_T */ + #define ASSIGN_uint16_t_TO_uint64_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: uint16_t dst: uint64_t */ + +/* src: uint16_t, dst: ptrdiff_t */ +#if H5_SIZEOF_UINT16_T < H5_SIZEOF_PTRDIFF_T + #define ASSIGN_uint16_t_TO_ptrdiff_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_UINT16_T > H5_SIZEOF_PTRDIFF_T + #define ASSIGN_uint16_t_TO_ptrdiff_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_UINT16_T == H5_SIZEOF_PTRDIFF_T */ + #define ASSIGN_uint16_t_TO_ptrdiff_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#endif /* src: uint16_t dst: ptrdiff_t */ + +/* src: uint16_t, dst: size_t */ +#if H5_SIZEOF_UINT16_T < H5_SIZEOF_SIZE_T + #define ASSIGN_uint16_t_TO_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_UINT16_T > H5_SIZEOF_SIZE_T + #define ASSIGN_uint16_t_TO_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_UINT16_T == H5_SIZEOF_SIZE_T */ + #define ASSIGN_uint16_t_TO_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: uint16_t dst: size_t */ + +/* src: uint16_t, dst: ssize_t */ +#if H5_SIZEOF_UINT16_T < H5_SIZEOF_SSIZE_T + #define ASSIGN_uint16_t_TO_ssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_UINT16_T > H5_SIZEOF_SSIZE_T + #define ASSIGN_uint16_t_TO_ssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_UINT16_T == H5_SIZEOF_SSIZE_T */ + #define ASSIGN_uint16_t_TO_ssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#endif /* src: uint16_t dst: ssize_t */ + +/* src: uint16_t, dst: haddr_t */ +#if H5_SIZEOF_UINT16_T < H5_SIZEOF_HADDR_T + #define ASSIGN_uint16_t_TO_haddr_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_UINT16_T > H5_SIZEOF_HADDR_T + #define ASSIGN_uint16_t_TO_haddr_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_UINT16_T == H5_SIZEOF_HADDR_T */ + #define ASSIGN_uint16_t_TO_haddr_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: uint16_t dst: haddr_t */ + +/* src: uint16_t, dst: hsize_t */ +#if H5_SIZEOF_UINT16_T < H5_SIZEOF_HSIZE_T + #define ASSIGN_uint16_t_TO_hsize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_UINT16_T > H5_SIZEOF_HSIZE_T + #define ASSIGN_uint16_t_TO_hsize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_UINT16_T == H5_SIZEOF_HSIZE_T */ + #define ASSIGN_uint16_t_TO_hsize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: uint16_t dst: hsize_t */ + +/* src: uint16_t, dst: hssize_t */ +#if H5_SIZEOF_UINT16_T < H5_SIZEOF_HSSIZE_T + #define ASSIGN_uint16_t_TO_hssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_UINT16_T > H5_SIZEOF_HSSIZE_T + #define ASSIGN_uint16_t_TO_hssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_UINT16_T == H5_SIZEOF_HSSIZE_T */ + #define ASSIGN_uint16_t_TO_hssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#endif /* src: uint16_t dst: hssize_t */ + +/* src: uint16_t, dst: h5_stat_size_t */ +#if H5_SIZEOF_UINT16_T < H5_SIZEOF_H5_STAT_SIZE_T + #define ASSIGN_uint16_t_TO_h5_stat_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_UINT16_T > H5_SIZEOF_H5_STAT_SIZE_T + #define ASSIGN_uint16_t_TO_h5_stat_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_UINT16_T == H5_SIZEOF_H5_STAT_SIZE_T */ + #define ASSIGN_uint16_t_TO_h5_stat_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: uint16_t dst: h5_stat_size_t */ + + /* Assignment checks for uint32_t */ /* src: uint32_t, dst: unsigned */ @@ -432,6 +651,18 @@ ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) #endif /* src: uint32_t dst: uint8_t */ +/* src: uint32_t, dst: uint16_t */ +#if H5_SIZEOF_UINT32_T < H5_SIZEOF_UINT16_T + #define ASSIGN_uint32_t_TO_uint16_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_UINT32_T > H5_SIZEOF_UINT16_T + #define ASSIGN_uint32_t_TO_uint16_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_UINT32_T == H5_SIZEOF_UINT16_T */ + #define ASSIGN_uint32_t_TO_uint16_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: uint32_t dst: uint16_t */ + /* src: uint32_t, dst: uint64_t */ #if H5_SIZEOF_UINT32_T < H5_SIZEOF_UINT64_T #define ASSIGN_uint32_t_TO_uint64_t(dst, dsttype, src, srctype) \ @@ -444,6 +675,18 @@ ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) #endif /* src: uint32_t dst: uint64_t */ +/* src: uint32_t, dst: ptrdiff_t */ +#if H5_SIZEOF_UINT32_T < H5_SIZEOF_PTRDIFF_T + #define ASSIGN_uint32_t_TO_ptrdiff_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_UINT32_T > H5_SIZEOF_PTRDIFF_T + #define ASSIGN_uint32_t_TO_ptrdiff_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_UINT32_T == H5_SIZEOF_PTRDIFF_T */ + #define ASSIGN_uint32_t_TO_ptrdiff_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#endif /* src: uint32_t dst: ptrdiff_t */ + /* src: uint32_t, dst: size_t */ #if H5_SIZEOF_UINT32_T < H5_SIZEOF_SIZE_T #define ASSIGN_uint32_t_TO_size_t(dst, dsttype, src, srctype) \ @@ -555,6 +798,18 @@ ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) #endif /* src: uint64_t dst: uint8_t */ +/* src: uint64_t, dst: uint16_t */ +#if H5_SIZEOF_UINT64_T < H5_SIZEOF_UINT16_T + #define ASSIGN_uint64_t_TO_uint16_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_UINT64_T > H5_SIZEOF_UINT16_T + #define ASSIGN_uint64_t_TO_uint16_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_UINT64_T == H5_SIZEOF_UINT16_T */ + #define ASSIGN_uint64_t_TO_uint16_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: uint64_t dst: uint16_t */ + /* src: uint64_t, dst: uint32_t */ #if H5_SIZEOF_UINT64_T < H5_SIZEOF_UINT32_T #define ASSIGN_uint64_t_TO_uint32_t(dst, dsttype, src, srctype) \ @@ -567,6 +822,18 @@ ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) #endif /* src: uint64_t dst: uint32_t */ +/* src: uint64_t, dst: ptrdiff_t */ +#if H5_SIZEOF_UINT64_T < H5_SIZEOF_PTRDIFF_T + #define ASSIGN_uint64_t_TO_ptrdiff_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_UINT64_T > H5_SIZEOF_PTRDIFF_T + #define ASSIGN_uint64_t_TO_ptrdiff_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_UINT64_T == H5_SIZEOF_PTRDIFF_T */ + #define ASSIGN_uint64_t_TO_ptrdiff_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#endif /* src: uint64_t dst: ptrdiff_t */ + /* src: uint64_t, dst: size_t */ #if H5_SIZEOF_UINT64_T < H5_SIZEOF_SIZE_T #define ASSIGN_uint64_t_TO_size_t(dst, dsttype, src, srctype) \ @@ -640,6 +907,153 @@ #endif /* src: uint64_t dst: h5_stat_size_t */ +/* Assignment checks for ptrdiff_t */ + +/* src: ptrdiff_t, dst: unsigned */ +#if H5_SIZEOF_PTRDIFF_T < H5_SIZEOF_UNSIGNED + #define ASSIGN_ptrdiff_t_TO_unsigned(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_PTRDIFF_T > H5_SIZEOF_UNSIGNED + #define ASSIGN_ptrdiff_t_TO_unsigned(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_PTRDIFF_T == H5_SIZEOF_UNSIGNED */ + #define ASSIGN_ptrdiff_t_TO_unsigned(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#endif /* src: ptrdiff_t dst: unsigned */ + +/* src: ptrdiff_t, dst: int */ +#if H5_SIZEOF_PTRDIFF_T < H5_SIZEOF_INT + #define ASSIGN_ptrdiff_t_TO_int(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_PTRDIFF_T > H5_SIZEOF_INT + #define ASSIGN_ptrdiff_t_TO_int(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_PTRDIFF_T == H5_SIZEOF_INT */ + #define ASSIGN_ptrdiff_t_TO_int(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: ptrdiff_t dst: int */ + +/* src: ptrdiff_t, dst: uint8_t */ +#if H5_SIZEOF_PTRDIFF_T < H5_SIZEOF_UINT8_T + #define ASSIGN_ptrdiff_t_TO_uint8_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_PTRDIFF_T > H5_SIZEOF_UINT8_T + #define ASSIGN_ptrdiff_t_TO_uint8_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_PTRDIFF_T == H5_SIZEOF_UINT8_T */ + #define ASSIGN_ptrdiff_t_TO_uint8_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#endif /* src: ptrdiff_t dst: uint8_t */ + +/* src: ptrdiff_t, dst: uint16_t */ +#if H5_SIZEOF_PTRDIFF_T < H5_SIZEOF_UINT16_T + #define ASSIGN_ptrdiff_t_TO_uint16_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_PTRDIFF_T > H5_SIZEOF_UINT16_T + #define ASSIGN_ptrdiff_t_TO_uint16_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_PTRDIFF_T == H5_SIZEOF_UINT16_T */ + #define ASSIGN_ptrdiff_t_TO_uint16_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#endif /* src: ptrdiff_t dst: uint16_t */ + +/* src: ptrdiff_t, dst: uint32_t */ +#if H5_SIZEOF_PTRDIFF_T < H5_SIZEOF_UINT32_T + #define ASSIGN_ptrdiff_t_TO_uint32_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_PTRDIFF_T > H5_SIZEOF_UINT32_T + #define ASSIGN_ptrdiff_t_TO_uint32_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_PTRDIFF_T == H5_SIZEOF_UINT32_T */ + #define ASSIGN_ptrdiff_t_TO_uint32_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#endif /* src: ptrdiff_t dst: uint32_t */ + +/* src: ptrdiff_t, dst: uint64_t */ +#if H5_SIZEOF_PTRDIFF_T < H5_SIZEOF_UINT64_T + #define ASSIGN_ptrdiff_t_TO_uint64_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_PTRDIFF_T > H5_SIZEOF_UINT64_T + #define ASSIGN_ptrdiff_t_TO_uint64_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_PTRDIFF_T == H5_SIZEOF_UINT64_T */ + #define ASSIGN_ptrdiff_t_TO_uint64_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#endif /* src: ptrdiff_t dst: uint64_t */ + +/* src: ptrdiff_t, dst: size_t */ +#if H5_SIZEOF_PTRDIFF_T < H5_SIZEOF_SIZE_T + #define ASSIGN_ptrdiff_t_TO_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_PTRDIFF_T > H5_SIZEOF_SIZE_T + #define ASSIGN_ptrdiff_t_TO_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_PTRDIFF_T == H5_SIZEOF_SIZE_T */ + #define ASSIGN_ptrdiff_t_TO_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#endif /* src: ptrdiff_t dst: size_t */ + +/* src: ptrdiff_t, dst: ssize_t */ +#if H5_SIZEOF_PTRDIFF_T < H5_SIZEOF_SSIZE_T + #define ASSIGN_ptrdiff_t_TO_ssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_PTRDIFF_T > H5_SIZEOF_SSIZE_T + #define ASSIGN_ptrdiff_t_TO_ssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_PTRDIFF_T == H5_SIZEOF_SSIZE_T */ + #define ASSIGN_ptrdiff_t_TO_ssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: ptrdiff_t dst: ssize_t */ + +/* src: ptrdiff_t, dst: haddr_t */ +#if H5_SIZEOF_PTRDIFF_T < H5_SIZEOF_HADDR_T + #define ASSIGN_ptrdiff_t_TO_haddr_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_PTRDIFF_T > H5_SIZEOF_HADDR_T + #define ASSIGN_ptrdiff_t_TO_haddr_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_PTRDIFF_T == H5_SIZEOF_HADDR_T */ + #define ASSIGN_ptrdiff_t_TO_haddr_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#endif /* src: ptrdiff_t dst: haddr_t */ + +/* src: ptrdiff_t, dst: hsize_t */ +#if H5_SIZEOF_PTRDIFF_T < H5_SIZEOF_HSIZE_T + #define ASSIGN_ptrdiff_t_TO_hsize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_PTRDIFF_T > H5_SIZEOF_HSIZE_T + #define ASSIGN_ptrdiff_t_TO_hsize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_PTRDIFF_T == H5_SIZEOF_HSIZE_T */ + #define ASSIGN_ptrdiff_t_TO_hsize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#endif /* src: ptrdiff_t dst: hsize_t */ + +/* src: ptrdiff_t, dst: hssize_t */ +#if H5_SIZEOF_PTRDIFF_T < H5_SIZEOF_HSSIZE_T + #define ASSIGN_ptrdiff_t_TO_hssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_PTRDIFF_T > H5_SIZEOF_HSSIZE_T + #define ASSIGN_ptrdiff_t_TO_hssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_PTRDIFF_T == H5_SIZEOF_HSSIZE_T */ + #define ASSIGN_ptrdiff_t_TO_hssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: ptrdiff_t dst: hssize_t */ + +/* src: ptrdiff_t, dst: h5_stat_size_t */ +#if H5_SIZEOF_PTRDIFF_T < H5_SIZEOF_H5_STAT_SIZE_T + #define ASSIGN_ptrdiff_t_TO_h5_stat_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_PTRDIFF_T > H5_SIZEOF_H5_STAT_SIZE_T + #define ASSIGN_ptrdiff_t_TO_h5_stat_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_PTRDIFF_T == H5_SIZEOF_H5_STAT_SIZE_T */ + #define ASSIGN_ptrdiff_t_TO_h5_stat_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#endif /* src: ptrdiff_t dst: h5_stat_size_t */ + + /* Assignment checks for size_t */ /* src: size_t, dst: unsigned */ @@ -678,6 +1092,18 @@ ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) #endif /* src: size_t dst: uint8_t */ +/* src: size_t, dst: uint16_t */ +#if H5_SIZEOF_SIZE_T < H5_SIZEOF_UINT16_T + #define ASSIGN_size_t_TO_uint16_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_SIZE_T > H5_SIZEOF_UINT16_T + #define ASSIGN_size_t_TO_uint16_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_SIZE_T == H5_SIZEOF_UINT16_T */ + #define ASSIGN_size_t_TO_uint16_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: size_t dst: uint16_t */ + /* src: size_t, dst: uint32_t */ #if H5_SIZEOF_SIZE_T < H5_SIZEOF_UINT32_T #define ASSIGN_size_t_TO_uint32_t(dst, dsttype, src, srctype) \ @@ -702,6 +1128,18 @@ ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) #endif /* src: size_t dst: uint64_t */ +/* src: size_t, dst: ptrdiff_t */ +#if H5_SIZEOF_SIZE_T < H5_SIZEOF_PTRDIFF_T + #define ASSIGN_size_t_TO_ptrdiff_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_SIZE_T > H5_SIZEOF_PTRDIFF_T + #define ASSIGN_size_t_TO_ptrdiff_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_SIZE_T == H5_SIZEOF_PTRDIFF_T */ + #define ASSIGN_size_t_TO_ptrdiff_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#endif /* src: size_t dst: ptrdiff_t */ + /* src: size_t, dst: ssize_t */ #if H5_SIZEOF_SIZE_T < H5_SIZEOF_SSIZE_T #define ASSIGN_size_t_TO_ssize_t(dst, dsttype, src, srctype) \ @@ -801,6 +1239,18 @@ ASSIGN_TO_SAME_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) #endif /* src: ssize_t dst: uint8_t */ +/* src: ssize_t, dst: uint16_t */ +#if H5_SIZEOF_SSIZE_T < H5_SIZEOF_UINT16_T + #define ASSIGN_ssize_t_TO_uint16_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_SSIZE_T > H5_SIZEOF_UINT16_T + #define ASSIGN_ssize_t_TO_uint16_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_SSIZE_T == H5_SIZEOF_UINT16_T */ + #define ASSIGN_ssize_t_TO_uint16_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#endif /* src: ssize_t dst: uint16_t */ + /* src: ssize_t, dst: uint32_t */ #if H5_SIZEOF_SSIZE_T < H5_SIZEOF_UINT32_T #define ASSIGN_ssize_t_TO_uint32_t(dst, dsttype, src, srctype) \ @@ -825,6 +1275,18 @@ ASSIGN_TO_SAME_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) #endif /* src: ssize_t dst: uint64_t */ +/* src: ssize_t, dst: ptrdiff_t */ +#if H5_SIZEOF_SSIZE_T < H5_SIZEOF_PTRDIFF_T + #define ASSIGN_ssize_t_TO_ptrdiff_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_SSIZE_T > H5_SIZEOF_PTRDIFF_T + #define ASSIGN_ssize_t_TO_ptrdiff_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_SSIZE_T == H5_SIZEOF_PTRDIFF_T */ + #define ASSIGN_ssize_t_TO_ptrdiff_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: ssize_t dst: ptrdiff_t */ + /* src: ssize_t, dst: size_t */ #if H5_SIZEOF_SSIZE_T < H5_SIZEOF_SIZE_T #define ASSIGN_ssize_t_TO_size_t(dst, dsttype, src, srctype) \ @@ -924,6 +1386,18 @@ ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) #endif /* src: haddr_t dst: uint8_t */ +/* src: haddr_t, dst: uint16_t */ +#if H5_SIZEOF_HADDR_T < H5_SIZEOF_UINT16_T + #define ASSIGN_haddr_t_TO_uint16_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_HADDR_T > H5_SIZEOF_UINT16_T + #define ASSIGN_haddr_t_TO_uint16_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_HADDR_T == H5_SIZEOF_UINT16_T */ + #define ASSIGN_haddr_t_TO_uint16_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: haddr_t dst: uint16_t */ + /* src: haddr_t, dst: uint32_t */ #if H5_SIZEOF_HADDR_T < H5_SIZEOF_UINT32_T #define ASSIGN_haddr_t_TO_uint32_t(dst, dsttype, src, srctype) \ @@ -948,6 +1422,18 @@ ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) #endif /* src: haddr_t dst: uint64_t */ +/* src: haddr_t, dst: ptrdiff_t */ +#if H5_SIZEOF_HADDR_T < H5_SIZEOF_PTRDIFF_T + #define ASSIGN_haddr_t_TO_ptrdiff_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_HADDR_T > H5_SIZEOF_PTRDIFF_T + #define ASSIGN_haddr_t_TO_ptrdiff_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_HADDR_T == H5_SIZEOF_PTRDIFF_T */ + #define ASSIGN_haddr_t_TO_ptrdiff_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#endif /* src: haddr_t dst: ptrdiff_t */ + /* src: haddr_t, dst: size_t */ #if H5_SIZEOF_HADDR_T < H5_SIZEOF_SIZE_T #define ASSIGN_haddr_t_TO_size_t(dst, dsttype, src, srctype) \ @@ -1047,6 +1533,18 @@ ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) #endif /* src: hsize_t dst: uint8_t */ +/* src: hsize_t, dst: uint16_t */ +#if H5_SIZEOF_HSIZE_T < H5_SIZEOF_UINT16_T + #define ASSIGN_hsize_t_TO_uint16_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_HSIZE_T > H5_SIZEOF_UINT16_T + #define ASSIGN_hsize_t_TO_uint16_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_HSIZE_T == H5_SIZEOF_UINT16_T */ + #define ASSIGN_hsize_t_TO_uint16_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: hsize_t dst: uint16_t */ + /* src: hsize_t, dst: uint32_t */ #if H5_SIZEOF_HSIZE_T < H5_SIZEOF_UINT32_T #define ASSIGN_hsize_t_TO_uint32_t(dst, dsttype, src, srctype) \ @@ -1071,6 +1569,18 @@ ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) #endif /* src: hsize_t dst: uint64_t */ +/* src: hsize_t, dst: ptrdiff_t */ +#if H5_SIZEOF_HSIZE_T < H5_SIZEOF_PTRDIFF_T + #define ASSIGN_hsize_t_TO_ptrdiff_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_HSIZE_T > H5_SIZEOF_PTRDIFF_T + #define ASSIGN_hsize_t_TO_ptrdiff_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_HSIZE_T == H5_SIZEOF_PTRDIFF_T */ + #define ASSIGN_hsize_t_TO_ptrdiff_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#endif /* src: hsize_t dst: ptrdiff_t */ + /* src: hsize_t, dst: size_t */ #if H5_SIZEOF_HSIZE_T < H5_SIZEOF_SIZE_T #define ASSIGN_hsize_t_TO_size_t(dst, dsttype, src, srctype) \ @@ -1170,6 +1680,18 @@ ASSIGN_TO_SAME_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) #endif /* src: hssize_t dst: uint8_t */ +/* src: hssize_t, dst: uint16_t */ +#if H5_SIZEOF_HSSIZE_T < H5_SIZEOF_UINT16_T + #define ASSIGN_hssize_t_TO_uint16_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_HSSIZE_T > H5_SIZEOF_UINT16_T + #define ASSIGN_hssize_t_TO_uint16_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_HSSIZE_T == H5_SIZEOF_UINT16_T */ + #define ASSIGN_hssize_t_TO_uint16_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#endif /* src: hssize_t dst: uint16_t */ + /* src: hssize_t, dst: uint32_t */ #if H5_SIZEOF_HSSIZE_T < H5_SIZEOF_UINT32_T #define ASSIGN_hssize_t_TO_uint32_t(dst, dsttype, src, srctype) \ @@ -1194,6 +1716,18 @@ ASSIGN_TO_SAME_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) #endif /* src: hssize_t dst: uint64_t */ +/* src: hssize_t, dst: ptrdiff_t */ +#if H5_SIZEOF_HSSIZE_T < H5_SIZEOF_PTRDIFF_T + #define ASSIGN_hssize_t_TO_ptrdiff_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_HSSIZE_T > H5_SIZEOF_PTRDIFF_T + #define ASSIGN_hssize_t_TO_ptrdiff_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_HSSIZE_T == H5_SIZEOF_PTRDIFF_T */ + #define ASSIGN_hssize_t_TO_ptrdiff_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: hssize_t dst: ptrdiff_t */ + /* src: hssize_t, dst: size_t */ #if H5_SIZEOF_HSSIZE_T < H5_SIZEOF_SIZE_T #define ASSIGN_hssize_t_TO_size_t(dst, dsttype, src, srctype) \ @@ -1293,6 +1827,18 @@ ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) #endif /* src: h5_stat_size_t dst: uint8_t */ +/* src: h5_stat_size_t, dst: uint16_t */ +#if H5_SIZEOF_H5_STAT_SIZE_T < H5_SIZEOF_UINT16_T + #define ASSIGN_h5_stat_size_t_TO_uint16_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_H5_STAT_SIZE_T > H5_SIZEOF_UINT16_T + #define ASSIGN_h5_stat_size_t_TO_uint16_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_H5_STAT_SIZE_T == H5_SIZEOF_UINT16_T */ + #define ASSIGN_h5_stat_size_t_TO_uint16_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: h5_stat_size_t dst: uint16_t */ + /* src: h5_stat_size_t, dst: uint32_t */ #if H5_SIZEOF_H5_STAT_SIZE_T < H5_SIZEOF_UINT32_T #define ASSIGN_h5_stat_size_t_TO_uint32_t(dst, dsttype, src, srctype) \ @@ -1317,6 +1863,18 @@ ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) #endif /* src: h5_stat_size_t dst: uint64_t */ +/* src: h5_stat_size_t, dst: ptrdiff_t */ +#if H5_SIZEOF_H5_STAT_SIZE_T < H5_SIZEOF_PTRDIFF_T + #define ASSIGN_h5_stat_size_t_TO_ptrdiff_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_H5_STAT_SIZE_T > H5_SIZEOF_PTRDIFF_T + #define ASSIGN_h5_stat_size_t_TO_ptrdiff_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_H5_STAT_SIZE_T == H5_SIZEOF_PTRDIFF_T */ + #define ASSIGN_h5_stat_size_t_TO_ptrdiff_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#endif /* src: h5_stat_size_t dst: ptrdiff_t */ + /* src: h5_stat_size_t, dst: size_t */ #if H5_SIZEOF_H5_STAT_SIZE_T < H5_SIZEOF_SIZE_T #define ASSIGN_h5_stat_size_t_TO_size_t(dst, dsttype, src, srctype) \ diff --git a/src/H5overflow.txt b/src/H5overflow.txt index ea62fa0..c093fd5 100644 --- a/src/H5overflow.txt +++ b/src/H5overflow.txt @@ -33,8 +33,10 @@ unsigned, UNSIGNED; int, SIGNED; uint8_t, UNSIGNED; +uint16_t, UNSIGNED; uint32_t, UNSIGNED; uint64_t, UNSIGNED; +ptrdiff_t, SIGNED; size_t, UNSIGNED; ssize_t, SIGNED; haddr_t, UNSIGNED; diff --git a/test/dt_arith.c b/test/dt_arith.c index ff6b4e0..78a05be 100644 --- a/test/dt_arith.c +++ b/test/dt_arith.c @@ -2821,6 +2821,10 @@ test_conv_flt_1 (const char *name, int run_test, hid_t src, hid_t dst) return 0; /*child exit after catching SIGFPE*/ } else if (WIFEXITED(status)) { return WEXITSTATUS(status); + } else if (WIFSIGNALED(status)) { + sprintf(str, " Child caught signal %d.", WTERMSIG(status)); + HDputs(str); + return 1; /*child exit after catching non-SIGFPE signal */ } else { HDputs(" Child didn't exit normally."); return 1; @@ -3367,10 +3371,7 @@ test_conv_flt_1 (const char *name, int run_test, hid_t src, hid_t dst) if(!fails_all_tests) PASSED(); - done: -#ifdef AKCDEBUG - printf("uflow=%d, fails_all_tests=%d\n", uflow, fails_all_tests); -#endif +done: if (buf) aligned_free(buf); if (saved) aligned_free(saved); if (aligned) HDfree(aligned); @@ -3391,7 +3392,7 @@ test_conv_flt_1 (const char *name, int run_test, hid_t src, hid_t dst) return 0; #endif - error: +error: if (buf) aligned_free(buf); if (saved) aligned_free(saved); if (aligned) HDfree(aligned); diff --git a/test/fheap.c b/test/fheap.c index 26bcaec..314b9ce 100644 --- a/test/fheap.c +++ b/test/fheap.c @@ -15608,6 +15608,9 @@ test_write(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) if(H5Fclose(file) < 0) FAIL_STACK_ERROR + /* Free resources */ + if(tparam->comp == FHEAP_TEST_COMPRESS) + H5O_msg_reset(H5O_PLINE_ID, &tmp_cparam.pline); /* Release the I/O pipeline filter information */ /* Free resources */ H5MM_xfree(keep_ids.ids); |