summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2016-06-28 21:53:48 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2016-06-28 21:53:48 (GMT)
commit83724bd7873e3e199a94ba9c3526732d8117e996 (patch)
treeb724d9adeb1130e81bbf3afa8ec705b63067affe
parentb8f809981bb6c378e2a942aad551620feaa47125 (diff)
downloadhdf5-83724bd7873e3e199a94ba9c3526732d8117e996.zip
hdf5-83724bd7873e3e199a94ba9c3526732d8117e996.tar.gz
hdf5-83724bd7873e3e199a94ba9c3526732d8117e996.tar.bz2
[svn-r30113] Description:
Clean up warnings (from 2774 -> 1560, with my standard debug build) Tested on: MacOSX/64 10.11.5 (amazon) w/serial, parallel & production (h5committest forthcoming)
-rw-r--r--hl/fortran/src/H5LTfc.c4
-rw-r--r--hl/fortran/src/H5TBff.F901
-rw-r--r--hl/fortran/test/tstds.F9084
-rw-r--r--hl/fortran/test/tstimage.F9054
-rw-r--r--hl/fortran/test/tstlite.F9082
-rw-r--r--hl/fortran/test/tsttable.F9074
-rw-r--r--src/H5AC.c11
-rw-r--r--src/H5B2int.c8
-rw-r--r--src/H5FD.c6
-rw-r--r--src/H5FDcore.c4
-rw-r--r--src/H5FDfamily.c8
-rw-r--r--src/H5FDmulti.c4
-rw-r--r--src/H5FDprivate.h2
-rw-r--r--src/H5FDpublic.h4
-rw-r--r--src/H5FDstdio.c4
-rw-r--r--src/H5MM.c8
-rw-r--r--src/H5PL.c2
-rw-r--r--src/H5T.c2
-rw-r--r--src/H5Znbit.c836
-rw-r--r--src/H5Zscaleoffset.c211
-rw-r--r--src/H5Ztrans.c141
-rw-r--r--src/H5detect.c2
-rw-r--r--src/H5private.h33
-rw-r--r--src/H5public.h19
-rw-r--r--test/cache_common.c2
-rw-r--r--test/dt_arith.c96
-rw-r--r--test/fheap.c2
-rw-r--r--test/freespace.c2
-rw-r--r--test/h5test.c6
-rw-r--r--test/tcheck_version.c2
-rw-r--r--test/tchecksum.c2
-rw-r--r--test/tconfig.c6
-rw-r--r--test/testframe.c10
-rw-r--r--test/titerate.c4
-rw-r--r--test/tmeta.c2
-rw-r--r--test/tselect.c2
-rw-r--r--test/ttsafe.c2
-rw-r--r--test/ttsafe_acreate.c4
-rw-r--r--tools/h5copy/h5copy.c18
-rw-r--r--tools/h5diff/h5diff_common.c2
-rw-r--r--tools/h5diff/h5diff_main.c3
-rw-r--r--tools/h5dump/h5dump.c64
-rw-r--r--tools/h5dump/h5dump.h8
-rw-r--r--tools/h5dump/h5dump_ddl.c150
-rw-r--r--tools/h5dump/h5dump_extern.h6
-rw-r--r--tools/h5dump/h5dump_xml.c1054
-rw-r--r--tools/h5dump/h5dumpgentest.c474
-rw-r--r--tools/h5repack/h5repack_copy.c2214
-rw-r--r--tools/h5repack/h5repack_refs.c241
-rw-r--r--tools/h5repack/h5repack_verify.c246
-rw-r--r--tools/lib/h5diff.c3
-rw-r--r--tools/lib/h5diff_array.c3205
-rw-r--r--tools/lib/h5diff_util.c100
-rw-r--r--tools/lib/h5tools.c88
-rw-r--r--tools/lib/h5tools.h18
-rw-r--r--tools/lib/h5tools_dump.c121
-rw-r--r--tools/lib/h5tools_filters.c79
-rw-r--r--tools/lib/h5tools_str.c240
-rw-r--r--tools/lib/h5tools_utils.c30
-rw-r--r--tools/lib/h5tools_utils.h6
-rw-r--r--tools/lib/h5trav.c8
-rw-r--r--tools/lib/io_timer.c2
-rw-r--r--tools/misc/h5repart.c4
63 files changed, 4930 insertions, 5200 deletions
diff --git a/hl/fortran/src/H5LTfc.c b/hl/fortran/src/H5LTfc.c
index 3a94664..a90c24b 100644
--- a/hl/fortran/src/H5LTfc.c
+++ b/hl/fortran/src/H5LTfc.c
@@ -327,8 +327,10 @@ h5ltset_attribute_c(hid_t_f *loc_id,
ret = H5LT_set_attribute_numerical(c_loc_id,c_name,c_attrname, c_size, H5T_NATIVE_INT, (const int *)buf);
else if ((size_t)*sizeof_val == sizeof(long))
ret = H5LT_set_attribute_numerical(c_loc_id,c_name,c_attrname, c_size, H5T_NATIVE_LONG, (const long *)buf);
+#if H5_SIZEOF_LONG != H5_SIZEOF_LONG_LONG
else if ((size_t)*sizeof_val == sizeof(long long))
ret = H5LT_set_attribute_numerical(c_loc_id,c_name,c_attrname, c_size, H5T_NATIVE_LLONG, (const long long *)buf);
+#endif /* H5_SIZEOF_LONG != H5_SIZEOF_LONG_LONG */
else
goto done;
} else if ( HDstrncmp(dtype,"R",1) == 0 ) {
@@ -420,8 +422,10 @@ h5ltget_attribute_c(hid_t_f *loc_id,
ret = H5LTget_attribute(c_loc_id,c_name,c_attrname,H5T_NATIVE_INT,buf);
else if ((size_t)*sizeof_val == sizeof(long))
ret = H5LTget_attribute(c_loc_id,c_name,c_attrname,H5T_NATIVE_LONG,buf);
+#if H5_SIZEOF_LONG != H5_SIZEOF_LONG_LONG
else if ((size_t)*sizeof_val == sizeof(long long))
ret = H5LTget_attribute(c_loc_id,c_name,c_attrname,H5T_NATIVE_LLONG,buf);
+#endif /* H5_SIZEOF_LONG != H5_SIZEOF_LONG_LONG */
else
goto done;
} else if ( HDstrncmp(dtype,"R",1) == 0 ) {
diff --git a/hl/fortran/src/H5TBff.F90 b/hl/fortran/src/H5TBff.F90
index 266f74a..a31c751 100644
--- a/hl/fortran/src/H5TBff.F90
+++ b/hl/fortran/src/H5TBff.F90
@@ -380,7 +380,6 @@ CONTAINS
INTEGER :: errcode ! error code
INTEGER(size_t) :: namelen ! name length
- INTEGER(hsize_t) :: i ! general purpose integer
INTERFACE
INTEGER FUNCTION h5tbread_table_c(loc_id,&
diff --git a/hl/fortran/test/tstds.F90 b/hl/fortran/test/tstds.F90
index cbf6c38..f5df4ef 100644
--- a/hl/fortran/test/tstds.F90
+++ b/hl/fortran/test/tstds.F90
@@ -12,25 +12,59 @@
! * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
! * access to either file, you may request a copy from help@hdfgroup.org. *
! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-PROGRAM test_ds
+
+MODULE TSTDS
+
+CONTAINS
+
+!-------------------------------------------------------------------------
+! test_begin
+!-------------------------------------------------------------------------
+
+SUBROUTINE test_begin(string)
+ CHARACTER(LEN=*), INTENT(IN) :: string
+ WRITE(*, fmt = '(A)', advance = 'no') ADJUSTL(string)
+END SUBROUTINE test_begin
+
+!-------------------------------------------------------------------------
+! passed/failed
+!-------------------------------------------------------------------------
+SUBROUTINE write_test_status( test_result)
+
+! Writes the results of the tests
IMPLICIT NONE
- INTEGER :: err
+ INTEGER, INTENT(IN) :: test_result ! negative, failed
+ ! 0 , passed
- CALL test_testds(err)
+! Controls the output style for reporting test results
- IF(err.LT.0)THEN
- WRITE(*,'(5X,A)') "DIMENSION SCALES TEST *FAILED*"
+ CHARACTER(LEN=8) :: error_string
+ CHARACTER(LEN=8), PARAMETER :: success = ' PASSED '
+ CHARACTER(LEN=8), PARAMETER :: failure = '*FAILED*'
+
+ error_string = failure
+ IF (test_result .EQ. 0) THEN
+ error_string = success
ENDIF
+
+ WRITE(*, fmt = '(T34, A)') error_string
-END PROGRAM test_ds
+END SUBROUTINE write_test_status
+
+END MODULE TSTDS
+
+MODULE TSTDS_TESTS
+
+CONTAINS
SUBROUTINE test_testds(err)
USE HDF5
USE H5LT
USE H5DS
+ USE TSTDS ! module for testing dataset support routines
IMPLICIT NONE
@@ -44,7 +78,6 @@ SUBROUTINE test_testds(err)
CHARACTER(LEN=6), PARAMETER :: DSET_NAME = "Mydata"
CHARACTER(LEN=5), PARAMETER :: DS_1_NAME = "Yaxis"
- CHARACTER(LEN=5), PARAMETER :: DS_1_NAME_A = "Yaxiz"
CHARACTER(LEN=5), PARAMETER :: DS_2_NAME = "Xaxis"
@@ -316,38 +349,21 @@ SUBROUTINE test_testds(err)
END SUBROUTINE test_testds
-!-------------------------------------------------------------------------
-! test_begin
-!-------------------------------------------------------------------------
-
-SUBROUTINE test_begin(string)
- CHARACTER(LEN=*), INTENT(IN) :: string
- WRITE(*, fmt = '(A)', advance = 'no') ADJUSTL(string)
-END SUBROUTINE test_begin
+END MODULE TSTDS_TESTS
-!-------------------------------------------------------------------------
-! passed/failed
-!-------------------------------------------------------------------------
-SUBROUTINE write_test_status( test_result)
-
-! Writes the results of the tests
+PROGRAM test_ds
+ USE TSTDS_TESTS ! module for testing dataset routines
+
IMPLICIT NONE
- INTEGER, INTENT(IN) :: test_result ! negative, failed
- ! 0 , passed
-
-! Controls the output style for reporting test results
+ INTEGER :: err
- CHARACTER(LEN=8) :: error_string
- CHARACTER(LEN=8), PARAMETER :: success = ' PASSED '
- CHARACTER(LEN=8), PARAMETER :: failure = '*FAILED*'
+ CALL test_testds(err)
- error_string = failure
- IF (test_result .EQ. 0) THEN
- error_string = success
+ IF(err.LT.0)THEN
+ WRITE(*,'(5X,A)') "DIMENSION SCALES TEST *FAILED*"
ENDIF
-
- WRITE(*, fmt = '(T34, A)') error_string
-END SUBROUTINE write_test_status
+END PROGRAM test_ds
+
diff --git a/hl/fortran/test/tstimage.F90 b/hl/fortran/test/tstimage.F90
index 0bff6b2..7e90664 100644
--- a/hl/fortran/test/tstimage.F90
+++ b/hl/fortran/test/tstimage.F90
@@ -17,12 +17,34 @@
! This file contains the FORTRAN90 tests for H5LT
!
-program image_test
+MODULE TSTIMAGE
-call make_image1()
+CONTAINS
-end program image_test
+!-------------------------------------------------------------------------
+! test_begin
+!-------------------------------------------------------------------------
+
+subroutine test_begin(string)
+character(len=*), intent(in) :: string
+write(*, fmt = '(14a)', advance = 'no') string
+write(*, fmt = '(40x,a)', advance = 'no') ' '
+end subroutine test_begin
+
+!-------------------------------------------------------------------------
+! passed
+!-------------------------------------------------------------------------
+
+subroutine passed()
+write(*, fmt = '(6a)') 'PASSED'
+end subroutine passed
+
+END MODULE TSTIMAGE
+
+
+MODULE TSTIMAGE_TESTS
+CONTAINS
!-------------------------------------------------------------------------
! make_image1
@@ -32,6 +54,7 @@ subroutine make_image1()
use h5im ! module of H5IM
use hdf5 ! module of HDF5 library
+USE TSTIMAGE ! module for testing image support routines
implicit none
@@ -320,20 +343,17 @@ call h5close_f(errcode)
!
end subroutine make_image1
-!-------------------------------------------------------------------------
-! test_begin
-!-------------------------------------------------------------------------
+END MODULE TSTIMAGE_TESTS
-subroutine test_begin(string)
-character(len=*), intent(in) :: string
-write(*, fmt = '(14a)', advance = 'no') string
-write(*, fmt = '(40x,a)', advance = 'no') ' '
-end subroutine test_begin
-!-------------------------------------------------------------------------
-! passed
-!-------------------------------------------------------------------------
+program image_test
+
+USE TSTIMAGE_TESTS ! module for testing dataset routines
+
+IMPLICIT NONE
+
+call make_image1()
+
+end program image_test
+
-subroutine passed()
-write(*, fmt = '(6a)') 'PASSED'
-end subroutine passed
diff --git a/hl/fortran/test/tstlite.F90 b/hl/fortran/test/tstlite.F90
index 3937c3c..9d47c59 100644
--- a/hl/fortran/test/tstlite.F90
+++ b/hl/fortran/test/tstlite.F90
@@ -18,19 +18,33 @@
!
#include <H5config_f.inc>
-PROGRAM lite_test
-
- CALL test_dataset1D()
- CALL test_dataset2D()
- CALL test_dataset3D()
- CALL test_datasetND(4)
- CALL test_datasetND(5)
- CALL test_datasetND(6)
- CALL test_datasetND(7)
- CALL test_datasets()
- CALL test_attributes()
+MODULE TSTLITE
-END PROGRAM lite_test
+CONTAINS
+
+!-------------------------------------------------------------------------
+! test_begin
+!-------------------------------------------------------------------------
+
+SUBROUTINE test_begin(string)
+ CHARACTER(LEN=*), INTENT(IN) :: string
+ WRITE(*, fmt = '(14a)', advance = 'no') string
+ WRITE(*, fmt = '(40x,a)', advance = 'no') ' '
+END SUBROUTINE test_begin
+
+!-------------------------------------------------------------------------
+! passed
+!-------------------------------------------------------------------------
+
+SUBROUTINE passed()
+ WRITE(*, fmt = '(6a)') 'PASSED'
+END SUBROUTINE passed
+
+END MODULE TSTLITE
+
+MODULE TSTLITE_TESTS
+
+CONTAINS
!-------------------------------------------------------------------------
@@ -42,6 +56,7 @@ SUBROUTINE test_dataset1D()
USE, INTRINSIC :: ISO_C_BINDING
USE H5LT ! module of H5LT
USE HDF5 ! module of HDF5 library
+ USE TSTLITE ! module for testing lite support routines
IMPLICIT NONE
@@ -191,6 +206,7 @@ SUBROUTINE test_dataset2D()
USE, INTRINSIC :: ISO_C_BINDING
USE H5LT ! module of H5LT
USE HDF5 ! module of HDF5 library
+ USE TSTLITE ! module for testing lite support routines
IMPLICIT NONE
@@ -387,6 +403,7 @@ SUBROUTINE test_dataset3D()
USE, INTRINSIC :: ISO_C_BINDING
USE H5LT ! module of H5LT
USE HDF5 ! module of HDF5 library
+ USE TSTLITE ! module for testing lite support routines
IMPLICIT NONE
@@ -702,6 +719,7 @@ SUBROUTINE test_datasetND(rank)
USE, INTRINSIC :: ISO_C_BINDING
USE H5LT ! module of H5LT
USE HDF5 ! module of HDF5 library
+ USE TSTLITE ! module for testing lite support routines
IMPLICIT NONE
@@ -1293,6 +1311,7 @@ SUBROUTINE test_datasets()
USE, INTRINSIC :: ISO_C_BINDING
USE H5LT ! module of H5LT
USE HDF5 ! module of HDF5 library
+ USE TSTLITE ! module for testing lite support routines
IMPLICIT NONE
@@ -1302,7 +1321,6 @@ SUBROUTINE test_datasets()
INTEGER, PARAMETER :: DIM1 = 10 ! Dimension of array
INTEGER, PARAMETER :: LEN0 = 3
INTEGER, PARAMETER :: LEN1 = 12
- CHARACTER(LEN=5), PARAMETER :: dsetname1 = "dset1" ! Dataset name
CHARACTER(LEN=5), PARAMETER :: dsetname2 = "dset2" ! Dataset name
CHARACTER(LEN=5), PARAMETER :: dsetname3 = "dset3" ! Dataset name
CHARACTER(LEN=5), PARAMETER :: dsetname4 = "dset4" ! Dataset name
@@ -1665,21 +1683,21 @@ SUBROUTINE test_attributes()
USE, INTRINSIC :: ISO_C_BINDING
USE H5LT ! module of H5LT
USE HDF5 ! module of HDF5 library
+ USE TSTLITE ! module for testing lite support routines
IMPLICIT NONE
CHARACTER(len=9), PARAMETER :: filename = "dsetf5.h5"! File name
- CHARACTER(len=9), PARAMETER :: filename1 ="tattr.h5" ! C written attribute file
+!!$ CHARACTER(len=9), PARAMETER :: filename1 ="tattr.h5" ! C written attribute file
INTEGER(HID_T) :: file_id ! File identifier
! INTEGER(HID_T) :: file_id1
INTEGER, PARAMETER :: DIM1 = 10 ! Dimension of array
- CHARACTER(LEN=5), PARAMETER :: attrname1 = "attr1" ! Attribute name
CHARACTER(LEN=5), PARAMETER :: attrname2 = "attr2" ! Attribute name
CHARACTER(LEN=5), PARAMETER :: attrname3 = "attr3" ! Attribute name
CHARACTER(LEN=5), PARAMETER :: attrname4 = "attr4" ! Attribute name
CHARACTER(LEN=5), PARAMETER :: attrname5 = "attr5" ! Attribute name
CHARACTER(LEN=8), PARAMETER :: buf1 = "mystring" ! Data buffer
- CHARACTER(LEN=16), PARAMETER :: buf_c = "string attribute"
+!!$ CHARACTER(LEN=16), PARAMETER :: buf_c = "string attribute"
CHARACTER(LEN=8) :: bufr1 ! Data buffer
CHARACTER(LEN=10) :: bufr1_lg ! Data buffer
! CHARACTER(LEN=16) :: bufr_c ! Data buffer
@@ -1969,20 +1987,24 @@ SUBROUTINE test_attributes()
!
END SUBROUTINE test_attributes
-!-------------------------------------------------------------------------
-! test_begin
-!-------------------------------------------------------------------------
+END MODULE TSTLITE_TESTS
-SUBROUTINE test_begin(string)
- CHARACTER(LEN=*), INTENT(IN) :: string
- WRITE(*, fmt = '(14a)', advance = 'no') string
- WRITE(*, fmt = '(40x,a)', advance = 'no') ' '
-END SUBROUTINE test_begin
+PROGRAM lite_test
+
+ USE TSTLITE_TESTS ! module for testing lite routines
+
+ IMPLICIT NONE
+
+ CALL test_dataset1D()
+ CALL test_dataset2D()
+ CALL test_dataset3D()
+ CALL test_datasetND(4)
+ CALL test_datasetND(5)
+ CALL test_datasetND(6)
+ CALL test_datasetND(7)
+ CALL test_datasets()
+ CALL test_attributes()
+
+END PROGRAM lite_test
-!-------------------------------------------------------------------------
-! passed
-!-------------------------------------------------------------------------
-SUBROUTINE passed()
- WRITE(*, fmt = '(6a)') 'PASSED'
-END SUBROUTINE passed
diff --git a/hl/fortran/test/tsttable.F90 b/hl/fortran/test/tsttable.F90
index 5c55a66..822f116 100644
--- a/hl/fortran/test/tsttable.F90
+++ b/hl/fortran/test/tsttable.F90
@@ -18,29 +18,33 @@
!
#include <H5config_f.inc>
-PROGRAM table_test
+MODULE TSTTABLE
- USE H5TB ! module of H5TB
- USE HDF5 ! module of HDF5 library
+CONTAINS
- IMPLICIT NONE
- INTEGER :: errcode = 0
+!-------------------------------------------------------------------------
+! test_begin
+!-------------------------------------------------------------------------
- !
- ! Initialize FORTRAN predefined datatypes.
- !
- CALL h5open_f(errcode)
+SUBROUTINE test_begin(string)
+ CHARACTER(LEN=*), INTENT(IN) :: string
+ WRITE(*, fmt = '(A)', ADVANCE = 'no') string
+END SUBROUTINE test_begin
- CALL test_table1()
- CALL test_table2()
+!-------------------------------------------------------------------------
+! passed
+!-------------------------------------------------------------------------
- !
- ! Close FORTRAN predefined datatypes.
- !
- CALL h5close_f(errcode)
+SUBROUTINE passed()
+ WRITE(*, fmt = '(T12,A6)') 'PASSED'
+END SUBROUTINE passed
+
+END MODULE TSTTABLE
-END PROGRAM table_test
+MODULE TSTTABLE_TESTS
+
+CONTAINS
!-------------------------------------------------------------------------
! test_table1
@@ -50,6 +54,7 @@ SUBROUTINE test_table1()
USE H5TB ! module of H5TB
USE HDF5 ! module of HDF5 library
+ USE TSTTABLE ! module for testing table support routines
IMPLICIT NONE
@@ -536,6 +541,7 @@ SUBROUTINE test_table2()
USE H5TB ! module of H5TB
USE HDF5 ! module of HDF5 library
+ USE TSTTABLE ! module for testing table support routines
IMPLICIT NONE
@@ -574,7 +580,6 @@ SUBROUTINE test_table2()
INTEGER(hsize_t), PARAMETER :: chunk_size = 10
TYPE(particle_t), DIMENSION(1:nrecords), TARGET :: fill_data
INTEGER :: compress
- INTEGER :: status
INTEGER :: i
INTEGER(SIZE_T) :: dst_size
TYPE(particle_t), DIMENSION(1:nrecords), TARGET :: dst_buf
@@ -711,22 +716,31 @@ SUBROUTINE test_table2()
END SUBROUTINE test_table2
+END MODULE TSTTABLE_TESTS
-!-------------------------------------------------------------------------
-! test_begin
-!-------------------------------------------------------------------------
-SUBROUTINE test_begin(string)
- CHARACTER(LEN=*), INTENT(IN) :: string
- WRITE(*, fmt = '(A)', ADVANCE = 'no') string
-END SUBROUTINE test_begin
+PROGRAM table_test
-!-------------------------------------------------------------------------
-! passed
-!-------------------------------------------------------------------------
+ USE H5TB ! module of H5TB
+ USE HDF5 ! module of HDF5 library
+ USE TSTTABLE_TESTS ! module for testing table routines
-SUBROUTINE passed()
- WRITE(*, fmt = '(T12,A6)') 'PASSED'
-END SUBROUTINE passed
+ IMPLICIT NONE
+ INTEGER :: errcode = 0
+
+ !
+ ! Initialize FORTRAN predefined datatypes.
+ !
+ CALL h5open_f(errcode)
+
+ CALL test_table1()
+ CALL test_table2()
+
+ !
+ ! Close FORTRAN predefined datatypes.
+ !
+ CALL h5close_f(errcode)
+
+END PROGRAM table_test
diff --git a/src/H5AC.c b/src/H5AC.c
index 1a2dfcf..0c6aac1 100644
--- a/src/H5AC.c
+++ b/src/H5AC.c
@@ -183,13 +183,13 @@ done:
herr_t
H5AC__init_package(void)
{
+#ifdef H5_DEBUG_BUILD
H5P_genplist_t *xfer_plist; /* Dataset transfer property list object */
+ H5FD_dxpl_type_t dxpl_type; /* Property indicating the type of the internal dxpl */
+#endif /* H5_DEBUG_BUILD */
#ifdef H5_HAVE_PARALLEL
H5P_coll_md_read_flag_t coll_meta_read;
#endif /* H5_HAVE_PARALLEL */
-#ifdef H5_DEBUG_BUILD
- H5FD_dxpl_type_t dxpl_type; /* Property indicating the type of the internal dxpl */
-#endif /* H5_DEBUG_BUILD */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
@@ -201,9 +201,8 @@ H5AC__init_package(void)
const char *s; /* String for environment variables */
s = HDgetenv("H5_COLL_API_SANITY_CHECK");
- if(s && HDisdigit(*s)) {
+ if(s && HDisdigit(*s))
H5_coll_api_sanity_check_g = (hbool_t)HDstrtol(s, NULL, 0);
- }
}
#endif /* H5_HAVE_PARALLEL */
@@ -278,7 +277,9 @@ H5AC__init_package(void)
H5AC_rawdata_dxpl_id = H5P_DATASET_XFER_DEFAULT;
#endif /* defined(H5_HAVE_PARALLEL) || defined(H5_DEBUG_BUILD) */
+#if defined(H5_DEBUG_BUILD) | defined(H5_HAVE_PARALLEL)
done:
+#endif /* defined(H5_DEBUG_BUILD) | defined(H5_HAVE_PARALLEL) */
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5AC__init_package() */
diff --git a/src/H5B2int.c b/src/H5B2int.c
index e877a17..3bd788c 100644
--- a/src/H5B2int.c
+++ b/src/H5B2int.c
@@ -3612,7 +3612,7 @@ done:
*
*-------------------------------------------------------------------------
*/
-static herr_t
+H5_ATTR_PURE static herr_t
H5B2__assert_leaf(const H5B2_hdr_t *hdr, const H5B2_leaf_t *leaf)
{
/* General sanity checking on node */
@@ -3635,7 +3635,7 @@ H5B2__assert_leaf(const H5B2_hdr_t *hdr, const H5B2_leaf_t *leaf)
*
*-------------------------------------------------------------------------
*/
-static herr_t
+H5_ATTR_PURE static herr_t
H5B2__assert_leaf2(const H5B2_hdr_t *hdr, const H5B2_leaf_t *leaf, const H5B2_leaf_t H5_ATTR_UNUSED *leaf2)
{
/* General sanity checking on node */
@@ -3658,7 +3658,7 @@ H5B2__assert_leaf2(const H5B2_hdr_t *hdr, const H5B2_leaf_t *leaf, const H5B2_le
*
*-------------------------------------------------------------------------
*/
-static herr_t
+H5_ATTR_PURE static herr_t
H5B2__assert_internal(hsize_t parent_all_nrec, const H5B2_hdr_t *hdr, const H5B2_internal_t *internal)
{
hsize_t tot_all_nrec; /* Total number of records at or below this node */
@@ -3699,7 +3699,7 @@ H5B2__assert_internal(hsize_t parent_all_nrec, const H5B2_hdr_t *hdr, const H5B2
*
*-------------------------------------------------------------------------
*/
-static herr_t
+H5_ATTR_PURE static herr_t
H5B2__assert_internal2(hsize_t parent_all_nrec, const H5B2_hdr_t *hdr, const H5B2_internal_t *internal, const H5B2_internal_t *internal2)
{
hsize_t tot_all_nrec; /* Total number of records at or below this node */
diff --git a/src/H5FD.c b/src/H5FD.c
index 2a15fe8..57905b1 100644
--- a/src/H5FD.c
+++ b/src/H5FD.c
@@ -1608,12 +1608,12 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5FDflush(H5FD_t *file, hid_t dxpl_id, unsigned closing)
+H5FDflush(H5FD_t *file, hid_t dxpl_id, hbool_t closing)
{
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
- H5TRACE3("e", "*xiIu", file, dxpl_id, closing);
+ H5TRACE3("e", "*xib", file, dxpl_id, closing);
/* Check args */
if(!file || !file->cls)
@@ -1647,7 +1647,7 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5FD_flush(H5FD_t *file, hid_t dxpl_id, unsigned closing)
+H5FD_flush(H5FD_t *file, hid_t dxpl_id, hbool_t closing)
{
herr_t ret_value = SUCCEED; /* Return value */
diff --git a/src/H5FDcore.c b/src/H5FDcore.c
index 865a29e..5ce6560 100644
--- a/src/H5FDcore.c
+++ b/src/H5FDcore.c
@@ -139,7 +139,7 @@ static herr_t H5FD__core_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, had
size_t size, void *buf);
static herr_t H5FD__core_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr,
size_t size, const void *buf);
-static herr_t H5FD__core_flush(H5FD_t *_file, hid_t dxpl_id, unsigned closing);
+static herr_t H5FD__core_flush(H5FD_t *_file, hid_t dxpl_id, hbool_t closing);
static herr_t H5FD__core_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing);
static herr_t H5FD_core_lock(H5FD_t *_file, hbool_t rw);
static herr_t H5FD_core_unlock(H5FD_t *_file);
@@ -1335,7 +1335,7 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5FD__core_flush(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, unsigned H5_ATTR_UNUSED closing)
+H5FD__core_flush(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR_UNUSED closing)
{
H5FD_core_t *file = (H5FD_core_t*)_file;
herr_t ret_value = SUCCEED; /* Return value */
diff --git a/src/H5FDfamily.c b/src/H5FDfamily.c
index b92a685..3b38836 100644
--- a/src/H5FDfamily.c
+++ b/src/H5FDfamily.c
@@ -104,8 +104,8 @@ static herr_t H5FD_family_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, ha
size_t size, void *_buf/*out*/);
static herr_t H5FD_family_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr,
size_t size, const void *_buf);
-static herr_t H5FD_family_flush(H5FD_t *_file, hid_t dxpl_id, unsigned closing);
-static herr_t H5FD_family_truncate(H5FD_t *_file, hid_t dxpl_id, unsigned closing);
+static herr_t H5FD_family_flush(H5FD_t *_file, hid_t dxpl_id, hbool_t closing);
+static herr_t H5FD_family_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing);
static herr_t H5FD_family_lock(H5FD_t *_file, hbool_t rw);
static herr_t H5FD_family_unlock(H5FD_t *_file);
@@ -1249,7 +1249,7 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5FD_family_flush(H5FD_t *_file, hid_t dxpl_id, unsigned closing)
+H5FD_family_flush(H5FD_t *_file, hid_t dxpl_id, hbool_t closing)
{
H5FD_family_t *file = (H5FD_family_t*)_file;
unsigned u, nerrors = 0;
@@ -1284,7 +1284,7 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5FD_family_truncate(H5FD_t *_file, hid_t dxpl_id, unsigned closing)
+H5FD_family_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing)
{
H5FD_family_t *file = (H5FD_family_t*)_file;
unsigned u, nerrors = 0;
diff --git a/src/H5FDmulti.c b/src/H5FDmulti.c
index bf27b1a..0e49813 100644
--- a/src/H5FDmulti.c
+++ b/src/H5FDmulti.c
@@ -133,7 +133,7 @@ static herr_t H5FD_multi_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, had
size_t size, void *_buf/*out*/);
static herr_t H5FD_multi_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr,
size_t size, const void *_buf);
-static herr_t H5FD_multi_flush(H5FD_t *_file, hid_t dxpl_id, unsigned closing);
+static herr_t H5FD_multi_flush(H5FD_t *_file, hid_t dxpl_id, hbool_t closing);
static herr_t H5FD_multi_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing);
static herr_t H5FD_multi_lock(H5FD_t *_file, hbool_t rw);
static herr_t H5FD_multi_unlock(H5FD_t *_file);
@@ -1686,7 +1686,7 @@ H5FD_multi_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr,
*-------------------------------------------------------------------------
*/
static herr_t
-H5FD_multi_flush(H5FD_t *_file, hid_t dxpl_id, unsigned closing)
+H5FD_multi_flush(H5FD_t *_file, hid_t dxpl_id, hbool_t closing)
{
H5FD_multi_t *file = (H5FD_multi_t*)_file;
H5FD_mem_t mt;
diff --git a/src/H5FDprivate.h b/src/H5FDprivate.h
index 639f3eb..915f7e1 100644
--- a/src/H5FDprivate.h
+++ b/src/H5FDprivate.h
@@ -158,7 +158,7 @@ H5_DLL herr_t H5FD_read(H5FD_t *file, const H5P_genplist_t *dxpl, H5FD_mem_t typ
haddr_t addr, size_t size, void *buf/*out*/);
H5_DLL herr_t H5FD_write(H5FD_t *file, const H5P_genplist_t *dxpl, H5FD_mem_t type,
haddr_t addr, size_t size, const void *buf);
-H5_DLL herr_t H5FD_flush(H5FD_t *file, hid_t dxpl_id, unsigned closing);
+H5_DLL herr_t H5FD_flush(H5FD_t *file, hid_t dxpl_id, hbool_t closing);
H5_DLL herr_t H5FD_truncate(H5FD_t *file, hid_t dxpl_id, hbool_t closing);
H5_DLL herr_t H5FD_lock(H5FD_t *file, hbool_t rw);
H5_DLL herr_t H5FD_unlock(H5FD_t *file);
diff --git a/src/H5FDpublic.h b/src/H5FDpublic.h
index 4183d14..4931e0f 100644
--- a/src/H5FDpublic.h
+++ b/src/H5FDpublic.h
@@ -272,7 +272,7 @@ typedef struct H5FD_class_t {
haddr_t addr, size_t size, void *buffer);
herr_t (*write)(H5FD_t *file, H5FD_mem_t type, hid_t dxpl,
haddr_t addr, size_t size, const void *buffer);
- herr_t (*flush)(H5FD_t *file, hid_t dxpl_id, unsigned closing);
+ herr_t (*flush)(H5FD_t *file, hid_t dxpl_id, hbool_t closing);
herr_t (*truncate)(H5FD_t *file, hid_t dxpl_id, hbool_t closing);
herr_t (*lock)(H5FD_t *file, hbool_t rw);
herr_t (*unlock)(H5FD_t *file);
@@ -353,7 +353,7 @@ H5_DLL herr_t H5FDread(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id,
haddr_t addr, size_t size, void *buf/*out*/);
H5_DLL herr_t H5FDwrite(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id,
haddr_t addr, size_t size, const void *buf);
-H5_DLL herr_t H5FDflush(H5FD_t *file, hid_t dxpl_id, unsigned closing);
+H5_DLL herr_t H5FDflush(H5FD_t *file, hid_t dxpl_id, hbool_t closing);
H5_DLL herr_t H5FDtruncate(H5FD_t *file, hid_t dxpl_id, hbool_t closing);
H5_DLL herr_t H5FDlock(H5FD_t *file, hbool_t rw);
H5_DLL herr_t H5FDunlock(H5FD_t *file);
diff --git a/src/H5FDstdio.c b/src/H5FDstdio.c
index bc85c74..0168ff4 100644
--- a/src/H5FDstdio.c
+++ b/src/H5FDstdio.c
@@ -173,7 +173,7 @@ static herr_t H5FD_stdio_read(H5FD_t *lf, H5FD_mem_t type, hid_t fapl_id, haddr_
size_t size, void *buf);
static herr_t H5FD_stdio_write(H5FD_t *lf, H5FD_mem_t type, hid_t fapl_id, haddr_t addr,
size_t size, const void *buf);
-static herr_t H5FD_stdio_flush(H5FD_t *_file, hid_t dxpl_id, unsigned closing);
+static herr_t H5FD_stdio_flush(H5FD_t *_file, hid_t dxpl_id, hbool_t closing);
static herr_t H5FD_stdio_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing);
static herr_t H5FD_stdio_lock(H5FD_t *_file, hbool_t rw);
static herr_t H5FD_stdio_unlock(H5FD_t *_file);
@@ -955,7 +955,7 @@ H5FD_stdio_write(H5FD_t *_file, H5FD_mem_t /*UNUSED*/ type, hid_t /*UNUSED*/ dxp
*-------------------------------------------------------------------------
*/
static herr_t
-H5FD_stdio_flush(H5FD_t *_file, hid_t /*UNUSED*/ dxpl_id, unsigned closing)
+H5FD_stdio_flush(H5FD_t *_file, hid_t /*UNUSED*/ dxpl_id, hbool_t closing)
{
H5FD_stdio_t *file = (H5FD_stdio_t*)_file;
static const char *func = "H5FD_stdio_flush"; /* Function Name for error reporting */
diff --git a/src/H5MM.c b/src/H5MM.c
index 5c2a731..daef7b1 100644
--- a/src/H5MM.c
+++ b/src/H5MM.c
@@ -156,7 +156,7 @@ H5MM__is_our_block(void *mem)
*
*-------------------------------------------------------------------------
*/
-static void
+H5_ATTR_PURE static void
H5MM__sanity_check_block(const H5MM_block_t *block)
{
HDassert(block->u.info.size > 0);
@@ -182,7 +182,7 @@ H5MM__sanity_check_block(const H5MM_block_t *block)
*
*-------------------------------------------------------------------------
*/
-static void
+H5_ATTR_PURE static void
H5MM__sanity_check(void *mem)
{
H5MM_block_t *block = H5MM_BLOCK_FROM_BUF(mem);
@@ -203,7 +203,7 @@ H5MM__sanity_check(void *mem)
*
*-------------------------------------------------------------------------
*/
-void
+H5_ATTR_PURE void
H5MM_sanity_check_all(void)
{
H5MM_block_t *curr = NULL;
@@ -228,7 +228,7 @@ H5MM_sanity_check_all(void)
*
*-------------------------------------------------------------------------
*/
-void
+H5_ATTR_PURE void
H5MM_final_sanity_check(void)
{
HDassert(0 == H5MM_curr_alloc_bytes_s);
diff --git a/src/H5PL.c b/src/H5PL.c
index a196884..f482fef 100644
--- a/src/H5PL.c
+++ b/src/H5PL.c
@@ -704,7 +704,7 @@ H5PL__search_table(H5PL_type_t plugin_type, int type_id, const void **info)
const H5Z_class2_t *plugin_info;
if(NULL == (get_plugin_info = (H5PL_get_plugin_info_t)H5PL_GET_LIB_FUNC((H5PL_table_g[i]).handle, "H5PLget_plugin_info")))
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't get function for H5PLget_plugin_info")
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't get function for H5PLget_plugin_info")
if(NULL == (plugin_info = (const H5Z_class2_t *)(*get_plugin_info)()))
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't get plugin info")
diff --git a/src/H5T.c b/src/H5T.c
index 86c7860..a8c9903 100644
--- a/src/H5T.c
+++ b/src/H5T.c
@@ -3036,8 +3036,10 @@ H5T__create(H5T_class_t type, size_t size)
subtype = H5T_NATIVE_INT_g;
else if(sizeof(long) == size)
subtype = H5T_NATIVE_LONG_g;
+#if H5_SIZEOF_LONG != H5_SIZEOF_LONG_LONG
else if(sizeof(long long) == size)
subtype = H5T_NATIVE_LLONG_g;
+#endif /* H5_SIZEOF_LONG != H5_SIZEOF_LONG_LONG */
else
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "no applicable native integer type")
if(NULL == (dt = H5T__alloc()))
diff --git a/src/H5Znbit.c b/src/H5Znbit.c
index e2fb300..04e8869 100644
--- a/src/H5Znbit.c
+++ b/src/H5Znbit.c
@@ -29,10 +29,10 @@
* one nbit atomic datatype: integer or floating-point
*/
typedef struct {
- size_t size; /* size of datatype */
- int order; /* datatype endianness order */
- int precision; /* datatype precision */
- int offset; /* datatype offset */
+ unsigned size; /* size of datatype */
+ unsigned order; /* datatype endianness order */
+ unsigned precision; /* datatype precision */
+ unsigned offset; /* datatype offset */
} parms_atomic;
/* Local function prototypes */
@@ -41,41 +41,50 @@ static herr_t H5Z_set_local_nbit(hid_t dcpl_id, hid_t type_id, hid_t space_id);
static size_t H5Z_filter_nbit(unsigned flags, size_t cd_nelmts, const unsigned cd_values[],
size_t nbytes, size_t *buf_size, void **buf);
-static void H5Z_calc_parms_nooptype(void);
-static void H5Z_calc_parms_atomic(void);
-static herr_t H5Z_calc_parms_array(const H5T_t *type);
-static herr_t H5Z_calc_parms_compound(const H5T_t *type);
-
-static herr_t H5Z_set_parms_nooptype(const H5T_t *type, unsigned cd_values[]);
-static herr_t H5Z_set_parms_atomic(const H5T_t *type, unsigned cd_values[]);
-static herr_t H5Z_set_parms_array(const H5T_t *type, unsigned cd_values[]);
-static herr_t H5Z_set_parms_compound(const H5T_t *type, unsigned cd_values[]);
-
-static void H5Z_nbit_next_byte(size_t *j, int *buf_len);
-static void H5Z_nbit_decompress_one_byte(unsigned char *data, size_t data_offset, int k, int begin_i,
-int end_i, unsigned char *buffer, size_t *j, int *buf_len, parms_atomic p, int datatype_len);
-static void H5Z_nbit_compress_one_byte(unsigned char *data, size_t data_offset, int k, int begin_i,
-int end_i, unsigned char *buffer, size_t *j, int *buf_len, parms_atomic p, int datatype_len);
+static void H5Z_calc_parms_nooptype(size_t *cd_values_actual_nparms);
+static void H5Z_calc_parms_atomic(size_t *cd_values_actual_nparms);
+static herr_t H5Z_calc_parms_array(const H5T_t *type, size_t *cd_values_actual_nparms);
+static herr_t H5Z_calc_parms_compound(const H5T_t *type, size_t *cd_values_actual_nparms);
+
+static herr_t H5Z_set_parms_nooptype(const H5T_t *type, unsigned *cd_values_index,
+ unsigned cd_values[]);
+static herr_t H5Z_set_parms_atomic(const H5T_t *type, unsigned *cd_values_index,
+ unsigned cd_values[], hbool_t *need_not_compress);
+static herr_t H5Z_set_parms_array(const H5T_t *type, unsigned *cd_values_index,
+ unsigned cd_values[], hbool_t *need_not_compress);
+static herr_t H5Z_set_parms_compound(const H5T_t *type, unsigned *cd_values_index,
+ unsigned cd_values[], hbool_t *need_not_compress);
+
+static void H5Z_nbit_next_byte(size_t *j, size_t *buf_len);
+static void H5Z_nbit_decompress_one_byte(unsigned char *data, size_t data_offset,
+ unsigned k, unsigned begin_i, unsigned end_i, unsigned char *buffer, size_t *j,
+ size_t *buf_len, const parms_atomic *p, size_t datatype_len);
+static void H5Z_nbit_compress_one_byte(unsigned char *data, size_t data_offset, unsigned k, unsigned begin_i,
+ unsigned end_i, unsigned char *buffer, size_t *j, size_t *buf_len, const parms_atomic *p, size_t datatype_len);
static void H5Z_nbit_decompress_one_nooptype(unsigned char *data, size_t data_offset,
- unsigned char *buffer, size_t *j, int *buf_len, unsigned size);
+ unsigned char *buffer, size_t *j, size_t *buf_len, unsigned size);
static void H5Z_nbit_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, size_t *buf_len, const parms_atomic *p);
static void H5Z_nbit_decompress_one_array(unsigned char *data, size_t data_offset,
- unsigned char *buffer, size_t *j, int *buf_len, const unsigned parms[]);
+ unsigned char *buffer, size_t *j, size_t *buf_len, const unsigned parms[],
+ unsigned *parms_index);
static void H5Z_nbit_decompress_one_compound(unsigned char *data, size_t data_offset,
- unsigned char *buffer, size_t *j, int *buf_len, const unsigned parms[]);
+ unsigned char *buffer, size_t *j, size_t *buf_len, const unsigned parms[],
+ unsigned *parms_index);
static void H5Z_nbit_decompress(unsigned char *data, unsigned d_nelmts, unsigned char *buffer,
- const unsigned parms[]);
+ const unsigned parms[]);
static void H5Z_nbit_compress_one_nooptype(unsigned char *data, size_t data_offset,
- unsigned char *buffer, size_t *j, int *buf_len, unsigned size);
+ unsigned char *buffer, size_t *j, size_t *buf_len, unsigned size);
static void H5Z_nbit_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, size_t *buf_len, const parms_atomic *p);
static void H5Z_nbit_compress_one_array(unsigned char *data, size_t data_offset,
- unsigned char *buffer, size_t *j, int *buf_len, const unsigned parms[]);
+ unsigned char *buffer, size_t *j, size_t *buf_len, const unsigned parms[],
+ unsigned *parms_index);
static void H5Z_nbit_compress_one_compound(unsigned char *data, size_t data_offset,
- unsigned char *buffer, size_t *j, int *buf_len, const unsigned parms[]);
+ unsigned char *buffer, size_t *j, size_t *buf_len, const unsigned parms[],
+ unsigned *parms_index);
static void H5Z_nbit_compress(unsigned char *data, unsigned d_nelmts, unsigned char *buffer,
- size_t *buffer_size, const unsigned parms[]);
+ size_t *buffer_size, const unsigned parms[]);
/* This message derives from H5Z */
H5Z_class2_t H5Z_NBIT[1] = {{
@@ -99,16 +108,6 @@ H5Z_class2_t H5Z_NBIT[1] = {{
#define H5Z_NBIT_ORDER_BE 1 /* Big endian for datatype byte order */
/* Local variables */
-/*
- * cd_values_index: index of array cd_values inside function H5Z_set_local_nbit
- * cd_values_actual_nparms: number of parameters in array cd_values[]
- * need_not_compress: flag if TRUE indicating no need to do nbit compression
- * parms_index: index of array parms used by compression/decompression functions
- */
-static unsigned cd_values_index = 0;
-static size_t cd_values_actual_nparms = 0;
-static unsigned char need_not_compress = FALSE;
-static unsigned parms_index = 0;
/*-------------------------------------------------------------------------
@@ -166,13 +165,14 @@ done:
*
*-------------------------------------------------------------------------
*/
-static void H5Z_calc_parms_nooptype(void)
+static void
+H5Z_calc_parms_nooptype(size_t *cd_values_actual_nparms)
{
/* Store datatype class code */
- ++cd_values_actual_nparms;
+ *cd_values_actual_nparms += 1;
/* Store datatype size */
- ++cd_values_actual_nparms;
+ *cd_values_actual_nparms += 1;
}
@@ -190,22 +190,23 @@ static void H5Z_calc_parms_nooptype(void)
*
*-------------------------------------------------------------------------
*/
-static void H5Z_calc_parms_atomic(void)
+static void
+H5Z_calc_parms_atomic(size_t *cd_values_actual_nparms)
{
/* Store datatype class code */
- ++cd_values_actual_nparms;
+ *cd_values_actual_nparms += 1;
/* Store datatype size */
- ++cd_values_actual_nparms;
+ *cd_values_actual_nparms += 1;
/* Store datatype endianness */
- ++cd_values_actual_nparms;
+ *cd_values_actual_nparms += 1;
/* Store datatype's precision */
- ++cd_values_actual_nparms;
+ *cd_values_actual_nparms += 1;
/* Store datatype's offset */
- ++cd_values_actual_nparms;
+ *cd_values_actual_nparms += 1;
}
@@ -227,7 +228,7 @@ static void H5Z_calc_parms_atomic(void)
*-------------------------------------------------------------------------
*/
static herr_t
-H5Z_calc_parms_array(const H5T_t *type)
+H5Z_calc_parms_array(const H5T_t *type, size_t *cd_values_actual_nparms)
{
H5T_t *dtype_base = NULL; /* Array datatype's base datatype */
H5T_class_t dtype_base_class; /* Array datatype's base datatype's class */
@@ -236,10 +237,10 @@ H5Z_calc_parms_array(const H5T_t *type)
FUNC_ENTER_NOAPI_NOINIT
/* Store datatype class code */
- ++cd_values_actual_nparms;
+ *cd_values_actual_nparms += 1;
/* Store array datatype's size */
- ++cd_values_actual_nparms;
+ *cd_values_actual_nparms += 1;
/* Get array datatype's base datatype */
if(NULL == (dtype_base = H5T_get_super(type)))
@@ -253,16 +254,16 @@ H5Z_calc_parms_array(const H5T_t *type)
switch(dtype_base_class) {
case H5T_INTEGER:
case H5T_FLOAT:
- H5Z_calc_parms_atomic();
+ H5Z_calc_parms_atomic(cd_values_actual_nparms);
break;
case H5T_ARRAY:
- if(H5Z_calc_parms_array(dtype_base) == FAIL)
+ if(H5Z_calc_parms_array(dtype_base, cd_values_actual_nparms) == FAIL)
HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "nbit cannot compute parameters for datatype")
break;
case H5T_COMPOUND:
- if(H5Z_calc_parms_compound(dtype_base) == FAIL)
+ if(H5Z_calc_parms_compound(dtype_base, cd_values_actual_nparms) == FAIL)
HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "nbit cannot compute parameters for datatype")
break;
@@ -274,7 +275,7 @@ H5Z_calc_parms_array(const H5T_t *type)
case H5T_ENUM:
case H5T_VLEN:
/* Other datatype classes: nbit does no compression */
- H5Z_calc_parms_nooptype();
+ H5Z_calc_parms_nooptype(cd_values_actual_nparms);
break;
case H5T_NO_CLASS:
@@ -312,31 +313,32 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5Z_calc_parms_compound(const H5T_t *type)
+H5Z_calc_parms_compound(const H5T_t *type, size_t *cd_values_actual_nparms)
{
int nmembers; /* Compound datatype's number of members */
H5T_t *dtype_member = NULL; /* Compound datatype's member datatype */
- H5T_class_t dtype_member_class; /* Compound datatype's member datatype's class */
unsigned u; /* Local index variable */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
/* Store compound datatype class code */
- ++cd_values_actual_nparms;
+ *cd_values_actual_nparms += 1;
/* Store compound datatype's size */
- ++cd_values_actual_nparms;
+ *cd_values_actual_nparms += 1;
/* Get number of members */
if((nmembers = H5T_get_nmembers(type)) < 0)
HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype number of members")
/* Store number of members */
- ++cd_values_actual_nparms;
+ *cd_values_actual_nparms += 1;
/* For each member, calculate parameters */
for(u = 0; u < (unsigned)nmembers; u++) {
+ H5T_class_t dtype_member_class; /* Compound datatype's member datatype's class */
+
/* Get member datatype */
if(NULL == (dtype_member = H5T_get_member_type(type, u, H5T_COPY_TRANSIENT)))
HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad member datatype")
@@ -346,22 +348,22 @@ H5Z_calc_parms_compound(const H5T_t *type)
HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad member datatype class")
/* Store member offset */
- ++cd_values_actual_nparms;
+ *cd_values_actual_nparms += 1;
/* Calculate parameters according to member's datatype class */
switch(dtype_member_class) {
case H5T_INTEGER:
case H5T_FLOAT:
- H5Z_calc_parms_atomic();
+ H5Z_calc_parms_atomic(cd_values_actual_nparms);
break;
case H5T_ARRAY:
- if(H5Z_calc_parms_array(dtype_member) == FAIL)
+ if(H5Z_calc_parms_array(dtype_member, cd_values_actual_nparms) == FAIL)
HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "nbit cannot compute parameters for datatype")
break;
case H5T_COMPOUND:
- if(H5Z_calc_parms_compound(dtype_member) == FAIL)
+ if(H5Z_calc_parms_compound(dtype_member, cd_values_actual_nparms) == FAIL)
HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "nbit cannot compute parameters for datatype")
break;
@@ -373,7 +375,7 @@ H5Z_calc_parms_compound(const H5T_t *type)
case H5T_ENUM:
case H5T_VLEN:
/* Other datatype classes: nbit does no compression */
- H5Z_calc_parms_nooptype();
+ H5Z_calc_parms_nooptype(cd_values_actual_nparms);
break;
case H5T_NO_CLASS:
@@ -418,7 +420,7 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5Z_set_parms_nooptype(const H5T_t *type, unsigned cd_values[])
+H5Z_set_parms_nooptype(const H5T_t *type, unsigned *cd_values_index, unsigned cd_values[])
{
size_t dtype_size; /* No-op datatype's size (in bytes) */
herr_t ret_value = SUCCEED; /* Return value */
@@ -426,14 +428,15 @@ H5Z_set_parms_nooptype(const H5T_t *type, unsigned cd_values[])
FUNC_ENTER_NOAPI_NOINIT
/* Set datatype class code */
- cd_values[cd_values_index++] = H5Z_NBIT_NOOPTYPE;
+ cd_values[(*cd_values_index)++] = H5Z_NBIT_NOOPTYPE;
/* Get datatype's size */
if((dtype_size = H5T_get_size(type)) == 0)
HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype size")
/* Set "local" parameter for datatype size */
- cd_values[cd_values_index++] = dtype_size;
+ H5_CHECK_OVERFLOW(dtype_size, size_t, unsigned);
+ cd_values[(*cd_values_index)++] = (unsigned)dtype_size;
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -457,25 +460,28 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5Z_set_parms_atomic(const H5T_t *type, unsigned cd_values[])
+H5Z_set_parms_atomic(const H5T_t *type, unsigned *cd_values_index,
+ unsigned cd_values[], hbool_t *need_not_compress)
{
H5T_order_t dtype_order; /* Atomic datatype's endianness order */
size_t dtype_size; /* Atomic datatype's size (in bytes) */
size_t dtype_precision; /* Atomic datatype's precision (in bits) */
- int dtype_offset; /* Atomic datatype's offset (in bits) */
+ int sdtype_offset; /* Atomic datatype's offset (in bits) */
+ unsigned dtype_offset; /* Atomic datatype's offset (in bits) */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
/* Set datatype class code */
- cd_values[cd_values_index++] = H5Z_NBIT_ATOMIC;
+ cd_values[(*cd_values_index)++] = H5Z_NBIT_ATOMIC;
/* Get datatype's size */
if((dtype_size = H5T_get_size(type)) == 0)
HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype size")
/* Set "local" parameter for datatype size */
- cd_values[cd_values_index++] = dtype_size;
+ H5_CHECK_OVERFLOW(dtype_size, size_t, unsigned);
+ cd_values[(*cd_values_index)++] = (unsigned)dtype_size;
/* Get datatype's endianness order */
if((dtype_order = H5T_get_order(type)) == H5T_ORDER_ERROR)
@@ -484,11 +490,11 @@ H5Z_set_parms_atomic(const H5T_t *type, unsigned cd_values[])
/* Set "local" parameter for datatype endianness */
switch(dtype_order) {
case H5T_ORDER_LE: /* Little-endian byte order */
- cd_values[cd_values_index++] = H5Z_NBIT_ORDER_LE;
+ cd_values[(*cd_values_index)++] = H5Z_NBIT_ORDER_LE;
break;
case H5T_ORDER_BE: /* Big-endian byte order */
- cd_values[cd_values_index++] = H5Z_NBIT_ORDER_BE;
+ cd_values[(*cd_values_index)++] = H5Z_NBIT_ORDER_BE;
break;
case H5T_ORDER_VAX:
@@ -504,27 +510,28 @@ H5Z_set_parms_atomic(const H5T_t *type, unsigned cd_values[])
HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype precision")
/* Get datatype's offset */
- if((dtype_offset = H5T_get_offset(type)) < 0)
+ if((sdtype_offset = H5T_get_offset(type)) < 0)
HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype offset")
+ dtype_offset = (unsigned)sdtype_offset;
/* Check values of precision and offset */
- if(dtype_precision > dtype_size * 8 || (dtype_precision + dtype_offset) > dtype_size * 8
- || dtype_precision <= 0 || dtype_offset < 0)
+ if(dtype_precision > dtype_size * 8 || (dtype_precision + dtype_offset) > dtype_size * 8)
HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "invalid datatype precision/offset")
/* Set "local" parameter for datatype precision */
- cd_values[cd_values_index++] = dtype_precision;
+ H5_CHECK_OVERFLOW(dtype_precision, size_t, unsigned);
+ cd_values[(*cd_values_index)++] = (unsigned)dtype_precision;
/* Set "local" parameter for datatype offset */
- cd_values[cd_values_index++] = dtype_offset;
+ cd_values[(*cd_values_index)++] = dtype_offset;
/* If before this point, there is no need to compress, check the need to
* compress at this point. If current datatype is not full-precision,
* flag need_not_compress should be set to FALSE.
*/
- if(need_not_compress) /* so far no need to compress */
+ if(*need_not_compress) /* so far no need to compress */
if(dtype_offset != 0 || dtype_precision != dtype_size * 8)
- need_not_compress = FALSE;
+ *need_not_compress = FALSE;
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5Z_set_parms_atomic() */
@@ -547,7 +554,8 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5Z_set_parms_array(const H5T_t *type, unsigned cd_values[])
+H5Z_set_parms_array(const H5T_t *type, unsigned *cd_values_index,
+ unsigned cd_values[], hbool_t *need_not_compress)
{
H5T_t *dtype_base = NULL; /* Array datatype's base datatype */
H5T_class_t dtype_base_class; /* Array datatype's base datatype's class */
@@ -558,14 +566,15 @@ H5Z_set_parms_array(const H5T_t *type, unsigned cd_values[])
FUNC_ENTER_NOAPI_NOINIT
/* Set datatype class code */
- cd_values[cd_values_index++] = H5Z_NBIT_ARRAY;
+ cd_values[(*cd_values_index)++] = H5Z_NBIT_ARRAY;
/* Get array datatype's size */
if((dtype_size = H5T_get_size(type)) == 0)
HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype size")
/* Set "local" parameter for array datatype's size */
- cd_values[cd_values_index++]=dtype_size;
+ H5_CHECK_OVERFLOW(dtype_size, size_t, unsigned);
+ cd_values[(*cd_values_index)++] = (unsigned)dtype_size;
/* Get array datatype's base datatype */
if(NULL == (dtype_base = H5T_get_super(type)))
@@ -579,17 +588,17 @@ H5Z_set_parms_array(const H5T_t *type, unsigned cd_values[])
switch(dtype_base_class) {
case H5T_INTEGER:
case H5T_FLOAT:
- if(H5Z_set_parms_atomic(dtype_base, cd_values) == FAIL)
+ if(H5Z_set_parms_atomic(dtype_base, cd_values_index, cd_values, need_not_compress) < 0)
HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "nbit cannot set parameters for datatype")
break;
case H5T_ARRAY:
- if(H5Z_set_parms_array(dtype_base, cd_values) == FAIL)
+ if(H5Z_set_parms_array(dtype_base, cd_values_index, cd_values, need_not_compress) < 0)
HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "nbit cannot set parameters for datatype")
break;
case H5T_COMPOUND:
- if(H5Z_set_parms_compound(dtype_base, cd_values) == FAIL)
+ if(H5Z_set_parms_compound(dtype_base, cd_values_index, cd_values, need_not_compress) < 0)
HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "nbit cannot set parameters for datatype")
break;
@@ -602,7 +611,7 @@ H5Z_set_parms_array(const H5T_t *type, unsigned cd_values[])
if(dtype_base_class == H5T_VLEN || is_vlstring)
HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "datatype not supported by nbit")
- if(H5Z_set_parms_nooptype(dtype_base, cd_values) == FAIL)
+ if(H5Z_set_parms_nooptype(dtype_base, cd_values_index, cd_values) < 0)
HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "nbit cannot set parameters for datatype")
break;
@@ -612,7 +621,7 @@ H5Z_set_parms_array(const H5T_t *type, unsigned cd_values[])
case H5T_OPAQUE:
case H5T_REFERENCE:
case H5T_ENUM:
- if(H5Z_set_parms_nooptype(dtype_base, cd_values) == FAIL)
+ if(H5Z_set_parms_nooptype(dtype_base, cd_values_index, cd_values) < 0)
HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "nbit cannot set parameters for datatype")
break;
@@ -650,9 +659,11 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5Z_set_parms_compound(const H5T_t *type, unsigned cd_values[])
+H5Z_set_parms_compound(const H5T_t *type, unsigned *cd_values_index,
+ unsigned cd_values[], hbool_t *need_not_compress)
{
- int nmembers; /* Compound datatype's number of members */
+ int snmembers; /* Compound datatype's number of members */
+ unsigned nmembers; /* Compound datatype's number of members */
H5T_t *dtype_member = NULL; /* Compound datatype's member datatype */
H5T_class_t dtype_member_class; /* Compound datatype's member datatype's class */
size_t dtype_member_offset; /* Compound datatype's current member datatype's offset (in bytes) */
@@ -665,24 +676,26 @@ H5Z_set_parms_compound(const H5T_t *type, unsigned cd_values[])
FUNC_ENTER_NOAPI_NOINIT
/* Set "local" parameter for compound datatype class code */
- cd_values[cd_values_index++] = H5Z_NBIT_COMPOUND;
+ cd_values[(*cd_values_index)++] = H5Z_NBIT_COMPOUND;
/* Get datatype's size */
if((dtype_size = H5T_get_size(type)) == 0)
HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype size")
/* Set "local" parameter for compound datatype size */
- cd_values[cd_values_index++] = dtype_size;
+ H5_CHECK_OVERFLOW(dtype_size, size_t, unsigned);
+ cd_values[(*cd_values_index)++] = (unsigned)dtype_size;
/* Get number of members */
- if((nmembers = H5T_get_nmembers(type)) < 0)
+ if((snmembers = H5T_get_nmembers(type)) < 0)
HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype number of members")
+ nmembers = (unsigned)snmembers;
/* Set "local" parameter for number of members */
- cd_values[cd_values_index++] = nmembers;
+ cd_values[(*cd_values_index)++] = nmembers;
/* For each member, set parameters */
- for(u = 0; u < (unsigned)nmembers; u++) {
+ for(u = 0; u < nmembers; u++) {
/* Get member datatype */
if(NULL == (dtype_member = H5T_get_member_type(type, u, H5T_COPY_TRANSIENT)))
HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad member datatype")
@@ -695,23 +708,24 @@ H5Z_set_parms_compound(const H5T_t *type, unsigned cd_values[])
dtype_member_offset = H5T_get_member_offset(type, u);
/* Set "local" parameter for member offset */
- cd_values[cd_values_index++] = dtype_member_offset;
+ H5_CHECK_OVERFLOW(dtype_member_offset, size_t, unsigned);
+ cd_values[(*cd_values_index)++] = (unsigned)dtype_member_offset;
/* Call appropriate function according to member's datatype class */
switch(dtype_member_class) {
case H5T_INTEGER:
case H5T_FLOAT:
- if(H5Z_set_parms_atomic(dtype_member, cd_values) == FAIL)
+ if(H5Z_set_parms_atomic(dtype_member, cd_values_index, cd_values, need_not_compress) < 0)
HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "nbit cannot set parameters for datatype")
break;
case H5T_ARRAY:
- if(H5Z_set_parms_array(dtype_member, cd_values) == FAIL)
+ if(H5Z_set_parms_array(dtype_member, cd_values_index, cd_values, need_not_compress) < 0)
HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "nbit cannot set parameters for datatype")
break;
case H5T_COMPOUND:
- if(H5Z_set_parms_compound(dtype_member, cd_values) == FAIL)
+ if(H5Z_set_parms_compound(dtype_member, cd_values_index, cd_values, need_not_compress) < 0)
HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "nbit cannot set parameters for datatype")
break;
@@ -721,22 +735,24 @@ H5Z_set_parms_compound(const H5T_t *type, unsigned cd_values[])
HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot determine if datatype is a variable-length string")
/* Because for some no-op datatype (VL datatype and VL string datatype), its
- * size can not be retrieved correctly by using function call H5T_get_size,
- * special handling is needed for getting the size. Here the difference between
+ * size can not be retrieved correctly by using function call H5T_get_size,
+ * special handling is needed for getting the size. Here the difference between
* adjacent member offset is used (if alignment is present, the result can be
- * larger, but it does not affect the nbit filter's correctness).
+ * larger, but it does not affect the nbit filter's correctness).
*/
if(dtype_member_class == H5T_VLEN || is_vlstring) {
/* Set datatype class code */
- cd_values[cd_values_index++] = H5Z_NBIT_NOOPTYPE;
+ cd_values[(*cd_values_index)++] = H5Z_NBIT_NOOPTYPE;
- if(u != (unsigned)nmembers - 1)
+ if(u != nmembers - 1)
dtype_next_member_offset = H5T_get_member_offset(type, u + 1);
else /* current member is the last member */
dtype_next_member_offset = dtype_size;
/* Set "local" parameter for datatype size */
- cd_values[cd_values_index++] = dtype_next_member_offset - dtype_member_offset;
+ H5_CHECK_OVERFLOW(dtype_member_offset, size_t, unsigned);
+ H5_CHECK_OVERFLOW(dtype_next_member_offset, size_t, unsigned);
+ cd_values[(*cd_values_index)++] = (unsigned)dtype_next_member_offset - (unsigned)dtype_member_offset;
}
break;
@@ -747,7 +763,7 @@ H5Z_set_parms_compound(const H5T_t *type, unsigned cd_values[])
case H5T_REFERENCE:
case H5T_ENUM:
/* other datatype that nbit does no compression */
- if(H5Z_set_parms_nooptype(dtype_member, cd_values) == FAIL)
+ if(H5Z_set_parms_nooptype(dtype_member, cd_values_index, cd_values) < 0)
HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "nbit cannot set parameters for datatype")
break;
@@ -796,10 +812,13 @@ H5Z_set_local_nbit(hid_t dcpl_id, hid_t type_id, hid_t space_id)
const H5T_t *type; /* Datatype */
const H5S_t *ds; /* Dataspace */
unsigned flags; /* Filter flags */
+ unsigned cd_values_index; /* Index of array cd_values */
+ size_t cd_values_actual_nparms; /* Number of parameters in array cd_values[] */
size_t cd_nelmts = H5Z_NBIT_USER_NPARMS; /* Number of filter parameters */
unsigned *cd_values = NULL; /* Filter parameters */
hssize_t npoints; /* Number of points in the dataspace */
H5T_class_t dtype_class; /* Datatype's class */
+ hbool_t need_not_compress; /* Flag if TRUE indicating no need to do nbit compression */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -822,16 +841,16 @@ H5Z_set_local_nbit(hid_t dcpl_id, hid_t type_id, hid_t space_id)
switch(dtype_class) {
case H5T_INTEGER:
case H5T_FLOAT:
- H5Z_calc_parms_atomic();
+ H5Z_calc_parms_atomic(&cd_values_actual_nparms);
break;
case H5T_ARRAY:
- if(H5Z_calc_parms_array(type) == FAIL)
+ if(H5Z_calc_parms_array(type, &cd_values_actual_nparms) < 0)
HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "nbit cannot compute parameters for datatype")
break;
case H5T_COMPOUND:
- if(H5Z_calc_parms_compound(type) == FAIL)
+ if(H5Z_calc_parms_compound(type, &cd_values_actual_nparms) < 0)
HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "nbit cannot compute parameters for datatype")
break;
@@ -882,7 +901,8 @@ H5Z_set_local_nbit(hid_t dcpl_id, hid_t type_id, hid_t space_id)
cd_values_index = 2;
/* Set "local" parameter for number of elements in the chunk */
- H5_CHECKED_ASSIGN(cd_values[cd_values_index++], unsigned, npoints, hssize_t);
+ H5_CHECK_OVERFLOW(npoints, hssize_t, unsigned);
+ cd_values[cd_values_index++] = (unsigned)npoints;
/* Assume no need to compress now, will be changed to FALSE later if not */
need_not_compress = TRUE;
@@ -891,17 +911,17 @@ H5Z_set_local_nbit(hid_t dcpl_id, hid_t type_id, hid_t space_id)
switch(dtype_class) {
case H5T_INTEGER:
case H5T_FLOAT:
- if(H5Z_set_parms_atomic(type, cd_values) < 0)
+ if(H5Z_set_parms_atomic(type, &cd_values_index, cd_values, &need_not_compress) < 0)
HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "nbit cannot set parameters for datatype")
break;
case H5T_ARRAY:
- if(H5Z_set_parms_array(type, cd_values) < 0)
+ if(H5Z_set_parms_array(type, &cd_values_index, cd_values, &need_not_compress) < 0)
HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "nbit cannot set parameters for datatype")
break;
case H5T_COMPOUND:
- if(H5Z_set_parms_compound(type, cd_values) < 0)
+ if(H5Z_set_parms_compound(type, &cd_values_index, cd_values, &need_not_compress) < 0)
HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "nbit cannot set parameters for datatype")
break;
@@ -927,8 +947,9 @@ H5Z_set_local_nbit(hid_t dcpl_id, hid_t type_id, hid_t space_id)
HDassert(cd_values_actual_nparms == cd_values_index);
/* Finally set the first two entries of cd_values[] */
- cd_values[0] = cd_values_actual_nparms;
- cd_values[1] = need_not_compress;
+ H5_CHECK_OVERFLOW(cd_values_actual_nparms, size_t, unsigned);
+ cd_values[0] = (unsigned)cd_values_actual_nparms;
+ cd_values[1] = (unsigned)need_not_compress;
/* Modify the filter's parameters for this dataset */
if(H5P_modify_filter(dcpl_plist, H5Z_FILTER_NBIT, flags, cd_values_actual_nparms, cd_values) < 0)
@@ -957,7 +978,7 @@ done:
*/
static size_t
H5Z_filter_nbit(unsigned flags, size_t cd_nelmts, const unsigned cd_values[],
- size_t nbytes, size_t *buf_size, void **buf)
+ size_t nbytes, size_t *buf_size, void **buf)
{
unsigned char *outbuf; /* pointer to new output buffer */
size_t size_out = 0; /* size of output buffer */
@@ -1027,63 +1048,64 @@ done:
*/
static void
-H5Z_nbit_next_byte(size_t *j, int *buf_len)
+H5Z_nbit_next_byte(size_t *j, size_t *buf_len)
{
++(*j);
*buf_len = 8 * sizeof(unsigned char);
}
static void
-H5Z_nbit_decompress_one_byte(unsigned char *data, size_t data_offset, int k,
- int begin_i, int end_i, unsigned char *buffer, size_t *j, int *buf_len,
- parms_atomic p, int datatype_len)
+H5Z_nbit_decompress_one_byte(unsigned char *data, size_t data_offset, unsigned k,
+ unsigned begin_i, unsigned end_i, unsigned char *buffer, size_t *j, size_t *buf_len,
+ const parms_atomic *p, size_t datatype_len)
{
- int dat_len; /* dat_len is the number of bits to be copied in each data byte */
- int uchar_offset;
+ size_t dat_len; /* dat_len is the number of bits to be copied in each data byte */
+ size_t dat_offset;
unsigned char val; /* value to be copied in each data byte */
/* initialize value and bits of unsigned char to be copied */
val = buffer[*j];
- uchar_offset = 0;
+ dat_offset = 0;
if(begin_i != end_i) { /* significant bits occupy >1 unsigned char */
if(k == begin_i)
- dat_len = 8 - (datatype_len - p.precision - p.offset) % 8;
+ dat_len = 8 - (datatype_len - p->precision - p->offset) % 8;
else if(k == end_i) {
- dat_len = 8 - p.offset %8;
- uchar_offset = 8 - dat_len;
+ dat_len = 8 - p->offset % 8;
+ dat_offset = 8 - dat_len;
}
else
dat_len = 8;
} else { /* all significant bits in one unsigned char */
- uchar_offset = p.offset % 8;
- dat_len = p.precision;
+ dat_offset = p->offset % 8;
+ dat_len = p->precision;
}
if(*buf_len > dat_len) {
- data[data_offset + k] =
- ((val >> (*buf_len - dat_len)) & ~(~0 << dat_len)) << uchar_offset;
+ data[data_offset + k] = (unsigned char)(
+ ((unsigned)(val >> (*buf_len - dat_len)) & (unsigned)(~((unsigned)(~0) << dat_len))) << dat_offset);
*buf_len -= dat_len;
} else {
- data[data_offset + k] =
- ((val & ~(~0 << *buf_len)) << (dat_len - *buf_len)) << uchar_offset;
+ data[data_offset + k] = (unsigned char)(
+ ((val & ~((unsigned)(~0) << *buf_len)) << (dat_len - *buf_len)) << dat_offset);
dat_len -= *buf_len;
H5Z_nbit_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)) << uchar_offset;
+ data[data_offset + k] |= (unsigned char)(
+ ((unsigned)(val >> (*buf_len - dat_len)) & (unsigned)(~((unsigned)(~0) << dat_len))) << dat_offset);
*buf_len -= dat_len;
}
}
static void
H5Z_nbit_decompress_one_nooptype(unsigned char *data, size_t data_offset,
- unsigned char *buffer, size_t *j, int *buf_len, unsigned size)
+ unsigned char *buffer, size_t *j, size_t *buf_len, unsigned size)
{
unsigned i; /* index */
- unsigned dat_len; /* dat_len is the number of bits to be copied in each data byte */
+ size_t 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 */
for(i = 0; i < size; i++) {
@@ -1091,99 +1113,109 @@ H5Z_nbit_decompress_one_nooptype(unsigned char *data, size_t data_offset,
val = buffer[*j];
dat_len = sizeof(unsigned char) * 8;
- data[data_offset + i] = ((val & ~(~0 << *buf_len)) << (dat_len - *buf_len));
+ data[data_offset + i] = (unsigned char)(((val & ~((unsigned)(~0) << *buf_len)) << (dat_len - *buf_len)));
dat_len -= *buf_len;
H5Z_nbit_next_byte(j, buf_len);
- if(dat_len == 0) continue;
+ if(dat_len == 0)
+ continue;
val = buffer[*j];
- data[data_offset + i] |= ((val >> (*buf_len - dat_len)) & ~(~0 << dat_len));
+ data[data_offset + i] |= (unsigned char)((unsigned)(val >> (*buf_len - dat_len)) & (unsigned)(~((unsigned)(~0) << dat_len)));
*buf_len -= dat_len;
}
}
static void
H5Z_nbit_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, size_t *buf_len, const parms_atomic *p)
{
- /* begin_i: the index of byte having first significant bit
- end_i: the index of byte having last significant bit */
- int k, begin_i, end_i, datatype_len;
-
- datatype_len = p.size * 8;
-
- if(p.order == H5Z_NBIT_ORDER_LE) { /* little endian */
- /* calculate begin_i and end_i */
- if((p.precision + p.offset) % 8 != 0)
- begin_i = (p.precision + p.offset) / 8;
- else
- begin_i = (p.precision + p.offset) / 8 - 1;
- end_i = p.offset / 8;
-
- for(k = begin_i; k >= end_i; k--)
- H5Z_nbit_decompress_one_byte(data, data_offset, k, begin_i, end_i,
- buffer, j, buf_len, p, datatype_len);
- }
-
- if(p.order == H5Z_NBIT_ORDER_BE) { /* big endian */
- /* calculate begin_i and end_i */
- begin_i = (datatype_len - p.precision - p.offset) / 8;
- if(p.offset % 8 != 0)
- end_i = (datatype_len - p.offset) / 8;
- else
- end_i = (datatype_len - p.offset) / 8 - 1;
-
- for(k = begin_i; k <= end_i; k++)
- H5Z_nbit_decompress_one_byte(data, data_offset, k, begin_i, end_i,
- buffer, j, buf_len, p, datatype_len);
- }
+ /* begin_i: the index of byte having first significant bit
+ end_i: the index of byte having last significant bit */
+ int k;
+ unsigned begin_i, end_i;
+ size_t datatype_len;
+
+ datatype_len = p->size * 8;
+
+ if(p->order == H5Z_NBIT_ORDER_LE) { /* little endian */
+ /* calculate begin_i and end_i */
+ if((p->precision + p->offset) % 8 != 0)
+ begin_i = (p->precision + p->offset) / 8;
+ else
+ begin_i = (p->precision + p->offset) / 8 - 1;
+ end_i = p->offset / 8;
+
+ for(k = (int)begin_i; k >= (int)end_i; k--)
+ H5Z_nbit_decompress_one_byte(data, data_offset, (unsigned)k, begin_i, end_i,
+ buffer, j, buf_len, p, datatype_len);
+ }
+ else { /* big endian */
+ /* Sanity check */
+ HDassert(p->order == H5Z_NBIT_ORDER_BE);
+
+ /* calculate begin_i and end_i */
+ begin_i = ((unsigned)datatype_len - p->precision - p->offset) / 8;
+ if(p->offset % 8 != 0)
+ end_i = ((unsigned)datatype_len - p->offset) / 8;
+ else
+ end_i = ((unsigned)datatype_len - p->offset) / 8 - 1;
+
+ for(k = (int)begin_i; k <= (int)end_i; k++)
+ H5Z_nbit_decompress_one_byte(data, data_offset, (unsigned)k, begin_i, end_i,
+ buffer, j, buf_len, p, datatype_len);
+ }
}
static void
H5Z_nbit_decompress_one_array(unsigned char *data, size_t data_offset,
- unsigned char *buffer, size_t *j, int *buf_len, const unsigned parms[])
+ unsigned char *buffer, size_t *j, size_t *buf_len, const unsigned parms[],
+ unsigned *parms_index)
{
unsigned i, total_size, base_class, base_size, n, begin_index;
parms_atomic p;
- total_size = parms[parms_index++];
- base_class = parms[parms_index++];
+ total_size = parms[(*parms_index)++];
+ base_class = parms[(*parms_index)++];
switch(base_class) {
case H5Z_NBIT_ATOMIC:
- p.size = parms[parms_index++];
- p.order = parms[parms_index++];
- p.precision = parms[parms_index++];
- p.offset = parms[parms_index++];
- n = total_size/p.size;
+ p.size = parms[(*parms_index)++];
+ p.order = parms[(*parms_index)++];
+ p.precision = parms[(*parms_index)++];
+ p.offset = parms[(*parms_index)++];
+ n = total_size / p.size;
for(i = 0; i < n; i++)
- H5Z_nbit_decompress_one_atomic(data, data_offset + i*p.size,
- buffer, j, buf_len, p);
+ H5Z_nbit_decompress_one_atomic(data, data_offset + i * p.size,
+ buffer, j, buf_len, &p);
break;
+
case H5Z_NBIT_ARRAY:
- base_size = parms[parms_index]; /* read in advance */
- n = total_size/base_size; /* number of base_type elements inside the array datatype */
- begin_index = parms_index;
+ base_size = parms[*parms_index]; /* read in advance */
+ n = total_size / base_size; /* number of base_type elements inside the array datatype */
+ begin_index = *parms_index;
for(i = 0; i < n; i++) {
- H5Z_nbit_decompress_one_array(data, data_offset + i*base_size,
- buffer, j, buf_len, parms);
- parms_index = begin_index;
+ H5Z_nbit_decompress_one_array(data, data_offset + i * base_size,
+ buffer, j, buf_len, parms, parms_index);
+ *parms_index = begin_index;
}
break;
+
case H5Z_NBIT_COMPOUND:
- base_size = parms[parms_index]; /* read in advance */
- n = total_size/base_size; /* number of base_type elements inside the array datatype */
- begin_index = parms_index;
+ base_size = parms[*parms_index]; /* read in advance */
+ n = total_size / base_size; /* number of base_type elements inside the array datatype */
+ begin_index = *parms_index;
for(i = 0; i < n; i++) {
- H5Z_nbit_decompress_one_compound(data, data_offset + i*base_size,
- buffer, j, buf_len, parms);
- parms_index = begin_index;
+ H5Z_nbit_decompress_one_compound(data, data_offset + i * base_size,
+ buffer, j, buf_len, parms, parms_index);
+ *parms_index = begin_index;
}
break;
+
case H5Z_NBIT_NOOPTYPE:
- parms_index++; /* skip size of no-op type */
+ (*parms_index)++; /* skip size of no-op type */
H5Z_nbit_decompress_one_nooptype(data, data_offset, buffer, j, buf_len, total_size);
break;
+
default:
HDassert(0 && "This Should never be executed!");
} /* end switch */
@@ -1191,39 +1223,44 @@ H5Z_nbit_decompress_one_array(unsigned char *data, size_t data_offset,
static void
H5Z_nbit_decompress_one_compound(unsigned char *data, size_t data_offset,
- unsigned char *buffer, size_t *j, int *buf_len, const unsigned parms[])
+ unsigned char *buffer, size_t *j, size_t *buf_len, const unsigned parms[],
+ unsigned *parms_index)
{
unsigned i, nmembers, member_offset, member_class, size;
parms_atomic p;
- parms_index++; /* skip total size of compound datatype */
- nmembers = parms[parms_index++];
+ (*parms_index)++; /* skip total size of compound datatype */
+ nmembers = parms[(*parms_index)++];
for(i = 0; i < nmembers; i++) {
- member_offset = parms[parms_index++];
- member_class = parms[parms_index++];
+ member_offset = parms[(*parms_index)++];
+ member_class = parms[(*parms_index)++];
switch(member_class) {
case H5Z_NBIT_ATOMIC:
- p.size = parms[parms_index++];
- p.order = parms[parms_index++];
- p.precision = parms[parms_index++];
- p.offset = parms[parms_index++];
+ p.size = parms[(*parms_index)++];
+ p.order = parms[(*parms_index)++];
+ p.precision = parms[(*parms_index)++];
+ p.offset = parms[(*parms_index)++];
H5Z_nbit_decompress_one_atomic(data, data_offset + member_offset,
- buffer, j, buf_len, p);
+ buffer, j, buf_len, &p);
break;
+
case H5Z_NBIT_ARRAY:
H5Z_nbit_decompress_one_array(data, data_offset + member_offset,
- buffer, j, buf_len, parms);
+ buffer, j, buf_len, parms, parms_index);
break;
+
case H5Z_NBIT_COMPOUND:
H5Z_nbit_decompress_one_compound(data, data_offset+member_offset,
- buffer, j, buf_len, parms);
+ buffer, j, buf_len, parms, parms_index);
break;
+
case H5Z_NBIT_NOOPTYPE:
- size = parms[parms_index++];
+ size = parms[(*parms_index)++];
H5Z_nbit_decompress_one_nooptype(data, data_offset+member_offset,
buffer, j, buf_len, size);
break;
+
default:
HDassert(0 && "This Should never be executed!");
} /* end switch */
@@ -1232,94 +1269,101 @@ H5Z_nbit_decompress_one_compound(unsigned char *data, size_t data_offset,
static void
H5Z_nbit_decompress(unsigned char *data, unsigned d_nelmts, unsigned char *buffer,
- const unsigned parms[])
+ const unsigned parms[])
{
- /* i: index of data, j: index of buffer,
- buf_len: number of bits to be filled in current byte */
- size_t i, j, size;
- int buf_len;
- parms_atomic p;
+ /* i: index of data, j: index of buffer,
+ buf_len: number of bits to be filled in current byte */
+ unsigned i;
+ size_t j, size;
+ size_t buf_len;
+ parms_atomic p;
+ unsigned parms_index; /* index in array parms used by compression/decompression functions */
+
+ /* may not have to initialize to zeros */
+ HDmemset(data, 0, d_nelmts * parms[4]);
+
+ /* initialization before the loop */
+ j = 0;
+ buf_len = sizeof(unsigned char) * 8;
+
+ switch(parms[3]) {
+ case H5Z_NBIT_ATOMIC:
+ p.size = parms[4];
+ p.order = parms[5];
+ p.precision = parms[6];
+ p.offset = parms[7];
+ for(i = 0; i < d_nelmts; i++)
+ H5Z_nbit_decompress_one_atomic(data, i * p.size, buffer, &j, &buf_len, &p);
+ break;
- /* may not have to initialize to zeros */
- for(i = 0; i < d_nelmts*parms[4]; i++) data[i] = 0;
+ case H5Z_NBIT_ARRAY:
+ size = parms[4];
+ parms_index = 4; /* set the index before goto function call */
+ for(i = 0; i < d_nelmts; i++) {
+ H5Z_nbit_decompress_one_array(data, i * size, buffer, &j, &buf_len, parms, &parms_index);
+ parms_index = 4;
+ }
+ break;
- /* initialization before the loop */
- j = 0;
- buf_len = sizeof(unsigned char) * 8;
+ case H5Z_NBIT_COMPOUND:
+ size = parms[4];
+ parms_index = 4; /* set the index before goto function call */
+ for(i = 0; i < d_nelmts; i++) {
+ H5Z_nbit_decompress_one_compound(data, i * size, buffer, &j, &buf_len, parms, &parms_index);
+ parms_index = 4;
+ }
+ break;
- switch(parms[3]) {
- case H5Z_NBIT_ATOMIC:
- /* set the index before goto function call */
- p.size = parms[4];
- p.order = parms[5];
- p.precision = parms[6];
- p.offset = parms[7];
- for(i = 0; i < d_nelmts; i++) {
- H5Z_nbit_decompress_one_atomic(data, i*p.size, buffer, &j, &buf_len, p);
- }
- break;
- case H5Z_NBIT_ARRAY:
- size = parms[4];
- parms_index = 4;
- for(i = 0; i < d_nelmts; i++) {
- H5Z_nbit_decompress_one_array(data, i*size, buffer, &j, &buf_len, parms);
- parms_index = 4;
- }
- break;
- case H5Z_NBIT_COMPOUND:
- size = parms[4];
- parms_index = 4;
- for(i = 0; i < d_nelmts; i++) {
- H5Z_nbit_decompress_one_compound(data, i*size, buffer, &j, &buf_len, parms);
- parms_index = 4;
- }
- break;
- default:
- HDassert(0 && "This Should never be executed!");
- } /* end switch */
+ default:
+ HDassert(0 && "This Should never be executed!");
+ } /* end switch */
}
-static void H5Z_nbit_compress_one_byte(unsigned char *data, size_t data_offset, int k, int begin_i,
-int end_i, unsigned char *buffer, size_t *j, int *buf_len, parms_atomic p, int datatype_len)
+static void
+H5Z_nbit_compress_one_byte(unsigned char *data, size_t data_offset, unsigned k,
+ unsigned begin_i, unsigned end_i, unsigned char *buffer, size_t *j, size_t *buf_len,
+ const parms_atomic *p, size_t datatype_len)
{
- int dat_len; /* dat_len is the number of bits to be copied in each data byte */
+ size_t 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];
if(begin_i != end_i) { /* significant bits occupy >1 unsigned char */
if(k == begin_i)
- dat_len = 8 - (datatype_len - p.precision - p.offset) % 8;
+ dat_len = 8 - (datatype_len - p->precision - p->offset) % 8;
else if(k == end_i) {
- dat_len = 8 - p.offset % 8;
- val >>= 8 - dat_len;
+ dat_len = 8 - p->offset % 8;
+ val = (unsigned char)(val >> (8 - dat_len));
}
else
dat_len = 8;
} else { /* all significant bits in one unsigned char */
- val >>= p.offset % 8;
- dat_len = p.precision;
+ val = (unsigned char)(val >> (p->offset % 8));
+ dat_len = p->precision;
}
if(*buf_len > dat_len) {
- buffer[*j] |= (val & ~(~0 << dat_len)) << (*buf_len - dat_len);
+ buffer[*j] |= (unsigned char)((val & ~((unsigned)(~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)((unsigned)(val >> (dat_len - *buf_len)) & ~((unsigned)(~0) << *buf_len));
dat_len -= *buf_len;
H5Z_nbit_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 & ~((unsigned)(~0) << dat_len)) << (*buf_len - dat_len));
*buf_len -= dat_len;
}
}
-static void H5Z_nbit_compress_one_nooptype(unsigned char *data, size_t data_offset,
- unsigned char *buffer, size_t *j, int *buf_len, unsigned size)
+static void
+H5Z_nbit_compress_one_nooptype(unsigned char *data, size_t data_offset,
+ unsigned char *buffer, size_t *j, size_t *buf_len, unsigned size)
{
unsigned i; /* index */
- unsigned dat_len; /* dat_len is the number of bits to be copied in each data byte */
+ size_t 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 */
for(i = 0; i < size; i++) {
@@ -1327,192 +1371,214 @@ static void H5Z_nbit_compress_one_nooptype(unsigned char *data, size_t data_offs
val = data[data_offset + i];
dat_len = sizeof(unsigned char) * 8;
- buffer[*j] |= (val >> (dat_len - *buf_len)) & ~(~0 << *buf_len);
+ buffer[*j] |= (unsigned char)((unsigned)(val >> (dat_len - *buf_len)) & ~((unsigned)(~0) << *buf_len));
dat_len -= *buf_len;
H5Z_nbit_next_byte(j, buf_len);
- if(dat_len == 0) continue;
+ if(dat_len == 0)
+ continue;
- buffer[*j] = (val & ~(~0 << dat_len)) << (*buf_len - dat_len);
+ buffer[*j] = (unsigned char)((val & ~((unsigned)(~0) << dat_len)) << (*buf_len - dat_len));
*buf_len -= dat_len;
}
}
-static void H5Z_nbit_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_nbit_compress_one_atomic(unsigned char *data, size_t data_offset,
+ unsigned char *buffer, size_t *j, size_t *buf_len, const parms_atomic *p)
{
- /* begin_i: the index of byte having first significant bit
- end_i: the index of byte having last significant bit */
- int k, begin_i, end_i, datatype_len;
-
- datatype_len = p.size * 8;
-
- if(p.order == H5Z_NBIT_ORDER_LE) { /* little endian */
- /* calculate begin_i and end_i */
- if((p.precision + p.offset) % 8 != 0)
- begin_i = (p.precision + p.offset) / 8;
- else
- begin_i = (p.precision + p.offset) / 8 - 1;
- end_i = p.offset / 8;
-
- for(k = begin_i; k >= end_i; k--)
- H5Z_nbit_compress_one_byte(data, data_offset, k, begin_i, end_i,
- buffer, j, buf_len, p, datatype_len);
- }
-
- if(p.order == H5Z_NBIT_ORDER_BE) { /* big endian */
- /* calculate begin_i and end_i */
- begin_i = (datatype_len - p.precision - p.offset) / 8;
- if(p.offset % 8 != 0)
- end_i = (datatype_len - p.offset) / 8;
- else
- end_i = (datatype_len - p.offset) / 8 - 1;
-
- for(k = begin_i; k <= end_i; k++)
- H5Z_nbit_compress_one_byte(data, data_offset, k, begin_i, end_i,
- buffer, j, buf_len, p, datatype_len);
- }
+ /* begin_i: the index of byte having first significant bit
+ end_i: the index of byte having last significant bit */
+ int k;
+ unsigned begin_i, end_i;
+ size_t datatype_len;
+
+ datatype_len = p->size * 8;
+
+ if(p->order == H5Z_NBIT_ORDER_LE) { /* little endian */
+ /* calculate begin_i and end_i */
+ if((p->precision + p->offset) % 8 != 0)
+ begin_i = (p->precision + p->offset) / 8;
+ else
+ begin_i = (p->precision + p->offset) / 8 - 1;
+ end_i = p->offset / 8;
+
+ for(k = (int)begin_i; k >= (int)end_i; k--)
+ H5Z_nbit_compress_one_byte(data, data_offset, (unsigned)k, begin_i, end_i,
+ buffer, j, buf_len, p, datatype_len);
+ }
+ else { /* big endian */
+ /* Sanity check */
+ HDassert(p->order == H5Z_NBIT_ORDER_BE);
+
+ /* calculate begin_i and end_i */
+ begin_i = ((unsigned)datatype_len - p->precision - p->offset) / 8;
+ if(p->offset % 8 != 0)
+ end_i = ((unsigned)datatype_len - p->offset) / 8;
+ else
+ end_i = ((unsigned)datatype_len - p->offset) / 8 - 1;
+
+ for(k = (int)begin_i; k <= (int)end_i; k++)
+ H5Z_nbit_compress_one_byte(data, data_offset, (unsigned)k, begin_i, end_i,
+ buffer, j, buf_len, p, datatype_len);
+ }
}
-static void H5Z_nbit_compress_one_array(unsigned char *data, size_t data_offset, unsigned char *buffer,
- size_t *j, int *buf_len, const unsigned parms[])
+static void
+H5Z_nbit_compress_one_array(unsigned char *data, size_t data_offset,
+ unsigned char *buffer, size_t *j, size_t *buf_len, const unsigned parms[],
+ unsigned *parms_index)
{
unsigned i, total_size, base_class, base_size, n, begin_index;
parms_atomic p;
- total_size = parms[parms_index++];
- base_class = parms[parms_index++];
+ total_size = parms[(*parms_index)++];
+ base_class = parms[(*parms_index)++];
switch(base_class) {
case H5Z_NBIT_ATOMIC:
- p.size = parms[parms_index++];
- p.order = parms[parms_index++];
- p.precision = parms[parms_index++];
- p.offset = parms[parms_index++];
- n = total_size/p.size;
+ p.size = parms[(*parms_index)++];
+ p.order = parms[(*parms_index)++];
+ p.precision = parms[(*parms_index)++];
+ p.offset = parms[(*parms_index)++];
+ n = total_size / p.size;
for(i = 0; i < n; i++)
- H5Z_nbit_compress_one_atomic(data, data_offset + i*p.size,
- buffer, j, buf_len, p);
+ H5Z_nbit_compress_one_atomic(data, data_offset + i * p.size,
+ buffer, j, buf_len, &p);
break;
+
case H5Z_NBIT_ARRAY:
- base_size = parms[parms_index]; /* read in advance */
- n = total_size/base_size; /* number of base_type elements inside the array datatype */
- begin_index = parms_index;
+ base_size = parms[*parms_index]; /* read in advance */
+ n = total_size / base_size; /* number of base_type elements inside the array datatype */
+ begin_index = *parms_index;
for(i = 0; i < n; i++) {
- H5Z_nbit_compress_one_array(data, data_offset + i*base_size,
- buffer, j, buf_len, parms);
- parms_index = begin_index;
+ H5Z_nbit_compress_one_array(data, data_offset + i * base_size,
+ buffer, j, buf_len, parms, parms_index);
+ *parms_index = begin_index;
}
break;
+
case H5Z_NBIT_COMPOUND:
- base_size = parms[parms_index]; /* read in advance */
- n = total_size/base_size; /* number of base_type elements inside the array datatype */
- begin_index = parms_index;
+ base_size = parms[*parms_index]; /* read in advance */
+ n = total_size / base_size; /* number of base_type elements inside the array datatype */
+ begin_index = *parms_index;
for(i = 0; i < n; i++) {
- H5Z_nbit_compress_one_compound(data, data_offset + i*base_size,
- buffer, j, buf_len, parms);
- parms_index = begin_index;
+ H5Z_nbit_compress_one_compound(data, data_offset + i * base_size,
+ buffer, j, buf_len, parms, parms_index);
+ *parms_index = begin_index;
}
break;
+
case H5Z_NBIT_NOOPTYPE:
- parms_index++; /* skip size of no-op type */
+ (*parms_index)++; /* skip size of no-op type */
H5Z_nbit_compress_one_nooptype(data, data_offset, buffer, j, buf_len, total_size);
break;
+
default:
HDassert(0 && "This Should never be executed!");
} /* end switch */
}
-static void H5Z_nbit_compress_one_compound(unsigned char *data, size_t data_offset,
- unsigned char *buffer, size_t *j, int *buf_len, const unsigned parms[])
+static void
+H5Z_nbit_compress_one_compound(unsigned char *data, size_t data_offset,
+ unsigned char *buffer, size_t *j, size_t *buf_len, const unsigned parms[],
+ unsigned *parms_index)
{
unsigned i, nmembers, member_offset, member_class, size;
parms_atomic p;
- parms_index++; /* skip size of compound datatype */
- nmembers = parms[parms_index++];
+ (*parms_index)++; /* skip size of compound datatype */
+ nmembers = parms[(*parms_index)++];
for(i = 0; i < nmembers; i++) {
- member_offset = parms[parms_index++];
- member_class = parms[parms_index++];
+ member_offset = parms[(*parms_index)++];
+ member_class = parms[(*parms_index)++];
switch(member_class) {
case H5Z_NBIT_ATOMIC:
- p.size = parms[parms_index++];
- p.order = parms[parms_index++];
- p.precision = parms[parms_index++];
- p.offset = parms[parms_index++];
+ p.size = parms[(*parms_index)++];
+ p.order = parms[(*parms_index)++];
+ p.precision = parms[(*parms_index)++];
+ p.offset = parms[(*parms_index)++];
H5Z_nbit_compress_one_atomic(data, data_offset + member_offset,
- buffer, j, buf_len, p);
+ buffer, j, buf_len, &p);
break;
+
case H5Z_NBIT_ARRAY:
H5Z_nbit_compress_one_array(data, data_offset + member_offset,
- buffer, j, buf_len, parms);
+ buffer, j, buf_len, parms, parms_index);
break;
+
case H5Z_NBIT_COMPOUND:
H5Z_nbit_compress_one_compound(data, data_offset+member_offset,
- buffer, j, buf_len, parms);
+ buffer, j, buf_len, parms, parms_index);
break;
+
case H5Z_NBIT_NOOPTYPE:
- size = parms[parms_index++];
+ size = parms[(*parms_index)++];
H5Z_nbit_compress_one_nooptype(data, data_offset+member_offset,
buffer, j, buf_len, size);
break;
+
default:
HDassert(0 && "This Should never be executed!");
} /* end switch */
}
}
-static void H5Z_nbit_compress(unsigned char *data, unsigned d_nelmts, unsigned char *buffer,
- size_t *buffer_size, const unsigned parms[])
+static void
+H5Z_nbit_compress(unsigned char *data, unsigned d_nelmts, unsigned char *buffer,
+ size_t *buffer_size, const unsigned parms[])
{
- /* i: index of data, new_size: index of buffer,
- buf_len: number of bits to be filled in current byte */
- size_t i, size;
- size_t new_size = 0;
- int buf_len;
- parms_atomic p;
+ /* i: index of data, new_size: index of buffer,
+ buf_len: number of bits to be filled in current byte */
+ unsigned i;
+ size_t size;
+ size_t new_size = 0;
+ size_t buf_len;
+ parms_atomic p;
+ unsigned parms_index; /* index in array parms used by compression/decompression functions */
+
+ /* must initialize buffer to be zeros */
+ HDmemset(buffer, 0, *buffer_size);
+
+ /* initialization before the loop */
+ buf_len = sizeof(unsigned char) * 8;
+
+ switch(parms[3]) {
+ case H5Z_NBIT_ATOMIC:
+ p.size = parms[4];
+ p.order = parms[5];
+ p.precision = parms[6];
+ p.offset = parms[7];
+
+ for(i = 0; i < d_nelmts; i++)
+ H5Z_nbit_compress_one_atomic(data, i * p.size, buffer, &new_size, &buf_len, &p);
+ break;
- /* must initialize buffer to be zeros */
- HDmemset(buffer, 0, *buffer_size);
+ case H5Z_NBIT_ARRAY:
+ size = parms[4];
+ parms_index = 4;
+ for(i = 0; i < d_nelmts; i++) {
+ H5Z_nbit_compress_one_array(data, i * size, buffer, &new_size, &buf_len, parms, &parms_index);
+ parms_index = 4;
+ }
+ break;
- /* initialization before the loop */
- buf_len = sizeof(unsigned char) * 8;
+ case H5Z_NBIT_COMPOUND:
+ size = parms[4];
+ parms_index = 4;
+ for(i = 0; i < d_nelmts; i++) {
+ H5Z_nbit_compress_one_compound(data, i * size, buffer, &new_size, &buf_len, parms, &parms_index);
+ parms_index = 4;
+ }
+ break;
- switch(parms[3]) {
- case H5Z_NBIT_ATOMIC:
- /* set the index before goto function call */
- p.size = parms[4];
- p.order = parms[5];
- p.precision = parms[6];
- p.offset = parms[7];
-
- for(i = 0; i < d_nelmts; i++) {
- H5Z_nbit_compress_one_atomic(data, i*p.size, buffer, &new_size, &buf_len, p);
- }
- break;
- case H5Z_NBIT_ARRAY:
- size = parms[4];
- parms_index = 4;
- for(i = 0; i < d_nelmts; i++) {
- H5Z_nbit_compress_one_array(data, i*size, buffer, &new_size, &buf_len, parms);
- parms_index = 4;
- }
- break;
- case H5Z_NBIT_COMPOUND:
- size = parms[4];
- parms_index = 4;
- for(i = 0; i < d_nelmts; i++) {
- H5Z_nbit_compress_one_compound(data, i*size, buffer, &new_size, &buf_len, parms);
- parms_index = 4;
- }
- break;
- default:
- HDassert(0 && "This Should never be executed!");
- } /* end switch */
+ default:
+ HDassert(0 && "This Should never be executed!");
+ } /* end switch */
- /* Update the size to the new value after compression. If there are any bits hanging over in
- * the last byte, increment the value by 1. */
- *buffer_size = new_size + 1;
+ /* Update the size to the new value after compression. If there are any bits hanging over in
+ * the last byte, increment the value by 1. */
+ *buffer_size = new_size + 1;
}
diff --git a/src/H5Zscaleoffset.c b/src/H5Zscaleoffset.c
index 7c9dbf9..1cca9b1 100644
--- a/src/H5Zscaleoffset.c
+++ b/src/H5Zscaleoffset.c
@@ -28,7 +28,7 @@
/* Struct of parameters needed for compressing/decompressing one atomic datatype */
typedef struct {
- size_t size; /* datatype size */
+ unsigned size; /* datatype size */
uint32_t minbits; /* minimum bits to compress one value of such datatype */
unsigned mem_order; /* current memory endianness order */
} parms_atomic;
@@ -38,7 +38,6 @@ enum H5Z_scaleoffset_t {t_bad=0, t_uchar=1, t_ushort, t_uint, t_ulong, t_ulong_l
t_float, t_double};
/* Local function prototypes */
-static double H5Z_scaleoffset_rnd(double val);
static htri_t H5Z_can_apply_scaleoffset(hid_t dcpl_id, hid_t type_id, hid_t space_id);
static enum H5Z_scaleoffset_t H5Z_scaleoffset_get_type(unsigned dtype_class,
unsigned dtype_size, unsigned dtype_sign);
@@ -48,7 +47,7 @@ static herr_t H5Z_scaleoffset_set_parms_fillval(H5P_genplist_t *dcpl_plist,
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,
const unsigned cd_values[], size_t nbytes, size_t *buf_size, void **buf);
-static void H5Z_scaleoffset_convert(void *buf, unsigned d_nelmts, size_t dtype_size);
+static void H5Z_scaleoffset_convert(void *buf, unsigned d_nelmts, unsigned dtype_size);
static H5_ATTR_CONST unsigned H5Z_scaleoffset_log2(unsigned long long num);
static void H5Z_scaleoffset_precompress_i(void *data, unsigned d_nelmts,
enum H5Z_scaleoffset_t type, unsigned filavail, const unsigned cd_values[],
@@ -389,25 +388,28 @@ H5Z_class2_t H5Z_SCALEOFFSET[1] = {{
}
/* Check and handle special situation for floating-point type */
-#define H5Z_scaleoffset_check_3(i, type, max, min, minbits, D_val) \
+#define H5Z_scaleoffset_check_3(i, type, pow_fun, round_fun, max, min, minbits, D_val) \
{ \
- if(sizeof(type)==sizeof(int)) { \
- if(H5Z_scaleoffset_rnd(max*HDpow(10.0f, D_val) - min*HDpow(10.0f, D_val)) \
- > HDpow(2.0f, (double)(sizeof(int)*8 - 1))) { \
- *minbits = sizeof(int)*8; goto done; \
- } \
- } else if(sizeof(type)==sizeof(long)) { \
- if(H5Z_scaleoffset_rnd(max*HDpow(10.0f, D_val) - min*HDpow(10.0f, D_val)) \
- > HDpow(2.0f, (double)(sizeof(long)*8 - 1))) { \
- *minbits = sizeof(long)*8; goto done; \
- } \
- } else if(sizeof(type)==sizeof(long long)) { \
- if(H5Z_scaleoffset_rnd(max*HDpow(10.0f, D_val) - min*HDpow(10.0f, D_val)) \
- > HDpow(2.0f, (double)(sizeof(long long)*8 - 1))) { \
- *minbits = sizeof(long long)*8; goto done; \
- } \
- } else \
- HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer dataype")\
+ if(sizeof(type) == sizeof(int)) { \
+ if(round_fun(max * pow_fun(10.0f, (type)D_val) - min * pow_fun(10.0f, (type)D_val)) \
+ > pow_fun(2.0f, (type)(sizeof(int) * 8 - 1))) { \
+ *minbits = sizeof(int) * 8; \
+ goto done; \
+ } \
+ } else if(sizeof(type) == sizeof(long)) { \
+ if(round_fun(max * pow_fun(10.0f, (type)D_val) - min * pow_fun(10.0f, (type)D_val)) \
+ > pow_fun(2.0f, (type)(sizeof(long) * 8 - 1))) { \
+ *minbits = sizeof(long) * 8; \
+ goto done; \
+ } \
+ } else if(sizeof(type) == sizeof(long long)) { \
+ if(round_fun(max * pow_fun(10.0f, (type)D_val) - min * pow_fun(10.0f, (type)D_val)) \
+ > pow_fun(2.0f, (type)(sizeof(long long) * 8 - 1))) { \
+ *minbits = sizeof(long long) * 8; \
+ goto done; \
+ } \
+ } else \
+ HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer dataype") \
}
/* Precompress for unsigned integer type */
@@ -477,53 +479,47 @@ H5Z_class2_t H5Z_SCALEOFFSET[1] = {{
}
/* Modify values of data in precompression if fill value defined for floating-point type */
-#define H5Z_scaleoffset_modify_1(i, type, buf, d_nelmts, filval, minbits, min, D_val) \
+#define H5Z_scaleoffset_modify_1(i, type, pow_fun, abs_fun, lround_fun, llround_fun, buf, d_nelmts, filval, minbits, min, D_val) \
{ \
- if(sizeof(type)==sizeof(int)) \
+ if(sizeof(type) == sizeof(int)) \
for(i = 0; i < d_nelmts; i++) { \
- if(HDfabs(buf[i] - filval) < HDpow(10.0f, -D_val)) \
+ if(abs_fun(buf[i] - filval) < pow_fun(10.0f, (type)-D_val)) \
*(int *)&buf[i] = (int)(((unsigned int)1 << *minbits) - 1); \
else \
- *(int *)&buf[i] = H5Z_scaleoffset_rnd( \
- buf[i]*HDpow(10.0f, D_val) - min*HDpow(10.0f, D_val)); \
+ *(int *)&buf[i] = (int)lround_fun(buf[i] * pow_fun(10.0f, (type)D_val) - min * pow_fun(10.0f, (type)D_val)); \
} \
- else if(sizeof(type)==sizeof(long)) \
+ else if(sizeof(type) == sizeof(long)) \
for(i = 0; i < d_nelmts; i++) { \
- if(HDfabs(buf[i] - filval) < HDpow(10.0f, -D_val)) \
+ if(abs_fun(buf[i] - filval) < pow_fun(10.0f, (type)-D_val)) \
*(long *)&buf[i] = (long)(((unsigned long)1 << *minbits) - 1); \
else \
- *(long *)&buf[i] = H5Z_scaleoffset_rnd( \
- buf[i]*HDpow(10.0f, D_val) - min*HDpow(10.0f, D_val)); \
+ *(long *)&buf[i] = lround_fun(buf[i] * pow_fun(10.0f, (type)D_val) - min * pow_fun(10.0f, (type)D_val)); \
} \
- else if(sizeof(type)==sizeof(long long)) \
+ else if(sizeof(type) == sizeof(long long)) \
for(i = 0; i < d_nelmts; i++) { \
- if(HDfabs(buf[i] - filval) < HDpow(10.0f, -D_val)) \
+ if(abs_fun(buf[i] - filval) < pow_fun(10.0f, (type)-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.0f, D_val) - min*HDpow(10.0f, D_val)); \
+ *(long long *)&buf[i] = llround_fun(buf[i] * pow_fun(10.0f, (type)D_val) - min * pow_fun(10.0f, (type)D_val)); \
} \
else \
- HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer dataype")\
+ HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer dataype") \
}
/* Modify values of data in precompression if fill value undefined for floating-point type */
-#define H5Z_scaleoffset_modify_2(i, type, buf, d_nelmts, min, D_val) \
+#define H5Z_scaleoffset_modify_2(i, type, pow_fun, lround_fun, llround_fun, buf, d_nelmts, min, D_val) \
{ \
- if(sizeof(type)==sizeof(int)) \
+ if(sizeof(type) == sizeof(int)) \
for(i = 0; i < d_nelmts; i++) \
- *(int *)&buf[i] = H5Z_scaleoffset_rnd( \
- buf[i]*HDpow(10.0f, D_val) - min*HDpow(10.0f, D_val)); \
- else if(sizeof(type)==sizeof(long)) \
+ *(int *)&buf[i] = (int)lround_fun(buf[i] * pow_fun(10.0f, (type)D_val) - min * pow_fun(10.0f, (type)D_val)); \
+ else if(sizeof(type) == sizeof(long)) \
for(i = 0; i < d_nelmts; i++) \
- *(long *)&buf[i] = H5Z_scaleoffset_rnd( \
- buf[i]*HDpow(10.0f, D_val) - min*HDpow(10.0f, D_val)); \
- else if(sizeof(type)==sizeof(long long)) \
+ *(long *)&buf[i] = lround_fun(buf[i] * pow_fun(10.0f, (type)D_val) - min * pow_fun(10.0f, (type)D_val)); \
+ else if(sizeof(type) == sizeof(long long)) \
for(i = 0; i < d_nelmts; i++) \
- *(long long *)&buf[i] = H5Z_scaleoffset_rnd( \
- buf[i]*HDpow(10.0f, D_val) - min*HDpow(10.0f, D_val)); \
+ *(long long *)&buf[i] = llround_fun(buf[i] * pow_fun(10.0f, (type)D_val) - min * pow_fun(10.0f, (type)D_val)); \
else \
- HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer dataype")\
+ HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer dataype") \
}
/* Save the minimum value for floating-point type */
@@ -546,7 +542,7 @@ H5Z_class2_t H5Z_SCALEOFFSET[1] = {{
}
/* Precompress for floating-point type using variable-minimum-bits method */
-#define H5Z_scaleoffset_precompress_3(type, data, d_nelmts, filavail, cd_values, \
+#define H5Z_scaleoffset_precompress_3(type, pow_fun, abs_fun, round_fun, lround_fun, llround_fun, data, d_nelmts, filavail, cd_values, \
minbits, minval, D_val) \
{ \
type *buf = (type *)data, min = 0, max = 0, filval = 0; \
@@ -557,18 +553,18 @@ H5Z_class2_t H5Z_SCALEOFFSET[1] = {{
if(filavail == H5Z_SCALEOFFSET_FILL_DEFINED) { /* fill value defined */ \
H5Z_scaleoffset_get_filval_2(type, cd_values, 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.0f, D_val) - min * HDpow(10.0f, D_val)) + 1; \
- *minbits = H5Z_scaleoffset_log2((unsigned long long)(span + 1)); \
+ H5Z_scaleoffset_check_3(i, type, pow_fun, round_fun, max, min, minbits, D_val) \
+ span = (unsigned long long)(llround_fun(max * pow_fun(10.0f, (type)D_val) - min * pow_fun(10.0f, (type)D_val)) + 1); \
+ *minbits = H5Z_scaleoffset_log2(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) \
+ H5Z_scaleoffset_modify_1(i, type, pow_fun, abs_fun, lround_fun, llround_fun, 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.0f, D_val) - min * HDpow(10.0f, D_val)) + 1; \
- *minbits = H5Z_scaleoffset_log2((unsigned long long)span); \
+ H5Z_scaleoffset_check_3(i, type, pow_fun, round_fun, max, min, minbits, D_val) \
+ span = (unsigned long long)(llround_fun(max * pow_fun(10.0f, (type)D_val) - min * pow_fun(10.0f, (type)D_val)) + 1); \
+ *minbits = H5Z_scaleoffset_log2(span); \
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_modify_2(i, type, pow_fun, lround_fun, llround_fun, buf, d_nelmts, min, D_val) \
} \
H5Z_scaleoffset_save_min(i, type, minval, min) \
}
@@ -621,42 +617,42 @@ H5Z_class2_t H5Z_SCALEOFFSET[1] = {{
}
/* Modify values of data in postdecompression if fill value defined for floating-point type */
-#define H5Z_scaleoffset_modify_3(i, type, buf, d_nelmts, filval, minbits, min, D_val) \
+#define H5Z_scaleoffset_modify_3(i, type, pow_fun, buf, d_nelmts, filval, minbits, min, D_val) \
{ \
- if(sizeof(type)==sizeof(int)) \
+ if(sizeof(type) == sizeof(int)) \
for(i = 0; i < d_nelmts; i++) \
buf[i] = (type)((*(int *)&buf[i] == (int)(((unsigned int)1 << minbits) - 1)) ? \
- filval : (double)(*(int *)&buf[i]) / HDpow(10.0f, D_val) + min); \
- else if(sizeof(type)==sizeof(long)) \
+ filval : (type)(*(int *)&buf[i]) / pow_fun(10.0f, (type)D_val) + min); \
+ else if(sizeof(type) == sizeof(long)) \
for(i = 0; i < d_nelmts; i++) \
buf[i] = (type)((*(long *)&buf[i] == (long)(((unsigned long)1 << minbits) - 1)) ? \
- filval : (double)(*(long *)&buf[i]) / HDpow(10.0f, D_val) + min); \
- else if(sizeof(type)==sizeof(long long)) \
+ filval : (type)(*(long *)&buf[i]) / pow_fun(10.0f, (type)D_val) + min); \
+ else if(sizeof(type) == sizeof(long long)) \
for(i = 0; i < d_nelmts; i++) \
buf[i] = (type)((*(long long *)&buf[i] == (long long)(((unsigned long long)1 << minbits) - 1)) ? \
- filval : (double)(*(long long *)&buf[i]) / HDpow(10.0f, D_val) + min); \
+ filval : (type)(*(long long *)&buf[i]) / pow_fun(10.0f, (type)D_val) + min); \
else \
HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer dataype") \
}
/* Modify values of data in postdecompression if fill value undefined for floating-point type */
-#define H5Z_scaleoffset_modify_4(i, type, buf, d_nelmts, min, D_val) \
+#define H5Z_scaleoffset_modify_4(i, type, pow_fun, buf, d_nelmts, min, D_val) \
{ \
if(sizeof(type)==sizeof(int)) \
for(i = 0; i < d_nelmts; i++) \
- buf[i] = (type)((double)(*(int *)&buf[i]) / HDpow(10.0f, D_val) + min); \
+ buf[i] = ((type)(*(int *)&buf[i]) / pow_fun(10.0f, (type)D_val) + min); \
else if(sizeof(type)==sizeof(long)) \
for(i = 0; i < d_nelmts; i++) \
- buf[i] = (type)((double)(*(long *)&buf[i]) / HDpow(10.0f, D_val) + min); \
+ buf[i] = ((type)(*(long *)&buf[i]) / pow_fun(10.0f, (type)D_val) + min); \
else if(sizeof(type)==sizeof(long long)) \
for(i = 0; i < d_nelmts; i++) \
- buf[i] = (type)((double)(*(long long *)&buf[i]) / HDpow(10.0f, D_val) + min); \
+ buf[i] = ((type)(*(long long *)&buf[i]) / pow_fun(10.0f, (type)D_val) + min); \
else \
HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer dataype") \
}
/* Postdecompress for floating-point type using variable-minimum-bits method */
-#define H5Z_scaleoffset_postdecompress_3(type, data, d_nelmts, filavail, cd_values, \
+#define H5Z_scaleoffset_postdecompress_3(type, pow_fun, data, d_nelmts, filavail, cd_values, \
minbits, minval, D_val) \
{ \
type *buf = (type *)data, filval = 0, min = 0; \
@@ -666,9 +662,9 @@ H5Z_class2_t H5Z_SCALEOFFSET[1] = {{
\
if(filavail == H5Z_SCALEOFFSET_FILL_DEFINED) { /* fill value defined */ \
H5Z_scaleoffset_get_filval_2(type, cd_values, filval) \
- H5Z_scaleoffset_modify_3(i, type, buf, d_nelmts, filval, minbits, min, D_val) \
+ H5Z_scaleoffset_modify_3(i, type, pow_fun, buf, d_nelmts, filval, minbits, min, D_val) \
} else /* fill value undefined */ \
- H5Z_scaleoffset_modify_4(i, type, buf, d_nelmts, min, D_val) \
+ H5Z_scaleoffset_modify_4(i, type, pow_fun, buf, d_nelmts, min, D_val) \
}
@@ -756,7 +752,9 @@ H5Z_scaleoffset_get_type(unsigned dtype_class, unsigned dtype_size, unsigned dty
else if(dtype_size == sizeof(unsigned short)) type = t_ushort;
else if(dtype_size == sizeof(unsigned int)) type = t_uint;
else if(dtype_size == sizeof(unsigned long)) type = t_ulong;
+#if H5_SIZEOF_LONG != H5_SIZEOF_LONG_LONG
else if(dtype_size == sizeof(unsigned long long)) type = t_ulong_long;
+#endif /* H5_SIZEOF_LONG != H5_SIZEOF_LONG_LONG */
else
HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, t_bad, "cannot find matched memory dataype")
}
@@ -766,7 +764,9 @@ H5Z_scaleoffset_get_type(unsigned dtype_class, unsigned dtype_size, unsigned dty
else if(dtype_size == sizeof(short)) type = t_short;
else if(dtype_size == sizeof(int)) type = t_int;
else if(dtype_size == sizeof(long)) type = t_long;
+#if H5_SIZEOF_LONG != H5_SIZEOF_LONG_LONG
else if(dtype_size == sizeof(long long)) type = t_long_long;
+#endif /* H5_SIZEOF_LONG != H5_SIZEOF_LONG_LONG */
else
HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, t_bad, "cannot find matched memory dataype")
}
@@ -935,7 +935,8 @@ H5Z_set_local_scaleoffset(hid_t dcpl_id, hid_t type_id, hid_t space_id)
HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype size")
/* Set "local" parameter for datatype size */
- cd_values[H5Z_SCALEOFFSET_PARM_SIZE] = dtype_size;
+ H5_CHECK_OVERFLOW(dtype_size, size_t, unsigned);
+ cd_values[H5Z_SCALEOFFSET_PARM_SIZE] = (unsigned)dtype_size;
if(dtype_class == H5T_INTEGER) {
/* Get datatype's sign */
@@ -1196,7 +1197,7 @@ H5Z_filter_scaleoffset(unsigned flags, size_t cd_nelmts, const unsigned cd_value
}
/* before postprocess, get memory type */
- if((type = H5Z_scaleoffset_get_type(dtype_class, (unsigned)p.size, dtype_sign)) == 0)
+ if((type = H5Z_scaleoffset_get_type(dtype_class, p.size, dtype_sign)) == 0)
HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, 0, "cannot use C integer datatype for cast")
/* postprocess after decompression */
@@ -1224,7 +1225,7 @@ H5Z_filter_scaleoffset(unsigned flags, size_t cd_nelmts, const unsigned cd_value
H5Z_scaleoffset_convert(*buf, d_nelmts, p.size);
/* before preprocess, get memory type */
- if((type = H5Z_scaleoffset_get_type(dtype_class, (unsigned)p.size, dtype_sign))==0)
+ if((type = H5Z_scaleoffset_get_type(dtype_class, p.size, dtype_sign))==0)
HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, 0, "cannot use C integer datatype for cast")
/* preprocess before compression */
@@ -1316,10 +1317,10 @@ done:
* or from big-endian to little-endian 2/21/2005
*/
static void
-H5Z_scaleoffset_convert(void *buf, unsigned d_nelmts, size_t dtype_size)
+H5Z_scaleoffset_convert(void *buf, unsigned d_nelmts, unsigned dtype_size)
{
if(dtype_size > 1) {
- unsigned i, j;
+ size_t i, j;
unsigned char *buffer, temp;
buffer = (unsigned char *)buf;
@@ -1333,32 +1334,6 @@ H5Z_scaleoffset_convert(void *buf, unsigned d_nelmts, size_t dtype_size)
} /* 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)
-{
- double u_val, l_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;
- } /* 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
*/
@@ -1507,19 +1482,19 @@ H5Z_scaleoffset_precompress_fd(void *data, unsigned d_nelmts, enum H5Z_scaleoffs
unsigned filavail, const unsigned cd_values[], uint32_t *minbits,
unsigned long long *minval, double D_val)
{
- herr_t ret_value=SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT
+ FUNC_ENTER_NOAPI_NOINIT
- if(type == t_float)
- H5Z_scaleoffset_precompress_3(float, data, d_nelmts,
- filavail, cd_values, minbits, minval, D_val)
- else if(type == t_double)
- H5Z_scaleoffset_precompress_3(double, data, d_nelmts,
- filavail, cd_values, minbits, minval, D_val)
+ if(type == t_float)
+ H5Z_scaleoffset_precompress_3(float, HDpowf, HDfabsf, HDroundf, HDlroundf, HDllroundf, data, d_nelmts,
+ filavail, cd_values, minbits, minval, D_val)
+ else if(type == t_double)
+ H5Z_scaleoffset_precompress_3(double, HDpow, HDfabs, HDround, HDlround, HDllround, data, d_nelmts,
+ filavail, cd_values, minbits, minval, D_val)
done:
- FUNC_LEAVE_NOAPI(ret_value)
+ FUNC_LEAVE_NOAPI(ret_value)
}
/* postdecompress for floating-point type, variable-minimum-bits method
@@ -1535,10 +1510,10 @@ H5Z_scaleoffset_postdecompress_fd(void *data, unsigned d_nelmts, enum H5Z_scaleo
FUNC_ENTER_NOAPI_NOINIT
if(type == t_float)
- H5Z_scaleoffset_postdecompress_3(float, data, d_nelmts, filavail,
+ H5Z_scaleoffset_postdecompress_3(float, HDpowf, data, d_nelmts, filavail,
cd_values, minbits, sminval, D_val)
else if(type == t_double)
- H5Z_scaleoffset_postdecompress_3(double, data, d_nelmts, filavail,
+ H5Z_scaleoffset_postdecompress_3(double, HDpow, data, d_nelmts, filavail,
cd_values, minbits, sminval, D_val)
done:
@@ -1568,18 +1543,18 @@ H5Z_scaleoffset_decompress_one_byte(unsigned char *data, size_t data_offset,
dat_len = 8;
if(*buf_len > dat_len) {
- data[data_offset + k] = (unsigned char)((val >> (*buf_len - dat_len)) & ~(~0 << dat_len));
+ data[data_offset + k] = (unsigned char)((unsigned)(val >> (*buf_len - dat_len)) & (unsigned)(~((unsigned)~0 << dat_len)));
*buf_len -= dat_len;
} /* end if */
else {
- data[data_offset + k] = (unsigned char)((val & ~(~0 << *buf_len)) << (dat_len - *buf_len));
+ data[data_offset + k] = (unsigned char)((val & ~((unsigned)(~0) << *buf_len)) << (dat_len - *buf_len));
dat_len -= *buf_len;
H5Z_scaleoffset_next_byte(j, buf_len);
if(dat_len == 0)
return;
val = buffer[*j];
- data[data_offset + k] |= (unsigned char)((val >> (*buf_len - dat_len)) & ~(~0 << dat_len));
+ data[data_offset + k] |= (unsigned char)((unsigned)(val >> (*buf_len - dat_len)) & ~((unsigned)(~0) << dat_len));
*buf_len -= dat_len;
} /* end else */
}
@@ -1625,7 +1600,7 @@ H5Z_scaleoffset_decompress(unsigned char *data, unsigned d_nelmts,
unsigned buf_len;
/* must initialize to zeros */
- for(i = 0; i < d_nelmts*p.size; i++)
+ for(i = 0; i < d_nelmts * p.size; i++)
data[i] = 0;
/* initialization before the loop */
@@ -1653,16 +1628,16 @@ H5Z_scaleoffset_compress_one_byte(unsigned char *data, size_t data_offset,
dat_len = 8;
if(*buf_len > dat_len) {
- buffer[*j] |= (unsigned char)((val & ~(~0 << dat_len)) << (*buf_len - dat_len));
+ buffer[*j] |= (unsigned char)((val & ~((unsigned)(~0) << dat_len)) << (*buf_len - dat_len));
*buf_len -= dat_len;
} else {
- buffer[*j] |= (unsigned char)((val >> (dat_len - *buf_len)) & ~(~0 << *buf_len));
+ buffer[*j] |= (unsigned char)((unsigned)(val >> (dat_len - *buf_len)) & ~((unsigned)(~0) << *buf_len));
dat_len -= *buf_len;
H5Z_scaleoffset_next_byte(j, buf_len);
if(dat_len == 0)
return;
- buffer[*j] = (unsigned char)((val & ~(~0 << dat_len)) << (*buf_len - dat_len));
+ buffer[*j] = (unsigned char)((val & ~((unsigned)(~0) << dat_len)) << (*buf_len - dat_len));
*buf_len -= dat_len;
} /* end else */
}
diff --git a/src/H5Ztrans.c b/src/H5Ztrans.c
index 2627a29..f30f0b2 100644
--- a/src/H5Ztrans.c
+++ b/src/H5Ztrans.c
@@ -124,8 +124,8 @@ static void H5Z_print(H5Z_node *tree, FILE *stream);
tree_val = ((RESR).type==H5Z_XFORM_INTEGER ? (double)(RESR).value.int_val : (RESR).value.float_val); \
p = (TYPE*)(RESL).value.dat_val; \
\
- for(u=0; u<(SIZE); u++) { \
- *p = *p OP tree_val; \
+ for(u = 0; u < (SIZE); u++) { \
+ *p = (TYPE)((double)*p OP tree_val); \
p++; \
} \
} \
@@ -141,32 +141,31 @@ static void H5Z_print(H5Z_node *tree, FILE *stream);
tree_val = ((RESL).type==H5Z_XFORM_INTEGER ? (double)(RESL).value.int_val : (RESL).value.float_val); \
\
p = (TYPE*)(RESR).value.dat_val; \
- for(u=0; u<(SIZE); u++) { \
- *p = tree_val OP *p; \
+ for(u = 0; u < (SIZE); u++) { \
+ *p = (TYPE)(tree_val OP (double)*p); \
p++; \
} \
} \
- else if( ((RESL).type == H5Z_XFORM_SYMBOL) && ((RESR).type==H5Z_XFORM_SYMBOL)) \
- { \
- TYPE* pl = (TYPE*)(RESL).value.dat_val; \
- TYPE* pr = (TYPE*)(RESR).value.dat_val; \
- \
- for(u=0; u<(SIZE); u++) { \
- *pl = *pl OP *pr; \
- pl++; pr++; \
- } \
- } \
- else \
+ else if( ((RESL).type == H5Z_XFORM_SYMBOL) && ((RESR).type == H5Z_XFORM_SYMBOL)) \
+ { \
+ TYPE* pl = (TYPE*)(RESL).value.dat_val; \
+ TYPE* pr = (TYPE*)(RESR).value.dat_val; \
+ \
+ for(u = 0; u < (SIZE); u++) { \
+ *pl = (TYPE)(*pl OP *pr); \
+ pl++; pr++; \
+ } \
+ } \
+ else \
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Unexpected type conversion operation") \
}
-#if H5_SIZEOF_LONG_DOUBLE !=0
+#if H5_SIZEOF_LONG_DOUBLE != 0
+#if CHAR_MIN >= 0
#define H5Z_XFORM_TYPE_OP(RESL,RESR,TYPE,OP,SIZE) \
{ \
if((TYPE) == H5T_NATIVE_CHAR) \
H5Z_XFORM_DO_OP1((RESL), (RESR), char, OP, (SIZE)) \
- else if((TYPE) == H5T_NATIVE_UCHAR) \
- H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned char, OP, (SIZE)) \
else if((TYPE) == H5T_NATIVE_SCHAR) \
H5Z_XFORM_DO_OP1((RESL), (RESR), signed char, OP, (SIZE)) \
else if((TYPE) == H5T_NATIVE_SHORT) \
@@ -182,7 +181,7 @@ static void H5Z_print(H5Z_node *tree, FILE *stream);
else if((TYPE) == H5T_NATIVE_ULONG) \
H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned long, OP, (SIZE)) \
else if((TYPE) == H5T_NATIVE_LLONG) \
- H5Z_XFORM_DO_OP1((RESL), (RESR), long long, OP, (SIZE)) \
+ H5Z_XFORM_DO_OP1((RESL), (RESR), long long, OP, (SIZE)) \
else if((TYPE) == H5T_NATIVE_ULLONG) \
H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned long long, OP, (SIZE)) \
else if((TYPE) == H5T_NATIVE_FLOAT) \
@@ -192,13 +191,43 @@ static void H5Z_print(H5Z_node *tree, FILE *stream);
else if((TYPE) == H5T_NATIVE_LDOUBLE) \
H5Z_XFORM_DO_OP1((RESL), (RESR), long double, OP, (SIZE)) \
}
-#else
+#else /* CHAR_MIN >= 0 */
#define H5Z_XFORM_TYPE_OP(RESL,RESR,TYPE,OP,SIZE) \
{ \
if((TYPE) == H5T_NATIVE_CHAR) \
H5Z_XFORM_DO_OP1((RESL), (RESR), char, OP, (SIZE)) \
else if((TYPE) == H5T_NATIVE_UCHAR) \
H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned char, OP, (SIZE)) \
+ else if((TYPE) == H5T_NATIVE_SHORT) \
+ H5Z_XFORM_DO_OP1((RESL), (RESR), short, OP, (SIZE)) \
+ else if((TYPE) == H5T_NATIVE_USHORT) \
+ H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned short, OP, (SIZE)) \
+ else if((TYPE) == H5T_NATIVE_INT) \
+ H5Z_XFORM_DO_OP1((RESL), (RESR), int, OP, (SIZE)) \
+ else if((TYPE) == H5T_NATIVE_UINT) \
+ H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned int, OP, (SIZE)) \
+ else if((TYPE) == H5T_NATIVE_LONG) \
+ H5Z_XFORM_DO_OP1((RESL), (RESR), long, OP, (SIZE)) \
+ else if((TYPE) == H5T_NATIVE_ULONG) \
+ H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned long, OP, (SIZE)) \
+ else if((TYPE) == H5T_NATIVE_LLONG) \
+ H5Z_XFORM_DO_OP1((RESL), (RESR), long long, OP, (SIZE)) \
+ else if((TYPE) == H5T_NATIVE_ULLONG) \
+ H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned long long, OP, (SIZE)) \
+ else if((TYPE) == H5T_NATIVE_FLOAT) \
+ H5Z_XFORM_DO_OP1((RESL), (RESR), float, OP, (SIZE)) \
+ else if((TYPE) == H5T_NATIVE_DOUBLE) \
+ H5Z_XFORM_DO_OP1((RESL), (RESR), double, OP, (SIZE)) \
+ else if((TYPE) == H5T_NATIVE_LDOUBLE) \
+ H5Z_XFORM_DO_OP1((RESL), (RESR), long double, OP, (SIZE)) \
+}
+#endif /* CHAR_MIN >= 0 */
+#else
+#if CHAR_MIN >= 0
+#define H5Z_XFORM_TYPE_OP(RESL,RESR,TYPE,OP,SIZE) \
+{ \
+ if((TYPE) == H5T_NATIVE_CHAR) \
+ H5Z_XFORM_DO_OP1((RESL), (RESR), char, OP, (SIZE)) \
else if((TYPE) == H5T_NATIVE_SCHAR) \
H5Z_XFORM_DO_OP1((RESL), (RESR), signed char, OP, (SIZE)) \
else if((TYPE) == H5T_NATIVE_SHORT) \
@@ -222,6 +251,35 @@ static void H5Z_print(H5Z_node *tree, FILE *stream);
else if((TYPE) == H5T_NATIVE_DOUBLE) \
H5Z_XFORM_DO_OP1((RESL), (RESR), double, OP, (SIZE)) \
}
+#else /* CHAR_MIN >= 0 */
+#define H5Z_XFORM_TYPE_OP(RESL,RESR,TYPE,OP,SIZE) \
+{ \
+ if((TYPE) == H5T_NATIVE_CHAR) \
+ H5Z_XFORM_DO_OP1((RESL), (RESR), char, OP, (SIZE)) \
+ else if((TYPE) == H5T_NATIVE_UCHAR) \
+ H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned char, OP, (SIZE)) \
+ else if((TYPE) == H5T_NATIVE_SHORT) \
+ H5Z_XFORM_DO_OP1((RESL), (RESR), short, OP, (SIZE)) \
+ else if((TYPE) == H5T_NATIVE_USHORT) \
+ H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned short, OP, (SIZE)) \
+ else if((TYPE) == H5T_NATIVE_INT) \
+ H5Z_XFORM_DO_OP1((RESL), (RESR), int, OP, (SIZE)) \
+ else if((TYPE) == H5T_NATIVE_UINT) \
+ H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned int, OP, (SIZE)) \
+ else if((TYPE) == H5T_NATIVE_LONG) \
+ H5Z_XFORM_DO_OP1((RESL), (RESR), long, OP, (SIZE)) \
+ else if((TYPE) == H5T_NATIVE_ULONG) \
+ H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned long, OP, (SIZE)) \
+ else if((TYPE) == H5T_NATIVE_LLONG) \
+ H5Z_XFORM_DO_OP1((RESL), (RESR), long long, OP, (SIZE)) \
+ else if((TYPE) == H5T_NATIVE_ULLONG) \
+ H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned long long, OP, (SIZE)) \
+ else if((TYPE) == H5T_NATIVE_FLOAT) \
+ H5Z_XFORM_DO_OP1((RESL), (RESR), float, OP, (SIZE)) \
+ else if((TYPE) == H5T_NATIVE_DOUBLE) \
+ H5Z_XFORM_DO_OP1((RESL), (RESR), double, OP, (SIZE)) \
+}
+#endif /* CHAR_MIN >= 0 */
#endif /*H5_SIZEOF_LONG_DOUBLE */
#define H5Z_XFORM_DO_OP3(OP) \
@@ -977,17 +1035,20 @@ H5Z_xform_eval(H5Z_data_xform_t *data_xform_prop, void* array, size_t array_size
if(tree->type == H5Z_XFORM_INTEGER || tree->type == H5Z_XFORM_FLOAT) {
if(array_type == H5T_NATIVE_CHAR)
H5Z_XFORM_DO_OP5(char, array_size)
- else if(array_type == H5T_NATIVE_UCHAR)
- H5Z_XFORM_DO_OP5(unsigned char, array_size)
+#if CHAR_MIN >= 0
else if(array_type == H5T_NATIVE_SCHAR)
H5Z_XFORM_DO_OP5(signed char, array_size)
+#else /* CHAR_MIN >= 0 */
+ else if(array_type == H5T_NATIVE_UCHAR)
+ H5Z_XFORM_DO_OP5(unsigned char, array_size)
+#endif /* CHAR_MIN >= 0 */
else if(array_type == H5T_NATIVE_SHORT)
H5Z_XFORM_DO_OP5(short, array_size)
else if(array_type == H5T_NATIVE_USHORT)
H5Z_XFORM_DO_OP5(unsigned short, array_size)
else if(array_type == H5T_NATIVE_INT)
H5Z_XFORM_DO_OP5(int, array_size)
- else if(array_type == H5T_NATIVE_UINT)
+ else if(array_type == H5T_NATIVE_UINT)
H5Z_XFORM_DO_OP5(unsigned int, array_size)
else if(array_type == H5T_NATIVE_LONG)
H5Z_XFORM_DO_OP5(long, array_size)
@@ -1106,34 +1167,32 @@ H5Z_xform_eval_full(H5Z_node *tree, const size_t array_size, const hid_t array_
* 1. See if "x" is on left hand side, right hand side, or if both sides are "x"
* 2. Figure out what type of data we're going to be manipulating
* 3. Do the operation on the data. */
-
-
switch (tree->type) {
case H5Z_XFORM_PLUS:
- H5Z_XFORM_TYPE_OP(resl, resr, array_type, +, array_size)
- break;
+ H5Z_XFORM_TYPE_OP(resl, resr, array_type, +, array_size)
+ break;
case H5Z_XFORM_MINUS:
- H5Z_XFORM_TYPE_OP(resl, resr, array_type, -, array_size)
- break;
+ H5Z_XFORM_TYPE_OP(resl, resr, array_type, -, array_size)
+ break;
case H5Z_XFORM_MULT:
- H5Z_XFORM_TYPE_OP(resl, resr, array_type, *, array_size)
- break;
+ H5Z_XFORM_TYPE_OP(resl, resr, array_type, *, array_size)
+ break;
case H5Z_XFORM_DIVIDE:
- H5Z_XFORM_TYPE_OP(resl, resr, array_type, /, array_size)
- break;
+ H5Z_XFORM_TYPE_OP(resl, resr, array_type, /, array_size)
+ break;
- case H5Z_XFORM_ERROR:
- case H5Z_XFORM_INTEGER:
- case H5Z_XFORM_FLOAT:
- case H5Z_XFORM_SYMBOL:
- case H5Z_XFORM_LPAREN:
- case H5Z_XFORM_RPAREN:
- case H5Z_XFORM_END:
+ case H5Z_XFORM_ERROR:
+ case H5Z_XFORM_INTEGER:
+ case H5Z_XFORM_FLOAT:
+ case H5Z_XFORM_SYMBOL:
+ case H5Z_XFORM_LPAREN:
+ case H5Z_XFORM_RPAREN:
+ case H5Z_XFORM_END:
default:
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Invalid expression tree")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Invalid expression tree")
} /* end switch */
/* The result stores a pointer to the new data */
diff --git a/src/H5detect.c b/src/H5detect.c
index ee02c52..94e841e 100644
--- a/src/H5detect.c
+++ b/src/H5detect.c
@@ -1177,7 +1177,7 @@ imp_bit(unsigned int n, int *perm, void *_a, void *_b, const unsigned char *pad_
*
*-------------------------------------------------------------------------
*/
-static unsigned int
+H5_ATTR_PURE static unsigned int
find_bias(unsigned int epos, unsigned int esize, int *perm, void *_a)
{
unsigned char *a = (unsigned char *) _a;
diff --git a/src/H5private.h b/src/H5private.h
index d400469..6a677bb 100644
--- a/src/H5private.h
+++ b/src/H5private.h
@@ -657,6 +657,9 @@ typedef struct {
#ifndef HDatol
#define HDatol(S) atol(S)
#endif /* HDatol */
+#ifndef HDatoll
+ #define HDatoll(S) atoll(S)
+#endif /* HDatol */
#ifndef HDbsearch
#define HDbsearch(K,B,N,Z,F) bsearch(K,B,N,Z,F)
#endif /* HDbsearch */
@@ -1029,6 +1032,15 @@ typedef off_t h5_stat_size_t;
#ifndef HDlink
#define HDlink(OLD,NEW) link(OLD,NEW)
#endif /* HDlink */
+#ifndef HDllround
+ #define HDllround(V) llround(V)
+#endif /* HDround */
+#ifndef HDllroundf
+ #define HDllroundf(V) llroundf(V)
+#endif /* HDllroundf */
+#ifndef HDllroundl
+ #define HDllroundl(V) llroundl(V)
+#endif /* HDllroundl */
#ifndef HDlocaleconv
#define HDlocaleconv() localeconv()
#endif /* HDlocaleconv */
@@ -1044,6 +1056,15 @@ typedef off_t h5_stat_size_t;
#ifndef HDlongjmp
#define HDlongjmp(J,N) longjmp(J,N)
#endif /* HDlongjmp */
+#ifndef HDlround
+ #define HDlround(V) lround(V)
+#endif /* HDround */
+#ifndef HDlroundf
+ #define HDlroundf(V) lroundf(V)
+#endif /* HDlroundf */
+#ifndef HDlroundl
+ #define HDlroundl(V) lroundl(V)
+#endif /* HDroundl */
#ifndef HDlseek
#define HDlseek(F,O,W) lseek(F,O,W)
#endif /* HDlseek */
@@ -1118,6 +1139,9 @@ typedef off_t h5_stat_size_t;
#ifndef HDpow
#define HDpow(X,Y) pow(X,Y)
#endif /* HDpow */
+#ifndef HDpowf
+ #define HDpowf(X,Y) powf(X,Y)
+#endif /* HDpowf */
/* printf() variable arguments */
#ifndef HDputc
#define HDputc(C,F) putc(C,F)
@@ -1180,6 +1204,15 @@ typedef off_t h5_stat_size_t;
#ifndef HDrewinddir
#define HDrewinddir(D) rewinddir(D)
#endif /* HDrewinddir */
+#ifndef HDround
+ #define HDround(V) round(V)
+#endif /* HDround */
+#ifndef HDroundf
+ #define HDroundf(V) roundf(V)
+#endif /* HDroundf */
+#ifndef HDroundl
+ #define HDroundl(V) roundl(V)
+#endif /* HDroundl */
#ifndef HDrmdir
#define HDrmdir(S) rmdir(S)
#endif /* HDrmdir */
diff --git a/src/H5public.h b/src/H5public.h
index 554ad26..2f21648 100644
--- a/src/H5public.h
+++ b/src/H5public.h
@@ -194,28 +194,21 @@ H5_GCC_DIAG_ON(long-long)
/*
* File addresses have their own types.
*/
-#if H5_SIZEOF_INT64_T>=8
- typedef uint64_t haddr_t;
-# define HADDR_UNDEF ((haddr_t)(int64_t)(-1))
-# define H5_SIZEOF_HADDR_T H5_SIZEOF_INT64_T
-# ifdef H5_HAVE_PARALLEL
-# define HADDR_AS_MPI_TYPE MPI_LONG_LONG_INT
-# endif /* H5_HAVE_PARALLEL */
-#elif H5_SIZEOF_INT>=8
+#if H5_SIZEOF_INT >= 8
typedef unsigned haddr_t;
# define HADDR_UNDEF ((haddr_t)(-1))
# define H5_SIZEOF_HADDR_T H5_SIZEOF_INT
# ifdef H5_HAVE_PARALLEL
# define HADDR_AS_MPI_TYPE MPI_UNSIGNED
# endif /* H5_HAVE_PARALLEL */
-#elif H5_SIZEOF_LONG>=8
+#elif H5_SIZEOF_LONG >= 8
typedef unsigned long haddr_t;
# define HADDR_UNDEF ((haddr_t)(long)(-1))
# define H5_SIZEOF_HADDR_T H5_SIZEOF_LONG
# ifdef H5_HAVE_PARALLEL
# define HADDR_AS_MPI_TYPE MPI_UNSIGNED_LONG
# endif /* H5_HAVE_PARALLEL */
-#elif H5_SIZEOF_LONG_LONG>=8
+#elif H5_SIZEOF_LONG_LONG >= 8
typedef unsigned long long haddr_t;
# define HADDR_UNDEF ((haddr_t)(long long)(-1))
# define H5_SIZEOF_HADDR_T H5_SIZEOF_LONG_LONG
@@ -225,11 +218,11 @@ H5_GCC_DIAG_ON(long-long)
#else
# error "nothing appropriate for haddr_t"
#endif
-#if H5_SIZEOF_HADDR_T ==H5_SIZEOF_INT
+#if H5_SIZEOF_HADDR_T == H5_SIZEOF_INT
# define H5_PRINTF_HADDR_FMT "%u"
-#elif H5_SIZEOF_HADDR_T ==H5_SIZEOF_LONG
+#elif H5_SIZEOF_HADDR_T == H5_SIZEOF_LONG
# define H5_PRINTF_HADDR_FMT "%lu"
-#elif H5_SIZEOF_HADDR_T ==H5_SIZEOF_LONG_LONG
+#elif H5_SIZEOF_HADDR_T == H5_SIZEOF_LONG_LONG
# define H5_PRINTF_HADDR_FMT "%" H5_PRINTF_LL_WIDTH "u"
#else
# error "nothing appropriate for H5_PRINTF_HADDR_FMT"
diff --git a/test/cache_common.c b/test/cache_common.c
index b92a7b0..21f0366 100644
--- a/test/cache_common.c
+++ b/test/cache_common.c
@@ -6237,7 +6237,7 @@ check_and_validate_cache_size(hid_t file_id,
} /* check_and_validate_cache_size() */
-hbool_t
+H5_ATTR_PURE hbool_t
resize_configs_are_equal(const H5C_auto_size_ctl_t *a,
const H5C_auto_size_ctl_t *b,
hbool_t compare_init)
diff --git a/test/dt_arith.c b/test/dt_arith.c
index bd8babe..639ad52 100644
--- a/test/dt_arith.c
+++ b/test/dt_arith.c
@@ -127,39 +127,39 @@ static int without_hardware_g = 0;
/*positive values, ascending order. VALUE1 starts from 00000001, to 00000010, until 10000000*/ \
/*VALUE2 ascends from 00000000, to 00000011, 00000111,..., until 11111111.*/ \
for(n=0; n<SRC_PREC; n++) { \
- if(value1<=SRC_MAX && value1>=SRC_MIN) { \
- memcpy(buf_p, &value1, SRC_SIZE); \
- memcpy(saved_p, &value1, SRC_SIZE); \
+ { \
+ HDmemcpy(buf_p, &value1, SRC_SIZE); \
+ HDmemcpy(saved_p, &value1, SRC_SIZE); \
buf_p += SRC_SIZE; \
saved_p += SRC_SIZE; \
} \
- if(value2<=SRC_MAX && value2>=SRC_MIN) { \
- memcpy(buf_p, &value2, SRC_SIZE); \
- memcpy(saved_p, &value2, SRC_SIZE); \
+ { \
+ HDmemcpy(buf_p, &value2, SRC_SIZE); \
+ HDmemcpy(saved_p, &value2, SRC_SIZE); \
buf_p += SRC_SIZE; \
saved_p += SRC_SIZE; \
} \
\
if(n<SRC_PREC-2) { \
- value1 <<= 1; \
- value2 = (value1 - 1) | value1; \
+ value1 = (TYPE)(value1 << 1); \
+ value2 = (TYPE)((value1 - 1) | value1); \
} else if(n==SRC_PREC-2) { /*to avoid overflow of negative values for signed integer*/ \
- value1 <<= 1; \
- value2 = (~value1) | value1; \
+ value1 = (TYPE)(value1 << 1); \
+ value2 = (TYPE)((~value1) | value1); \
} \
} \
\
/* negative values for signed; descending positive values for unsigned */ \
/* VALUE2 descends from 11111111 to 11111110, 11111100, ..., until 10000000. */ \
for(n=0; n<SRC_PREC-1; n++) { \
- if(value2<=SRC_MAX && value2>=SRC_MIN) { \
- memcpy(buf_p, &value2, SRC_SIZE); \
- memcpy(saved_p, &value2, SRC_SIZE); \
+ { \
+ HDmemcpy(buf_p, &value2, SRC_SIZE); \
+ HDmemcpy(saved_p, &value2, SRC_SIZE); \
buf_p += SRC_SIZE; \
saved_p += SRC_SIZE; \
} \
if(n<SRC_PREC-1) \
- value2 <<= 1; \
+ value2 = (TYPE)(value2 << 1); \
} \
}
@@ -242,15 +242,15 @@ static int without_hardware_g = 0;
value2 = -SRC_MIN; \
for(n=0; n<num_norm; n++) { \
if(value1<SRC_MAX) { /*positive*/ \
- memcpy(buf_p, &value1, SRC_SIZE); \
- memcpy(saved_p, &value1, SRC_SIZE); \
+ HDmemcpy(buf_p, &value1, SRC_SIZE); \
+ HDmemcpy(saved_p, &value1, SRC_SIZE); \
value1 *= multiply; \
buf_p += SRC_SIZE; \
saved_p += SRC_SIZE; \
} \
if(value2>-SRC_MAX) { /*negative*/ \
- memcpy(buf_p, &value2, SRC_SIZE); \
- memcpy(saved_p, &value2, SRC_SIZE); \
+ HDmemcpy(buf_p, &value2, SRC_SIZE); \
+ HDmemcpy(saved_p, &value2, SRC_SIZE); \
value2 *= multiply; \
buf_p += SRC_SIZE; \
saved_p += SRC_SIZE; \
@@ -258,14 +258,14 @@ static int without_hardware_g = 0;
} \
\
value1 = SRC_MAX; /*maximal value*/ \
- memcpy(buf_p, &value1, SRC_SIZE); \
- memcpy(saved_p, &value1, SRC_SIZE); \
+ HDmemcpy(buf_p, &value1, SRC_SIZE); \
+ HDmemcpy(saved_p, &value1, SRC_SIZE); \
buf_p += SRC_SIZE; \
saved_p += SRC_SIZE; \
\
value2 = -SRC_MAX; /*negative value*/ \
- memcpy(buf_p, &value2, SRC_SIZE); \
- memcpy(saved_p, &value2, SRC_SIZE); \
+ HDmemcpy(buf_p, &value2, SRC_SIZE); \
+ HDmemcpy(saved_p, &value2, SRC_SIZE); \
buf_p += SRC_SIZE; \
saved_p += SRC_SIZE; \
}
@@ -290,37 +290,37 @@ static int without_hardware_g = 0;
HDmemset(BUF, 0, NELMTS*MAX(SRC_SIZE, DST_SIZE)); \
HDmemset(SAVED, 0, NELMTS*MAX(SRC_SIZE, DST_SIZE)); \
\
- tmp1 = (unsigned char*)HDcalloc((size_t)1, (size_t)SRC_SIZE); \
- tmp2 = (unsigned char*)HDcalloc((size_t)1, (size_t)SRC_SIZE); \
+ tmp1 = (unsigned char*)HDcalloc((size_t)1, (size_t)SRC_SIZE); \
+ tmp2 = (unsigned char*)HDcalloc((size_t)1, (size_t)SRC_SIZE); \
\
buf_p = BUF; \
saved_p = SAVED; \
\
/*Denormalized values. Exponent is 0. Let mantissa starts from 00000001, 00000011, \
*00000111,..., until 11111111.*/ \
- memset(tmp1, 0, SRC_SIZE); \
- memset(tmp2, 0, SRC_SIZE); \
- H5T__bit_set (tmp2, SRC_PREC-1, (size_t)1, TRUE); /*the negative value*/ \
+ HDmemset(tmp1, 0, SRC_SIZE); \
+ HDmemset(tmp2, 0, SRC_SIZE); \
+ H5T__bit_set (tmp2, SRC_PREC-1, (size_t)1, TRUE); /*the negative value*/ \
for(n=0; n<SRC_MANT_DIG-1; n++) { \
- H5T__bit_set (tmp1, n, (size_t)1, TRUE); /*turn on 1 bit each time*/ \
+ H5T__bit_set (tmp1, n, (size_t)1, TRUE); /*turn on 1 bit each time*/ \
CHANGE_ORDER(tmp1, SRC_ORDR, SRC_SIZE); /*change order for big endian*/ \
- memcpy(buf_p, tmp1, SRC_SIZE); \
- memcpy(saved_p, tmp1, SRC_SIZE); \
+ HDmemcpy(buf_p, tmp1, SRC_SIZE); \
+ HDmemcpy(saved_p, tmp1, SRC_SIZE); \
CHANGE_ORDER(tmp1, SRC_ORDR, SRC_SIZE); /*change back the order for bit operation*/ \
buf_p += SRC_SIZE; \
saved_p += SRC_SIZE; \
\
/*negative values*/ \
- H5T__bit_set (tmp2, n, (size_t)1, TRUE); \
+ H5T__bit_set (tmp2, n, (size_t)1, TRUE); \
CHANGE_ORDER(tmp2, SRC_ORDR, SRC_SIZE); \
- memcpy(buf_p, tmp2, SRC_SIZE); \
- memcpy(saved_p, tmp2, SRC_SIZE); \
+ HDmemcpy(buf_p, tmp2, SRC_SIZE); \
+ HDmemcpy(saved_p, tmp2, SRC_SIZE); \
CHANGE_ORDER(tmp2, SRC_ORDR, SRC_SIZE); \
buf_p += SRC_SIZE; \
saved_p += SRC_SIZE; \
} \
- HDfree(tmp1); \
- HDfree(tmp2); \
+ HDfree(tmp1); \
+ HDfree(tmp2); \
}
/* Allocate buffer and initialize it with floating-point special values, +/-0, +/-infinity,
@@ -342,50 +342,50 @@ static int without_hardware_g = 0;
SAVED = (unsigned char*)aligned_malloc( NELMTS*MAX(SRC_SIZE, DST_SIZE)); \
HDmemset(BUF, 0, NELMTS*MAX(SRC_SIZE, DST_SIZE)); \
HDmemset(SAVED, 0, NELMTS*MAX(SRC_SIZE, DST_SIZE)); \
- value = (unsigned char*)HDcalloc(SRC_SIZE, sizeof(unsigned char)); \
+ value = (unsigned char*)HDcalloc(SRC_SIZE, sizeof(unsigned char)); \
\
buf_p = BUF; \
\
/* +0 */ \
- H5T__bit_set(value, (size_t)0, SRC_PREC, FALSE); \
- memcpy(buf_p, value, SRC_SIZE*sizeof(unsigned char)); \
+ H5T__bit_set(value, (size_t)0, SRC_PREC, FALSE); \
+ HDmemcpy(buf_p, value, SRC_SIZE*sizeof(unsigned char)); \
buf_p += SRC_SIZE; \
\
for(n=0; n<2; n++) { \
if(n==1) { \
memset(value, 0, SRC_SIZE*sizeof(unsigned char)); \
/* -0 */ \
- H5T__bit_set(value, (size_t)(SRC_PREC - 1), (size_t)1, TRUE); \
+ H5T__bit_set(value, (size_t)(SRC_PREC - 1), (size_t)1, TRUE); \
CHANGE_ORDER(value, SRC_ORDR, SRC_SIZE);/*change order for big endian*/ \
- HDmemcpy(buf_p, value, SRC_SIZE*sizeof(unsigned char)); \
+ HDmemcpy(buf_p, value, SRC_SIZE*sizeof(unsigned char)); \
CHANGE_ORDER(value, SRC_ORDR, SRC_SIZE);/*change back the order for bit operation*/ \
buf_p += SRC_SIZE; \
} \
\
/* +/-infinity */ \
- H5T__bit_set(value, (size_t)(SRC_MANT_DIG - 1), SRC_PREC-SRC_MANT_DIG, TRUE); \
+ H5T__bit_set(value, (size_t)(SRC_MANT_DIG - 1), SRC_PREC-SRC_MANT_DIG, TRUE); \
CHANGE_ORDER(value, SRC_ORDR, SRC_SIZE); /*change order for big endian*/ \
- HDmemcpy(buf_p, value, SRC_SIZE*sizeof(unsigned char)); \
+ HDmemcpy(buf_p, value, SRC_SIZE*sizeof(unsigned char)); \
CHANGE_ORDER(value, SRC_ORDR, SRC_SIZE); /*change back the order for bit operation*/ \
buf_p += SRC_SIZE; \
\
/* +/-SNaN */ \
- H5T__bit_set(value, (size_t)0, (size_t)1, TRUE); \
+ H5T__bit_set(value, (size_t)0, (size_t)1, TRUE); \
CHANGE_ORDER(value, SRC_ORDR, SRC_SIZE); /*change order for big endian*/ \
- HDmemcpy(buf_p, value, SRC_SIZE * sizeof(unsigned char)); \
+ HDmemcpy(buf_p, value, SRC_SIZE * sizeof(unsigned char)); \
CHANGE_ORDER(value, SRC_ORDR, SRC_SIZE); /*change back the order for bit operation*/ \
buf_p += SRC_SIZE; \
\
/* +/-QNaN */ \
- H5T__bit_set(value, (size_t)(SRC_MANT_DIG - 2), (size_t)1, TRUE); \
+ H5T__bit_set(value, (size_t)(SRC_MANT_DIG - 2), (size_t)1, TRUE); \
CHANGE_ORDER(value, SRC_ORDR, SRC_SIZE); /*change order for big endian*/ \
- HDmemcpy(buf_p, value, SRC_SIZE*sizeof(unsigned char)); \
+ HDmemcpy(buf_p, value, SRC_SIZE*sizeof(unsigned char)); \
CHANGE_ORDER(value, SRC_ORDR, SRC_SIZE); /*change back the order for bit operation*/ \
buf_p += SRC_SIZE; \
} \
\
- HDmemcpy(SAVED, BUF, NELMTS*MAX(SRC_SIZE, DST_SIZE)); \
- HDfree(value); \
+ HDmemcpy(SAVED, BUF, NELMTS*MAX(SRC_SIZE, DST_SIZE)); \
+ HDfree(value); \
}
void some_dummy_func(float x);
diff --git a/test/fheap.c b/test/fheap.c
index 558cb44..a59c27f 100644
--- a/test/fheap.c
+++ b/test/fheap.c
@@ -498,7 +498,7 @@ get_del_string(const fheap_test_param_t *tparam)
*
*-------------------------------------------------------------------------
*/
-static size_t
+H5_ATTR_PURE static size_t
get_fill_size(const fheap_test_param_t *tparam)
{
switch(tparam->fill) {
diff --git a/test/freespace.c b/test/freespace.c
index 2023724..6e680c3 100644
--- a/test/freespace.c
+++ b/test/freespace.c
@@ -221,7 +221,7 @@ TEST_sect_init_cls(H5FS_section_class_t *cls, void *_udata)
* Check if the two sections can be merged:
* true if second section adjoins the first section
*/
-static herr_t
+H5_ATTR_PURE static herr_t
TEST_sect_can_merge(const H5FS_section_info_t *_sect1,
const H5FS_section_info_t *_sect2, void H5_ATTR_UNUSED *_udata)
{
diff --git a/test/h5test.c b/test/h5test.c
index 39731a2..6267137 100644
--- a/test/h5test.c
+++ b/test/h5test.c
@@ -767,15 +767,15 @@ h5_fixname_real(const char *base_name, hid_t fapl, const char *_suffix,
*
*-------------------------------------------------------------------------
*/
-const char *
+H5_ATTR_PURE const char *
h5_rmprefix(const char *filename)
{
const char *ret_ptr;
if ((ret_ptr = HDstrstr(filename, ":")) == NULL)
- ret_ptr = filename;
+ ret_ptr = filename;
else
- ret_ptr++;
+ ret_ptr++;
return(ret_ptr);
}
diff --git a/test/tcheck_version.c b/test/tcheck_version.c
index a75d642..1abab69 100644
--- a/test/tcheck_version.c
+++ b/test/tcheck_version.c
@@ -104,7 +104,7 @@ parse(int ac, char **av)
* some systems may produce extra messages and/or produce core dump.
* This tries to eliminate those side effects.
*/
-void
+H5_ATTR_NORETURN void
abort_intercept (int H5_ATTR_UNUSED sig)
{
HDexit(6);
diff --git a/test/tchecksum.c b/test/tchecksum.c
index 350a218..cb7c023 100644
--- a/test/tchecksum.c
+++ b/test/tchecksum.c
@@ -247,7 +247,7 @@ test_checksum(void)
*
*-------------------------------------------------------------------------
*/
-void
+H5_ATTR_PURE void
cleanup_checksum(void)
{
/* no file to clean */
diff --git a/test/tconfig.c b/test/tconfig.c
index 3ae26c2..1604c61 100644
--- a/test/tconfig.c
+++ b/test/tconfig.c
@@ -86,7 +86,7 @@ test_configure(void)
*
*-------------------------------------------------------------------------
*/
-void
+H5_ATTR_PURE void
cleanup_configure(void)
{
/* no file to clean */
@@ -109,7 +109,7 @@ cleanup_configure(void)
*
*-------------------------------------------------------------------------
*/
-void
+H5_ATTR_PURE void
test_config_ctypes(void)
{
/* standard C89 basic types */
@@ -218,7 +218,7 @@ test_config_ctypes(void)
*
*-------------------------------------------------------------------------
*/
-void
+H5_ATTR_PURE void
test_exit_definitions(void)
{
/* Verify the EXIT_SUCCESS and EXIT_FAILURE are 0 and 1 respectively. */
diff --git a/test/testframe.c b/test/testframe.c
index daa27c5..1c56f88 100644
--- a/test/testframe.c
+++ b/test/testframe.c
@@ -365,7 +365,7 @@ void TestCleanup(void)
/*
* Retrieve the verbosity level for the testing framework
*/
-int GetTestVerbosity(void)
+H5_ATTR_PURE int GetTestVerbosity(void)
{
return(TestVerbosity);
}
@@ -452,7 +452,7 @@ int SetTestExpress(int newval)
* Retrieve Summary request value.
* 0 means no summary, 1 means yes.
*/
-int GetTestSummary(void)
+H5_ATTR_PURE int GetTestSummary(void)
{
return(Summary);
}
@@ -461,7 +461,7 @@ int GetTestSummary(void)
* Retrieve Cleanup request value.
* 0 means no Cleanup, 1 means yes.
*/
-int GetTestCleanup(void)
+H5_ATTR_PURE int GetTestCleanup(void)
{
return(CleanUp);
}
@@ -498,7 +498,7 @@ void ParseTestVerbosity(char *argv)
/*
* Retrieve the number of testing errors for the testing framework
*/
-int GetTestNumErrs(void)
+H5_ATTR_PURE int GetTestNumErrs(void)
{
return(num_errs);
}
@@ -516,7 +516,7 @@ void IncTestNumErrs(void)
/*
* Retrieve the current Test Parameters pointer.
*/
-const void *GetTestParameters(void)
+H5_ATTR_PURE const void *GetTestParameters(void)
{
return(Test_parameters);
}
diff --git a/test/titerate.c b/test/titerate.c
index 20a3940..f61842a 100644
--- a/test/titerate.c
+++ b/test/titerate.c
@@ -72,7 +72,7 @@ herr_t aiter_cb(hid_t group, const char *name, const H5A_info_t *ainfo,
** iter_strcmp(): String comparison routine for qsort
**
****************************************************************/
-int iter_strcmp(const void *s1, const void *s2)
+H5_ATTR_PURE int iter_strcmp(const void *s1, const void *s2)
{
return(HDstrcmp(*(const char * const *)s1,*(const char * const *)s2));
}
@@ -527,7 +527,7 @@ static void test_iter_attr(hid_t fapl, hbool_t new_format)
** iter_strcmp2(): String comparison routine for qsort
**
****************************************************************/
-int iter_strcmp2(const void *s1, const void *s2)
+H5_ATTR_PURE int iter_strcmp2(const void *s1, const void *s2)
{
return(HDstrcmp((const char *)s1, (const char *)s2));
} /* end iter_strcmp2() */
diff --git a/test/tmeta.c b/test/tmeta.c
index a7fd688..e69c057 100644
--- a/test/tmeta.c
+++ b/test/tmeta.c
@@ -123,7 +123,7 @@ test_metadata(void)
*
*-------------------------------------------------------------------------
*/
-void
+H5_ATTR_PURE void
cleanup_metadata(void)
{
/* no file to clean */
diff --git a/test/tselect.c b/test/tselect.c
index 670406d..73b8015 100644
--- a/test/tselect.c
+++ b/test/tselect.c
@@ -2630,7 +2630,7 @@ test_select_hyper_checker_board_dr__select_checker_board(hid_t tgt_n_cube_sid,
** a selected or an unselected checker.
**
****************************************************************/
-static hbool_t
+H5_ATTR_PURE static hbool_t
test_select_hyper_checker_board_dr__verify_data(uint16_t * buf_ptr,
unsigned rank, unsigned edge_size, unsigned checker_edge_size,
uint16_t first_expected_val, hbool_t buf_starts_in_checker)
diff --git a/test/ttsafe.c b/test/ttsafe.c
index d3c5cfb..1fb9446 100644
--- a/test/ttsafe.c
+++ b/test/ttsafe.c
@@ -45,7 +45,7 @@
#define NAME_OFFSET 6 /* offset for "name<num>" */
/* pre-condition: num must be a non-negative number */
-static unsigned
+H5_ATTR_PURE static unsigned
num_digits(int num)
{
unsigned u;
diff --git a/test/ttsafe_acreate.c b/test/ttsafe_acreate.c
index dec2eee..cc3f405 100644
--- a/test/ttsafe_acreate.c
+++ b/test/ttsafe_acreate.c
@@ -113,7 +113,7 @@ void tts_acreate(void)
* with the dataset
*/
for(i = 0; i < NUM_THREADS; i++) {
- attrib_data = HDmalloc(sizeof(ttsafe_name_data_t));
+ attrib_data = (ttsafe_name_data_t *)HDmalloc(sizeof(ttsafe_name_data_t));
attrib_data->dataset = dataset;
attrib_data->datatype = datatype;
attrib_data->dataspace = dataspace;
@@ -170,7 +170,7 @@ void *tts_acreate_thread(void *client_data)
H5P_DEFAULT, H5P_DEFAULT);
/* Write data to the attribute */
- attribute_data = HDmalloc(sizeof(int));
+ attribute_data = (int *)HDmalloc(sizeof(int));
*attribute_data = attrib_data->current_index;
H5Awrite(attribute, H5T_NATIVE_INT, attribute_data);
H5Aclose(attribute);
diff --git a/tools/h5copy/h5copy.c b/tools/h5copy/h5copy.c
index 9947168..f3a0d7a 100644
--- a/tools/h5copy/h5copy.c
+++ b/tools/h5copy/h5copy.c
@@ -90,7 +90,7 @@ leave(int ret)
*-------------------------------------------------------------------------
*/
static void
-usage (const char *prog)
+usage (void)
{
FLUSHSTREAM(rawoutstream);
PRINTVALSTREAM(rawoutstream, "\n");
@@ -253,7 +253,7 @@ main (int argc, const char *argv[])
/* Check for no command line parameters */
if(argc == 1)
{
- usage(h5tools_getprogname());
+ usage();
leave(EXIT_FAILURE);
} /* end if */
@@ -270,14 +270,14 @@ main (int argc, const char *argv[])
/* validate flag */
if (parse_flag(opt_arg,&flag)<0)
{
- usage(h5tools_getprogname());
+ usage();
leave(EXIT_FAILURE);
}
str_flag = HDstrdup(opt_arg);
break;
case 'h':
- usage(h5tools_getprogname());
+ usage();
leave(EXIT_SUCCESS);
break;
@@ -311,7 +311,7 @@ main (int argc, const char *argv[])
break;
default:
- usage(h5tools_getprogname());
+ usage();
leave(EXIT_FAILURE);
}
} /* end of while */
@@ -323,28 +323,28 @@ main (int argc, const char *argv[])
if (fname_src==NULL)
{
error_msg("Input file name missing\n");
- usage(h5tools_getprogname());
+ usage();
leave(EXIT_FAILURE);
}
if (fname_dst==NULL)
{
error_msg("Output file name missing\n");
- usage(h5tools_getprogname());
+ usage();
leave(EXIT_FAILURE);
}
if (oname_src==NULL)
{
error_msg("Source object name missing\n");
- usage(h5tools_getprogname());
+ usage();
leave(EXIT_FAILURE);
}
if (oname_dst==NULL)
{
error_msg("Destination object name missing\n");
- usage(h5tools_getprogname());
+ usage();
leave(EXIT_FAILURE);
}
diff --git a/tools/h5diff/h5diff_common.c b/tools/h5diff/h5diff_common.c
index a371cc0..8a996d9 100644
--- a/tools/h5diff/h5diff_common.c
+++ b/tools/h5diff/h5diff_common.c
@@ -358,7 +358,7 @@ void parse_command_line(int argc,
*
*-------------------------------------------------------------------------
*/
-static int
+H5_ATTR_PURE static int
check_n_input( const char *str )
{
unsigned i;
diff --git a/tools/h5diff/h5diff_main.c b/tools/h5diff/h5diff_main.c
index a916ec5..7b4bc39 100644
--- a/tools/h5diff/h5diff_main.c
+++ b/tools/h5diff/h5diff_main.c
@@ -136,7 +136,8 @@ int main(int argc, const char *argv[])
*
*-------------------------------------------------------------------------
*/
-void h5diff_exit(int status)
+void
+h5diff_exit(int status)
{
exit(status);
}
diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c
index 553db93..3b46912 100644
--- a/tools/h5dump/h5dump.c
+++ b/tools/h5dump/h5dump.c
@@ -438,7 +438,7 @@ table_list_add(hid_t oid, unsigned long file_no)
*
*-------------------------------------------------------------------------
*/
-ssize_t
+H5_ATTR_PURE ssize_t
table_list_visited(unsigned long file_no)
{
size_t u; /* Local index variable */
@@ -625,9 +625,8 @@ parse_hsize_list(const char *h_list, subset_d *d)
last_digit = 1;
}
- else {
+ else
last_digit = 0;
- }
if (size_count == 0)
/* there aren't any integers to read */
@@ -639,7 +638,7 @@ parse_hsize_list(const char *h_list, subset_d *d)
for (ptr = h_list; i < size_count && ptr && *ptr && *ptr != ';' && *ptr != ']'; ptr++)
if(HDisdigit(*ptr)) {
/* we should have an integer now */
- p_list[i++] = (hsize_t)HDatof(ptr);
+ p_list[i++] = (hsize_t)HDatoll(ptr);
while (HDisdigit(*ptr))
/* scroll to end of integer */
@@ -647,8 +646,6 @@ parse_hsize_list(const char *h_list, subset_d *d)
}
d->data = p_list;
d->len = size_count;
-
- return;
}
/*-------------------------------------------------------------------------
@@ -671,7 +668,7 @@ static struct subset_t *
parse_subset_params(char *dset)
{
struct subset_t *s = NULL;
- register char *brace;
+ char *brace;
if (!disable_compact_subset && ((brace = HDstrrchr(dset, '[')) != NULL)) {
*brace++ = '\0';
@@ -715,14 +712,15 @@ parse_subset_params(char *dset)
*
* Failure: FAIL
*
- *
*-------------------------------------------------------------------------
*/
static int
parse_mask_list(const char *h_list)
{
- int offset_value;
- int length_value;
+ int soffset_value;
+ unsigned offset_value;
+ int slength_value;
+ unsigned length_value;
unsigned long long temp_mask;
const char *ptr = NULL;
@@ -740,10 +738,11 @@ parse_mask_list(const char *h_list)
error_msg("Bad mask list(%s)\n", h_list);
return FAIL;
}
- offset_value = HDatoi(ptr);
- if (offset_value < 0 || offset_value >= PACKED_BITS_SIZE_MAX) {
- error_msg("Packed Bit offset value(%d) must be between 0 and %d\n",
- offset_value, PACKED_BITS_SIZE_MAX - 1);
+ soffset_value = HDatoi(ptr);
+ offset_value = (unsigned)soffset_value;
+ if (soffset_value < 0 || offset_value >= PACKED_BITS_SIZE_MAX) {
+ error_msg("Packed Bit offset value(%d) must be between 0 and %u\n",
+ soffset_value, (unsigned)(PACKED_BITS_SIZE_MAX - 1));
return FAIL;
}
@@ -761,14 +760,15 @@ parse_mask_list(const char *h_list)
error_msg("Bad mask list(%s)\n", h_list);
return FAIL;
}
- length_value = HDatoi(ptr);
- if (length_value <= 0) {
- error_msg("Packed Bit length value(%d) must be positive.\n", length_value);
+ slength_value = HDatoi(ptr);
+ if (slength_value <= 0) {
+ error_msg("Packed Bit length value(%d) must be positive.\n", slength_value);
return FAIL;
}
- if ((offset_value + length_value) > PACKED_BITS_SIZE_MAX){
- error_msg("Packed Bit offset+length value(%d) too large. Max is %d\n",
- offset_value+length_value, PACKED_BITS_SIZE_MAX);
+ length_value = (unsigned)slength_value;
+ if ((offset_value + length_value) > PACKED_BITS_SIZE_MAX) {
+ error_msg("Packed Bit offset+length value(%u) too large. Max is %u\n",
+ offset_value+length_value, (unsigned)PACKED_BITS_SIZE_MAX);
return FAIL;
}
@@ -787,8 +787,8 @@ parse_mask_list(const char *h_list)
/* create the bit mask by left shift 1's by length, then negate it. */
/* After packed_mask is calculated, packed_length is not needed but */
/* keep it for debug purpose. */
- temp_mask = ~0L;
- if(length_value<8*sizeof(unsigned long long)) {
+ temp_mask = ~0ULL;
+ if(length_value < (int)(8 *sizeof(unsigned long long))) {
temp_mask = temp_mask << length_value;
packed_mask[packed_bits_num] = ~temp_mask;
}
@@ -960,11 +960,15 @@ parse_start:
goto done;
break;
case 'w':
- h5tools_nCols = HDatoi(opt_arg);
- if (h5tools_nCols <= 0) {
- h5tools_nCols = 65535;
+ {
+ int sh5tools_nCols = HDatoi(opt_arg);
+
+ if (sh5tools_nCols <= 0)
+ h5tools_nCols = 65535;
+ else
+ h5tools_nCols = (unsigned)sh5tools_nCols;
+ last_was_dset = FALSE;
}
- last_was_dset = FALSE;
break;
case 'N':
display_all = 0;
@@ -1173,12 +1177,10 @@ parse_start:
usage(h5tools_getprogname());
goto error;
}
- if (HDstrcmp(opt_arg,":") == 0) {
+ if (HDstrcmp(opt_arg,":") == 0)
xmlnsprefix = "";
- }
- else {
+ else
xmlnsprefix = opt_arg;
- }
h5tools_nCols = 0;
break;
/** end XML parameters **/
@@ -1716,7 +1718,7 @@ h5_fileaccess(void)
memb_map[mt] = mt;
sprintf(sv[mt], "%%s-%c.h5", multi_letters[mt]);
memb_name[mt] = sv[mt];
- memb_addr[mt] = MAX(mt-1,0)*(HADDR_MAX/10);
+ memb_addr[mt] = (haddr_t)MAX(mt - 1, 0) * (HADDR_MAX / 10);
}
if (H5Pset_fapl_multi(fapl, memb_map, memb_fapl, memb_name, memb_addr, FALSE) < 0)
diff --git a/tools/h5dump/h5dump.h b/tools/h5dump/h5dump.h
index 8f86567..8224c02 100644
--- a/tools/h5dump/h5dump.h
+++ b/tools/h5dump/h5dump.h
@@ -53,7 +53,7 @@ typedef struct h5dump_table_list_t {
h5dump_table_list_t table_list = {0, 0, NULL};
table_t *group_table = NULL, *dset_table = NULL, *type_table = NULL;
-int dump_indent = 0; /*how far in to indent the line */
+unsigned dump_indent = 0; /*how far in to indent the line */
int unamedtype = 0; /* shared datatype with no name */
hbool_t hit_elink = FALSE; /* whether we have traversed an external link */
@@ -85,13 +85,13 @@ H5_index_t sort_by = H5_INDEX_NAME; /*sort_by [creation_order | name
H5_iter_order_t sort_order = H5_ITER_INC; /*sort_order [ascending | descending] */
#define PACKED_BITS_MAX 8 /* Maximum number of packed-bits to display */
-#define PACKED_BITS_SIZE_MAX 8*sizeof(long long) /* Maximum bits size of integer types of packed-bits */
+#define PACKED_BITS_SIZE_MAX (8*sizeof(long long)) /* Maximum bits size of integer types of packed-bits */
/* mask list for packed bits */
unsigned long long packed_mask[PACKED_BITS_MAX]; /* packed bits are restricted to 8*sizeof(llong) bytes */
/* packed bits display parameters */
-int packed_offset[PACKED_BITS_MAX];
-int packed_length[PACKED_BITS_MAX];
+unsigned packed_offset[PACKED_BITS_MAX];
+unsigned packed_length[PACKED_BITS_MAX];
/*
* The global table is set to either ddl_function_table or
diff --git a/tools/h5dump/h5dump_ddl.c b/tools/h5dump/h5dump_ddl.c
index 09751ab..182d570 100644
--- a/tools/h5dump/h5dump_ddl.c
+++ b/tools/h5dump/h5dump_ddl.c
@@ -26,12 +26,12 @@
typedef struct {
hid_t fid; /* File ID being traversed */
- char *op_name; /* Object name wanted */
+ const char *op_name; /* Object name wanted */
} trav_handle_udata_t;
typedef struct {
- char *path; /* Path of object being searched */
- char *op_name; /* Object name wanted */
+ const char *path; /* Path of object being searched */
+ const char *op_name; /* Object name wanted */
} trav_attr_udata_t;
/* callback function used by H5Literate() */
@@ -59,7 +59,7 @@ dump_datatype(hid_t type)
h5tool_format_t *outputformat = &h5tools_dataformat;
HDmemset(&ctx, 0, sizeof(ctx));
- ctx.indent_level = dump_indent/COL;
+ ctx.indent_level = dump_indent / COL;
ctx.cur_column = dump_indent;
h5dump_type_table = type_table;
@@ -88,7 +88,7 @@ dump_dataspace(hid_t space)
h5tool_format_t *outputformat = &h5tools_dataformat;
HDmemset(&ctx, 0, sizeof(ctx));
- ctx.indent_level = dump_indent/COL;
+ ctx.indent_level = dump_indent / COL;
ctx.cur_column = dump_indent;
h5tools_dump_dataspace(rawoutstream, outputformat, &ctx, space);
@@ -122,7 +122,7 @@ dump_attr_cb(hid_t oid, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED *
herr_t ret = SUCCEED;
HDmemset(&ctx, 0, sizeof(ctx));
- ctx.indent_level = dump_indent/COL;
+ ctx.indent_level = dump_indent / COL;
ctx.cur_column = dump_indent;
attr_id = H5Aopen(oid, attr_name, H5P_DEFAULT);
@@ -137,7 +137,7 @@ dump_attr_cb(hid_t oid, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED *
string_dataformat.fmt_float = fp_format;
}
- if (h5tools_nCols==0) {
+ if (h5tools_nCols == 0) {
string_dataformat.line_ncols = 65535;
string_dataformat.line_per_line = 1;
}
@@ -198,7 +198,7 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void H5_ATTR
HDmemset(&buffer, 0, sizeof(h5tools_str_t));
HDmemset(&ctx, 0, sizeof(ctx));
- ctx.indent_level = dump_indent/COL;
+ ctx.indent_level = dump_indent / COL;
ctx.cur_column = dump_indent;
string_dataformat = *outputformat;
@@ -208,7 +208,7 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void H5_ATTR
string_dataformat.fmt_float = fp_format;
}
- if (h5tools_nCols==0) {
+ if (h5tools_nCols == 0) {
string_dataformat.line_ncols = 65535;
string_dataformat.line_per_line = 1;
}
@@ -379,8 +379,8 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void H5_ATTR
H5Dclose(obj);
}
else {
- if (dapl_id)
- H5Pclose(dapl_id && dapl_id != H5P_DEFAULT);
+ if (dapl_id != H5P_DEFAULT)
+ H5Pclose(dapl_id);
error_msg("unable to dump dataset \"%s\"\n", name);
h5tools_setstatus(EXIT_FAILURE);
ret = FAIL;
@@ -670,7 +670,7 @@ dump_named_datatype(hid_t tid, const char *name)
HDmemset(&buffer, 0, sizeof(h5tools_str_t));
HDmemset(&ctx, 0, sizeof(ctx));
- ctx.indent_level = dump_indent/COL;
+ ctx.indent_level = dump_indent / COL;
ctx.cur_column = dump_indent;
string_dataformat = *outputformat;
@@ -680,7 +680,7 @@ dump_named_datatype(hid_t tid, const char *name)
string_dataformat.fmt_float = fp_format;
}
- if (h5tools_nCols==0) {
+ if (h5tools_nCols == 0) {
string_dataformat.line_ncols = 65535;
string_dataformat.line_per_line = 1;
}
@@ -833,7 +833,7 @@ dump_group(hid_t gid, const char *name)
HDmemset(&buffer, 0, sizeof(h5tools_str_t));
HDmemset(&ctx, 0, sizeof(ctx));
- ctx.indent_level = dump_indent/COL;
+ ctx.indent_level = dump_indent / COL;
ctx.cur_column = dump_indent;
string_dataformat = *outputformat;
@@ -843,7 +843,7 @@ dump_group(hid_t gid, const char *name)
string_dataformat.fmt_float = fp_format;
}
- if (h5tools_nCols==0) {
+ if (h5tools_nCols == 0) {
string_dataformat.line_ncols = 65535;
string_dataformat.line_per_line = 1;
}
@@ -880,9 +880,8 @@ dump_group(hid_t gid, const char *name)
}
} /* end if */
- if(display_oid) {
+ if(display_oid)
h5tools_dump_oid(rawoutstream, outputformat, &ctx, gid);
- }
h5tools_dump_comment(rawoutstream, outputformat, &ctx, gid);
@@ -968,7 +967,7 @@ dump_dataset(hid_t did, const char *name, struct subset_t *sset)
hsize_t curr_pos = 0; /* total data element position */
HDmemset(&ctx, 0, sizeof(ctx));
- ctx.indent_level = dump_indent/COL;
+ ctx.indent_level = dump_indent / COL;
ctx.cur_column = dump_indent;
string_dataformat = *outputformat;
@@ -978,7 +977,7 @@ dump_dataset(hid_t did, const char *name, struct subset_t *sset)
string_dataformat.fmt_float = fp_format;
}
- if (h5tools_nCols==0) {
+ if (h5tools_nCols == 0) {
string_dataformat.line_ncols = 65535;
string_dataformat.line_per_line = 1;
}
@@ -1038,20 +1037,20 @@ dump_dataset(hid_t did, const char *name, struct subset_t *sset)
H5Pclose(dcpl_id);
if(display_data) {
- int data_loop = 1;
- int i;
+ unsigned data_loop = 1;
+ unsigned u;
if(display_packed_bits)
data_loop = packed_bits_num;
- for(i=0; i<data_loop; i++) {
+ for(u = 0; u < data_loop; u++) {
if(display_packed_bits) {
ctx.need_prefix = TRUE;
h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
/* Render the element */
h5tools_str_reset(&buffer);
- packed_data_mask = packed_mask[i];
- packed_data_offset = packed_offset[i];
- packed_data_length = packed_length[i];
+ packed_data_mask = packed_mask[u];
+ packed_data_offset = packed_offset[u];
+ packed_data_length = packed_length[u];
h5tools_print_packed_bits(&buffer, type);
h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
}
@@ -1090,7 +1089,7 @@ dump_dataset(hid_t did, const char *name, struct subset_t *sset)
HDassert(0);
break;
} /* end switch */
- } /* for(i=0;i<data_loop;i++) */
+ } /* for(u=0; u<data_loop; u++) */
}
H5Tclose(type);
@@ -1147,7 +1146,7 @@ dump_data(hid_t obj_id, int obj_data, struct subset_t *sset, int display_index)
string_dataformat.fmt_float = fp_format;
}
- if (h5tools_nCols==0) {
+ if (h5tools_nCols == 0) {
string_dataformat.line_ncols = 65535;
string_dataformat.line_per_line = 1;
}
@@ -1158,7 +1157,7 @@ dump_data(hid_t obj_id, int obj_data, struct subset_t *sset, int display_index)
outputformat = &string_dataformat;
HDmemset(&ctx, 0, sizeof(ctx));
- ctx.indent_level = dump_indent/COL;
+ ctx.indent_level = dump_indent / COL;
ctx.cur_column = dump_indent;
if(obj_data == DATASET_DATA)
@@ -1331,19 +1330,17 @@ static herr_t
attr_search(hid_t oid, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED *ainfo, void *_op_data)
{
herr_t ret = SUCCEED;
- int i;
int j;
- int k;
char *obj_op_name;
char *obj_name;
trav_attr_udata_t *attr_data = (trav_attr_udata_t*)_op_data;
- char *buf = attr_data->path;
- char *op_name = attr_data->op_name;
+ const char *buf = attr_data->path;
+ const char *op_name = attr_data->op_name;
j = (int)HDstrlen(op_name) - 1;
/* find the last / */
while(j >= 0) {
- if (op_name[j] == '/' && (j==0 || (j>0 && op_name[j-1]!='\\')))
+ if(op_name[j] == '/' && (j == 0 || (j > 0 && op_name[j - 1] != '\\')))
break;
j--;
}
@@ -1356,23 +1353,25 @@ attr_search(hid_t oid, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED *a
}
else {
if(HDstrcmp(attr_name, obj_op_name)==0) {
+ size_t u, v, w;
+
/* object name */
- i = (int)HDstrlen(buf);
- j = (int)HDstrlen(op_name);
- k = (size_t)i + 1 + (size_t)j + 1 + 2;
- obj_name = (char *)HDmalloc((size_t)k);
+ u = HDstrlen(buf);
+ v = HDstrlen(op_name);
+ w = u + 1 + v + 1 + 2;
+ obj_name = (char *)HDmalloc(w);
if(obj_name == NULL) {
h5tools_setstatus(EXIT_FAILURE);
ret = FAIL;
}
else {
- HDmemset(obj_name, '\0', (size_t)k);
+ HDmemset(obj_name, '\0', w);
if(op_name[0] != '/') {
- HDstrncat(obj_name, buf, (size_t)i + 1);
- if(buf[i-1] != '/')
+ HDstrncat(obj_name, buf, u + 1);
+ if(buf[u - 1] != '/')
HDstrncat(obj_name, "/", (size_t)2);
}
- HDstrncat(obj_name, op_name, (size_t)j + 1);
+ HDstrncat(obj_name, op_name, v + 1);
handle_attributes(oid, obj_name, NULL, 0, NULL);
HDfree(obj_name);
@@ -1387,29 +1386,32 @@ static herr_t
obj_search(const char *path, const H5O_info_t *oi, const char H5_ATTR_UNUSED *already_visited, void *_op_data)
{
trav_handle_udata_t *handle_data = (trav_handle_udata_t*)_op_data;
- char *op_name = (char*)handle_data->op_name;
-
+ const char *op_name = handle_data->op_name;
trav_attr_udata_t attr_data;
- attr_data.path = (char*)path;
+
+ attr_data.path = path;
attr_data.op_name = op_name;
H5Aiterate_by_name(handle_data->fid, path, H5_INDEX_NAME, H5_ITER_INC, NULL, attr_search, (void*)&attr_data, H5P_DEFAULT);
- if(HDstrcmp(path, op_name)==0) {
+ if(HDstrcmp(path, op_name) == 0) {
switch(oi->type) {
- case H5O_TYPE_GROUP:
- handle_groups(handle_data->fid, path, NULL, 0, NULL);
- break;
- case H5O_TYPE_DATASET:
- handle_datasets(handle_data->fid, path, NULL, 0, NULL);
- break;
- case H5O_TYPE_NAMED_DATATYPE:
- handle_datatypes(handle_data->fid, path, NULL, 0, NULL);
- break;
- case H5O_TYPE_UNKNOWN:
- case H5O_TYPE_NTYPES:
- default:
- error_msg("unknown object type value\n");
- h5tools_setstatus(EXIT_FAILURE);
+ case H5O_TYPE_GROUP:
+ handle_groups(handle_data->fid, path, NULL, 0, NULL);
+ break;
+
+ case H5O_TYPE_DATASET:
+ handle_datasets(handle_data->fid, path, NULL, 0, NULL);
+ break;
+
+ case H5O_TYPE_NAMED_DATATYPE:
+ handle_datatypes(handle_data->fid, path, NULL, 0, NULL);
+ break;
+
+ case H5O_TYPE_UNKNOWN:
+ case H5O_TYPE_NTYPES:
+ default:
+ error_msg("unknown object type value\n");
+ h5tools_setstatus(EXIT_FAILURE);
} /* end switch */
}
@@ -1419,19 +1421,18 @@ obj_search(const char *path, const H5O_info_t *oi, const char H5_ATTR_UNUSED *al
static herr_t
lnk_search(const char *path, const H5L_info_t *li, void *_op_data)
{
- int search_len;
- int k;
+ size_t search_len;
+ size_t k;
char *search_name;
trav_handle_udata_t *handle_data = (trav_handle_udata_t*)_op_data;
- char *op_name = (char*)handle_data->op_name;
+ const char *op_name = handle_data->op_name;
search_len = HDstrlen(op_name);
- if(search_len > 0 && op_name[0] != '/') {
+ if(search_len > 0 && op_name[0] != '/')
k = 2;
- }
else
k = 1;
- search_name = (char *)HDmalloc((size_t)(search_len + k));
+ search_name = (char *)HDmalloc(search_len + k);
if(search_name == NULL) {
error_msg("creating temporary link\n");
h5tools_setstatus(EXIT_FAILURE);
@@ -1439,10 +1440,10 @@ lnk_search(const char *path, const H5L_info_t *li, void *_op_data)
else {
if (k == 2) {
HDstrcpy(search_name, "/");
- HDstrncat(search_name, op_name, (size_t)search_len + 1);
+ HDstrncat(search_name, op_name, search_len + 1);
}
else
- HDstrncpy(search_name, op_name, (size_t)search_len + 1);
+ HDstrncpy(search_name, op_name, search_len + 1);
search_name[search_len + k - 1] = '\0';
if(HDstrcmp(path, search_name) == 0) {
@@ -1513,7 +1514,7 @@ handle_paths(hid_t fid, const char *path_name, void H5_ATTR_UNUSED * data, int H
}
handle_udata.fid = fid;
- handle_udata.op_name = (char*)path_name;
+ handle_udata.op_name = path_name;
if(h5trav_visit(fid, "/", TRUE, TRUE, obj_search, lnk_search, &handle_udata) < 0) {
error_msg("error traversing information\n");
h5tools_setstatus(EXIT_FAILURE);
@@ -1574,7 +1575,7 @@ handle_attributes(hid_t fid, const char *attr, void H5_ATTR_UNUSED * data, int H
dump_indent += COL;
HDmemset(&ctx, 0, sizeof(ctx));
- ctx.indent_level = dump_indent/COL;
+ ctx.indent_level = dump_indent / COL;
ctx.cur_column = dump_indent;
string_dataformat = *outputformat;
@@ -1584,7 +1585,7 @@ handle_attributes(hid_t fid, const char *attr, void H5_ATTR_UNUSED * data, int H
string_dataformat.fmt_float = fp_format;
}
- if (h5tools_nCols==0) {
+ if (h5tools_nCols == 0) {
string_dataformat.line_ncols = 65535;
string_dataformat.line_per_line = 1;
}
@@ -1713,9 +1714,8 @@ handle_datasets(hid_t fid, const char *dset, void *data, int pe, const char *dis
}
}
if((dsetid = H5Dopen2(fid, dset, dapl_id)) < 0) {
- if (pe) {
+ if (pe)
handle_links(fid, dset, data, pe, display_name);
- }
return;
} /* end if */
@@ -1731,8 +1731,7 @@ handle_datasets(hid_t fid, const char *dset, void *data, int pe, const char *dis
h5tools_setstatus(EXIT_FAILURE);
return;
}
- else
- ndims = ndims_res;
+ ndims = (unsigned)ndims_res;
if(!sset->start.data || !sset->stride.data || !sset->count.data || !sset->block.data) {
/* they didn't specify a ``stride'' or ``block''. default to 1 in all
@@ -2142,12 +2141,15 @@ dump_extlink(hid_t group, const char *linkname, const char *objname)
case H5O_TYPE_GROUP:
handle_groups(group, linkname, NULL, 0, objname);
break;
+
case H5O_TYPE_DATASET:
handle_datasets(group, linkname, NULL, 0, objname);
break;
+
case H5O_TYPE_NAMED_DATATYPE:
handle_datatypes(group, linkname, NULL, 0, objname);
break;
+
case H5O_TYPE_UNKNOWN:
case H5O_TYPE_NTYPES:
default:
diff --git a/tools/h5dump/h5dump_extern.h b/tools/h5dump/h5dump_extern.h
index 262cef1..8fef1b9 100644
--- a/tools/h5dump/h5dump_extern.h
+++ b/tools/h5dump/h5dump_extern.h
@@ -52,7 +52,7 @@ typedef struct h5dump_table_list_t {
extern h5dump_table_list_t table_list;
extern table_t *group_table, *dset_table, *type_table;
-extern int dump_indent; /*how far in to indent the line */
+extern unsigned dump_indent; /*how far in to indent the line */
extern int unamedtype; /* shared datatype with no name */
extern hbool_t hit_elink; /* whether we have traversed an external link */
@@ -89,8 +89,8 @@ extern H5_iter_order_t sort_order; /*sort_order [ascending | descending] */
extern unsigned long long packed_mask[PACKED_BITS_MAX]; /* packed bits are restricted to 8*sizeof(llong) bytes */
/* packed bits display parameters */
-extern int packed_offset[PACKED_BITS_MAX];
-extern int packed_length[PACKED_BITS_MAX];
+extern unsigned packed_offset[PACKED_BITS_MAX];
+extern unsigned packed_length[PACKED_BITS_MAX];
/*
* The global table is set to either ddl_function_table or
diff --git a/tools/h5dump/h5dump_xml.c b/tools/h5dump/h5dump_xml.c
index 5bc43eb..41f3914 100644
--- a/tools/h5dump/h5dump_xml.c
+++ b/tools/h5dump/h5dump_xml.c
@@ -156,7 +156,7 @@ xml_dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void H5_
HDmemset(&buffer, 0, sizeof(h5tools_str_t));
HDmemset(&ctx, 0, sizeof(ctx));
- ctx.indent_level = dump_indent/COL;
+ ctx.indent_level = dump_indent / COL;
ctx.cur_column = dump_indent;
string_dataformat = *outputformat;
@@ -332,9 +332,8 @@ xml_dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void H5_
H5Dclose(obj);
goto done;
}
- else {
+ else
found_obj->displayed = TRUE;
- }
} /* end if */
dump_function_table->dump_dataset_function(obj, name, NULL);
@@ -756,7 +755,7 @@ xml_escape_the_string(const char *str, int slen)
if (slen < 0)
len = HDstrlen(str);
else
- len = slen;
+ len = (size_t)slen;
extra = 0;
@@ -878,7 +877,7 @@ xml_print_datatype(hid_t type, unsigned in_group)
HDmemset(&buffer, 0, sizeof(h5tools_str_t));
HDmemset(&ctx, 0, sizeof(ctx));
- ctx.indent_level = dump_indent/COL;
+ ctx.indent_level = dump_indent / COL;
ctx.cur_column = dump_indent;
string_dataformat = *outputformat;
@@ -954,353 +953,370 @@ xml_print_datatype(hid_t type, unsigned in_group)
}
}
else {
-
switch (H5Tget_class(type)) {
- case H5T_INTEGER:
- ctx.need_prefix = TRUE;
- h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
-
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sAtomicType>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- ctx.indent_level++;
-
- /* <hdf5:IntegerType ByteOrder="bo" Sign="torf" Size="bytes"/> */
- ord = H5Tget_order(type);
- sgn = H5Tget_sign(type);
-
- ctx.need_prefix = TRUE;
- h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
-
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sIntegerType ByteOrder=\"",xmlnsprefix);
- switch (ord) {
- case H5T_ORDER_LE:
- h5tools_str_append(&buffer, "LE");
- break;
- case H5T_ORDER_BE:
- h5tools_str_append(&buffer, "BE");
- break;
- case H5T_ORDER_VAX:
- case H5T_ORDER_MIXED:
- case H5T_ORDER_NONE:
- case H5T_ORDER_ERROR:
- default:
- h5tools_str_append(&buffer, "ERROR_UNKNOWN");
- break;
- } /* end switch */
-
- h5tools_str_append(&buffer, "\" Sign=\"");
-
- switch (sgn) {
- case H5T_SGN_NONE:
- h5tools_str_append(&buffer, "false");
- break;
- case H5T_SGN_2:
- h5tools_str_append(&buffer, "true");
- break;
- case H5T_SGN_ERROR:
- case H5T_NSGN:
- default:
- h5tools_str_append(&buffer, "ERROR_UNKNOWN");
- break;
- } /* end switch */
-
- h5tools_str_append(&buffer, "\" Size=\"");
- sz = H5Tget_size(type);
- h5tools_str_append(&buffer, "%lu", (unsigned long)sz);
- h5tools_str_append(&buffer, "\" />");
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- ctx.indent_level--;
-
- ctx.need_prefix = TRUE;
- h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
-
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "</%sAtomicType>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- break;
+ case H5T_INTEGER:
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
- case H5T_FLOAT:
- /* <hdf5:FloatType ByteOrder="bo" Size="bytes"
- SignBitLocation="bytes"
- ExponentBits="eb" ExponentLocation="el"
- MantissaBits="mb" MantissaLocation="ml" /> */
- ord = H5Tget_order(type);
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sAtomicType>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ ctx.indent_level++;
- ctx.need_prefix = TRUE;
- h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
+ /* <hdf5:IntegerType ByteOrder="bo" Sign="torf" Size="bytes"/> */
+ ord = H5Tget_order(type);
+ sgn = H5Tget_sign(type);
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sAtomicType>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- ctx.indent_level++;
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
- ctx.need_prefix = TRUE;
- h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sIntegerType ByteOrder=\"",xmlnsprefix);
+ switch (ord) {
+ case H5T_ORDER_LE:
+ h5tools_str_append(&buffer, "LE");
+ break;
+ case H5T_ORDER_BE:
+ h5tools_str_append(&buffer, "BE");
+ break;
+ case H5T_ORDER_VAX:
+ case H5T_ORDER_MIXED:
+ case H5T_ORDER_NONE:
+ case H5T_ORDER_ERROR:
+ default:
+ h5tools_str_append(&buffer, "ERROR_UNKNOWN");
+ break;
+ } /* end switch */
+
+ h5tools_str_append(&buffer, "\" Sign=\"");
+
+ switch (sgn) {
+ case H5T_SGN_NONE:
+ h5tools_str_append(&buffer, "false");
+ break;
+ case H5T_SGN_2:
+ h5tools_str_append(&buffer, "true");
+ break;
+ case H5T_SGN_ERROR:
+ case H5T_NSGN:
+ default:
+ h5tools_str_append(&buffer, "ERROR_UNKNOWN");
+ break;
+ } /* end switch */
+
+ h5tools_str_append(&buffer, "\" Size=\"");
+ sz = H5Tget_size(type);
+ h5tools_str_append(&buffer, "%lu", (unsigned long)sz);
+ h5tools_str_append(&buffer, "\" />");
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ ctx.indent_level--;
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sFloatType ByteOrder=\"",xmlnsprefix);
-
- switch (ord) {
- case H5T_ORDER_LE:
- h5tools_str_append(&buffer, "LE");
- break;
- case H5T_ORDER_BE:
- h5tools_str_append(&buffer, "BE");
- break;
- case H5T_ORDER_VAX:
- h5tools_str_append(&buffer, "VAX");
- break;
- case H5T_ORDER_MIXED:
- case H5T_ORDER_NONE:
- case H5T_ORDER_ERROR:
- default:
- h5tools_str_append(&buffer, "ERROR_UNKNOWN");
- } /* end switch */
-
- h5tools_str_append(&buffer, "\" Size=\"");
- sz = H5Tget_size(type);
- h5tools_str_append(&buffer, "%lu", (unsigned long)sz);
- H5Tget_fields(type, &spos, &epos, &esize, &mpos, &msize);
- h5tools_str_append(&buffer, "\" SignBitLocation=\"%lu\" ", (unsigned long)spos);
- h5tools_str_append(&buffer, "ExponentBits=\"%lu\" ExponentLocation=\"%lu\" ", (unsigned long)esize, (unsigned long)epos);
- h5tools_str_append(&buffer, "MantissaBits=\"%lu\" MantissaLocation=\"%lu\" />", (unsigned long)msize, (unsigned long)mpos);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- ctx.indent_level--;
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
- ctx.need_prefix = TRUE;
- h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sAtomicType>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ break;
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "</%sAtomicType>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- break;
+ case H5T_FLOAT:
+ /* <hdf5:FloatType ByteOrder="bo" Size="bytes"
+ SignBitLocation="bytes"
+ ExponentBits="eb" ExponentLocation="el"
+ MantissaBits="mb" MantissaLocation="ml" /> */
+ ord = H5Tget_order(type);
- case H5T_TIME:
- ctx.need_prefix = TRUE;
- h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sAtomicType>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- ctx.indent_level++;
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sAtomicType>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ ctx.indent_level++;
- ctx.need_prefix = TRUE;
- h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sTimeType />",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- h5tools_str_append(&buffer, "<!-- H5T_TIME: not yet implemented -->");
- ctx.indent_level--;
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sFloatType ByteOrder=\"",xmlnsprefix);
+
+ switch (ord) {
+ case H5T_ORDER_LE:
+ h5tools_str_append(&buffer, "LE");
+ break;
+ case H5T_ORDER_BE:
+ h5tools_str_append(&buffer, "BE");
+ break;
+ case H5T_ORDER_VAX:
+ h5tools_str_append(&buffer, "VAX");
+ break;
+ case H5T_ORDER_MIXED:
+ case H5T_ORDER_NONE:
+ case H5T_ORDER_ERROR:
+ default:
+ h5tools_str_append(&buffer, "ERROR_UNKNOWN");
+ } /* end switch */
+
+ h5tools_str_append(&buffer, "\" Size=\"");
+ sz = H5Tget_size(type);
+ h5tools_str_append(&buffer, "%lu", (unsigned long)sz);
+ H5Tget_fields(type, &spos, &epos, &esize, &mpos, &msize);
+ h5tools_str_append(&buffer, "\" SignBitLocation=\"%lu\" ", (unsigned long)spos);
+ h5tools_str_append(&buffer, "ExponentBits=\"%lu\" ExponentLocation=\"%lu\" ", (unsigned long)esize, (unsigned long)epos);
+ h5tools_str_append(&buffer, "MantissaBits=\"%lu\" MantissaLocation=\"%lu\" />", (unsigned long)msize, (unsigned long)mpos);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ ctx.indent_level--;
- ctx.need_prefix = TRUE;
- h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "</%sAtomicType>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- break;
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sAtomicType>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ break;
- case H5T_STRING:
- /* <hdf5:StringType Cset="cs" StrSize="chars" StrPad="pad" /> */
- size = H5Tget_size(type);
- str_pad = H5Tget_strpad(type);
- cset = H5Tget_cset(type);
- is_vlstr = H5Tis_variable_str(type);
+ case H5T_TIME:
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
- ctx.need_prefix = TRUE;
- h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sAtomicType>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ ctx.indent_level++;
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sAtomicType>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
- ctx.indent_level++;
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sTimeType />",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer, "<!-- H5T_TIME: not yet implemented -->");
+ ctx.indent_level--;
- ctx.need_prefix = TRUE;
- h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sStringType Cset=\"",xmlnsprefix);
- if (cset == H5T_CSET_ASCII) {
- h5tools_str_append(&buffer, "H5T_CSET_ASCII\" ");
- }
- else {
- h5tools_str_append(&buffer, "unknown_cset\" ");
- }
- if(is_vlstr)
- h5tools_str_append(&buffer, "StrSize=\"H5T_VARIABLE\" StrPad=\"");
- else
- h5tools_str_append(&buffer, "StrSize=\"%d\" StrPad=\"", (int) size);
- if (str_pad == H5T_STR_NULLTERM) {
- h5tools_str_append(&buffer, "H5T_STR_NULLTERM\"/>");
- }
- else if (str_pad == H5T_STR_NULLPAD) {
- h5tools_str_append(&buffer, "H5T_STR_NULLPAD\"/>");
- }
- else if (str_pad == H5T_STR_SPACEPAD) {
- h5tools_str_append(&buffer, "H5T_STR_SPACEPAD\"/>");
- }
- else {
- h5tools_str_append(&buffer, "H5T_STR_ERROR\"/>");
- }
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- ctx.indent_level--;
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sAtomicType>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ break;
- ctx.need_prefix = TRUE;
- h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
+ case H5T_STRING:
+ /* <hdf5:StringType Cset="cs" StrSize="chars" StrPad="pad" /> */
+ size = H5Tget_size(type);
+ str_pad = H5Tget_strpad(type);
+ cset = H5Tget_cset(type);
+ is_vlstr = H5Tis_variable_str(type);
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "</%sAtomicType>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- break;
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
- case H5T_BITFIELD:
- /* <hdf5:BitfieldType ByteOrder="bo" Size="bytes"/> */
- ord = H5Tget_order(type);
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sAtomicType>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- ctx.need_prefix = TRUE;
- h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
+ ctx.indent_level++;
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sAtomicType>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- ctx.indent_level++;
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
- ctx.need_prefix = TRUE;
- h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sStringType Cset=\"",xmlnsprefix);
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sBitfieldType ByteOrder=\"",xmlnsprefix);
-
- switch (ord) {
- case H5T_ORDER_LE:
- h5tools_str_append(&buffer, "LE");
- break;
- case H5T_ORDER_BE:
- h5tools_str_append(&buffer, "BE");
- break;
- case H5T_ORDER_VAX:
- case H5T_ORDER_MIXED:
- case H5T_ORDER_NONE:
- case H5T_ORDER_ERROR:
- default:
- h5tools_str_append(&buffer, "ERROR_UNKNOWN");
- } /* end switch */
-
- size = H5Tget_size(type);
- h5tools_str_append(&buffer, "\" Size=\"%lu\"/>", (unsigned long)size);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- ctx.indent_level--;
+ if (cset == H5T_CSET_ASCII)
+ h5tools_str_append(&buffer, "H5T_CSET_ASCII\" ");
+ else
+ h5tools_str_append(&buffer, "unknown_cset\" ");
- ctx.need_prefix = TRUE;
- h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
+ if(is_vlstr)
+ h5tools_str_append(&buffer, "StrSize=\"H5T_VARIABLE\" StrPad=\"");
+ else
+ h5tools_str_append(&buffer, "StrSize=\"%d\" StrPad=\"", (int) size);
+
+ if (str_pad == H5T_STR_NULLTERM)
+ h5tools_str_append(&buffer, "H5T_STR_NULLTERM\"/>");
+ else if (str_pad == H5T_STR_NULLPAD)
+ h5tools_str_append(&buffer, "H5T_STR_NULLPAD\"/>");
+ else if (str_pad == H5T_STR_SPACEPAD)
+ h5tools_str_append(&buffer, "H5T_STR_SPACEPAD\"/>");
+ else
+ h5tools_str_append(&buffer, "H5T_STR_ERROR\"/>");
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ ctx.indent_level--;
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "</%sAtomicType>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- break;
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
- case H5T_OPAQUE:
- /* <hdf5:OpaqueType Tag="tag" Size="bytes" /> */
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sAtomicType>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ break;
- ctx.need_prefix = TRUE;
- h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
+ case H5T_BITFIELD:
+ /* <hdf5:BitfieldType ByteOrder="bo" Size="bytes"/> */
+ ord = H5Tget_order(type);
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sAtomicType>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- ctx.indent_level++;
- mname = H5Tget_tag(type);
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
- ctx.need_prefix = TRUE;
- h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sAtomicType>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ ctx.indent_level++;
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sOpaqueType Tag=\"%s\" ",xmlnsprefix, mname);
- H5free_memory(mname);
- size = H5Tget_size(type);
- h5tools_str_append(&buffer, "Size=\"%lu\"/>", (unsigned long)size);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- ctx.indent_level--;
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
- ctx.need_prefix = TRUE;
- h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sBitfieldType ByteOrder=\"",xmlnsprefix);
+
+ switch (ord) {
+ case H5T_ORDER_LE:
+ h5tools_str_append(&buffer, "LE");
+ break;
+ case H5T_ORDER_BE:
+ h5tools_str_append(&buffer, "BE");
+ break;
+ case H5T_ORDER_VAX:
+ case H5T_ORDER_MIXED:
+ case H5T_ORDER_NONE:
+ case H5T_ORDER_ERROR:
+ default:
+ h5tools_str_append(&buffer, "ERROR_UNKNOWN");
+ } /* end switch */
+
+ size = H5Tget_size(type);
+ h5tools_str_append(&buffer, "\" Size=\"%lu\"/>", (unsigned long)size);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ ctx.indent_level--;
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "</%sAtomicType>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- break;
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
- case H5T_COMPOUND:
- /* recursively describe the components of a compound datatype */
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sAtomicType>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ break;
- /* type of a dataset */
- nmembers = H5Tget_nmembers(type);
+ case H5T_OPAQUE:
+ /* <hdf5:OpaqueType Tag="tag" Size="bytes" /> */
- ctx.need_prefix = TRUE;
- h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sCompoundType>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sAtomicType>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ ctx.indent_level++;
+ mname = H5Tget_tag(type);
- /* List each member Field of the type */
- /* <hdf5:Field FieldName="name" > */
- /* <hdf5:DataType > */
- ctx.indent_level++;
- dump_indent += COL;
- for (i = 0; i < nmembers; i++) {
- char *t_fname;
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
- mname = H5Tget_member_name(type, i);
- mtype = H5Tget_member_type(type, i);
- t_fname = xml_escape_the_name(mname);
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sOpaqueType Tag=\"%s\" ",xmlnsprefix, mname);
+ H5free_memory(mname);
+ size = H5Tget_size(type);
+ h5tools_str_append(&buffer, "Size=\"%lu\"/>", (unsigned long)size);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ ctx.indent_level--;
ctx.need_prefix = TRUE;
h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sField FieldName=\"%s\">",xmlnsprefix, t_fname);
+ h5tools_str_append(&buffer, "</%sAtomicType>",xmlnsprefix);
h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ break;
- H5free_memory(mname);
- HDfree(t_fname);
- dump_indent += COL;
- ctx.indent_level++;
+ case H5T_COMPOUND:
+ /* recursively describe the components of a compound datatype */
+
+ /* type of a dataset */
+ nmembers = (unsigned)H5Tget_nmembers(type);
ctx.need_prefix = TRUE;
h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sDataType>",xmlnsprefix);
+ h5tools_str_append(&buffer, "<%sCompoundType>",xmlnsprefix);
h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+
+ /* List each member Field of the type */
+ /* <hdf5:Field FieldName="name" > */
+ /* <hdf5:DataType > */
ctx.indent_level++;
dump_indent += COL;
- xml_print_datatype(mtype,0);
+ for (i = 0; i < nmembers; i++) {
+ char *t_fname;
+
+ mname = H5Tget_member_name(type, i);
+ mtype = H5Tget_member_type(type, i);
+ t_fname = xml_escape_the_name(mname);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sField FieldName=\"%s\">",xmlnsprefix, t_fname);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+
+ H5free_memory(mname);
+ HDfree(t_fname);
+ dump_indent += COL;
+ ctx.indent_level++;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sDataType>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ ctx.indent_level++;
+ dump_indent += COL;
+ xml_print_datatype(mtype,0);
+ dump_indent -= COL;
+ ctx.indent_level--;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sDataType>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ dump_indent -= COL;
+ ctx.indent_level--;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sField>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ }
dump_indent -= COL;
ctx.indent_level--;
@@ -1309,248 +1325,227 @@ xml_print_datatype(hid_t type, unsigned in_group)
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "</%sDataType>",xmlnsprefix);
+ h5tools_str_append(&buffer, "</%sCompoundType>",xmlnsprefix);
h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- dump_indent -= COL;
- ctx.indent_level--;
+ break;
+ case H5T_REFERENCE:
ctx.need_prefix = TRUE;
h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "</%sField>",xmlnsprefix);
+ h5tools_str_append(&buffer, "<%sAtomicType>",xmlnsprefix);
h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- }
- dump_indent -= COL;
- ctx.indent_level--;
-
- ctx.need_prefix = TRUE;
- h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
+ ctx.indent_level++;
+ /* Only Object references supported at this time */
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "</%sCompoundType>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- break;
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
- case H5T_REFERENCE:
- ctx.need_prefix = TRUE;
- h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sReferenceType>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ ctx.indent_level++;
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sAtomicType>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- ctx.indent_level++;
- /* Only Object references supported at this time */
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
- ctx.need_prefix = TRUE;
- h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sObjectReferenceType />",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ ctx.indent_level--;
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sReferenceType>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- ctx.indent_level++;
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
- ctx.need_prefix = TRUE;
- h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sReferenceType>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ ctx.indent_level--;
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sObjectReferenceType />",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- ctx.indent_level--;
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
- ctx.need_prefix = TRUE;
- h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sAtomicType>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ break;
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "</%sReferenceType>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- ctx.indent_level--;
+ case H5T_ENUM:
+ /* <hdf5:EnumType Nelems="ne" > list Name, values of enum */
+ nmembs = H5Tget_nmembers(type);
- ctx.need_prefix = TRUE;
- h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "</%sAtomicType>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- break;
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sAtomicType>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ dump_indent += COL;
+ ctx.indent_level++;
- case H5T_ENUM:
- /* <hdf5:EnumType Nelems="ne" > list Name, values of enum */
- nmembs = H5Tget_nmembers(type);
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
- ctx.need_prefix = TRUE;
- h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sEnumType Nelems=\"%d\">",xmlnsprefix, nmembs);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ xml_print_enum(type);
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sAtomicType>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- dump_indent += COL;
- ctx.indent_level++;
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
- ctx.need_prefix = TRUE;
- h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sEnumType>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ dump_indent -= COL;
+ ctx.indent_level--;
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sEnumType Nelems=\"%d\">",xmlnsprefix, nmembs);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- xml_print_enum(type);
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
- ctx.need_prefix = TRUE;
- h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sAtomicType>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ break;
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "</%sEnumType>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- dump_indent -= COL;
- ctx.indent_level--;
+ case H5T_VLEN:
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
- ctx.need_prefix = TRUE;
- h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sVLType>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ super = H5Tget_super(type);
+ dump_indent += COL;
+ ctx.indent_level++;
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "</%sAtomicType>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- break;
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
- case H5T_VLEN:
- ctx.need_prefix = TRUE;
- h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sDataType>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ dump_indent += COL;
+ ctx.indent_level++;
+ xml_print_datatype(super,0);
+ dump_indent -= COL;
+ ctx.indent_level--;
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sVLType>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- super = H5Tget_super(type);
- dump_indent += COL;
- ctx.indent_level++;
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
- ctx.need_prefix = TRUE;
- h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sDataType>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ dump_indent -= COL;
+ ctx.indent_level--;
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sDataType>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- dump_indent += COL;
- ctx.indent_level++;
- xml_print_datatype(super,0);
- dump_indent -= COL;
- ctx.indent_level--;
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
- ctx.need_prefix = TRUE;
- h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sVLType>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ H5Tclose(super);
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "</%sDataType>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- dump_indent -= COL;
- ctx.indent_level--;
+ break;
- ctx.need_prefix = TRUE;
- h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
+ case H5T_ARRAY:
+ /* Get array base type */
+ super = H5Tget_super(type);
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "</%sVLType>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- H5Tclose(super);
+ /* Print lead-in */
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
- break;
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sArrayType Ndims=\"",xmlnsprefix);
+ ndims = (unsigned)H5Tget_array_ndims(type);
+ h5tools_str_append(&buffer, "%u\">", ndims);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- case H5T_ARRAY:
- /* Get array base type */
- super = H5Tget_super(type);
+ /* Get array information */
+ H5Tget_array_dims2(type, dims);
- /* Print lead-in */
- ctx.need_prefix = TRUE;
- h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
+ /* list of dimensions */
+ ctx.indent_level++;
+ for (i = 0; i < ndims; i++) {
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sArrayType Ndims=\"",xmlnsprefix);
- ndims = H5Tget_array_ndims(type);
- h5tools_str_append(&buffer, "%u\">", ndims);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sArrayDimension DimSize=\"%u\"/>", xmlnsprefix, (int) dims[i]);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ }
+ ctx.indent_level--;
- /* Get array information */
- H5Tget_array_dims2(type, dims);
+ dump_indent += COL;
+ ctx.indent_level++;
- /* list of dimensions */
- ctx.indent_level++;
- for (i = 0; i < ndims; i++) {
ctx.need_prefix = TRUE;
h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sArrayDimension DimSize=\"%u\"/>", xmlnsprefix, (int) dims[i]);
+ h5tools_str_append(&buffer, "<%sDataType>",xmlnsprefix);
h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- }
- ctx.indent_level--;
-
- dump_indent += COL;
- ctx.indent_level++;
-
- ctx.need_prefix = TRUE;
- h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
-
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sDataType>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- dump_indent += COL;
- ctx.indent_level++;
- xml_print_datatype(super,0);
- dump_indent -= COL;
- ctx.indent_level--;
+ dump_indent += COL;
+ ctx.indent_level++;
+ xml_print_datatype(super,0);
+ dump_indent -= COL;
+ ctx.indent_level--;
- ctx.need_prefix = TRUE;
- h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "</%sDataType>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- dump_indent -= COL;
- ctx.indent_level--;
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sDataType>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ dump_indent -= COL;
+ ctx.indent_level--;
- ctx.need_prefix = TRUE;
- h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "</%sArrayType>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- /* Close array base type */
- H5Tclose(super);
- break;
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sArrayType>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ /* Close array base type */
+ H5Tclose(super);
+ break;
- case H5T_NO_CLASS:
- case H5T_NCLASSES:
- HDassert(0);
- /* fall through */
- default:
- ctx.need_prefix = TRUE;
- h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
+ case H5T_NO_CLASS:
+ case H5T_NCLASSES:
+ HDassert(0);
+ /* fall through */
+ default:
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<!-- unknown datatype -->");
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- h5tools_setstatus(EXIT_FAILURE);
- break;
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<!-- unknown datatype -->");
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_setstatus(EXIT_FAILURE);
+ break;
}
} /* end else */
@@ -1583,7 +1578,7 @@ xml_dump_datatype(hid_t type)
HDmemset(&buffer, 0, sizeof(h5tools_str_t));
HDmemset(&ctx, 0, sizeof(ctx));
- ctx.indent_level = dump_indent/COL;
+ ctx.indent_level = dump_indent / COL;
ctx.cur_column = dump_indent;
string_dataformat = *outputformat;
@@ -1593,7 +1588,7 @@ xml_dump_datatype(hid_t type)
string_dataformat.fmt_float = fp_format;
}
- if (h5tools_nCols==0) {
+ if (h5tools_nCols == 0) {
string_dataformat.line_ncols = 65535;
string_dataformat.line_per_line = 1;
}
@@ -1722,7 +1717,7 @@ xml_dump_dataspace(hid_t space)
HDmemset(&buffer, 0, sizeof(h5tools_str_t));
HDmemset(&ctx, 0, sizeof(ctx));
- ctx.indent_level = dump_indent/COL;
+ ctx.indent_level = dump_indent / COL;
ctx.cur_column = dump_indent;
string_dataformat = *outputformat;
@@ -1732,7 +1727,7 @@ xml_dump_dataspace(hid_t space)
string_dataformat.fmt_float = fp_format;
}
- if (h5tools_nCols==0) {
+ if (h5tools_nCols == 0) {
string_dataformat.line_ncols = 65535;
string_dataformat.line_per_line = 1;
}
@@ -1898,7 +1893,7 @@ xml_dump_data(hid_t obj_id, int obj_data, struct subset_t H5_ATTR_UNUSED * sset,
h5tool_format_t string_dataformat;
HDmemset(&ctx, 0, sizeof(ctx));
- ctx.indent_level = dump_indent/COL;
+ ctx.indent_level = dump_indent / COL;
ctx.cur_column = dump_indent;
/* Print all the values. */
@@ -1912,7 +1907,7 @@ xml_dump_data(hid_t obj_id, int obj_data, struct subset_t H5_ATTR_UNUSED * sset,
string_dataformat.fmt_float = fp_format;
}
- if (h5tools_nCols==0) {
+ if (h5tools_nCols == 0) {
string_dataformat.line_ncols = 65535;
string_dataformat.line_per_line = 1;
}
@@ -1951,12 +1946,10 @@ xml_dump_data(hid_t obj_id, int obj_data, struct subset_t H5_ATTR_UNUSED * sset,
if (obj_data == DATASET_DATA) {
type = H5Dget_type(obj_id);
- if (H5Tget_class(type) == H5T_REFERENCE) {
+ if (H5Tget_class(type) == H5T_REFERENCE)
status = xml_print_refs(obj_id, DATASET_DATA);
- }
- else if (H5Tget_class(type) == H5T_STRING) {
+ else if (H5Tget_class(type) == H5T_STRING)
status = xml_print_strs(obj_id, DATASET_DATA);
- }
else {
h5tools_context_t datactx;
HDmemset(&datactx, 0, sizeof(datactx));
@@ -2096,7 +2089,7 @@ xml_dump_attr(hid_t attr, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED
HDmemset(&buffer, 0, sizeof(h5tools_str_t));
HDmemset(&ctx, 0, sizeof(ctx));
- ctx.indent_level = dump_indent/COL;
+ ctx.indent_level = dump_indent / COL;
ctx.cur_column = dump_indent;
string_dataformat = *outputformat;
@@ -2106,7 +2099,7 @@ xml_dump_attr(hid_t attr, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED
string_dataformat.fmt_float = fp_format;
}
- if (h5tools_nCols==0) {
+ if (h5tools_nCols == 0) {
string_dataformat.line_ncols = 65535;
string_dataformat.line_per_line = 1;
}
@@ -2426,7 +2419,7 @@ xml_dump_named_datatype(hid_t type, const char *name)
HDmemset(&buffer, 0, sizeof(h5tools_str_t));
HDmemset(&ctx, 0, sizeof(ctx));
- ctx.indent_level = dump_indent/COL;
+ ctx.indent_level = dump_indent / COL;
ctx.cur_column = dump_indent;
string_dataformat = *outputformat;
@@ -2436,7 +2429,7 @@ xml_dump_named_datatype(hid_t type, const char *name)
string_dataformat.fmt_float = fp_format;
}
- if (h5tools_nCols==0) {
+ if (h5tools_nCols == 0) {
string_dataformat.line_ncols = 65535;
string_dataformat.line_per_line = 1;
}
@@ -2651,7 +2644,7 @@ xml_dump_group(hid_t gid, const char *name)
HDmemset(&buffer, 0, sizeof(h5tools_str_t));
HDmemset(&ctx, 0, sizeof(ctx));
- ctx.indent_level = dump_indent/COL;
+ ctx.indent_level = dump_indent / COL;
ctx.cur_column = dump_indent;
string_dataformat = *outputformat;
@@ -2661,7 +2654,7 @@ xml_dump_group(hid_t gid, const char *name)
string_dataformat.fmt_float = fp_format;
}
- if (h5tools_nCols==0) {
+ if (h5tools_nCols == 0) {
string_dataformat.line_ncols = 65535;
string_dataformat.line_per_line = 1;
}
@@ -3007,14 +3000,13 @@ xml_print_refs(hid_t did, int source)
if ((tsiz = H5Tget_size(type)) == 0)
goto error;
- buf = (char *) HDcalloc((size_t)(ssiz * tsiz), sizeof(char));
+ buf = (char *) HDcalloc((size_t)ssiz, tsiz);
if (buf == NULL)
goto error;
e = H5Dread(did, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf);
/* need to check result here */
- if (e < 0) {
+ if (e < 0)
goto error;
- }
}
else if (source == ATTRIBUTE_DATA) {
space = H5Aget_space(did);
@@ -3023,15 +3015,13 @@ xml_print_refs(hid_t did, int source)
if ((tsiz = H5Tget_size(type)) == 0)
goto error;
- buf = (char *) HDcalloc((size_t)(ssiz * tsiz), sizeof(char));
- if (buf == NULL) {
+ buf = (char *) HDcalloc((size_t)ssiz, tsiz);
+ if (buf == NULL)
goto error;
- }
e = H5Aread(did, H5T_STD_REF_OBJ, buf);
/* need to check the result here */
- if (e < 0) {
+ if (e < 0)
goto error;
- }
}
refbuf = (hobj_ref_t *) buf;
@@ -3040,7 +3030,7 @@ xml_print_refs(hid_t did, int source)
HDmemset(&buffer, 0, sizeof(h5tools_str_t));
HDmemset(&ctx, 0, sizeof(ctx));
- ctx.indent_level = dump_indent/COL;
+ ctx.indent_level = dump_indent / COL;
ctx.cur_column = dump_indent;
string_dataformat = *outputformat;
@@ -3050,7 +3040,7 @@ xml_print_refs(hid_t did, int source)
string_dataformat.fmt_float = fp_format;
}
- if (h5tools_nCols==0) {
+ if (h5tools_nCols == 0) {
string_dataformat.line_ncols = 65535;
string_dataformat.line_per_line = 1;
}
@@ -3130,7 +3120,7 @@ xml_print_strs(hid_t did, int source)
hssize_t ssiz = -1;
htri_t is_vlstr = FALSE;
size_t tsiz = 0;
- size_t i;
+ hsize_t i;
size_t str_size = 0;
char *bp = NULL;
char *onestring = NULL;
@@ -3141,20 +3131,16 @@ xml_print_strs(hid_t did, int source)
h5tool_format_t string_dataformat;
hsize_t curr_pos = 0; /* total data element position */
- if (source == DATASET_DATA) {
+ if (source == DATASET_DATA)
type = H5Dget_type(did);
- }
- else if (source == ATTRIBUTE_DATA) {
+ else if (source == ATTRIBUTE_DATA)
type = H5Aget_type(did);
- }
- else {
+ else
/* return an error */
return FAIL;
- }
- if (H5Tget_class(type) != H5T_STRING) {
+ if (H5Tget_class(type) != H5T_STRING)
/* return an error */
goto error;
- }
/* Check if we have VL data in the dataset's datatype */
is_vlstr = H5Tis_variable_str(type);
@@ -3165,14 +3151,13 @@ xml_print_strs(hid_t did, int source)
if((tsiz = H5Tget_size(type)) == 0)
goto error;
- buf = HDmalloc((size_t)(ssiz * tsiz));
+ buf = HDmalloc((size_t)ssiz * tsiz);
if (buf == NULL)
goto error;
e = H5Dread(did, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf);
- if (e < 0) {
+ if (e < 0)
goto error;
- }
}
else if (source == ATTRIBUTE_DATA) {
space = H5Aget_space(did);
@@ -3181,14 +3166,13 @@ xml_print_strs(hid_t did, int source)
if((tsiz = H5Tget_size(type)) == 0)
goto error;
- buf = HDmalloc((size_t)(ssiz * tsiz));
+ buf = HDmalloc((size_t)ssiz * tsiz);
if (buf == NULL)
goto error;
e = H5Aread(did, type, buf);
- if (e < 0) {
+ if (e < 0)
goto error;
- }
}
bp = (char*) buf;
@@ -3199,7 +3183,7 @@ xml_print_strs(hid_t did, int source)
HDmemset(&buffer, 0, sizeof(h5tools_str_t));
HDmemset(&ctx, 0, sizeof(ctx));
- ctx.indent_level = dump_indent/COL;
+ ctx.indent_level = dump_indent / COL;
ctx.cur_column = dump_indent;
string_dataformat = *outputformat;
@@ -3209,7 +3193,7 @@ xml_print_strs(hid_t did, int source)
string_dataformat.fmt_float = fp_format;
}
- if (h5tools_nCols==0) {
+ if (h5tools_nCols == 0) {
string_dataformat.line_ncols = 65535;
string_dataformat.line_per_line = 1;
}
@@ -3219,11 +3203,11 @@ xml_print_strs(hid_t did, int source)
string_dataformat.do_escape = display_escape;
outputformat = &string_dataformat;
- for (i = 0; i < ssiz; i++) {
+ for (i = 0; i < (hsize_t)ssiz; i++) {
if (is_vlstr) {
onestring = *(char **) bp;
if (onestring)
- str_size = (size_t) HDstrlen(onestring);
+ str_size = HDstrlen(onestring);
}
else {
HDstrncpy(onestring, bp, tsiz);
@@ -3240,7 +3224,7 @@ xml_print_strs(hid_t did, int source)
h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
}
else {
- char *t_onestring = xml_escape_the_string(onestring, (int) str_size);
+ char *t_onestring = xml_escape_the_string(onestring, (int)str_size);
if (t_onestring) {
ctx.need_prefix = TRUE;
h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
@@ -3315,7 +3299,7 @@ check_filters(hid_t dcpl)
HDmemset(&buffer, 0, sizeof(h5tools_str_t));
HDmemset(&ctx, 0, sizeof(ctx));
- ctx.indent_level = dump_indent/COL;
+ ctx.indent_level = dump_indent / COL;
ctx.cur_column = dump_indent;
string_dataformat = *outputformat;
@@ -3325,7 +3309,7 @@ check_filters(hid_t dcpl)
string_dataformat.fmt_float = fp_format;
}
- if (h5tools_nCols==0) {
+ if (h5tools_nCols == 0) {
string_dataformat.line_ncols = 65535;
string_dataformat.line_per_line = 1;
}
@@ -3455,7 +3439,7 @@ xml_dump_fill_value(hid_t dcpl, hid_t type)
HDmemset(&buffer, 0, sizeof(h5tools_str_t));
HDmemset(&ctx, 0, sizeof(ctx));
- ctx.indent_level = dump_indent/COL;
+ ctx.indent_level = dump_indent / COL;
ctx.cur_column = dump_indent;
string_dataformat = *outputformat;
@@ -3465,7 +3449,7 @@ xml_dump_fill_value(hid_t dcpl, hid_t type)
string_dataformat.fmt_float = fp_format;
}
- if (h5tools_nCols==0) {
+ if (h5tools_nCols == 0) {
string_dataformat.line_ncols = 65535;
string_dataformat.line_per_line = 1;
}
@@ -3825,7 +3809,7 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED * s
HDmemset(&buffer, 0, sizeof(h5tools_str_t));
HDmemset(&ctx, 0, sizeof(ctx));
- ctx.indent_level = dump_indent/COL;
+ ctx.indent_level = dump_indent / COL;
ctx.cur_column = dump_indent;
t_name = xml_escape_the_name(name);
@@ -3839,7 +3823,7 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED * s
string_dataformat.fmt_float = fp_format;
}
- if (h5tools_nCols==0) {
+ if (h5tools_nCols == 0) {
string_dataformat.line_ncols = 65535;
string_dataformat.line_per_line = 1;
}
@@ -4419,7 +4403,7 @@ xml_print_enum(hid_t type)
HDmemset(&buffer, 0, sizeof(h5tools_str_t));
HDmemset(&ctx, 0, sizeof(ctx));
- ctx.indent_level = dump_indent/COL;
+ ctx.indent_level = dump_indent / COL;
ctx.cur_column = dump_indent;
string_dataformat = *outputformat;
@@ -4429,7 +4413,7 @@ xml_print_enum(hid_t type)
string_dataformat.fmt_float = fp_format;
}
- if (h5tools_nCols==0) {
+ if (h5tools_nCols == 0) {
string_dataformat.line_ncols = 65535;
string_dataformat.line_per_line = 1;
}
diff --git a/tools/h5dump/h5dumpgentest.c b/tools/h5dump/h5dumpgentest.c
index 46386a0..1cdf6cf 100644
--- a/tools/h5dump/h5dumpgentest.c
+++ b/tools/h5dump/h5dumpgentest.c
@@ -448,7 +448,7 @@ gent_dataset(void)
for(i = 0; i < 30; i++)
for(j = 0; j < 20; j++)
- dset2[i][j] = 0.0001F * j + i;
+ dset2[i][j] = 0.0001F * (float)j + (float)i;
H5Dwrite(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset2);
@@ -543,7 +543,7 @@ gent_attribute(void)
space = H5Screate_simple(1, dims, NULL);
attr = H5Acreate2(root, "attr3", H5T_IEEE_F64BE, space, H5P_DEFAULT, H5P_DEFAULT);
- for(i = 0; i < 10; i++) d[i] = 0.1F * i;
+ for(i = 0; i < 10; i++) d[i] = 0.1F * (float)i;
H5Awrite(attr, H5T_NATIVE_DOUBLE, d);
H5Sclose(space);
@@ -971,16 +971,16 @@ static void gent_compound_dt(void) { /* test compound data type */
for(i = 0; i < (int)sdim; i++) {
dset1[i].a = i;
dset1[i].b = (float)(i*i);
- dset1[i].c = (float)(1.0F/(i+1));
+ dset1[i].c = (float)(1.0F/(float)(i+1));
dset2[i].a = i;
- dset2[i].b = (float)(i+ i*0.1F);
+ dset2[i].b = (float)((float)i+ (float)i*0.1F);
dset4[i].a = i;
dset4[i].b = (float)(i+3);
dset5[i].a = i;
- dset5[i].b = (float)(i*0.1F);
+ dset5[i].b = (float)((float)i*0.1F);
}
@@ -1156,16 +1156,16 @@ static void gent_compound_dt2(void) { /* test compound data type */
for(i = 0; i < (int)sdim; i++) {
dset1[i].a = i;
dset1[i].b = (float)(i*i);
- dset1[i].c = (float)(1.0F/(i+1));
+ dset1[i].c = (float)(1.0F / (float)(i+ 1));
dset2[i].a = i;
- dset2[i].b = (float)(i+ i*0.1F);
+ dset2[i].b = (float)((float)i + (float)i * 0.1F);
dset4[i].a = i;
- dset4[i].b = (float)(i*1.0F);
+ dset4[i].b = (float)((float)i * 1.0F);
dset5[i].a = i;
- dset5[i].b = (float)(i*1.0F);
+ dset5[i].b = (float)((float)i * 1.0F);
}
fid = H5Fcreate(FILE9, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
@@ -1405,7 +1405,7 @@ static void gent_all(void)
space = H5Screate_simple(1, dims, NULL);
dataset = H5Dcreate2(group, "dset2.1", H5T_IEEE_F32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
for(i = 0; i < 10; i++)
- dset2_1[i] = (float)(i * 0.1F + 1);
+ dset2_1[i] = (float)((float)i * 0.1F + 1);
H5Dwrite(dataset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset2_1);
H5Sclose(space);
H5Dclose(dataset);
@@ -1416,7 +1416,7 @@ static void gent_all(void)
dataset = H5Dcreate2(group, "dset2.2", H5T_IEEE_F32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
for(i = 0; i < 3; i++)
for(j = 0; j < 5; j++)
- dset2_2[i][j] = (float)((i + 1) * j * 0.1F);
+ dset2_2[i][j] = (float)((float)(i + 1) * (float)j * 0.1F);
H5Dwrite(dataset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset2_2);
H5Sclose(space);
H5Dclose(dataset);
@@ -1584,7 +1584,7 @@ gent_many(void)
space2 = H5Screate_simple(1, dims, NULL);
attr = H5Acreate2(dataset, "attr3", H5T_IEEE_F64BE, space2, H5P_DEFAULT, H5P_DEFAULT);
for(i = 0; i < 10; i++)
- d[i] = 0.1F * i;
+ d[i] = 0.1F * (float)i;
H5Awrite(attr, H5T_NATIVE_DOUBLE, d);
H5Sclose(space2);
H5Aclose(attr);
@@ -1594,9 +1594,9 @@ gent_many(void)
for(i2 = 0; i2 < 2; i2++) {
for(i1 = 0; i1 < 2; i1++) {
for(i0 = 0; i0 < 2; i0++) {
- dset1[j].a[i3][i2][i1][i0] = i0+j;
- dset1[j].b[i3][i2][i1][i0] = (double)(i0+j);
- dset1[j].c[i3][i2][i1][i0] = (double)(i0+j+sdim);
+ dset1[j].a[i3][i2][i1][i0] = i0 + j;
+ dset1[j].b[i3][i2][i1][i0] = (double)(i0 + j);
+ dset1[j].c[i3][i2][i1][i0] = (double)((hsize_t)i0 + (hsize_t)j + sdim);
}
}
}
@@ -1899,7 +1899,7 @@ static void gent_str2(void)
block[0]=1;
for(i = 0; (hsize_t)i < sdim; i++) {
- start[0] = i;
+ start[0] = (hsize_t)i;
sprintf(buf, "This is row %1d of type H5T_STR_NULLTERM of", i);
H5Tset_size(memtype, HDstrlen(buf)+1);
H5Sselect_hyperslab(hyper_space, H5S_SELECT_SET, start, stride, count, block);
@@ -1912,7 +1912,7 @@ static void gent_str2(void)
dataset = H5Dcreate2(group, "dset2", fxdlenstr, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
for(i = 0; (hsize_t)i < sdim; i++) {
- start[0] = i;
+ start[0] = (hsize_t)i;
sprintf(buf, "This is row %1d of type H5T_STR_NULLTERM of string array", i);
H5Tset_size(memtype, HDstrlen(buf)+1);
H5Sselect_hyperslab(hyper_space, H5S_SELECT_SET, start, stride, count, block);
@@ -1932,7 +1932,7 @@ static void gent_str2(void)
dataset = H5Dcreate2(group, "dset3", fxdlenstr, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
for(i = 0;(hsize_t) i < sdim; i++) {
- start[0] = i;
+ start[0] = (hsize_t)i;
sprintf(buf, "This is row %1d of type H5T_STR_NULLPAD of", i);
H5Tset_size(memtype, HDstrlen(buf)+1);
H5Sselect_hyperslab(hyper_space, H5S_SELECT_SET, start, stride, count, block);
@@ -1946,7 +1946,7 @@ static void gent_str2(void)
dataset = H5Dcreate2(group, "dset4", fxdlenstr, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
for(i = 0; (hsize_t)i < sdim; i++) {
- start[0] = i;
+ start[0] = (hsize_t)i;
sprintf(buf, "This is row %1d of type H5T_STR_NULLPAD of string array", i);
H5Tset_size(memtype, HDstrlen(buf)+1);
H5Sselect_hyperslab(hyper_space, H5S_SELECT_SET, start, stride, count, block);
@@ -1965,7 +1965,7 @@ static void gent_str2(void)
dataset = H5Dcreate2(group, "dset5", fxdlenstr, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
for(i = 0; (hsize_t)i < sdim; i++) {
- start[0] = i;
+ start[0] = (hsize_t)i;
sprintf(buf, "This is row %1d of type H5T_STR_SPACEPAD of", i);
H5Tset_size(memtype, HDstrlen(buf) + 1);
H5Sselect_hyperslab(hyper_space, H5S_SELECT_SET, start, stride, count, block);
@@ -1979,7 +1979,7 @@ static void gent_str2(void)
dataset = H5Dcreate2(group, "dset6", fxdlenstr, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
for(i = 0; (hsize_t)i < sdim; i++) {
- start[0] = i;
+ start[0] = (hsize_t)i;
sprintf(buf, "This is row %1d of type H5T_STR_SPACEPAD of string array", i);
H5Tset_size(memtype, HDstrlen(buf) + 1);
H5Sselect_hyperslab(hyper_space, H5S_SELECT_SET, start, stride, count, block);
@@ -2065,7 +2065,7 @@ static void gent_objref(void)
dataset = H5Dcreate2(group, "Dataset1", H5T_STD_U32BE, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
for(tu32 = (uint32_t *)((void*)wbuf), i = 0; i < SPACE1_DIM1; i++)
- *tu32++ = i * 3;
+ *tu32++ = (uint32_t)(i * 3);
/* Write selection to disk */
H5Dwrite(dataset, H5T_NATIVE_UINT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf);
@@ -2170,7 +2170,7 @@ static void gent_datareg(void)
dset2 = H5Dcreate2(fid1, "Dataset2", H5T_STD_U8BE, sid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
for(tu8 = dwbuf, i = 0; i < SPACE2_DIM1 * SPACE2_DIM2; i++)
- *tu8++=i*3;
+ *tu8++ = (uint8_t)(i * 3);
/* Write selection to disk */
H5Dwrite(dset2, H5T_NATIVE_UCHAR, H5S_ALL, H5S_ALL, H5P_DEFAULT, dwbuf);
@@ -2279,7 +2279,7 @@ static void gent_attrreg(void)
dset2 = H5Dcreate2(fid1, "Dataset2", H5T_STD_U8BE, sid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
for(tu8 = dwbuf, i = 0; i < SPACE2_DIM1 * SPACE2_DIM2; i++)
- *tu8++=i*3;
+ *tu8++ = (uint8_t)(i * 3);
/* Write selection to disk */
H5Dwrite(dset2, H5T_NATIVE_UCHAR, H5S_ALL, H5S_ALL, H5P_DEFAULT, dwbuf);
@@ -2397,8 +2397,8 @@ static void gent_nestcomp(void)
for(i = 0; i< 10; i++) {
s1[i].a = i;
s1[i].b = (float)(i*i);
- s1[i].c = 1.0F/(i+1);
- s1[i].d.a = 65 + i;
+ s1[i].c = 1.0F/(float)(i + 1);
+ s1[i].d.a = (char)(65 + i);
s1[i].d.b[0] = -100.0F;
s1[i].d.b[1] = 100.0F;
}
@@ -2469,8 +2469,8 @@ static void gent_opaque(void)
hsize_t dim = 2;
for(x = 0; x < 100; x++){
- test[x][0] = x;
- test[x][1] = 99 - x;
+ test[x][0] = (char)x;
+ test[x][1] = (char)(99 - x);
}
/*
@@ -2570,8 +2570,8 @@ static void gent_vldatatypes(void)
for(i = 0; i < SPACE1_DIM1; i++) {
int j;
- wdata[i].p = HDmalloc((i + 1) * sizeof(int));
- wdata[i].len = i + 1;
+ wdata[i].p = HDmalloc((size_t)(i + 1) * sizeof(int));
+ wdata[i].len = (size_t)(i + 1);
for(j = 0; j < i + 1; j++)
((int *)wdata[i].p)[j] = i * 10 + j;
@@ -2597,12 +2597,12 @@ static void gent_vldatatypes(void)
for(i = 0; i < SPACE1_DIM1; i++) {
int j;
- wdata[i].p = HDmalloc((i + 1) * sizeof(float));
- wdata[i].len = i + 1;
+ wdata[i].p = HDmalloc((size_t)(i + 1) * sizeof(float));
+ wdata[i].len = (size_t)(i + 1);
for(j = 0; j < i + 1; j++)
- ((float *)wdata[i].p)[j] = (float)(i * 10 + ((float)j) / 10.0F);
- }
+ ((float *)wdata[i].p)[j] = (float)((float)(i * 10) + ((float)j) / 10.0F);
+ } /* end for */
/* write out the floats in little-endian format */
space = H5Screate_simple(SPACE1_RANK, dims, NULL);
@@ -2719,9 +2719,9 @@ gent_vldatatypes2(void)
static void gent_vldatatypes3(void)
{
typedef struct { /* Struct that the VL sequences are composed of */
- int i;
- float f;
- hvl_t v;
+ int i;
+ float f;
+ hvl_t v;
} s1;
s1 wdata[SPACE1_DIM1]; /* Information to write */
hid_t fid1; /* HDF5 File IDs */
@@ -2734,12 +2734,12 @@ static void gent_vldatatypes3(void)
/* Allocate and initialize VL data to write */
for(i=0; i<SPACE1_DIM1; i++) {
- wdata[i].i=i*10;
- wdata[i].f=(float)((i*20)/3.0F);
- wdata[i].v.p=HDmalloc((i+1)*sizeof(unsigned int));
- wdata[i].v.len=i+1;
- for(j=0; j<(i+1); j++)
- ((unsigned int *)wdata[i].v.p)[j]=i*10+j;
+ wdata[i].i = (int)(i * 10);
+ wdata[i].f = (float)((float)(i * 20)/3.0F);
+ wdata[i].v.p = HDmalloc((size_t)(i + 1) * sizeof(unsigned int));
+ wdata[i].v.len = (size_t)(i + 1);
+ for(j = 0; j < (i + 1); j++)
+ ((unsigned int *)wdata[i].v.p)[j] = i * 10 + j;
} /* end for */
/* Create file */
@@ -2789,8 +2789,8 @@ static void gent_vldatatypes3(void)
static void gent_vldatatypes4(void)
{
typedef struct { /* Struct that the VL sequences are composed of */
- int i;
- float f;
+ int i;
+ float f;
} s1;
hvl_t wdata[SPACE1_DIM1]; /* Information to write */
hid_t fid1; /* HDF5 File IDs */
@@ -2803,11 +2803,11 @@ static void gent_vldatatypes4(void)
/* Allocate and initialize VL data to write */
for(i=0; i<SPACE1_DIM1; i++) {
- wdata[i].p=HDmalloc((i+1)*sizeof(s1));
- wdata[i].len=i+1;
- for(j=0; j<(i+1); j++) {
- ((s1 *)wdata[i].p)[j].i=i*10+j;
- ((s1 *)wdata[i].p)[j].f=(float)((i*20+j)/3.0F);
+ wdata[i].p = HDmalloc((i + 1) * sizeof(s1));
+ wdata[i].len = i + 1;
+ for(j = 0; j < (i + 1); j++) {
+ ((s1 *)wdata[i].p)[j].i = (int)(i * 10 + j);
+ ((s1 *)wdata[i].p)[j].f = (float)((float)(i * 20 + j) / 3.0F);
} /* end for */
} /* end for */
@@ -2872,10 +2872,10 @@ static void gent_vldatatypes5(void)
wdata[i].p=NULL;
} /* end if */
else {
- wdata[i].len=i+5;
- wdata[i].p=HDmalloc(sizeof(unsigned)*(i+5));
- for(j=0; j<i+5; j++)
- ((unsigned *)wdata[i].p)[j]=j*2;
+ wdata[i].len = (size_t)(i + 5);
+ wdata[i].p = HDmalloc(sizeof(unsigned) * (size_t)(i + 5));
+ for(j = 0; j < i + 5; j++)
+ ((unsigned *)wdata[i].p)[j] = (unsigned)(j * 2);
} /* end else */
} /* end for */
@@ -3177,8 +3177,8 @@ static void gent_array4(void)
/* Initialize array data to write */
for(i=0; i<SPACE1_DIM1; i++)
for(j=0; j<ARRAY1_DIM1; j++) {
- wdata[i][j].i=i*10+j;
- wdata[i][j].f=(float)(i*2.5F+j);
+ wdata[i][j].i = i * 10 + j;
+ wdata[i][j].f = (float)((float)i * 2.5F + (float)j);
} /* end for */
/* Create file */
@@ -3244,9 +3244,9 @@ static void gent_array5(void)
/* Initialize array data to write */
for(i=0; i<SPACE1_DIM1; i++)
for(j=0; j<ARRAY1_DIM1; j++) {
- wdata[i][j].i=i*10+j;
+ wdata[i][j].i = i * 10 + j;
for(k=0; k<ARRAY1_DIM1; k++)
- wdata[i][j].f[k]=(float)(i*10+j*2.5F+k);
+ wdata[i][j].f[k] = (float)((float)i * 10 + (float)j * 2.5F + (float)k);
} /* end for */
/* Create file */
@@ -3314,10 +3314,10 @@ static void gent_array6(void)
/* Initialize array data to write */
for(i=0; i<SPACE1_DIM1; i++)
for(j=0; j<ARRAY1_DIM1; j++) {
- wdata[i][j].p=HDmalloc((i+j+1)*sizeof(unsigned int));
- wdata[i][j].len=i+j+1;
- for(k=0; k<(i+j+1); k++)
- ((unsigned int *)wdata[i][j].p)[k]=i*100+j*10+k;
+ wdata[i][j].p = HDmalloc((size_t)(i + j + 1) * sizeof(unsigned int));
+ wdata[i][j].len = (size_t)(i + j + 1);
+ for(k = 0; k < (i + j + 1); k++)
+ ((unsigned int *)wdata[i][j].p)[k] = (unsigned)(i * 100 + j * 10 + k);
} /* end for */
/* Create file */
@@ -3375,11 +3375,11 @@ static void gent_array7(void)
/* Initialize array data to write */
for(i=0; i<SPACE1_DIM1; i++)
for(j=0; j<ARRAY1_DIM1; j++) {
- wdata[i][j].p=HDmalloc((i+j+1)*(sizeof(unsigned int)*ARRAY1_DIM1));
- wdata[i][j].len=i+j+1;
- for(k=0; k<(i+j+1); k++)
- for(l=0; l<ARRAY1_DIM1; l++)
- ((unsigned int *)wdata[i][j].p)[k*ARRAY1_DIM1+l]=i*1000+j*100+k*10+l;
+ wdata[i][j].p = HDmalloc((size_t)(i + j + 1) * (sizeof(unsigned int) * ARRAY1_DIM1));
+ wdata[i][j].len = (size_t)(i + j + 1);
+ for(k = 0; k < (i + j + 1); k++)
+ for(l = 0; l<ARRAY1_DIM1; l++)
+ ((unsigned int *)wdata[i][j].p)[k * ARRAY1_DIM1 + l] = (unsigned)(i * 1000+j * 100+k * 10 + l);
} /* end for */
/* Create file */
@@ -3437,15 +3437,15 @@ static void gent_array8(void)
herr_t status = -1;
hsize_t sdims[] = {F64_DIM0};
hsize_t tdims[] = {F64_DIM1};
- int wdata[(F64_DIM1) * sizeof(int)]; /* Write buffer */
+ int wdata[F64_DIM1]; /* Write buffer */
unsigned int i;
/*
* Initialize data. i is the element in the dataspace, j and k the
* elements within the array datatype.
*/
- for (i=0; i<F64_DIM1; i++)
- wdata[i] = i;
+ for (i = 0; i < F64_DIM1; i++)
+ wdata[i] = (int)i;
/*
* Create a new file using the default properties.
@@ -3719,7 +3719,7 @@ void gent_multi(void)
sprintf(sv[mt], "%%s-%c.h5", multi_letters[mt]);
memb_name[mt] = sv[mt];
/*printf("memb_name[%d]=%s, memb_map[%d]=%d; ", mt, memb_name[mt], mt, memb_map[mt]);*/
- memb_addr[mt] = MAX(mt - 1,0) * (HADDR_MAX / 10);
+ memb_addr[mt] = (haddr_t)MAX(mt - 1, 0) * (HADDR_MAX / 10);
}
memb_map[H5FD_MEM_DEFAULT] = H5FD_MEM_SUPER;
@@ -4106,8 +4106,8 @@ static void write_attr_in(hid_t loc_id,
for(j = 0; j < 2; j++) {
int l;
- buf52[i][j].p = HDmalloc((i + 1) * sizeof(int));
- buf52[i][j].len = i + 1;
+ buf52[i][j].p = HDmalloc((size_t)(i + 1) * sizeof(int));
+ buf52[i][j].len = (size_t)(i + 1);
for(l = 0; l < i + 1; l++)
((int *)buf52[i][j].p)[l] = n++;
}
@@ -4163,7 +4163,7 @@ static void write_attr_in(hid_t loc_id,
for(i = 0; i < 4; i++) {
for(j = 0; j < 3; j++) {
for(k = 0; k < 2; k++) {
- buf23[i][j][k]=n++;
+ buf23[i][j][k] = (char)n++;
}
}
}
@@ -4189,7 +4189,7 @@ static void write_attr_in(hid_t loc_id,
for(i = 0; i < 4; i++) {
for(j = 0; j < 3; j++) {
for(k = 0; k < 2; k++) {
- buf33[i][j][k].a=n++;
+ buf33[i][j][k].a = (char)n++;
buf33[i][j][k].b=n++;
}
}
@@ -4238,8 +4238,8 @@ static void write_attr_in(hid_t loc_id,
for(k = 0; k < 2; k++) {
int l;
- buf53[i][j][k].p = HDmalloc((i + 1) * sizeof(int));
- buf53[i][j][k].len = i + 1;
+ buf53[i][j][k].p = HDmalloc((size_t)(i + 1) * sizeof(int));
+ buf53[i][j][k].len = (size_t)(i + 1);
for(l = 0; l < i + 1; l++)
((int *)buf53[i][j][k].p)[l] = n++;
}
@@ -4548,8 +4548,8 @@ static void write_dset_in(hid_t loc_id,
for(j = 0; j < 2; j++) {
int l;
- buf52[i][j].p = HDmalloc((i + 1) * sizeof(int));
- buf52[i][j].len = i + 1;
+ buf52[i][j].p = HDmalloc((size_t)(i + 1) * sizeof(int));
+ buf52[i][j].len = (size_t)(i + 1);
for(l = 0; l < i + 1; l++)
((int *)buf52[i][j].p)[l] = n++;
}
@@ -4614,13 +4614,10 @@ static void write_dset_in(hid_t loc_id,
*/
n=1;
- for(i = 0; i < 4; i++) {
- for(j = 0; j < 3; j++) {
- for(k = 0; k < 2; k++) {
- buf23[i][j][k]=n++;
- }
- }
- }
+ for(i = 0; i < 4; i++)
+ for(j = 0; j < 3; j++)
+ for(k = 0; k < 2; k++)
+ buf23[i][j][k] = (char)n++;
tid = H5Tcopy(H5T_STD_B8LE);
write_dset(loc_id,3,dims3,"bitfield3D",tid,buf23);
status = H5Tclose(tid);
@@ -4640,14 +4637,12 @@ static void write_dset_in(hid_t loc_id,
*/
n=1;
- for(i = 0; i < 4; i++) {
- for(j = 0; j < 3; j++) {
+ for(i = 0; i < 4; i++)
+ for(j = 0; j < 3; j++)
for(k = 0; k < 2; k++) {
- buf33[i][j][k].a=n++;
- buf33[i][j][k].b=n++;
+ buf33[i][j][k].a = (char)n++;
+ buf33[i][j][k].b = n++;
}
- }
- }
tid = H5Tcreate (H5T_COMPOUND, sizeof(s_t));
H5Tinsert(tid, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR);
H5Tinsert(tid, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE);
@@ -4692,8 +4687,8 @@ static void write_dset_in(hid_t loc_id,
for(k = 0; k < 2; k++) {
int l;
- buf53[i][j][k].p = HDmalloc((i + 1) * sizeof(int));
- buf53[i][j][k].len = i + 1;
+ buf53[i][j][k].p = HDmalloc(((size_t)i + 1) * sizeof(int));
+ buf53[i][j][k].len = (size_t)(i + 1);
for(l = 0; l < i + 1; l++)
((int *)buf53[i][j][k].p)[l] = n++;
}
@@ -4938,25 +4933,20 @@ static void gent_compound_complex(void)
for(m = 0; m< F41_LENGTH; m++) {
Array1[m].a = m;
- for(n = 0; n < F41_DIMb; n++) {
+ for(n = 0; n < F41_DIMb; n++)
Array1[m].b[n] = quote[n];
- }
- for(n = 0; n < F41_ARRAY_DIMc; n++) {
+ for(n = 0; n < F41_ARRAY_DIMc; n++)
Array1[m].c[n] = chararray[n];
- }
- for(n = 0; n < F41_ARRAY_DIMd1; n++) {
- for(o = 0; o < F41_ARRAY_DIMd2; o++){
- Array1[m].d[n][o] = m + n + o;
- }
- }
+ for(n = 0; n < F41_ARRAY_DIMd1; n++)
+ for(o = 0; o < F41_ARRAY_DIMd2; o++)
+ Array1[m].d[n][o] = (short)(m + n + o);
- Array1[m].e = (float)( m * 0.96F );
+ Array1[m].e = (float)((float)m * 0.96F );
- for(n = 0; n < F41_ARRAY_DIMf; n++) {
- Array1[m].f[n] = ( m * 1024.9637F );
- }
+ for(n = 0; n < F41_ARRAY_DIMf; n++)
+ Array1[m].f[n] = ((float)m * 1024.9637F );
Array1[m].g = 'm';
}
@@ -7154,8 +7144,8 @@ gent_packedbits(void)
for(i = 0; i < dims[0]; i++){
dsetu8[i][0] = valu8bits;
for(j = 1; j < dims[1]; j++)
- dsetu8[i][j] = dsetu8[i][j-1] << 1;
- valu8bits <<= 1;
+ dsetu8[i][j] = (uint8_t)(dsetu8[i][j - 1] << 1);
+ valu8bits = (uint8_t)(valu8bits << 1);
}
H5Dwrite(dataset, H5T_NATIVE_UINT8, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu8);
@@ -7171,8 +7161,8 @@ gent_packedbits(void)
for(i = 0; i < dims[0]; i++){
dsetu16[i][0] = valu16bits;
for(j = 1; j < dims[1]; j++)
- dsetu16[i][j] = dsetu16[i][j-1] << 1;
- valu16bits <<= 1;
+ dsetu16[i][j] = (uint16_t)(dsetu16[i][j-1] << 1);
+ valu16bits = (uint16_t)(valu16bits << 1);
}
H5Dwrite(dataset, H5T_NATIVE_UINT16, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu16);
@@ -7222,8 +7212,8 @@ gent_packedbits(void)
for(i = 0; i < dims[0]; i++){
dset8[i][0] = val8bits;
for(j = 1; j < dims[1]; j++)
- dset8[i][j] = dset8[i][j-1] << 1;
- val8bits <<= 1;
+ dset8[i][j] = (int8_t)(dset8[i][j-1] << 1);
+ val8bits = (int8_t)(val8bits << 1);
}
H5Dwrite(dataset, H5T_NATIVE_INT8, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset8);
@@ -7239,8 +7229,8 @@ gent_packedbits(void)
for(i = 0; i < dims[0]; i++){
dset16[i][0] = val16bits;
for(j = 1; j < dims[1]; j++)
- dset16[i][j] = dset16[i][j-1] << 1;
- val16bits <<= 1;
+ dset16[i][j] = (int16_t)(dset16[i][j-1] << 1);
+ val16bits = (int16_t)(val16bits << 1);
}
H5Dwrite(dataset, H5T_NATIVE_INT16, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset16);
@@ -7288,7 +7278,7 @@ gent_packedbits(void)
for(i = 0; i < dims[0]; i++)
for(j = 0; j < dims[1]; j++)
- dsetdbl[i][j] = 0.0001F * j + i;
+ dsetdbl[i][j] = 0.0001F * (float)j + (float)i;
H5Dwrite(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetdbl);
@@ -7336,9 +7326,9 @@ gent_attr_intsize(void)
for(i = 0; i < dims[0]; i++){
dsetu8[i][0] = valu8bits;
for(j = 1; j < dims[1]; j++) {
- dsetu8[i][j] = dsetu8[i][j-1] << 1;
+ dsetu8[i][j] = (uint8_t)(dsetu8[i][j-1] << 1);
}
- valu8bits <<= 1;
+ valu8bits = (uint8_t)(valu8bits << 1);
}
H5Awrite(attr, H5T_NATIVE_UINT8, dsetu8);
@@ -7354,9 +7344,9 @@ gent_attr_intsize(void)
for(i = 0; i < dims[0]; i++){
dsetu16[i][0] = valu16bits;
for(j = 1; j < dims[1]; j++) {
- dsetu16[i][j] = dsetu16[i][j-1] << 1;
+ dsetu16[i][j] = (uint16_t)(dsetu16[i][j-1] << 1);
}
- valu16bits <<= 1;
+ valu16bits = (uint16_t)(valu16bits << 1);
}
H5Awrite(attr, H5T_NATIVE_UINT16, dsetu16);
@@ -7408,9 +7398,9 @@ gent_attr_intsize(void)
for(i = 0; i < dims[0]; i++){
dset8[i][0] = val8bits;
for(j = 1; j < dims[1]; j++) {
- dset8[i][j] = dset8[i][j-1] << 1;
+ dset8[i][j] = (int8_t)(dset8[i][j-1] << 1);
}
- val8bits <<= 1;
+ val8bits = (int8_t)(val8bits << 1);
}
H5Awrite(attr, H5T_NATIVE_INT8, dset8);
@@ -7426,9 +7416,9 @@ gent_attr_intsize(void)
for(i = 0; i < dims[0]; i++){
dset16[i][0] = val16bits;
for(j = 1; j < dims[1]; j++) {
- dset16[i][j] = dset16[i][j-1] << 1;
+ dset16[i][j] = (int16_t)(dset16[i][j-1] << 1);
}
- val16bits <<= 1;
+ val16bits = (int16_t)(val16bits << 1);
}
H5Awrite(attr, H5T_NATIVE_INT16, dset16);
@@ -7478,7 +7468,7 @@ gent_attr_intsize(void)
for(i = 0; i < dims[0]; i++)
for(j = 0; j < dims[1]; j++)
- dsetdbl[i][j] = 0.0001F * j + i;
+ dsetdbl[i][j] = 0.0001F * (float)j + (float)i;
H5Awrite(attr, H5T_NATIVE_DOUBLE, dsetdbl);
@@ -7589,33 +7579,33 @@ static void gent_compound_intsizes(void) {
dims[0] = F70_XDIM; dims[1] = F70_YDIM8;
valu8bits = (uint8_t) ~0u; /* all 1s */
- for(n = 0; n < dims[0]; n++){
+ for(n = 0; n < (int)dims[0]; n++){
Array1[m].dsetu8[n][0] = valu8bits;
- for(o = 1; o < dims[1]; o++) {
- Array1[m].dsetu8[n][o] = Array1[m].dsetu8[n][o-1] << 1;
+ for(o = 1; o < (int)dims[1]; o++) {
+ Array1[m].dsetu8[n][o] = (uint8_t)(Array1[m].dsetu8[n][o-1] << 1);
}
- valu8bits <<= 1;
+ valu8bits = (uint8_t)(valu8bits << 1);
}
/* Array of 16 bits unsigned int */
dims[0] = F70_XDIM; dims[1] = F70_YDIM16;
valu16bits = (uint16_t) ~0u; /* all 1s */
- for(n = 0; n < dims[0]; n++){
+ for(n = 0; n < (int)dims[0]; n++){
Array1[m].dsetu16[n][0] = valu16bits;
- for(o = 1; o < dims[1]; o++) {
- Array1[m].dsetu16[n][o] = Array1[m].dsetu16[n][o-1] << 1;
+ for(o = 1; o < (int)dims[1]; o++) {
+ Array1[m].dsetu16[n][o] = (uint16_t)(Array1[m].dsetu16[n][o-1] << 1);
}
- valu16bits <<= 1;
+ valu16bits = (uint16_t)(valu16bits << 1);
}
/* Array of 32 bits unsigned int */
dims[0] = F70_XDIM; dims[1] = F70_YDIM32;
valu32bits = (uint32_t) ~0u; /* all 1s */
- for(n = 0; n < dims[0]; n++){
+ for(n = 0; n < (int)dims[0]; n++){
Array1[m].dsetu32[n][0] = valu32bits;
- for(o = 1; o < dims[1]; o++) {
+ for(o = 1; o < (int)dims[1]; o++) {
Array1[m].dsetu32[n][o] = Array1[m].dsetu32[n][o-1] << 1;
}
valu32bits <<= 1;
@@ -7625,9 +7615,9 @@ static void gent_compound_intsizes(void) {
dims[0] = F70_XDIM; dims[1] = F70_YDIM64;
valu64bits = (uint64_t) ~0Lu; /* all 1s */
- for(n = 0; n < dims[0]; n++){
+ for(n = 0; n < (int)dims[0]; n++){
Array1[m].dsetu64[n][0] = valu64bits;
- for(o = 1; o < dims[1]; o++) {
+ for(o = 1; o < (int)dims[1]; o++) {
Array1[m].dsetu64[n][o] = Array1[m].dsetu64[n][o-1] << 1;
}
valu64bits <<= 1;
@@ -7637,33 +7627,33 @@ static void gent_compound_intsizes(void) {
dims[0] = F70_XDIM; dims[1] = F70_YDIM8;
val8bits = (int8_t) ~0; /* all 1s */
- for(n = 0; n < dims[0]; n++){
+ for(n = 0; n < (int)dims[0]; n++){
Array1[m].dset8[n][0] = val8bits;
- for(o = 1; o < dims[1]; o++) {
- Array1[m].dset8[n][o] = Array1[m].dset8[n][o-1] << 1;
+ for(o = 1; o < (int)dims[1]; o++) {
+ Array1[m].dset8[n][o] = (int8_t)(Array1[m].dset8[n][o-1] << 1);
}
- val8bits <<= 1;
+ val8bits = (int8_t)(val8bits << 1);
}
/* Array of 16 bits signed int */
dims[0] = F70_XDIM; dims[1] = F70_YDIM16;
val16bits = (int16_t) ~0; /* all 1s */
- for(n = 0; n < dims[0]; n++){
+ for(n = 0; n < (int)dims[0]; n++){
Array1[m].dset16[n][0] = val16bits;
- for(o = 1; o < dims[1]; o++) {
- Array1[m].dset16[n][o] = Array1[m].dset16[n][o-1] << 1;
+ for(o = 1; o < (int)dims[1]; o++) {
+ Array1[m].dset16[n][o] = (int16_t)(Array1[m].dset16[n][o-1] << 1);
}
- val16bits <<= 1;
+ val16bits = (int16_t)(val16bits << 1);
}
/* Array of 32 bits signed int */
dims[0] = F70_XDIM; dims[1] = F70_YDIM32;
val32bits = (int32_t) ~0; /* all 1s */
- for(n = 0; n < dims[0]; n++){
+ for(n = 0; n < (int)dims[0]; n++){
Array1[m].dset32[n][0] = val32bits;
- for(o = 1; o < dims[1]; o++) {
+ for(o = 1; o < (int)dims[1]; o++) {
Array1[m].dset32[n][o] = Array1[m].dset32[n][o-1] << 1;
}
val32bits <<= 1;
@@ -7673,9 +7663,9 @@ static void gent_compound_intsizes(void) {
dims[0] = F70_XDIM; dims[1] = F70_YDIM64;
val64bits = (int64_t) ~0L; /* all 1s */
- for(n = 0; n < dims[0]; n++){
+ for(n = 0; n < (int)dims[0]; n++){
Array1[m].dset64[n][0] = val64bits;
- for(o = 1; o < dims[1]; o++) {
+ for(o = 1; o < (int)dims[1]; o++) {
Array1[m].dset64[n][o] = Array1[m].dset64[n][o-1] << 1;
}
val64bits <<= 1;
@@ -7684,9 +7674,9 @@ static void gent_compound_intsizes(void) {
/* Double Dummy set for failure tests */
dims[0] = F70_XDIM; dims[1] = F70_YDIM8;
- for(n = 0; n < dims[0]; n++)
- for(o = 0; o < dims[1]; o++)
- Array1[m].dsetdbl[n][o] = 0.0001F * o + n;
+ for(n = 0; n < (int)dims[0]; n++)
+ for(o = 0; o < (int)dims[1]; o++)
+ Array1[m].dsetdbl[n][o] = 0.0001F * (float)o + (float)n;
}
/* Create the array data type for the 8 bits signed int array */
@@ -7864,33 +7854,33 @@ static void gent_compound_attr_intsizes(void) {
dims[0] = F70_XDIM; dims[1] = F70_YDIM8;
valu8bits = (uint8_t) ~0u; /* all 1s */
- for(n = 0; n < dims[0]; n++){
+ for(n = 0; n < (int)dims[0]; n++){
Array1[m].dsetu8[n][0] = valu8bits;
- for(o = 1; o < dims[1]; o++) {
- Array1[m].dsetu8[n][o] = Array1[m].dsetu8[n][o-1] << 1;
+ for(o = 1; o < (int)dims[1]; o++) {
+ Array1[m].dsetu8[n][o] = (uint8_t)(Array1[m].dsetu8[n][o-1] << 1);
}
- valu8bits <<= 1;
+ valu8bits = (uint8_t)(valu8bits << 1);
}
/* Array of 16 bits unsigned int */
dims[0] = F70_XDIM; dims[1] = F70_YDIM16;
valu16bits = (uint16_t) ~0u; /* all 1s */
- for(n = 0; n < dims[0]; n++){
+ for(n = 0; n < (int)dims[0]; n++){
Array1[m].dsetu16[n][0] = valu16bits;
- for(o = 1; o < dims[1]; o++) {
- Array1[m].dsetu16[n][o] = Array1[m].dsetu16[n][o-1] << 1;
+ for(o = 1; o < (int)dims[1]; o++) {
+ Array1[m].dsetu16[n][o] = (uint16_t)(Array1[m].dsetu16[n][o-1] << 1);
}
- valu16bits <<= 1;
+ valu16bits = (uint16_t)(valu16bits << 1);
}
/* Array of 32 bits unsigned int */
dims[0] = F70_XDIM; dims[1] = F70_YDIM32;
valu32bits = (uint32_t) ~0u; /* all 1s */
- for(n = 0; n < dims[0]; n++){
+ for(n = 0; n < (int)dims[0]; n++){
Array1[m].dsetu32[n][0] = valu32bits;
- for(o = 1; o < dims[1]; o++) {
+ for(o = 1; o < (int)dims[1]; o++) {
Array1[m].dsetu32[n][o] = Array1[m].dsetu32[n][o-1] << 1;
}
valu32bits <<= 1;
@@ -7900,9 +7890,9 @@ static void gent_compound_attr_intsizes(void) {
dims[0] = F70_XDIM; dims[1] = F70_YDIM64;
valu64bits = (uint64_t) ~0Lu; /* all 1s */
- for(n = 0; n < dims[0]; n++){
+ for(n = 0; n < (int)dims[0]; n++){
Array1[m].dsetu64[n][0] = valu64bits;
- for(o = 1; o < dims[1]; o++) {
+ for(o = 1; o < (int)dims[1]; o++) {
Array1[m].dsetu64[n][o] = Array1[m].dsetu64[n][o-1] << 1;
}
valu64bits <<= 1;
@@ -7912,33 +7902,33 @@ static void gent_compound_attr_intsizes(void) {
dims[0] = F70_XDIM; dims[1] = F70_YDIM8;
val8bits = (int8_t) ~0; /* all 1s */
- for(n = 0; n < dims[0]; n++){
+ for(n = 0; n < (int)dims[0]; n++){
Array1[m].dset8[n][0] = val8bits;
- for(o = 1; o < dims[1]; o++) {
- Array1[m].dset8[n][o] = Array1[m].dset8[n][o-1] << 1;
+ for(o = 1; o < (int)dims[1]; o++) {
+ Array1[m].dset8[n][o] = (int8_t)(Array1[m].dset8[n][o-1] << 1);
}
- val8bits <<= 1;
+ val8bits = (int8_t)(val8bits << 1);
}
/* Array of 16 bits signed int */
dims[0] = F70_XDIM; dims[1] = F70_YDIM16;
val16bits = (int16_t) ~0; /* all 1s */
- for(n = 0; n < dims[0]; n++){
+ for(n = 0; n < (int)dims[0]; n++){
Array1[m].dset16[n][0] = val16bits;
- for(o = 1; o < dims[1]; o++) {
- Array1[m].dset16[n][o] = Array1[m].dset16[n][o-1] << 1;
+ for(o = 1; o < (int)dims[1]; o++) {
+ Array1[m].dset16[n][o] = (int16_t)(Array1[m].dset16[n][o-1] << 1);
}
- val16bits <<= 1;
+ val16bits = (int16_t)(val16bits << 1);
}
/* Array of 32 bits signed int */
dims[0] = F70_XDIM; dims[1] = F70_YDIM32;
val32bits = (int32_t) ~0; /* all 1s */
- for(n = 0; n < dims[0]; n++){
+ for(n = 0; n < (int)dims[0]; n++){
Array1[m].dset32[n][0] = val32bits;
- for(o = 1; o < dims[1]; o++) {
+ for(o = 1; o < (int)dims[1]; o++) {
Array1[m].dset32[n][o] = Array1[m].dset32[n][o-1] << 1;
}
val32bits <<= 1;
@@ -7948,9 +7938,9 @@ static void gent_compound_attr_intsizes(void) {
dims[0] = F70_XDIM; dims[1] = F70_YDIM64;
val64bits = (int64_t) ~0L; /* all 1s */
- for(n = 0; n < dims[0]; n++){
+ for(n = 0; n < (int)dims[0]; n++){
Array1[m].dset64[n][0] = val64bits;
- for(o = 1; o < dims[1]; o++) {
+ for(o = 1; o < (int)dims[1]; o++) {
Array1[m].dset64[n][o] = Array1[m].dset64[n][o-1] << 1;
}
val64bits <<= 1;
@@ -7959,9 +7949,9 @@ static void gent_compound_attr_intsizes(void) {
/* Double Dummy set for failure tests */
dims[0] = F70_XDIM; dims[1] = F70_YDIM8;
- for(n = 0; n < dims[0]; n++)
- for(o = 0; o < dims[1]; o++)
- Array1[m].dsetdbl[n][o] = 0.0001F * o + n;
+ for(n = 0; n < (int)dims[0]; n++)
+ for(o = 0; o < (int)dims[1]; o++)
+ Array1[m].dsetdbl[n][o] = 0.0001F * (float)o + (float)n;
}
/* Create the array data type for the 8 bits signed int array */
@@ -8129,17 +8119,17 @@ static void gent_nested_compound_dt(void) { /* test nested data type */
dset1[i].b = (float)(i*i);
dset2[i].a = i;
- dset2[i].b = (float)(i+i*0.1F);
+ dset2[i].b = (float)((float)i + (float)i * 0.1F);
dset2[i].c = GREEN;
for(j = 0; j < 5; j++) {
- dset3[i].a[j] = i*j;
+ dset3[i].a[j] = i * j;
for(k = 0; k < 6; k++) {
- dset3[i].b[j][k] = (float)(i*j*k*1.0F);
+ dset3[i].b[j][k] = (float)((float)i * (float)j * (float)k * 1.0F);
}
}
dset3[i].c.a = i;
- dset3[i].c.b = (float)(i*1.0F);
+ dset3[i].c.b = (float)((float)i * 1.0F);
}
fid = H5Fcreate(FILE72, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
@@ -8277,9 +8267,9 @@ gent_intscalars(void)
for(i = 0; i < dims[0]; i++){
dsetu8[i][0] = valu8bits;
for(j = 1; j < dims[1]; j++) {
- dsetu8[i][j] = dsetu8[i][j-1] << 1;
+ dsetu8[i][j] = (uint8_t)(dsetu8[i][j-1] << 1);
}
- valu8bits <<= 1;
+ valu8bits = (uint8_t)(valu8bits << 1);
}
H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu8);
@@ -8296,9 +8286,9 @@ gent_intscalars(void)
for(i = 0; i < dims[0]; i++){
dsetu16[i][0] = valu16bits;
for(j = 1; j < dims[1]; j++) {
- dsetu16[i][j] = dsetu16[i][j-1] << 1;
+ dsetu16[i][j] = (uint16_t)(dsetu16[i][j-1] << 1);
}
- valu16bits <<= 1;
+ valu16bits = (uint16_t)(valu16bits << 1);
}
H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu16);
@@ -8353,9 +8343,9 @@ gent_intscalars(void)
for(i = 0; i < dims[0]; i++){
dset8[i][0] = val8bits;
for(j = 1; j < dims[1]; j++) {
- dset8[i][j] = dset8[i][j-1] << 1;
+ dset8[i][j] = (int8_t)(dset8[i][j-1] << 1);
}
- val8bits <<= 1;
+ val8bits = (int8_t)(val8bits << 1);
}
H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset8);
@@ -8372,9 +8362,9 @@ gent_intscalars(void)
for(i = 0; i < dims[0]; i++){
dset16[i][0] = val16bits;
for(j = 1; j < dims[1]; j++) {
- dset16[i][j] = dset16[i][j-1] << 1;
+ dset16[i][j] = (int16_t)(dset16[i][j-1] << 1);
}
- val16bits <<= 1;
+ val16bits = (int16_t)(val16bits << 1);
}
H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset16);
@@ -8427,7 +8417,7 @@ gent_intscalars(void)
for(i = 0; i < dims[0]; i++)
for(j = 0; j < dims[1]; j++)
- dsetdbl[i][j] = 0.0001F * j + i;
+ dsetdbl[i][j] = 0.0001F * (float)j + (float)i;
H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetdbl);
@@ -8476,9 +8466,9 @@ gent_attr_intscalars(void)
for(i = 0; i < dims[0]; i++){
dsetu8[i][0] = valu8bits;
for(j = 1; j < dims[1]; j++) {
- dsetu8[i][j] = dsetu8[i][j-1] << 1;
+ dsetu8[i][j] = (uint8_t)(dsetu8[i][j-1] << 1);
}
- valu8bits <<= 1;
+ valu8bits = (uint8_t)(valu8bits << 1);
}
H5Awrite(attr, tid, dsetu8);
@@ -8495,9 +8485,9 @@ gent_attr_intscalars(void)
for(i = 0; i < dims[0]; i++){
dsetu16[i][0] = valu16bits;
for(j = 1; j < dims[1]; j++) {
- dsetu16[i][j] = dsetu16[i][j-1] << 1;
+ dsetu16[i][j] = (uint16_t)(dsetu16[i][j-1] << 1);
}
- valu16bits <<= 1;
+ valu16bits = (uint16_t)(valu16bits << 1);
}
H5Awrite(attr, tid, dsetu16);
@@ -8552,9 +8542,9 @@ gent_attr_intscalars(void)
for(i = 0; i < dims[0]; i++){
dset8[i][0] = val8bits;
for(j = 1; j < dims[1]; j++) {
- dset8[i][j] = dset8[i][j-1] << 1;
+ dset8[i][j] = (int8_t)(dset8[i][j-1] << 1);
}
- val8bits <<= 1;
+ val8bits = (int8_t)(val8bits << 1);
}
H5Awrite(attr, tid, dset8);
@@ -8571,9 +8561,9 @@ gent_attr_intscalars(void)
for(i = 0; i < dims[0]; i++){
dset16[i][0] = val16bits;
for(j = 1; j < dims[1]; j++) {
- dset16[i][j] = dset16[i][j-1] << 1;
+ dset16[i][j] = (int16_t)(dset16[i][j-1] << 1);
}
- val16bits <<= 1;
+ val16bits = (int16_t)(val16bits << 1);
}
H5Awrite(attr, tid, dset16);
@@ -8626,7 +8616,7 @@ gent_attr_intscalars(void)
for(i = 0; i < dims[0]; i++)
for(j = 0; j < dims[1]; j++)
- dsetdbl[i][j] = 0.0001F * j + i;
+ dsetdbl[i][j] = 0.0001F * (float)j + (float)i;
H5Awrite(attr, tid, dsetdbl);
@@ -8665,9 +8655,9 @@ gent_string_scalars(void)
memset(string, ' ', F73_XDIM * F73_YDIM8);
for(i = 0; i < dims[0]; i++) {
- string[i][0] = 'A' + i;
+ string[i][0] = (char)('A' + i);
for(j = 1; j < dims[1]; j++) {
- string[i][j] = string[i][j-1] + 1;
+ string[i][j] = (char)(string[i][j-1] + 1);
}
}
string[dims[0]-1][dims[1]-1] = 0;
@@ -8740,25 +8730,25 @@ static void gent_compound_int_array(void) {
dims[0] = F76_DIM8;
valu8bits = (uint8_t) ~0u; /* all 1s */
- for(n = 0; n < dims[0]; n++){
+ for(n = 0; n < (int)dims[0]; n++){
Cmpd1[m].dsetu8[n] = valu8bits;
- valu8bits <<= 1;
+ valu8bits = (uint8_t)(valu8bits << 1);
}
/* Array of 16 bits unsigned int */
dims[0] = F76_DIM16;
valu16bits = (uint16_t) ~0u; /* all 1s */
- for(n = 0; n < dims[0]; n++){
+ for(n = 0; n < (int)dims[0]; n++){
Cmpd1[m].dsetu16[n] = valu16bits;
- valu16bits <<= 1;
+ valu16bits = (uint16_t)(valu16bits << 1);
}
/* Array of 32 bits unsigned int */
dims[0] = F76_DIM32;
valu32bits = (uint32_t) ~0u; /* all 1s */
- for(n = 0; n < dims[0]; n++){
+ for(n = 0; n < (int)dims[0]; n++){
Cmpd1[m].dsetu32[n] = valu32bits;
valu32bits <<= 1;
}
@@ -8767,7 +8757,7 @@ static void gent_compound_int_array(void) {
dims[0] = F76_DIM64;
valu64bits = (uint64_t) ~0Lu; /* all 1s */
- for(n = 0; n < dims[0]; n++){
+ for(n = 0; n < (int)dims[0]; n++){
Cmpd1[m].dsetu64[n] = valu64bits;
valu64bits <<= 1;
}
@@ -8776,25 +8766,25 @@ static void gent_compound_int_array(void) {
dims[0] = F76_DIM8;
val8bits = (int8_t) ~0; /* all 1s */
- for(n = 0; n < dims[0]; n++){
+ for(n = 0; n < (int)dims[0]; n++){
Cmpd1[m].dset8[n] = val8bits;
- val8bits <<= 1;
+ val8bits = (int8_t)(val8bits << 1);
}
/* Array of 16 bits signed int */
dims[0] = F76_DIM16;
val16bits = (int16_t) ~0; /* all 1s */
- for(n = 0; n < dims[0]; n++){
+ for(n = 0; n < (int)dims[0]; n++){
Cmpd1[m].dset16[n] = val16bits;
- val16bits <<= 1;
+ val16bits = (int16_t)(val16bits << 1);
}
/* Array of 32 bits signed int */
dims[0] = F76_DIM32;
val32bits = (int32_t) ~0; /* all 1s */
- for(n = 0; n < dims[0]; n++){
+ for(n = 0; n < (int)dims[0]; n++){
Cmpd1[m].dset32[n] = val32bits;
val32bits <<= 1;
}
@@ -8803,7 +8793,7 @@ static void gent_compound_int_array(void) {
dims[0] = F76_DIM64;
val64bits = (int64_t) ~0L; /* all 1s */
- for(n = 0; n < dims[0]; n++){
+ for(n = 0; n < (int)dims[0]; n++){
Cmpd1[m].dset64[n] = val64bits;
val64bits <<= 1;
}
@@ -8811,8 +8801,8 @@ static void gent_compound_int_array(void) {
/* Double Dummy set for failure tests */
dims[0] = F76_DIM8;
- for(n = 0; n < dims[0]; n++)
- Cmpd1[m].dsetdbl[n] = 0.0001F + n;
+ for(n = 0; n < (int)dims[0]; n++)
+ Cmpd1[m].dsetdbl[n] = 0.0001F + (float)n;
}
/* Create the array data type for the 8 bits signed int array */
@@ -8991,14 +8981,14 @@ static void gent_compound_ints(void) {
valu8bits = (uint8_t) ~0u; /* all 1s */
Cmpd1[m].dsetu8 = valu8bits;
Cmpd2[m].dsetu8 = valu8bits;
- valu8bits <<= 1;
+ valu8bits = (uint8_t)(valu8bits << 1);
/* Array of 16 bits unsigned int */
if((m % F76_DIM16) == 0)
valu16bits = (uint16_t) ~0u; /* all 1s */
Cmpd1[m].dsetu16 = valu16bits;
Cmpd2[m].dsetu16 = valu16bits;
- valu16bits <<= 1;
+ valu16bits = (uint16_t)(valu16bits << 1);
/* Array of 32 bits unsigned int */
if((m % F76_DIM32) == 0)
@@ -9019,14 +9009,14 @@ static void gent_compound_ints(void) {
val8bits = (int8_t) ~0; /* all 1s */
Cmpd1[m].dset8 = val8bits;
Cmpd2[m].dset8 = val8bits;
- val8bits <<= 1;
+ val8bits = (int8_t)(val8bits << 1);
/* Array of 16 bits signed int */
if((m % F76_DIM16) == 0)
val16bits = (int16_t) ~0; /* all 1s */
Cmpd1[m].dset16 = val16bits;
Cmpd2[m].dset16 = val16bits;
- val16bits <<= 1;
+ val16bits = (int16_t)(val16bits << 1);
/* Array of 32 bits signed int */
if((m % F76_DIM32) == 0)
@@ -9043,8 +9033,8 @@ static void gent_compound_ints(void) {
val64bits <<= 1;
/* Double Dummy set for failure tests */
- Cmpd1[m].dsetdbl = 0.0001F + m;
- Cmpd2[m].dsetdbl = 0.0001F + m;
+ Cmpd1[m].dsetdbl = 0.0001F + (float)m;
+ Cmpd2[m].dsetdbl = 0.0001F + (float)m;
}
/* Create the dataspace */
@@ -9199,9 +9189,9 @@ gent_intattrscalars(void)
for(i = 0; i < dims[0]; i++){
dsetu8[i][0] = valu8bits;
for(j = 1; j < dims[1]; j++) {
- dsetu8[i][j] = dsetu8[i][j-1] << 1;
+ dsetu8[i][j] = (uint8_t)(dsetu8[i][j-1] << 1);
}
- valu8bits <<= 1;
+ valu8bits = (uint8_t)(valu8bits << 1);
}
H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu8);
@@ -9222,9 +9212,9 @@ gent_intattrscalars(void)
for(i = 0; i < dims[0]; i++){
dsetu16[i][0] = valu16bits;
for(j = 1; j < dims[1]; j++) {
- dsetu16[i][j] = dsetu16[i][j-1] << 1;
+ dsetu16[i][j] = (uint16_t)(dsetu16[i][j-1] << 1);
}
- valu16bits <<= 1;
+ valu16bits = (uint16_t)(valu16bits << 1);
}
H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu16);
@@ -9291,9 +9281,9 @@ gent_intattrscalars(void)
for(i = 0; i < dims[0]; i++){
dset8[i][0] = val8bits;
for(j = 1; j < dims[1]; j++) {
- dset8[i][j] = dset8[i][j-1] << 1;
+ dset8[i][j] = (int8_t)(dset8[i][j-1] << 1);
}
- val8bits <<= 1;
+ val8bits = (int8_t)(val8bits << 1);
}
H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset8);
@@ -9314,9 +9304,9 @@ gent_intattrscalars(void)
for(i = 0; i < dims[0]; i++){
dset16[i][0] = val16bits;
for(j = 1; j < dims[1]; j++) {
- dset16[i][j] = dset16[i][j-1] << 1;
+ dset16[i][j] = (int16_t)(dset16[i][j-1] << 1);
}
- val16bits <<= 1;
+ val16bits = (int16_t)(val16bits << 1);
}
H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset16);
@@ -9381,7 +9371,7 @@ gent_intattrscalars(void)
for(i = 0; i < dims[0]; i++)
for(j = 0; j < dims[1]; j++)
- dsetdbl[i][j] = 0.0001F * j + i;
+ dsetdbl[i][j] = 0.0001F * (float)j + (float)i;
H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetdbl);
/* Attribute of double */
@@ -9433,10 +9423,10 @@ gent_intsattrs(void)
dsetu8[i][0] = valu8bits;
asetu8[i*dims[1]] = dsetu8[i][0];
for(j = 1; j < dims[1]; j++) {
- dsetu8[i][j] = dsetu8[i][j-1] << 1;
+ dsetu8[i][j] = (uint8_t)(dsetu8[i][j-1] << 1);
asetu8[i*dims[1]+j] = dsetu8[i][j];
}
- valu8bits <<= 1;
+ valu8bits = (uint8_t)(valu8bits << 1);
}
H5Dwrite(dataset, H5T_NATIVE_UINT8, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu8);
@@ -9460,10 +9450,10 @@ gent_intsattrs(void)
dsetu16[i][0] = valu16bits;
asetu16[i*dims[1]] = dsetu16[i][0];
for(j = 1; j < dims[1]; j++) {
- dsetu16[i][j] = dsetu16[i][j-1] << 1;
+ dsetu16[i][j] = (uint16_t)(dsetu16[i][j-1] << 1);
asetu16[i*dims[1]+j] = dsetu16[i][j];
}
- valu16bits <<= 1;
+ valu16bits = (uint16_t)(valu16bits << 1);
}
H5Dwrite(dataset, H5T_NATIVE_UINT16, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu16);
@@ -9541,10 +9531,10 @@ gent_intsattrs(void)
dset8[i][0] = val8bits;
aset8[i*dims[1]] = dset8[i][0];
for(j = 1; j < dims[1]; j++) {
- dset8[i][j] = dset8[i][j-1] << 1;
+ dset8[i][j] = (int8_t)(dset8[i][j-1] << 1);
aset8[i*dims[1]+j] = dset8[i][j];
}
- val8bits <<= 1;
+ val8bits = (int8_t)(val8bits << 1);
}
H5Dwrite(dataset, H5T_NATIVE_INT8, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset8);
@@ -9568,10 +9558,10 @@ gent_intsattrs(void)
dset16[i][0] = val16bits;
aset16[i*dims[1]] = dset16[i][0];
for(j = 1; j < dims[1]; j++) {
- dset16[i][j] = dset16[i][j-1] << 1;
+ dset16[i][j] = (int16_t)(dset16[i][j-1] << 1);
aset16[i*dims[1]+j] = dset16[i][j];
}
- val16bits <<= 1;
+ val16bits = (int16_t)(val16bits << 1);
}
H5Dwrite(dataset, H5T_NATIVE_INT16, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset16);
@@ -9646,7 +9636,7 @@ gent_intsattrs(void)
for(i = 0; i < dims[0]; i++)
for(j = 0; j < dims[1]; j++) {
- dsetdbl[i][j] = 0.0001F * j + i;
+ dsetdbl[i][j] = 0.0001F * (float)j + (float)i;
asetdbl[i*dims[1]+j] = dsetdbl[i][j];
}
@@ -9823,7 +9813,7 @@ static void gent_bitnopaquefields(void)
static void
gent_intsfourdims(void)
{
- hid_t fid, dataset, space, tid;
+ hid_t fid, dataset, space;
hsize_t dims[F81_RANK];
uint32_t dset1[F81_ZDIM][F81_YDIM][F81_XDIM][F81_WDIM];
unsigned int i, j, k, l;
diff --git a/tools/h5repack/h5repack_copy.c b/tools/h5repack/h5repack_copy.c
index 9c01b7e..547f61a 100644
--- a/tools/h5repack/h5repack_copy.c
+++ b/tools/h5repack/h5repack_copy.c
@@ -36,7 +36,7 @@
#define USERBLOCK_XFER_SIZE 512
/* check H5Dread()/H5Dwrite() error, e.g. memory allocation error inside the library. */
-#define CHECK_H5DRW_ERROR(_fun, _did, _mtid, _msid, _fsid, _pid, _buf) { \
+#define CHECK_H5DRW_ERROR(_fun, _fail, _did, _mtid, _msid, _fsid, _pid, _buf) { \
H5E_BEGIN_TRY { \
if(_fun(_did, _mtid, _msid, _fsid, _pid, _buf) < 0) { \
hid_t _err_num = 0; \
@@ -44,7 +44,7 @@
H5Ewalk2(H5E_DEFAULT, H5E_WALK_DOWNWARD, walk_error_callback, &_err_num); \
H5Eget_msg(_err_num, NULL, _msg, (size_t)80); \
error_msg("%s %s -- %s\n", #_fun, "failed", _msg); \
- goto done; \
+ HGOTO_DONE(_fail) \
} \
} H5E_END_TRY; \
}
@@ -97,170 +97,166 @@ static herr_t walk_error_callback(H5_ATTR_UNUSED unsigned n, const H5E_error2_t
*-------------------------------------------------------------------------
*/
-int copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options) {
+int copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options)
+{
int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */
hid_t fidin;
- hid_t fidout = -1;
- trav_table_t *travt = NULL;
- hsize_t ub_size = 0; /* size of user block */
- hid_t fcpl = H5P_DEFAULT; /* file creation property list ID */
- hid_t fapl = H5P_DEFAULT; /* file access property list ID */
-
- /*-------------------------------------------------------------------------
- * open input file
- *-------------------------------------------------------------------------
- */
- if ((fidin = h5tools_fopen(fnamein, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL,
- (size_t) 0)) < 0) {
- error_msg("<%s>: %s\n", fnamein, H5FOPENERROR);
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed");
+ hid_t fidout = -1;
+ trav_table_t *travt = NULL;
+ hsize_t ub_size = 0; /* size of user block */
+ hid_t fcpl = H5P_DEFAULT; /* file creation property list ID */
+ hid_t fapl = H5P_DEFAULT; /* file access property list ID */
+
+ /*-------------------------------------------------------------------------
+ * open input file
+ *-------------------------------------------------------------------------
+ */
+ if ((fidin = h5tools_fopen(fnamein, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, (size_t) 0)) < 0) {
+ error_msg("<%s>: %s\n", fnamein, H5FOPENERROR);
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
}
- /* get user block size and file space strategy/threshold */
- {
- hid_t fcpl_in; /* file creation property list ID for input file */
+ /* get user block size and file space strategy/threshold */
+ {
+ hid_t fcpl_in; /* file creation property list ID for input file */
- if ((fcpl_in = H5Fget_create_plist(fidin)) < 0) {
- error_msg("failed to retrieve file creation property list\n");
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed");
+ if ((fcpl_in = H5Fget_create_plist(fidin)) < 0) {
+ error_msg("failed to retrieve file creation property list\n");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
}
- if (H5Pget_userblock(fcpl_in, &ub_size) < 0) {
- error_msg("failed to retrieve userblock size\n");
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed");
+ if (H5Pget_userblock(fcpl_in, &ub_size) < 0) {
+ error_msg("failed to retrieve userblock size\n");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
}
- if (!options->fs_strategy) {
- if (H5Pget_file_space(fcpl_in, &options->fs_strategy, NULL) < 0) {
- error_msg("failed to retrieve file space strategy\n");
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed");
+ if (!options->fs_strategy) {
+ if (H5Pget_file_space(fcpl_in, &options->fs_strategy, NULL) < 0) {
+ error_msg("failed to retrieve file space strategy\n");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
}
- }
+ }
- if (!options->fs_threshold) {
- if (H5Pget_file_space(fcpl_in, NULL, &options->fs_threshold) < 0) {
- error_msg("failed to retrieve file space threshold\n");
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed");
+ if (!options->fs_threshold) {
+ if (H5Pget_file_space(fcpl_in, NULL, &options->fs_threshold) < 0) {
+ error_msg("failed to retrieve file space threshold\n");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
}
- }
+ }
- if (H5Pclose(fcpl_in) < 0) {
- error_msg("failed to close property list\n");
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed");
+ if (H5Pclose(fcpl_in) < 0) {
+ error_msg("failed to close property list\n");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
}
- }
+ }
- /* Check if we need to create a non-default file creation property list */
- if (options->latest || ub_size > 0) {
- /* Create file creation property list */
- if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) {
- error_msg("fail to create a file creation property list\n");
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed");
+ /* Check if we need to create a non-default file creation property list */
+ if (options->latest || ub_size > 0) {
+ /* Create file creation property list */
+ if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) {
+ error_msg("fail to create a file creation property list\n");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
}
- if (ub_size > 0) {
- if (H5Pset_userblock(fcpl, ub_size) < 0) {
- error_msg("failed to set non-default userblock size\n");
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed");
+ if (ub_size > 0) {
+ if (H5Pset_userblock(fcpl, ub_size) < 0) {
+ error_msg("failed to set non-default userblock size\n");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
}
- }
+ }
- if (options->latest) {
- unsigned i = 0, nindex = 0, mesg_type_flags[5], min_mesg_sizes[5];
+ if (options->latest) {
+ unsigned i = 0, nindex = 0, mesg_type_flags[5], min_mesg_sizes[5];
- /* Adjust group creation parameters for root group */
- /* (So that it is created in "dense storage" form) */
- if (H5Pset_link_phase_change(fcpl, (unsigned) options->grp_compact,
- (unsigned) options->grp_indexed) < 0) {
- error_msg(
- "fail to adjust group creation parameters for root group\n");
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed");
+ /* Adjust group creation parameters for root group */
+ /* (So that it is created in "dense storage" form) */
+ if (H5Pset_link_phase_change(fcpl, (unsigned) options->grp_compact,
+ (unsigned) options->grp_indexed) < 0) {
+ error_msg("fail to adjust group creation parameters for root group\n");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
}
- for (i = 0; i < 5; i++) {
- if (options->msg_size[i] > 0) {
- switch (i) {
- case 0:
- mesg_type_flags[nindex] = H5O_SHMESG_SDSPACE_FLAG;
- break;
-
- case 1:
- mesg_type_flags[nindex] = H5O_SHMESG_DTYPE_FLAG;
- break;
-
- case 2:
- mesg_type_flags[nindex] = H5O_SHMESG_FILL_FLAG;
- break;
-
- case 3:
- mesg_type_flags[nindex] = H5O_SHMESG_PLINE_FLAG;
- break;
-
- case 4:
- mesg_type_flags[nindex] = H5O_SHMESG_ATTR_FLAG;
- break;
- default:
- break;
- } /* end switch */
- min_mesg_sizes[nindex] = (unsigned) options->msg_size[i];
-
- nindex++;
- } /* end if */
- } /* end for */
-
- if (nindex > 0) {
- if (H5Pset_shared_mesg_nindexes(fcpl, nindex) < 0) {
- error_msg(
- "fail to set the number of shared object header message indexes\n");
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed");
+ for (i = 0; i < 5; i++) {
+ if (options->msg_size[i] > 0) {
+ switch (i) {
+ case 0:
+ mesg_type_flags[nindex] = H5O_SHMESG_SDSPACE_FLAG;
+ break;
+
+ case 1:
+ mesg_type_flags[nindex] = H5O_SHMESG_DTYPE_FLAG;
+ break;
+
+ case 2:
+ mesg_type_flags[nindex] = H5O_SHMESG_FILL_FLAG;
+ break;
+
+ case 3:
+ mesg_type_flags[nindex] = H5O_SHMESG_PLINE_FLAG;
+ break;
+
+ case 4:
+ mesg_type_flags[nindex] = H5O_SHMESG_ATTR_FLAG;
+ break;
+
+ default:
+ break;
+ } /* end switch */
+ min_mesg_sizes[nindex] = (unsigned) options->msg_size[i];
+
+ nindex++;
+ } /* end if */
+ } /* end for */
+
+ if (nindex > 0) {
+ if (H5Pset_shared_mesg_nindexes(fcpl, nindex) < 0) {
+ error_msg("fail to set the number of shared object header message indexes\n");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
}
- /* msg_size[0]=dataspace, 1=datatype, 2=file value, 3=filter pipleline, 4=attribute */
- for (i = 0; i < (nindex - 1); i++) {
- if (H5Pset_shared_mesg_index(fcpl, i, mesg_type_flags[i],
- min_mesg_sizes[i]) < 0) {
- error_msg(
- "fail to configure the specified shared object header message index\n");
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed");
+ /* msg_size[0]=dataspace, 1=datatype, 2=file value, 3=filter pipleline, 4=attribute */
+ for (i = 0; i < (nindex - 1); i++) {
+ if (H5Pset_shared_mesg_index(fcpl, i, mesg_type_flags[i], min_mesg_sizes[i]) < 0) {
+ error_msg("fail to configure the specified shared object header message index\n");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
} /* end if */
- } /* end for */
- } /* if (nindex>0) */
+ } /* end for */
+ } /* if (nindex>0) */
- /* Create file access property list */
- if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) {
- error_msg("Could not create file access property list\n");
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed");
+ /* Create file access property list */
+ if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) {
+ error_msg("Could not create file access property list\n");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
} /* end if */
- if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) {
- error_msg(
- "Could not set property for using latest version of the format\n");
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed");
+ if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) {
+ error_msg("Could not set property for using latest version of the format\n");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
} /* end if */
- } /* end if */
- } /* end if */
+ } /* end if */
+ } /* end if */
#if defined (H5REPACK_DEBUG_USER_BLOCK)
- print_user_block(fnamein, fidin);
+print_user_block(fnamein, fidin);
#endif
- /*-------------------------------------------------------------------------
- * set the new user userblock options in the FCPL (before H5Fcreate )
- *-------------------------------------------------------------------------
- */
- if (options->ublock_size > 0) {
- /* either use the FCPL already created or create a new one */
- if (fcpl == H5P_DEFAULT) {
- /* create a file creation property list */
- if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) {
- error_msg("fail to create a file creation property list\n");
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed");
+ /*-------------------------------------------------------------------------
+ * set the new user userblock options in the FCPL (before H5Fcreate )
+ *-------------------------------------------------------------------------
+ */
+ if (options->ublock_size > 0) {
+ /* either use the FCPL already created or create a new one */
+ if (fcpl == H5P_DEFAULT) {
+ /* create a file creation property list */
+ if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) {
+ error_msg("fail to create a file creation property list\n");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
}
- }
+ }
/* set user block size */
if (H5Pset_userblock(fcpl, options->ublock_size) < 0) {
error_msg("failed to set userblock size\n");
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
}
}
@@ -274,13 +270,13 @@ int copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options)
/* create a file access property list */
if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) {
error_msg("Could not create file access property list\n");
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
}
}
if (H5Pset_alignment(fapl, options->threshold, options->alignment) < 0) {
error_msg("failed to set alignment\n");
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
}
}
@@ -294,13 +290,13 @@ int copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options)
/* create a file access property list */
if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) {
error_msg("Could not create file access property list\n");
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
}
}
if (H5Pset_meta_block_size(fapl, options->meta_block_size) < 0) {
error_msg("failed to set metadata block size\n");
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
}
}
@@ -314,14 +310,14 @@ int copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options)
/* create a file creation property list */
if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) {
error_msg("fail to create a file creation property list\n");
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
}
}
/* set file space strategy and free space threshold */
if (H5Pset_file_space(fcpl, options->fs_strategy, options->fs_threshold) < 0) {
error_msg("failed to set file space strategy & threshold \n");
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
}
/*-------------------------------------------------------------------------
@@ -333,7 +329,7 @@ int copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options)
if ((fidout = H5Fcreate(fnameout, H5F_ACC_TRUNC, fcpl, fapl)) < 0) {
error_msg("<%s>: Could not create file\n", fnameout);
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
}
/*-------------------------------------------------------------------------
@@ -341,95 +337,91 @@ int copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options)
*-------------------------------------------------------------------------
*/
if (options->ublock_size > 0) {
- if (copy_user_block(options->ublock_filename, fnameout,
- options->ublock_size) < 0) {
+ if (copy_user_block(options->ublock_filename, fnameout, options->ublock_size) < 0) {
error_msg("Could not copy user block. Exiting...\n");
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
}
}
- /*-------------------------------------------------------------------------
- * get list of objects
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * get list of objects
+ *-------------------------------------------------------------------------
+ */
- /* init table */
- trav_table_init(&travt);
+ /* init table */
+ trav_table_init(&travt);
- /* get the list of objects in the file */
- if (h5trav_gettable(fidin, travt) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed");
+ /* get the list of objects in the file */
+ if (h5trav_gettable(fidin, travt) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
- /*-------------------------------------------------------------------------
- * do the copy
- *-------------------------------------------------------------------------
- */
- if (do_copy_objects(fidin, fidout, travt, options) < 0) {
- error_msg("<%s>: Could not copy data to: %s\n", fnamein, fnameout);
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed");
+ /*-------------------------------------------------------------------------
+ * do the copy
+ *-------------------------------------------------------------------------
+ */
+ if (do_copy_objects(fidin, fidout, travt, options) < 0) {
+ error_msg("<%s>: Could not copy data to: %s\n", fnamein, fnameout);
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
} /* end if */
- /*-------------------------------------------------------------------------
- * do the copy of referenced objects
- * and create hard links
- *-------------------------------------------------------------------------
- */
- if (do_copy_refobjs(fidin, fidout, travt, options) < 0) {
- printf("h5repack: <%s>: Could not copy data to: %s\n", fnamein,
- fnameout);
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed");
+ /*-------------------------------------------------------------------------
+ * do the copy of referenced objects
+ * and create hard links
+ *-------------------------------------------------------------------------
+ */
+ if (do_copy_refobjs(fidin, fidout, travt, options) < 0) {
+ printf("h5repack: <%s>: Could not copy data to: %s\n", fnamein, fnameout);
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
}
- /*-------------------------------------------------------------------------
- * close
- *-------------------------------------------------------------------------
- */
-
- if (fapl > 0)
- H5Pclose(fapl);
+ /*-------------------------------------------------------------------------
+ * close
+ *-------------------------------------------------------------------------
+ */
- if (fcpl > 0)
- H5Pclose(fcpl);
+ if (fapl > 0)
+ H5Pclose(fapl);
- H5Fclose(fidin);
- H5Fclose(fidout);
+ if (fcpl > 0)
+ H5Pclose(fcpl);
- /* free table */
- trav_table_free(travt);
- travt = NULL;
+ H5Fclose(fidin);
+ H5Fclose(fidout);
- /*-------------------------------------------------------------------------
- * write only the input file user block if there is no user block file input
- *-------------------------------------------------------------------------
- */
+ /* free table */
+ trav_table_free(travt);
+ travt = NULL;
- if (ub_size > 0 && options->ublock_size == 0) {
- if (copy_user_block(fnamein, fnameout, ub_size) < 0) {
- error_msg("Could not copy user block. Exiting...\n");
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed");
+ /*-------------------------------------------------------------------------
+ * write only the input file user block if there is no user block file input
+ *-------------------------------------------------------------------------
+ */
- }
- }
+ if (ub_size > 0 && options->ublock_size == 0) {
+ if (copy_user_block(fnamein, fnameout, ub_size) < 0) {
+ error_msg("Could not copy user block. Exiting...\n");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
+ }
+ }
- return 0;
+ return 0;
- /*-------------------------------------------------------------------------
- * out
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * out
+ *-------------------------------------------------------------------------
+ */
done:
- H5E_BEGIN_TRY
- {
- H5Pclose(fapl);
- H5Pclose(fcpl);
- H5Fclose(fidin);
- H5Fclose(fidout);
- }H5E_END_TRY;
- if (travt)
- trav_table_free(travt);
-
- return -1;
+ H5E_BEGIN_TRY {
+ H5Pclose(fapl);
+ H5Pclose(fcpl);
+ H5Fclose(fidin);
+ H5Fclose(fidout);
+ } H5E_END_TRY;
+ if (travt)
+ trav_table_free(travt);
+
+ return ret_value;
}
/*-------------------------------------------------------------------------
@@ -470,133 +462,126 @@ done:
*-----------------------------------------*/
int Get_hyperslab(hid_t dcpl_id, int rank_dset, hsize_t dims_dset[],
- size_t size_datum, hsize_t dims_hslab[], hsize_t * hslab_nbytes_p) {
+ size_t size_datum, hsize_t dims_hslab[], hsize_t * hslab_nbytes_p)
+{
int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */
- int status = 0;
- int k;
- H5D_layout_t dset_layout;
- int rank_chunk;
- hsize_t dims_chunk[H5S_MAX_RANK];
- hsize_t size_chunk = 1;
- hsize_t nchunk_fit; /* number of chunks that fits in hyperslab buffer (H5TOOLS_BUFSIZE) */
- hsize_t ndatum_fit; /* number of dataum that fits in hyperslab buffer (H5TOOLS_BUFSIZE) */
- hsize_t chunk_dims_map[H5S_MAX_RANK]; /* mapped chunk dimentions */
- hsize_t hs_dims_map[H5S_MAX_RANK]; /* mapped hyperslab dimentions */
- hsize_t hslab_nbytes; /* size of hyperslab in byte */
-
- /* init to set as size of a data element */
- hslab_nbytes = size_datum;
-
- /* get layout of dataset */
- dset_layout = H5Pget_layout(dcpl_id);
-
- /* if dataset is chunked */
- if (dset_layout == H5D_CHUNKED) {
- /* get chunk dims */
- rank_chunk = H5Pget_chunk(dcpl_id, rank_dset, dims_chunk);
- if (rank_chunk < 0) {
- status = -1;
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed");
+ int k;
+ H5D_layout_t dset_layout;
+ int rank_chunk;
+ hsize_t dims_chunk[H5S_MAX_RANK];
+ hsize_t size_chunk = 1;
+ hsize_t nchunk_fit; /* number of chunks that fits in hyperslab buffer (H5TOOLS_BUFSIZE) */
+ hsize_t ndatum_fit; /* number of dataum that fits in hyperslab buffer (H5TOOLS_BUFSIZE) */
+ hsize_t chunk_dims_map[H5S_MAX_RANK]; /* mapped chunk dimentions */
+ hsize_t hs_dims_map[H5S_MAX_RANK]; /* mapped hyperslab dimentions */
+ hsize_t hslab_nbytes; /* size of hyperslab in byte */
+
+ /* init to set as size of a data element */
+ hslab_nbytes = size_datum;
+
+ /* get layout of dataset */
+ dset_layout = H5Pget_layout(dcpl_id);
+
+ /* if dataset is chunked */
+ if (dset_layout == H5D_CHUNKED) {
+ /* get chunk dims */
+ rank_chunk = H5Pget_chunk(dcpl_id, rank_dset, dims_chunk);
+ if (rank_chunk < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
+
+ for (k = rank_dset; k > 0; --k)
+ size_chunk *= dims_chunk[k - 1];
+
+ /* figure out how many chunks can fit in the hyperslab buffer */
+ nchunk_fit = (H5TOOLS_BUFSIZE / size_datum) / size_chunk;
+
+ /* 1. if a chunk fit in hyperslab buffer */
+ if (nchunk_fit >= 1) {
+ /* Calulate a hyperslab that contains as many chunks that can fit
+ * in hyperslab buffer. Hyperslab will be increased starting from
+ * the last dimention of the dataset (see h5dump's dims output).
+ * The calculation boundary is dataset dims.
+ * In the loop, used mapping from a datum to a chunk to figure out
+ * chunk based hyperslab.
+ */
+ for (k = rank_dset; k > 0; --k) {
+ /* map dataset dimentions with a chunk dims */
+ chunk_dims_map[k - 1] = dims_dset[k - 1] / dims_chunk[k - 1];
+
+ /* if reminder exist, increse by 1 to cover partial edge chunks */
+ if (dims_dset[k - 1] % dims_chunk[k - 1] > 0)
+ chunk_dims_map[k - 1]++;
+
+ /* get mapped hyperslab dims */
+ hs_dims_map[k - 1] = MIN (nchunk_fit, chunk_dims_map[k-1]);
+
+ /* prepare next round */
+ nchunk_fit = nchunk_fit / chunk_dims_map[k - 1];
+ /* if a chunk is bigger than the rest of buffer */
+ if (nchunk_fit == 0)
+ nchunk_fit = 1;
+
+ /* get hyperslab dimentions as unmapping to actual size */
+ dims_hslab[k - 1] = MIN( (hs_dims_map[k-1] * dims_chunk[k-1]), dims_dset[k-1]);
+
+ /* calculate total size for the hyperslab */
+ hslab_nbytes *= dims_hslab[k - 1];
+ }
}
-
- for (k = rank_dset; k > 0; --k)
- size_chunk *= dims_chunk[k - 1];
-
- /* figure out how many chunks can fit in the hyperslab buffer */
- nchunk_fit = (H5TOOLS_BUFSIZE / size_datum) / size_chunk;
-
- /* 1. if a chunk fit in hyperslab buffer */
- if (nchunk_fit >= 1) {
- /* Calulate a hyperslab that contains as many chunks that can fit
- * in hyperslab buffer. Hyperslab will be increased starting from
- * the last dimention of the dataset (see h5dump's dims output).
- * The calculation boundary is dataset dims.
- * In the loop, used mapping from a datum to a chunk to figure out
- * chunk based hyperslab.
- */
- for (k = rank_dset; k > 0; --k) {
- /* map dataset dimentions with a chunk dims */
- chunk_dims_map[k - 1] = dims_dset[k - 1] / dims_chunk[k - 1];
-
- /* if reminder exist, increse by 1 to cover partial edge chunks */
- if (dims_dset[k - 1] % dims_chunk[k - 1] > 0)
- chunk_dims_map[k - 1]++;
-
- /* get mapped hyperslab dims */
- hs_dims_map[k - 1] = MIN (nchunk_fit, chunk_dims_map[k-1]);
-
- /* prepare next round */
- nchunk_fit = nchunk_fit / chunk_dims_map[k - 1];
- /* if a chunk is bigger than the rest of buffer */
- if (nchunk_fit == 0)
- nchunk_fit = 1;
-
- /* get hyperslab dimentions as unmapping to actual size */
- dims_hslab[k - 1] =
- MIN( (hs_dims_map[k-1] * dims_chunk[k-1]), dims_dset[k-1]);
-
- /* calculate total size for the hyperslab */
- hslab_nbytes *= dims_hslab[k - 1];
- }
- }
- /* 2. if a chunk is bigger than hyperslab buffer */
- else {
- /* Calulate a hyperslab that contains as many data elements that
- * can fit in hyperslab buffer. Hyperslab will be increased
- * starting from the last dimention of the chunk (see h5dump's dims
- * output).
- * The calculation boundary is a chunk dims.
- */
- for (k = rank_dset; k > 0; --k) {
- ndatum_fit = H5TOOLS_BUFSIZE / hslab_nbytes;
-
- /* if a datum is bigger than rest of buffer */
- if (ndatum_fit == 0)
- ndatum_fit = 1;
- /* get hyperslab dimentions within a chunk boundary */
- dims_hslab[k - 1] = MIN (dims_chunk[k-1], ndatum_fit);
-
- /* calculate total size for the hyperslab */
- hslab_nbytes *= dims_hslab[k - 1];
-
- if (hslab_nbytes <= 0) {
- status = -1;
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed");
- }
- }
- }
- }
- /* 3. if dataset is not chunked */
- else {
- /* Calulate a hyperslab that contains as many data elements that can
- * fit in hyperslab buffer. Hyperslab will be increased starting from
- * the last dimention of the dataset (see h5dump's dims output).
- * The calculation boundary is dataset dims.
- */
- for (k = rank_dset; k > 0; --k) {
- ndatum_fit = H5TOOLS_BUFSIZE / hslab_nbytes;
-
- /* if a datum is bigger than rest of buffer */
- if (ndatum_fit == 0)
- ndatum_fit = 1;
- /* get hyperslab dimentions within dataset boundary */
- dims_hslab[k - 1] = MIN(dims_dset[k - 1], ndatum_fit);
-
- /* calculate total size for the hyperslab */
- hslab_nbytes *= dims_hslab[k - 1];
-
- if (hslab_nbytes <= 0) {
- status = -1;
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed");
+ /* 2. if a chunk is bigger than hyperslab buffer */
+ else {
+ /* Calulate a hyperslab that contains as many data elements that
+ * can fit in hyperslab buffer. Hyperslab will be increased
+ * starting from the last dimention of the chunk (see h5dump's dims
+ * output).
+ * The calculation boundary is a chunk dims.
+ */
+ for (k = rank_dset; k > 0; --k) {
+ ndatum_fit = H5TOOLS_BUFSIZE / hslab_nbytes;
+
+ /* if a datum is bigger than rest of buffer */
+ if (ndatum_fit == 0)
+ ndatum_fit = 1;
+ /* get hyperslab dimentions within a chunk boundary */
+ dims_hslab[k - 1] = MIN (dims_chunk[k-1], ndatum_fit);
+
+ /* calculate total size for the hyperslab */
+ hslab_nbytes *= dims_hslab[k - 1];
+
+ if (hslab_nbytes <= 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
}
- }
- }
+ }
+ }
+ /* 3. if dataset is not chunked */
+ else {
+ /* Calulate a hyperslab that contains as many data elements that can
+ * fit in hyperslab buffer. Hyperslab will be increased starting from
+ * the last dimention of the dataset (see h5dump's dims output).
+ * The calculation boundary is dataset dims.
+ */
+ for (k = rank_dset; k > 0; --k) {
+ ndatum_fit = H5TOOLS_BUFSIZE / hslab_nbytes;
+
+ /* if a datum is bigger than rest of buffer */
+ if (ndatum_fit == 0)
+ ndatum_fit = 1;
+ /* get hyperslab dimentions within dataset boundary */
+ dims_hslab[k - 1] = MIN(dims_dset[k - 1], ndatum_fit);
+
+ /* calculate total size for the hyperslab */
+ hslab_nbytes *= dims_hslab[k - 1];
+
+ if (hslab_nbytes <= 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
+ }
+ }
- /* pass out the hyperslab size*/
- *hslab_nbytes_p = hslab_nbytes;
+ /* pass out the hyperslab size*/
+ *hslab_nbytes_p = hslab_nbytes;
done:
- return status;
+ return ret_value;
}
/*-------------------------------------------------------------------------
@@ -698,709 +683,637 @@ int do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt,
{
int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */
hid_t grp_in = -1; /* group ID */
- hid_t grp_out = -1; /* group ID */
- hid_t dset_in = -1; /* read dataset ID */
- hid_t dset_out = -1; /* write dataset ID */
- hid_t gcpl_in = -1; /* group creation property list */
- hid_t gcpl_out = -1; /* group creation property list */
- hid_t type_in = -1; /* named type ID */
- hid_t type_out = -1; /* named type ID */
- hid_t dcpl_in = -1; /* dataset creation property list ID */
- hid_t dcpl_out = -1; /* dataset creation property list ID */
- hid_t f_space_id = -1; /* file space ID */
- hid_t ftype_id = -1; /* file type ID */
- hid_t wtype_id = -1; /* read/write type ID */
- named_dt_t *named_dt_head = NULL; /* Pointer to the stack of named datatypes copied */
- size_t msize; /* size of type */
- hsize_t nelmts; /* number of elements in dataset */
- H5D_space_status_t space_status; /* determines whether space has been allocated for the dataset */
- int rank; /* rank of dataset */
- hsize_t dims[H5S_MAX_RANK];/* dimensions of dataset */
- hsize_t dsize_in; /* input dataset size before filter */
- hsize_t dsize_out; /* output dataset size after filter */
- int apply_s; /* flag for apply filter to small dataset sizes */
- int apply_f; /* flag for apply filter to return error on H5Dcreate */
- void *buf = NULL; /* buffer for raw data */
- void *hslab_buf = NULL; /* hyperslab buffer for raw data */
- int has_filter; /* current object has a filter */
- int req_filter; /* there was a request for a filter */
- int req_obj_layout = 0; /* request layout to current object */
- unsigned crt_order_flags; /* group creation order flag */
- unsigned i;
- unsigned u;
- int is_ref = 0;
- htri_t is_named;
- hbool_t limit_maxdims;
- hsize_t size_dset;
-
- /*-------------------------------------------------------------------------
- * copy the suppplied object list
- *-------------------------------------------------------------------------
- */
-
- if (options->verbose) {
- printf("-----------------------------------------\n");
- printf(" Type Filter (Compression) Name\n");
- printf("-----------------------------------------\n");
- }
-
- for (i = 0; i < travt->nobjs; i++) {
- /* init variables per obj */
- buf = NULL;
- limit_maxdims = FALSE;
-
- switch (travt->objs[i].type) {
-
- case H5TRAV_TYPE_UNKNOWN:
- HDassert(0);
- break;
- /*-------------------------------------------------------------------------
- * H5TRAV_TYPE_GROUP
- *-------------------------------------------------------------------------
- */
- case H5TRAV_TYPE_GROUP:
-
- if (options->verbose) {
- printf(FORMAT_OBJ, "group", travt->objs[i].name);
- }
-
- /* open input group */
- if ((grp_in = H5Gopen2(fidin, travt->objs[i].name, H5P_DEFAULT))
- < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Gopen2 failed");
-
- /* get input group creation property list */
- if ((gcpl_in = H5Gget_create_plist(grp_in)) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Gget_create_plist failed");
-
- /* query and set the group creation properties */
- if (H5Pget_link_creation_order(gcpl_in, &crt_order_flags) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pget_link_creation_order failed");
-
- /* set up group creation property list */
- if ((gcpl_out = H5Pcreate(H5P_GROUP_CREATE)) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pcreate failed");
-
- if (H5Pset_link_creation_order(gcpl_out, crt_order_flags) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pset_link_creation_order failed");
-
- /*-------------------------------------------------------------------------
- * the root is a special case, we get an ID for the root group
- * and copy its attributes using that ID
- *-------------------------------------------------------------------------
- */
- if (HDstrcmp(travt->objs[i].name, "/") == 0) {
- if ((grp_out = H5Gopen2(fidout, "/", H5P_DEFAULT)) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Gopen2 failed");
- }
- else {
-
- if (options->grp_compact > 0 || options->grp_indexed > 0) {
- if (H5Pset_link_phase_change(gcpl_out,
- (unsigned) options->grp_compact,
- (unsigned) options->grp_indexed) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pset_link_phase_change failed");
- }
-
- if ((grp_out = H5Gcreate2(fidout, travt->objs[i].name,
- H5P_DEFAULT, gcpl_out, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Gcreate2 failed");
-
- }
-
- /*-------------------------------------------------------------------------
- * copy attrs
- *-------------------------------------------------------------------------
- */
- if (copy_attr(grp_in, grp_out, &named_dt_head, travt, options) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "copy_attr failed");
-
- if (H5Pclose(gcpl_out) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed");
- if (H5Pclose(gcpl_in) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed");
- if (H5Gclose(grp_out) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Gclose failed");
- if (H5Gclose(grp_in) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Gclose failed");
-
- break;
-
- /*-------------------------------------------------------------------------
- * H5TRAV_TYPE_DATASET
- *-------------------------------------------------------------------------
- */
- case H5TRAV_TYPE_DATASET:
-
- has_filter = 0;
- req_filter = 0;
-
- /* check if global filters were requested */
- if (options->n_filter_g)
- req_filter = 1;
-
- /* check if filters were requested for individual objects */
- for (u = 0; u < options->op_tbl->nelems; u++) {
-
- if (HDstrcmp(travt->objs[i].name, options->op_tbl->objs[u].path) == 0) {
- if (options->op_tbl->objs[u].filter->filtn > 0) {
- req_filter = 1;
- }
- }
- }
-
- /* check if layout change requested individual object */
- if (options->layout_g != H5D_LAYOUT_ERROR) {
- pack_info_t *pckinfo;
- /* any dataset is specified */
- if (options->op_tbl->nelems > 0) {
- /* check if object exist */
- pckinfo = options_get_object(travt->objs[i].name,
- options->op_tbl);
- if (pckinfo) {
- req_obj_layout = 1;
- }
- }
- }
-
- /* early detection of references */
- if ((dset_in = H5Dopen2(fidin, travt->objs[i].name, H5P_DEFAULT))
- < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dopen2 failed");
- if ((ftype_id = H5Dget_type(dset_in)) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dget_type failed");
- if (H5T_REFERENCE == H5Tget_class(ftype_id))
- is_ref = 1;
-
- /* Check if the datatype is committed */
- if ((is_named = H5Tcommitted(ftype_id)) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tcommitted failed");
- if (is_named)
- if ((wtype_id = copy_named_datatype(ftype_id, fidout,
- &named_dt_head, travt, options)) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "copy_named_datatype failed");
-
- if (H5Tclose(ftype_id) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
- if (H5Dclose(dset_in) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dclose failed");
-
- /*-------------------------------------------------------------------------
- * check if we should use H5Ocopy or not
- * if there is a request for filters/layout, we read/write the object
- * otherwise we do a copy using H5Ocopy
- *-------------------------------------------------------------------------
- */
- if (options->op_tbl->nelems || options->all_filter == 1
- || options->all_layout == 1 || is_ref || is_named) {
-
- int j;
-
- if ((dset_in = H5Dopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dopen2 failed");
- if ((f_space_id = H5Dget_space(dset_in)) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dget_space failed");
- if ((ftype_id = H5Dget_type(dset_in)) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dget_type failed");
- if ((dcpl_in = H5Dget_create_plist(dset_in)) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dget_create_plist failed");
- if ((dcpl_out = H5Pcopy(dcpl_in)) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pcopy failed");
- if ((rank = H5Sget_simple_extent_ndims(f_space_id)) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed");
- HDmemset(dims, 0, sizeof dims);
- if (H5Sget_simple_extent_dims(f_space_id, dims, NULL) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed");
-
- if (H5Dget_space_status(dset_in, &space_status) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dget_space_status failed");
-
- nelmts = 1;
- for (j = 0; j < rank; j++)
- nelmts *= dims[j];
-
- /* wtype_id will have already been set if using a named dtype */
- if (!is_named) {
- if (options->use_native == 1)
- wtype_id = h5tools_get_native_type(ftype_id);
- else
- wtype_id = H5Tcopy(ftype_id);
- } /* end if */
-
- if ((msize = H5Tget_size(wtype_id)) == 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tget_size failed");
-
- /* size of current dset */
- size_dset = nelmts * msize;
-
- /*-------------------------------------------------------------------------
- * check if the dataset creation property list has filters that
- * are not registered in the current configuration
- * 1) the external filters GZIP and SZIP might not be available
- * 2) the internal filters might be turned off
- *-------------------------------------------------------------------------
- */
- if (h5tools_canreadf((travt->objs[i].name), dcpl_in) == 1) {
- apply_s = 1;
- apply_f = 1;
-
- /*-------------------------------------------------------------------------
- * references are a special case
- * we cannot just copy the buffers, but instead we recreate the reference
- * in a second traversal of the output file
- *-------------------------------------------------------------------------
- */
- if (H5T_REFERENCE != H5Tget_class(wtype_id)) {
- /* get the storage size of the input dataset */
- dsize_in = H5Dget_storage_size(dset_in);
-
- /* check for small size datasets (less than 1k) except
- * changing to COMPACT. For the reference, COMPACT is limited
- * by size 64K by library.
- */
- if (options->layout_g != H5D_COMPACT) {
- if (size_dset < options->min_comp)
- apply_s = 0;
- }
-
- /* apply the filter */
- if (apply_s) {
- if (apply_filters(travt->objs[i].name, rank, dims,
- msize, dcpl_out, options, &has_filter) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "apply_filters failed");
- }
-
- /* only if layout change requested for entire file or
- * individual obj */
- if (options->all_layout > 0 || req_obj_layout == 1)
- /*-------------------------------------------------
- * Unset the unlimited max dims if convert to other
- * than chunk layouts, because unlimited max dims
- * only can be applied to chunk layout.
- * Also perform only for targeted dataset
- * Also check for size limit to convert to compact
- *-------------------------------------------------*/
- if (options->layout_g != H5D_CHUNKED) {
- /* any dataset is specified */
- if (options->op_tbl->nelems > 0) {
- /* if current obj match specified obj */
- if (options_get_object(travt->objs[i].name,
- options->op_tbl))
- limit_maxdims = TRUE;
- }
- else { /* no dataset is specified */
- limit_maxdims = TRUE;
- }
-
- /* if convert to COMPACT */
- if (options->layout_g == H5D_COMPACT) {
- /* should be smaller than 64K */
- if (size_dset > MAX_COMPACT_DSIZE)
- limit_maxdims = FALSE;
- }
-
- /* unset unlimited max dims */
- if (limit_maxdims)
- H5Sset_extent_simple(f_space_id, rank, dims,
- NULL);
- }
-
- /*-------------------------------------------------------------------------
- * create the output dataset;
- * disable error checking in case the dataset cannot be created with the
- * modified dcpl; in that case use the original instead
- *-------------------------------------------------------------------------
- */
- dset_out = H5Dcreate2(fidout,
- travt->objs[i].name, wtype_id,
- f_space_id, H5P_DEFAULT, dcpl_out,
- H5P_DEFAULT);
-
- if (dset_out == FAIL) {
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dcreate2 failed");
- if (options->verbose)
- printf(
- " warning: could not create dataset <%s>. Applying original settings\n",
- travt->objs[i].name);
-
- if ((dset_out = H5Dcreate2(fidout,
- travt->objs[i].name, wtype_id, f_space_id,
- H5P_DEFAULT, dcpl_in, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dcreate2 failed");
- apply_f = 0;
- }
-
- /*-------------------------------------------------------------------------
- * read/write
- *-------------------------------------------------------------------------
- */
- if (nelmts > 0 && space_status != H5D_SPACE_STATUS_NOT_ALLOCATED) {
- size_t need = (size_t)(nelmts * msize); /* bytes needed */
-
- /* have to read the whole dataset if there is only one element in the dataset */
- if (need < H5TOOLS_MALLOCSIZE)
- buf = HDmalloc(need);
-
- if (buf != NULL) {
- /* read/write: use the macro to check error, e.g. memory allocation error inside the library. */
- CHECK_H5DRW_ERROR(H5Dread, dset_in, wtype_id,
- H5S_ALL, H5S_ALL, H5P_DEFAULT, buf);
- CHECK_H5DRW_ERROR(H5Dwrite, dset_out, wtype_id,
- H5S_ALL, H5S_ALL, H5P_DEFAULT, buf);
-
- /* Check if we have VL data in the dataset's
- * datatype that must be reclaimed */
- if (TRUE == H5Tdetect_class(wtype_id, H5T_VLEN))
- if (H5Dvlen_reclaim(wtype_id, f_space_id,
- H5P_DEFAULT, buf) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dvlen_reclaim failed");
- }
- else { /* possibly not enough memory, read/write by hyperslabs */
- size_t p_type_nbytes = msize; /*size of memory type */
- hsize_t p_nelmts = nelmts; /*total elements */
- hsize_t elmtno; /*counter */
- int carry; /*counter carry value */
- unsigned int vl_data = 0; /*contains VL datatypes */
-
- /* hyperslab info */
- hsize_t hslab_dims[H5S_MAX_RANK]; /*hyperslab dims */
- hsize_t hslab_nbytes; /*bytes per hyperslab */
- hsize_t hslab_nelmts; /*elements per hyperslab*/
- hid_t hslab_space; /*hyperslab data space */
-
- /* hyperslab selection info */
- hsize_t hs_sel_offset[H5S_MAX_RANK];/* selection offset */
- hsize_t hs_sel_count[H5S_MAX_RANK]; /* selection count */
- hsize_t hs_select_nelmts; /* selected elements */
- hsize_t zero[8]; /*vector of zeros */
- int k;
- H5D_layout_t dset_layout;
- hid_t dcpl_tmp = -1; /* dataset creation property list ID */
-
- /* check if we have VL data in the dataset's datatype */
- if (H5Tdetect_class(wtype_id, H5T_VLEN) == TRUE)
- vl_data = TRUE;
-
- /* check first if writing dataset is chunked,
- * if so use its chunk layout for better performance. */
- dset_layout = H5Pget_layout(dcpl_out);
- if (dset_layout == H5D_CHUNKED)
- dcpl_tmp = dcpl_out; /* writing dataset */
- else { /* if reading dataset is chunked */
- dset_layout = H5Pget_layout(dcpl_in);
- if (dset_layout == H5D_CHUNKED)
- dcpl_tmp = dcpl_in; /* reading dataset */
- }
-
- /* get hyperslab dims and size in byte */
- if (Get_hyperslab(dcpl_tmp, rank, dims,
- p_type_nbytes, hslab_dims,
- &hslab_nbytes) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "Get_hyperslab failed");
-
- hslab_buf = HDmalloc((size_t)hslab_nbytes);
-
- hslab_nelmts = hslab_nbytes / p_type_nbytes;
- hslab_space = H5Screate_simple(1, &hslab_nelmts,
- NULL);
-
- /* the hyperslab selection loop */
- HDmemset(hs_sel_offset, 0,
- sizeof hs_sel_offset);
- HDmemset(zero, 0, sizeof zero);
-
- for (elmtno = 0; elmtno < p_nelmts; elmtno +=
- hs_select_nelmts) {
- if (rank > 0) {
- /* calculate the hyperslab selections. The selection would be same as the hyperslab except for remaining edge portion of the dataset which is smaller then the hyperslab.
- */
- for (k = 0, hs_select_nelmts = 1;
- k < rank; k++) {
- /* MIN() is used to get the remaining edge portion if exist.
- * "dims[k] - hs_sel_offset[k]" is remaining edge portion that is smaller then the hyperslab.*/
- hs_sel_count[k] =
- MIN(dims[k] - hs_sel_offset[k], hslab_dims[k]);
- hs_select_nelmts *= hs_sel_count[k];
- }
-
- if (H5Sselect_hyperslab(f_space_id,
- H5S_SELECT_SET, hs_sel_offset,
- NULL, hs_sel_count, NULL) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sselect_hyperslab failed");
- if (H5Sselect_hyperslab(hslab_space,
- H5S_SELECT_SET, zero, NULL,
- &hs_select_nelmts, NULL) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sselect_hyperslab failed");
- }
- else {
- H5Sselect_all(f_space_id);
- H5Sselect_all(hslab_space);
- hs_select_nelmts = 1;
- } /* rank */
-
- /* read/write: use the macro to check error, e.g. memory allocation error inside the library. */
- CHECK_H5DRW_ERROR(H5Dread, dset_in,
- wtype_id, hslab_space, f_space_id,
- H5P_DEFAULT, hslab_buf);
- CHECK_H5DRW_ERROR(H5Dwrite, dset_out,
- wtype_id, hslab_space, f_space_id,
- H5P_DEFAULT, hslab_buf);
-
- /* reclaim any VL memory, if necessary */
- if (vl_data)
- H5Dvlen_reclaim(wtype_id, hslab_space,
- H5P_DEFAULT, hslab_buf);
-
- /* calculate the next hyperslab offset */
- for (k = rank, carry = 1; k > 0 && carry;
- --k) {
- hs_sel_offset[k - 1] += hs_sel_count[k
- - 1];
- /* if reached the end of a dim */
- if (hs_sel_offset[k - 1] == dims[k - 1])
- hs_sel_offset[k - 1] = 0;
- else
- carry = 0;
- } /* k */
- } /* elmtno */
-
- H5Sclose(hslab_space);
- /* free */
- if (hslab_buf != NULL) {
- HDfree(hslab_buf);
- hslab_buf = NULL;
- }
- } /* hyperslab read */
- } /* if (nelmts>0 && space_status==H5D_SPACE_STATUS_NOT_ALLOCATED) */
-
- /*-------------------------------------------------------------------------
- * amount of compression used
- *-------------------------------------------------------------------------
- */
- if (options->verbose) {
- double ratio = 0;
-
- /* only print the compression ration if there was a filter request */
- if (apply_s && apply_f && req_filter) {
- /* get the storage size of the output dataset */
- dsize_out = H5Dget_storage_size(dset_out);
-
- /* compression ratio = uncompressed size / compressed size */
- if (dsize_out != 0)
- ratio = (double) dsize_in
- / (double) dsize_out;
-
- print_dataset_info(dcpl_out,
- travt->objs[i].name, ratio, 1);
- }
- else
- print_dataset_info(dcpl_in, travt->objs[i].name,
- ratio, 0);
-
- /* print a message that the filter was not applied
- (in case there was a filter)
- */
- if (has_filter && apply_s == 0)
- printf(
- " <warning: filter not applied to %s. dataset smaller than %d bytes>\n",
- travt->objs[i].name,
- (int) options->min_comp);
-
- if (has_filter && apply_f == 0)
- printf(
- " <warning: could not apply the filter to %s>\n",
- travt->objs[i].name);
-
- } /* verbose */
-
- /*-------------------------------------------------------------------------
- * copy attrs
- *-------------------------------------------------------------------------
- */
- if (copy_attr(dset_in, dset_out, &named_dt_head, travt,
- options) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "copy_attr failed");
- /*close */
- if (H5Dclose(dset_out) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dclose failed");
-
- }/*!H5T_REFERENCE*/
- }/*h5tools_canreadf*/
-
- /*-------------------------------------------------------------------------
- * close
- *-------------------------------------------------------------------------
- */
- if (H5Tclose(ftype_id) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
- if (H5Tclose(wtype_id) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
- if (H5Pclose(dcpl_in) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed");
- if (H5Pclose(dcpl_out) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed");
- if (H5Sclose(f_space_id) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed");
- if (H5Dclose(dset_in) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dclose failed");
-
- }
- /*-------------------------------------------------------------------------
- * we do not have request for filter/chunking use H5Ocopy instead
- *-------------------------------------------------------------------------
- */
- else {
- hid_t pid;
-
- /* create property to pass copy options */
- if ((pid = H5Pcreate(H5P_OBJECT_COPY)) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pcreate failed");
-
- /* set options for object copy */
- if (H5Pset_copy_object(pid, H5O_COPY_WITHOUT_ATTR_FLAG) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pset_copy_object failed");
-
- /*-------------------------------------------------------------------------
- * do the copy
- *-------------------------------------------------------------------------
- */
-
- if (H5Ocopy(fidin, /* Source file or group identifier */
- travt->objs[i].name, /* Name of the source object to be copied */
- fidout, /* Destination file or group identifier */
- travt->objs[i].name, /* Name of the destination object */
- pid, /* Properties which apply to the copy */
- H5P_DEFAULT) < 0) /* Properties which apply to the new hard link */
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Ocopy failed");
-
- /* close property */
- if (H5Pclose(pid) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed");
-
- /*-------------------------------------------------------------------------
- * copy attrs manually
- *-------------------------------------------------------------------------
- */
- if ((dset_in = H5Dopen2(fidin, travt->objs[i].name, H5P_DEFAULT))
- < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dopen2 failed");
- if ((dset_out = H5Dopen2(fidout, travt->objs[i].name, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dopen2 failed");
- if (copy_attr(dset_in, dset_out, &named_dt_head, travt, options) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "copy_attr failed");
- if (H5Dclose(dset_in) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dclose failed");
- if (H5Dclose(dset_out) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dclose failed");
-
- if (options->verbose)
- printf(FORMAT_OBJ, "dset", travt->objs[i].name);
-
- } /* end do we have request for filter/chunking */
-
- break;
-
- /*-------------------------------------------------------------------------
- * H5TRAV_TYPE_NAMED_DATATYPE
- *-------------------------------------------------------------------------
- */
- case H5TRAV_TYPE_NAMED_DATATYPE:
-
- if (options->verbose)
- printf(FORMAT_OBJ, "type", travt->objs[i].name);
-
- if ((type_in = H5Topen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Topen2 failed");
+ hid_t grp_out = -1; /* group ID */
+ hid_t dset_in = -1; /* read dataset ID */
+ hid_t dset_out = -1; /* write dataset ID */
+ hid_t gcpl_in = -1; /* group creation property list */
+ hid_t gcpl_out = -1; /* group creation property list */
+ hid_t type_in = -1; /* named type ID */
+ hid_t type_out = -1; /* named type ID */
+ hid_t dcpl_in = -1; /* dataset creation property list ID */
+ hid_t dcpl_out = -1; /* dataset creation property list ID */
+ hid_t f_space_id = -1; /* file space ID */
+ hid_t ftype_id = -1; /* file type ID */
+ hid_t wtype_id = -1; /* read/write type ID */
+ named_dt_t *named_dt_head = NULL; /* Pointer to the stack of named datatypes copied */
+ size_t msize; /* size of type */
+ hsize_t nelmts; /* number of elements in dataset */
+ H5D_space_status_t space_status; /* determines whether space has been allocated for the dataset */
+ int rank; /* rank of dataset */
+ hsize_t dims[H5S_MAX_RANK];/* dimensions of dataset */
+ hsize_t dsize_in; /* input dataset size before filter */
+ hsize_t dsize_out; /* output dataset size after filter */
+ int apply_s; /* flag for apply filter to small dataset sizes */
+ int apply_f; /* flag for apply filter to return error on H5Dcreate */
+ void *buf = NULL; /* buffer for raw data */
+ void *hslab_buf = NULL; /* hyperslab buffer for raw data */
+ int has_filter; /* current object has a filter */
+ int req_filter; /* there was a request for a filter */
+ int req_obj_layout = 0; /* request layout to current object */
+ unsigned crt_order_flags; /* group creation order flag */
+ unsigned i;
+ unsigned u;
+ int is_ref = 0;
+ htri_t is_named;
+ hbool_t limit_maxdims;
+ hsize_t size_dset;
- /* Copy the datatype anonymously */
- if ((type_out = copy_named_datatype(type_in, fidout, &named_dt_head,
- travt, options)) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "copy_named_datatype failed");
-
- /* Link in to group structure */
- if (H5Lcreate_hard(type_out, ".", fidout, travt->objs[i].name,
- H5P_DEFAULT, H5P_DEFAULT) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Lcreate_hard failed");
-
- /*-------------------------------------------------------------------------
- * copy attrs
- *-------------------------------------------------------------------------
- */
- if (copy_attr(type_in, type_out, &named_dt_head, travt, options) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "copy_attr failed");
-
- if (H5Tclose(type_in) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
- if (H5Tclose(type_out) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
+ /*-------------------------------------------------------------------------
+ * copy the suppplied object list
+ *-------------------------------------------------------------------------
+ */
- break;
+ if (options->verbose) {
+ printf("-----------------------------------------\n");
+ printf(" Type Filter (Compression) Name\n");
+ printf("-----------------------------------------\n");
+ }
- /*-------------------------------------------------------------------------
- * H5TRAV_TYPE_LINK
- * H5TRAV_TYPE_UDLINK
- *
- * Only handles external links; H5Lcopy will fail for other UD link types
- * since we don't have creation or copy callbacks for them.
- *-------------------------------------------------------------------------
- */
+ for (i = 0; i < travt->nobjs; i++) {
+ /* init variables per obj */
+ buf = NULL;
+ limit_maxdims = FALSE;
+
+ switch (travt->objs[i].type) {
+ case H5TRAV_TYPE_UNKNOWN:
+ HDassert(0);
+ break;
+
+ /*-------------------------------------------------------------------------
+ * H5TRAV_TYPE_GROUP
+ *-------------------------------------------------------------------------
+ */
+ case H5TRAV_TYPE_GROUP:
+ if (options->verbose)
+ printf(FORMAT_OBJ, "group", travt->objs[i].name);
+
+ /* open input group */
+ if ((grp_in = H5Gopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gopen2 failed");
+
+ /* get input group creation property list */
+ if ((gcpl_in = H5Gget_create_plist(grp_in)) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gget_create_plist failed");
+
+ /* query and set the group creation properties */
+ if (H5Pget_link_creation_order(gcpl_in, &crt_order_flags) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_link_creation_order failed");
+
+ /* set up group creation property list */
+ if ((gcpl_out = H5Pcreate(H5P_GROUP_CREATE)) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pcreate failed");
+
+ if (H5Pset_link_creation_order(gcpl_out, crt_order_flags) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_link_creation_order failed");
+
+ /*-------------------------------------------------------------------------
+ * the root is a special case, we get an ID for the root group
+ * and copy its attributes using that ID
+ *-------------------------------------------------------------------------
+ */
+ if (HDstrcmp(travt->objs[i].name, "/") == 0) {
+ if ((grp_out = H5Gopen2(fidout, "/", H5P_DEFAULT)) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gopen2 failed");
+ }
+ else {
+ if (options->grp_compact > 0 || options->grp_indexed > 0)
+ if (H5Pset_link_phase_change(gcpl_out, (unsigned) options->grp_compact, (unsigned) options->grp_indexed) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_link_phase_change failed");
- case H5TRAV_TYPE_LINK:
- case H5TRAV_TYPE_UDLINK: {
+ if ((grp_out = H5Gcreate2(fidout, travt->objs[i].name, H5P_DEFAULT, gcpl_out, H5P_DEFAULT)) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gcreate2 failed");
+ }
- if (options->verbose)
- printf(FORMAT_OBJ, "link", travt->objs[i].name);
+ /*-------------------------------------------------------------------------
+ * copy attrs
+ *-------------------------------------------------------------------------
+ */
+ if (copy_attr(grp_in, grp_out, &named_dt_head, travt, options) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "copy_attr failed");
+
+ if (H5Pclose(gcpl_out) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
+ if (H5Pclose(gcpl_in) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
+ if (H5Gclose(grp_out) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gclose failed");
+ if (H5Gclose(grp_in) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gclose failed");
+
+ break;
+
+ /*-------------------------------------------------------------------------
+ * H5TRAV_TYPE_DATASET
+ *-------------------------------------------------------------------------
+ */
+ case H5TRAV_TYPE_DATASET:
+ has_filter = 0;
+ req_filter = 0;
+
+ /* check if global filters were requested */
+ if (options->n_filter_g)
+ req_filter = 1;
+
+ /* check if filters were requested for individual objects */
+ for (u = 0; u < options->op_tbl->nelems; u++)
+ if (HDstrcmp(travt->objs[i].name, options->op_tbl->objs[u].path) == 0)
+ if (options->op_tbl->objs[u].filter->filtn > 0)
+ req_filter = 1;
+
+ /* check if layout change requested individual object */
+ if (options->layout_g != H5D_LAYOUT_ERROR) {
+ pack_info_t *pckinfo;
+
+ /* any dataset is specified */
+ if (options->op_tbl->nelems > 0) {
+ /* check if object exist */
+ pckinfo = options_get_object(travt->objs[i].name, options->op_tbl);
+ if (pckinfo)
+ req_obj_layout = 1;
+ }
+ }
- if (H5Lcopy(fidin, travt->objs[i].name, fidout, travt->objs[i].name,
- H5P_DEFAULT, H5P_DEFAULT) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Lcopy failed");
+ /* early detection of references */
+ if ((dset_in = H5Dopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 failed");
+ if ((ftype_id = H5Dget_type(dset_in)) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_type failed");
+ if (H5T_REFERENCE == H5Tget_class(ftype_id))
+ is_ref = 1;
+
+ /* Check if the datatype is committed */
+ if ((is_named = H5Tcommitted(ftype_id)) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tcommitted failed");
+ if (is_named)
+ if ((wtype_id = copy_named_datatype(ftype_id, fidout, &named_dt_head, travt, options)) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "copy_named_datatype failed");
+
+ if (H5Tclose(ftype_id) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed");
+ if (H5Dclose(dset_in) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed");
+
+ /*-------------------------------------------------------------------------
+ * check if we should use H5Ocopy or not
+ * if there is a request for filters/layout, we read/write the object
+ * otherwise we do a copy using H5Ocopy
+ *-------------------------------------------------------------------------
+ */
+ if (options->op_tbl->nelems || options->all_filter == 1
+ || options->all_layout == 1 || is_ref || is_named) {
+
+ int j;
+
+ if ((dset_in = H5Dopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 failed");
+ if ((f_space_id = H5Dget_space(dset_in)) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_space failed");
+ if ((ftype_id = H5Dget_type(dset_in)) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_type failed");
+ if ((dcpl_in = H5Dget_create_plist(dset_in)) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_create_plist failed");
+ if ((dcpl_out = H5Pcopy(dcpl_in)) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pcopy failed");
+ if ((rank = H5Sget_simple_extent_ndims(f_space_id)) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed");
+ HDmemset(dims, 0, sizeof dims);
+ if (H5Sget_simple_extent_dims(f_space_id, dims, NULL) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed");
+ if (H5Dget_space_status(dset_in, &space_status) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_space_status failed");
+
+ nelmts = 1;
+ for (j = 0; j < rank; j++)
+ nelmts *= dims[j];
+
+ /* wtype_id will have already been set if using a named dtype */
+ if (!is_named) {
+ if (options->use_native == 1)
+ wtype_id = h5tools_get_native_type(ftype_id);
+ else
+ wtype_id = H5Tcopy(ftype_id);
+ } /* end if */
- if (options->verbose)
- printf(FORMAT_OBJ, "link", travt->objs[i].name);
+ if ((msize = H5Tget_size(wtype_id)) == 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_size failed");
+
+ /* size of current dset */
+ size_dset = nelmts * msize;
+
+ /*-------------------------------------------------------------------------
+ * check if the dataset creation property list has filters that
+ * are not registered in the current configuration
+ * 1) the external filters GZIP and SZIP might not be available
+ * 2) the internal filters might be turned off
+ *-------------------------------------------------------------------------
+ */
+ if (h5tools_canreadf((travt->objs[i].name), dcpl_in) == 1) {
+ apply_s = 1;
+ apply_f = 1;
+
+ /*-------------------------------------------------------------------------
+ * references are a special case
+ * we cannot just copy the buffers, but instead we recreate the reference
+ * in a second traversal of the output file
+ *-------------------------------------------------------------------------
+ */
+ if (H5T_REFERENCE != H5Tget_class(wtype_id)) {
+ /* get the storage size of the input dataset */
+ dsize_in = H5Dget_storage_size(dset_in);
+
+ /* check for small size datasets (less than 1k) except
+ * changing to COMPACT. For the reference, COMPACT is limited
+ * by size 64K by library.
+ */
+ if (options->layout_g != H5D_COMPACT)
+ if (size_dset < options->min_comp)
+ apply_s = 0;
+
+ /* apply the filter */
+ if (apply_s)
+ if (apply_filters(travt->objs[i].name, rank, dims, msize, dcpl_out, options, &has_filter) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "apply_filters failed");
+
+ /* only if layout change requested for entire file or
+ * individual obj */
+ if (options->all_layout > 0 || req_obj_layout == 1)
+ /*-------------------------------------------------
+ * Unset the unlimited max dims if convert to other
+ * than chunk layouts, because unlimited max dims
+ * only can be applied to chunk layout.
+ * Also perform only for targeted dataset
+ * Also check for size limit to convert to compact
+ *-------------------------------------------------*/
+ if (options->layout_g != H5D_CHUNKED) {
+ /* any dataset is specified */
+ if (options->op_tbl->nelems > 0) {
+ /* if current obj match specified obj */
+ if (options_get_object(travt->objs[i].name, options->op_tbl))
+ limit_maxdims = TRUE;
+ }
+ else /* no dataset is specified */
+ limit_maxdims = TRUE;
+
+ /* if convert to COMPACT */
+ if (options->layout_g == H5D_COMPACT)
+ /* should be smaller than 64K */
+ if (size_dset > MAX_COMPACT_DSIZE)
+ limit_maxdims = FALSE;
+
+ /* unset unlimited max dims */
+ if (limit_maxdims)
+ H5Sset_extent_simple(f_space_id, rank, dims, NULL);
+ }
+
+ /*-------------------------------------------------------------------------
+ * create the output dataset;
+ * disable error checking in case the dataset cannot be created with the
+ * modified dcpl; in that case use the original instead
+ *-------------------------------------------------------------------------
+ */
+ dset_out = H5Dcreate2(fidout, travt->objs[i].name, wtype_id, f_space_id, H5P_DEFAULT, dcpl_out, H5P_DEFAULT);
+ if (dset_out == FAIL) {
+ H5Epush2(H5tools_ERR_STACK_g, __FILE__, FUNC, __LINE__, H5tools_ERR_CLS_g, H5E_tools_g, H5E_tools_min_id_g, "H5Dcreate2 failed");
+ if (options->verbose)
+ printf(" warning: could not create dataset <%s>. Applying original settings\n", travt->objs[i].name);
+
+ if ((dset_out = H5Dcreate2(fidout, travt->objs[i].name, wtype_id, f_space_id, H5P_DEFAULT, dcpl_in, H5P_DEFAULT)) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dcreate2 failed");
+ apply_f = 0;
+ }
- }
- break;
+ /*-------------------------------------------------------------------------
+ * read/write
+ *-------------------------------------------------------------------------
+ */
+ if (nelmts > 0 && space_status != H5D_SPACE_STATUS_NOT_ALLOCATED) {
+ size_t need = (size_t)(nelmts * msize); /* bytes needed */
+
+ /* have to read the whole dataset if there is only one element in the dataset */
+ if (need < H5TOOLS_MALLOCSIZE)
+ buf = HDmalloc(need);
+
+ if (buf != NULL) {
+ /* read/write: use the macro to check error, e.g. memory allocation error inside the library. */
+ CHECK_H5DRW_ERROR(H5Dread, FAIL, dset_in, wtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf);
+ CHECK_H5DRW_ERROR(H5Dwrite, FAIL, dset_out, wtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf);
+
+ /* Check if we have VL data in the dataset's
+ * datatype that must be reclaimed */
+ if (TRUE == H5Tdetect_class(wtype_id, H5T_VLEN))
+ if (H5Dvlen_reclaim(wtype_id, f_space_id, H5P_DEFAULT, buf) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dvlen_reclaim failed");
+ }
+ else { /* possibly not enough memory, read/write by hyperslabs */
+ size_t p_type_nbytes = msize; /*size of memory type */
+ hsize_t p_nelmts = nelmts; /*total elements */
+ hsize_t elmtno; /*counter */
+ int carry; /*counter carry value */
+ unsigned int vl_data = 0; /*contains VL datatypes */
+
+ /* hyperslab info */
+ hsize_t hslab_dims[H5S_MAX_RANK]; /*hyperslab dims */
+ hsize_t hslab_nbytes; /*bytes per hyperslab */
+ hsize_t hslab_nelmts; /*elements per hyperslab*/
+ hid_t hslab_space; /*hyperslab data space */
+
+ /* hyperslab selection info */
+ hsize_t hs_sel_offset[H5S_MAX_RANK];/* selection offset */
+ hsize_t hs_sel_count[H5S_MAX_RANK]; /* selection count */
+ hsize_t hs_select_nelmts; /* selected elements */
+ hsize_t zero[8]; /*vector of zeros */
+ int k;
+ H5D_layout_t dset_layout;
+ hid_t dcpl_tmp = -1; /* dataset creation property list ID */
+
+ /* check if we have VL data in the dataset's datatype */
+ if (H5Tdetect_class(wtype_id, H5T_VLEN) == TRUE)
+ vl_data = TRUE;
+
+ /* check first if writing dataset is chunked,
+ * if so use its chunk layout for better performance. */
+ dset_layout = H5Pget_layout(dcpl_out);
+ if (dset_layout == H5D_CHUNKED)
+ dcpl_tmp = dcpl_out; /* writing dataset */
+ else { /* if reading dataset is chunked */
+ dset_layout = H5Pget_layout(dcpl_in);
+ if (dset_layout == H5D_CHUNKED)
+ dcpl_tmp = dcpl_in; /* reading dataset */
+ }
- default:
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "Object type not found");
+ /* get hyperslab dims and size in byte */
+ if (Get_hyperslab(dcpl_tmp, rank, dims, p_type_nbytes, hslab_dims, &hslab_nbytes) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Get_hyperslab failed");
+
+ hslab_buf = HDmalloc((size_t)hslab_nbytes);
+
+ hslab_nelmts = hslab_nbytes / p_type_nbytes;
+ hslab_space = H5Screate_simple(1, &hslab_nelmts, NULL);
+
+ /* the hyperslab selection loop */
+ HDmemset(hs_sel_offset, 0, sizeof hs_sel_offset);
+ HDmemset(zero, 0, sizeof zero);
+
+ for (elmtno = 0; elmtno < p_nelmts; elmtno += hs_select_nelmts) {
+ if (rank > 0) {
+ /* calculate the hyperslab selections.
+ * The selection would be same as the hyperslab
+ * except for remaining edge portion of the dataset
+ * which is smaller then the hyperslab.
+ */
+ for (k = 0, hs_select_nelmts = 1; k < rank; k++) {
+ /* MIN() is used to get the remaining edge portion if exist.
+ * "dims[k] - hs_sel_offset[k]" is remaining edge portion that is smaller then the hyperslab.*/
+ hs_sel_count[k] = MIN(dims[k] - hs_sel_offset[k], hslab_dims[k]);
+ hs_select_nelmts *= hs_sel_count[k];
+ }
+
+ if (H5Sselect_hyperslab(f_space_id, H5S_SELECT_SET, hs_sel_offset, NULL, hs_sel_count, NULL) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sselect_hyperslab failed");
+ if (H5Sselect_hyperslab(hslab_space, H5S_SELECT_SET, zero, NULL, &hs_select_nelmts, NULL) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sselect_hyperslab failed");
+ }
+ else {
+ H5Sselect_all(f_space_id);
+ H5Sselect_all(hslab_space);
+ hs_select_nelmts = 1;
+ } /* rank */
+
+ /* read/write: use the macro to check error, e.g. memory allocation error inside the library. */
+ CHECK_H5DRW_ERROR(H5Dread, FAIL, dset_in, wtype_id, hslab_space, f_space_id, H5P_DEFAULT, hslab_buf);
+ CHECK_H5DRW_ERROR(H5Dwrite, FAIL, dset_out, wtype_id, hslab_space, f_space_id, H5P_DEFAULT, hslab_buf);
+
+ /* reclaim any VL memory, if necessary */
+ if (vl_data)
+ H5Dvlen_reclaim(wtype_id, hslab_space, H5P_DEFAULT, hslab_buf);
+
+ /* calculate the next hyperslab offset */
+ for (k = rank, carry = 1; k > 0 && carry; --k) {
+ hs_sel_offset[k - 1] += hs_sel_count[k - 1];
+ /* if reached the end of a dim */
+ if (hs_sel_offset[k - 1] == dims[k - 1])
+ hs_sel_offset[k - 1] = 0;
+ else
+ carry = 0;
+ } /* k */
+ } /* elmtno */
+
+ H5Sclose(hslab_space);
+ /* free */
+ if (hslab_buf != NULL) {
+ HDfree(hslab_buf);
+ hslab_buf = NULL;
+ }
+ } /* hyperslab read */
+ } /* if (nelmts>0 && space_status==H5D_SPACE_STATUS_NOT_ALLOCATED) */
+
+ /*-------------------------------------------------------------------------
+ * amount of compression used
+ *-------------------------------------------------------------------------
+ */
+ if (options->verbose) {
+ double ratio = 0;
+
+ /* only print the compression ration if there was a filter request */
+ if (apply_s && apply_f && req_filter) {
+ /* get the storage size of the output dataset */
+ dsize_out = H5Dget_storage_size(dset_out);
+
+ /* compression ratio = uncompressed size / compressed size */
+ if (dsize_out != 0)
+ ratio = (double) dsize_in / (double) dsize_out;
+ print_dataset_info(dcpl_out, travt->objs[i].name, ratio, 1);
+ }
+ else
+ print_dataset_info(dcpl_in, travt->objs[i].name, ratio, 0);
+
+ /* print a message that the filter was not applied
+ (in case there was a filter)
+ */
+ if (has_filter && apply_s == 0)
+ printf(" <warning: filter not applied to %s. dataset smaller than %d bytes>\n", travt->objs[i].name, (int) options->min_comp);
+
+ if (has_filter && apply_f == 0)
+ printf(" <warning: could not apply the filter to %s>\n", travt->objs[i].name);
+ } /* verbose */
+
+ /*-------------------------------------------------------------------------
+ * copy attrs
+ *-------------------------------------------------------------------------
+ */
+ if (copy_attr(dset_in, dset_out, &named_dt_head, travt, options) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "copy_attr failed");
+
+ /*close */
+ if (H5Dclose(dset_out) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed");
+ }/*!H5T_REFERENCE*/
+ }/*h5tools_canreadf*/
+
+ /*-------------------------------------------------------------------------
+ * close
+ *-------------------------------------------------------------------------
+ */
+ if (H5Tclose(ftype_id) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed");
+ if (H5Tclose(wtype_id) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed");
+ if (H5Pclose(dcpl_in) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
+ if (H5Pclose(dcpl_out) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
+ if (H5Sclose(f_space_id) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sclose failed");
+ if (H5Dclose(dset_in) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed");
+ }
+ /*-------------------------------------------------------------------------
+ * we do not have request for filter/chunking use H5Ocopy instead
+ *-------------------------------------------------------------------------
+ */
+ else {
+ hid_t pid;
+
+ /* create property to pass copy options */
+ if ((pid = H5Pcreate(H5P_OBJECT_COPY)) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pcreate failed");
+
+ /* set options for object copy */
+ if (H5Pset_copy_object(pid, H5O_COPY_WITHOUT_ATTR_FLAG) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_copy_object failed");
+
+ /*-------------------------------------------------------------------------
+ * do the copy
+ *-------------------------------------------------------------------------
+ */
+
+ if (H5Ocopy(fidin, /* Source file or group identifier */
+ travt->objs[i].name, /* Name of the source object to be copied */
+ fidout, /* Destination file or group identifier */
+ travt->objs[i].name, /* Name of the destination object */
+ pid, /* Properties which apply to the copy */
+ H5P_DEFAULT) < 0) /* Properties which apply to the new hard link */
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Ocopy failed");
+
+ /* close property */
+ if (H5Pclose(pid) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
+
+ /*-------------------------------------------------------------------------
+ * copy attrs manually
+ *-------------------------------------------------------------------------
+ */
+ if ((dset_in = H5Dopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 failed");
+ if ((dset_out = H5Dopen2(fidout, travt->objs[i].name, H5P_DEFAULT)) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 failed");
+ if (copy_attr(dset_in, dset_out, &named_dt_head, travt, options) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "copy_attr failed");
+ if (H5Dclose(dset_in) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed");
+ if (H5Dclose(dset_out) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed");
+
+ if (options->verbose)
+ printf(FORMAT_OBJ, "dset", travt->objs[i].name);
+
+ } /* end do we have request for filter/chunking */
+ break;
+
+ /*-------------------------------------------------------------------------
+ * H5TRAV_TYPE_NAMED_DATATYPE
+ *-------------------------------------------------------------------------
+ */
+ case H5TRAV_TYPE_NAMED_DATATYPE:
+ if (options->verbose)
+ printf(FORMAT_OBJ, "type", travt->objs[i].name);
+
+ if ((type_in = H5Topen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Topen2 failed");
+
+ /* Copy the datatype anonymously */
+ if ((type_out = copy_named_datatype(type_in, fidout, &named_dt_head, travt, options)) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "copy_named_datatype failed");
+
+ /* Link in to group structure */
+ if (H5Lcreate_hard(type_out, ".", fidout, travt->objs[i].name, H5P_DEFAULT, H5P_DEFAULT) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Lcreate_hard failed");
+
+ /*-------------------------------------------------------------------------
+ * copy attrs
+ *-------------------------------------------------------------------------
+ */
+ if (copy_attr(type_in, type_out, &named_dt_head, travt, options) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "copy_attr failed");
+
+ if (H5Tclose(type_in) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed");
+ if (H5Tclose(type_out) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed");
+
+ break;
+
+ /*-------------------------------------------------------------------------
+ * H5TRAV_TYPE_LINK
+ * H5TRAV_TYPE_UDLINK
+ *
+ * Only handles external links; H5Lcopy will fail for other UD link types
+ * since we don't have creation or copy callbacks for them.
+ *-------------------------------------------------------------------------
+ */
+ case H5TRAV_TYPE_LINK:
+ case H5TRAV_TYPE_UDLINK:
+ if (options->verbose)
+ printf(FORMAT_OBJ, "link", travt->objs[i].name);
+
+ if (H5Lcopy(fidin, travt->objs[i].name, fidout, travt->objs[i].name, H5P_DEFAULT, H5P_DEFAULT) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Lcopy failed");
+
+ if (options->verbose)
+ printf(FORMAT_OBJ, "link", travt->objs[i].name);
+ break;
+
+ default:
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Object type not found");
} /* switch */
- /* free */
- if (buf != NULL) {
- HDfree(buf);
- buf = NULL;
- }
+ /* free */
+ if (buf != NULL) {
+ HDfree(buf);
+ buf = NULL;
+ }
+ } /* i */
- } /* i */
+ /* Finalize (link) the stack of named datatypes (if any) */
+ named_datatype_free(&named_dt_head, 0);
- /* Finalize (link) the stack of named datatypes (if any) */
- named_datatype_free(&named_dt_head, 0);
-
- return 0;
+ return ret_value;
done:
- H5E_BEGIN_TRY
- {
- H5Gclose(grp_in);
- H5Gclose(grp_out);
- H5Pclose(dcpl_in);
- H5Pclose(gcpl_in);
- H5Pclose(gcpl_out);
- H5Sclose(f_space_id);
- H5Dclose(dset_in);
- H5Dclose(dset_out);
- H5Tclose(ftype_id);
- H5Tclose(wtype_id);
- H5Tclose(type_in);
- H5Tclose(type_out);
- named_datatype_free(&named_dt_head, 1);
- }H5E_END_TRY;
- /* free */
- if (buf != NULL)
- HDfree(buf);
- if (hslab_buf != NULL)
- HDfree(hslab_buf);
- return -1;
+ H5E_BEGIN_TRY
+ {
+ H5Gclose(grp_in);
+ H5Gclose(grp_out);
+ H5Pclose(dcpl_in);
+ H5Pclose(gcpl_in);
+ H5Pclose(gcpl_out);
+ H5Sclose(f_space_id);
+ H5Dclose(dset_in);
+ H5Dclose(dset_out);
+ H5Tclose(ftype_id);
+ H5Tclose(wtype_id);
+ H5Tclose(type_in);
+ H5Tclose(type_out);
+ named_datatype_free(&named_dt_head, 1);
+ }H5E_END_TRY;
+
+ /* free */
+ if (buf != NULL)
+ HDfree(buf);
+ if (hslab_buf != NULL)
+ HDfree(hslab_buf);
+
+ return ret_value;
}
/*-------------------------------------------------------------------------
@@ -1411,101 +1324,102 @@ done:
*-------------------------------------------------------------------------
*/
static void print_dataset_info(hid_t dcpl_id, char *objname, double ratio,
- int pr) {
- char strfilter[255];
+ int pr)
+{
+ char strfilter[255];
#if defined (PRINT_DEBUG )
- char temp[255];
+ char temp[255];
#endif
- int nfilters; /* number of filters */
- unsigned filt_flags; /* filter flags */
- H5Z_filter_t filtn; /* filter identification number */
- unsigned cd_values[20]; /* filter client data values */
- size_t cd_nelmts; /* filter client number of values */
- char f_objname[256]; /* filter objname */
- int i;
-
- HDstrcpy(strfilter, "\0");
+ int nfilters; /* number of filters */
+ unsigned filt_flags; /* filter flags */
+ H5Z_filter_t filtn; /* filter identification number */
+ unsigned cd_values[20]; /* filter client data values */
+ size_t cd_nelmts; /* filter client number of values */
+ char f_objname[256]; /* filter objname */
+ int i;
- /* get information about input filters */
- if ((nfilters = H5Pget_nfilters(dcpl_id)) < 0)
- return;
+ HDstrcpy(strfilter, "\0");
- for (i = 0; i < nfilters; i++) {
- cd_nelmts = NELMTS(cd_values);
+ /* get information about input filters */
+ if ((nfilters = H5Pget_nfilters(dcpl_id)) < 0)
+ return;
- filtn = H5Pget_filter2(dcpl_id, (unsigned) i, &filt_flags, &cd_nelmts,
- cd_values, sizeof(f_objname), f_objname, NULL);
+ for (i = 0; i < nfilters; i++) {
+ cd_nelmts = NELMTS(cd_values);
- switch (filtn) {
+ filtn = H5Pget_filter2(dcpl_id, (unsigned) i, &filt_flags, &cd_nelmts,
+ cd_values, sizeof(f_objname), f_objname, NULL);
- case H5Z_FILTER_NONE:
- HDstrcat(strfilter, "NONE ");
- break;
+ switch (filtn) {
+ case H5Z_FILTER_NONE:
+ HDstrcat(strfilter, "NONE ");
+ break;
- case H5Z_FILTER_DEFLATE:
- HDstrcat(strfilter, "GZIP ");
+ case H5Z_FILTER_DEFLATE:
+ HDstrcat(strfilter, "GZIP ");
#if defined (PRINT_DEBUG)
- {
- unsigned level=cd_values[0];
- sprintf(temp,"(%d)",level);
- HDstrcat(strfilter,temp);
- }
+ {
+ unsigned level = cd_values[0];
+
+ sprintf(temp,"(%d)", level);
+ HDstrcat(strfilter, temp);
+ }
#endif
- break;
+ break;
- case H5Z_FILTER_SZIP:
- HDstrcat(strfilter, "SZIP ");
+ case H5Z_FILTER_SZIP:
+ HDstrcat(strfilter, "SZIP ");
#if defined (PRINT_DEBUG)
- {
- unsigned options_mask=cd_values[0]; /* from dcpl, not filt*/
- unsigned ppb=cd_values[1];
- sprintf(temp,"(%d,",ppb);
- HDstrcat(strfilter,temp);
- if (options_mask & H5_SZIP_EC_OPTION_MASK)
- HDstrcpy(temp,"EC) ");
- else if (options_mask & H5_SZIP_NN_OPTION_MASK)
- HDstrcpy(temp,"NN) ");
- }
- HDstrcat(strfilter,temp);
-
+ {
+ unsigned options_mask = cd_values[0]; /* from dcpl, not filt*/
+ unsigned ppb = cd_values[1];
+
+ sprintf(temp,"(%d,", ppb);
+ HDstrcat(strfilter, temp);
+ if (options_mask & H5_SZIP_EC_OPTION_MASK)
+ HDstrcpy(temp, "EC) ");
+ else if (options_mask & H5_SZIP_NN_OPTION_MASK)
+ HDstrcpy(temp, "NN) ");
+ }
+ HDstrcat(strfilter, temp);
#endif
+ break;
- break;
-
- case H5Z_FILTER_SHUFFLE:
- HDstrcat(strfilter, "SHUF ");
- break;
-
- case H5Z_FILTER_FLETCHER32:
- HDstrcat(strfilter, "FLET ");
- break;
-
- case H5Z_FILTER_NBIT:
- HDstrcat(strfilter, "NBIT ");
- break;
-
- case H5Z_FILTER_SCALEOFFSET:
- HDstrcat(strfilter, "SCALEOFFSET ");
- break;
-
- default:
- HDstrcat(strfilter, "UD ");
- break;
- } /* switch */
- }/*i*/
-
- if (!pr)
- printf(FORMAT_OBJ, "dset", objname);
- else {
- char str[255], temp[28];
- HDstrcpy(str, "dset ");
- HDstrcat(str, strfilter);
- sprintf(temp, " (%.3f:1)", ratio);
- HDstrcat(str, temp);
- printf(FORMAT_OBJ, str, objname);
- }
+ case H5Z_FILTER_SHUFFLE:
+ HDstrcat(strfilter, "SHUF ");
+ break;
+
+ case H5Z_FILTER_FLETCHER32:
+ HDstrcat(strfilter, "FLET ");
+ break;
+
+ case H5Z_FILTER_NBIT:
+ HDstrcat(strfilter, "NBIT ");
+ break;
+
+ case H5Z_FILTER_SCALEOFFSET:
+ HDstrcat(strfilter, "SCALEOFFSET ");
+ break;
+
+ default:
+ HDstrcat(strfilter, "UD ");
+ break;
+ } /* switch */
+ }/*i*/
+
+ if (!pr)
+ printf(FORMAT_OBJ, "dset", objname);
+ else {
+ char str[255], temp[28];
+
+ HDstrcpy(str, "dset ");
+ HDstrcat(str, strfilter);
+ sprintf(temp, " (%.3f:1)", ratio);
+ HDstrcat(str, temp);
+ printf(FORMAT_OBJ, str, objname);
+ }
}
/*-------------------------------------------------------------------------
@@ -1522,74 +1436,66 @@ static void print_dataset_info(hid_t dcpl_id, char *objname, double ratio,
*-------------------------------------------------------------------------
*/
static int copy_user_block(const char *infile, const char *outfile,
- hsize_t size) {
+ hsize_t size)
+{
int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */
int infid = -1, outfid = -1; /* File descriptors */
- int status = 0; /* Return value */
-
- /* User block must be any power of 2 equal to 512 or greater (512, 1024, 2048, etc.) */
- HDassert(size > 0);
-
- /* Open files */
- if ((infid = HDopen(infile, O_RDONLY, 0)) < 0) {
- status = -1;
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "HDopen failed");
- }
- if ((outfid = HDopen(outfile, O_WRONLY, 0644)) < 0) {
- status = -1;
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "HDopen failed");
- }
-
- /* Copy the userblock from the input file to the output file */
- while (size > 0) {
- ssize_t nread, nbytes; /* # of bytes transfered, etc. */
- char rbuf[USERBLOCK_XFER_SIZE]; /* Buffer for reading */
- const char *wbuf; /* Pointer into buffer, for writing */
-
- /* Read buffer from source file */
- if (size > USERBLOCK_XFER_SIZE)
- nread = HDread(infid, rbuf, (size_t)USERBLOCK_XFER_SIZE);
- else
- nread = HDread(infid, rbuf, (size_t)size);
- if (nread < 0) {
- status = -1;
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "HDread failed");
- } /* end if */
-
- /* Write buffer to destination file */
- /* (compensating for interrupted writes & checking for errors, etc.) */
- nbytes = nread;
- wbuf = rbuf;
- while (nbytes > 0) {
- ssize_t nwritten; /* # of bytes written */
-
- do {
- nwritten = HDwrite(outfid, wbuf, (size_t)nbytes);
- } while (-1 == nwritten && EINTR == errno);
- if (-1 == nwritten) { /* error */
- status = -1;
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "HDwrite failed");
- } /* end if */
- HDassert(nwritten > 0);
- HDassert(nwritten <= nbytes);
-
- /* Update # of bytes left & offset in buffer */
- nbytes -= nwritten;
- wbuf += nwritten;
- HDassert(nbytes == 0 || wbuf < (rbuf + USERBLOCK_XFER_SIZE));
- } /* end while */
- /* Update size of userblock left to transfer */
- size = size - (hsize_t) nread;
- } /* end while */
+ /* User block must be any power of 2 equal to 512 or greater (512, 1024, 2048, etc.) */
+ HDassert(size > 0);
+
+ /* Open files */
+ if ((infid = HDopen(infile, O_RDONLY, 0)) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "HDopen failed");
+ if ((outfid = HDopen(outfile, O_WRONLY, 0644)) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "HDopen failed");
+
+ /* Copy the userblock from the input file to the output file */
+ while (size > 0) {
+ ssize_t nread, nbytes; /* # of bytes transfered, etc. */
+ char rbuf[USERBLOCK_XFER_SIZE]; /* Buffer for reading */
+ const char *wbuf; /* Pointer into buffer, for writing */
+
+ /* Read buffer from source file */
+ if (size > USERBLOCK_XFER_SIZE)
+ nread = HDread(infid, rbuf, (size_t)USERBLOCK_XFER_SIZE);
+ else
+ nread = HDread(infid, rbuf, (size_t)size);
+ if (nread < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "HDread failed");
+
+ /* Write buffer to destination file */
+ /* (compensating for interrupted writes & checking for errors, etc.) */
+ nbytes = nread;
+ wbuf = rbuf;
+ while (nbytes > 0) {
+ ssize_t nwritten; /* # of bytes written */
+
+ do {
+ nwritten = HDwrite(outfid, wbuf, (size_t)nbytes);
+ } while (-1 == nwritten && EINTR == errno);
+ if (-1 == nwritten) /* error */
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "HDwrite failed");
+ HDassert(nwritten > 0);
+ HDassert(nwritten <= nbytes);
+
+ /* Update # of bytes left & offset in buffer */
+ nbytes -= nwritten;
+ wbuf += nwritten;
+ HDassert(nbytes == 0 || wbuf < (rbuf + USERBLOCK_XFER_SIZE));
+ } /* end while */
+
+ /* Update size of userblock left to transfer */
+ size = size - (hsize_t) nread;
+ } /* end while */
done:
- if (infid > 0)
- HDclose(infid);
- if (outfid > 0)
- HDclose(outfid);
+ if (infid > 0)
+ HDclose(infid);
+ if (outfid > 0)
+ HDclose(outfid);
- return status;
+ return ret_value;
}
/*-------------------------------------------------------------------------
diff --git a/tools/h5repack/h5repack_refs.c b/tools/h5repack/h5repack_refs.c
index b2755c2..f0f32c3 100644
--- a/tools/h5repack/h5repack_refs.c
+++ b/tools/h5repack/h5repack_refs.c
@@ -1,4 +1,3 @@
-
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by The HDF Group. *
* Copyright by the Board of Trustees of the University of Illinois. *
@@ -86,18 +85,18 @@ int do_copy_refobjs(hid_t fidin,
*-------------------------------------------------------------------------
*/
if((grp_out = H5Gopen2(fidout, travt->objs[i].name, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Gopen2 failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gopen2 failed");
if((grp_in = H5Gopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Gopen2 failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gopen2 failed");
if(copy_refs_attr(grp_in, grp_out, options, travt, fidout) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "copy_refs_attr failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "copy_refs_attr failed");
if(H5Gclose(grp_out) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Gclose failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gclose failed");
if(H5Gclose(grp_in) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Gclose failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gclose failed");
/*-------------------------------------------------------------------------
* check for hard links
@@ -114,26 +113,26 @@ int do_copy_refobjs(hid_t fidin,
*/
case H5TRAV_TYPE_DATASET:
if((dset_in = H5Dopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dopen2 failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 failed");
if((space_id = H5Dget_space(dset_in)) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dget_space failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_space failed");
if((ftype_id = H5Dget_type(dset_in)) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dget_type failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_type failed");
if((dcpl_id = H5Dget_create_plist(dset_in)) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dget_create_plist failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_create_plist failed");
if((rank = H5Sget_simple_extent_ndims(space_id)) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed");
if(H5Sget_simple_extent_dims(space_id, dims, NULL) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed");
nelmts = 1;
for(k = 0; k < rank; k++)
nelmts *= dims[k];
if((mtype_id = h5tools_get_native_type(ftype_id)) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "h5tools_get_native_type failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "h5tools_get_native_type failed");
if((msize = H5Tget_size(mtype_id)) == 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tget_size failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_size failed");
/*-------------------------------------------------------------------------
* check if the dataset creation property list has filters that
@@ -169,15 +168,15 @@ int do_copy_refobjs(hid_t fidin,
buf = (hobj_ref_t *)HDmalloc((unsigned)(nelmts * msize));
if(buf==NULL) {
printf("cannot read into memory\n" );
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "HDmalloc failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "HDmalloc failed");
} /* end if */
if(H5Dread(dset_in, mtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dread failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dread failed");
refbuf = (hobj_ref_t*) HDcalloc((unsigned)nelmts, msize);
if(refbuf == NULL){
printf("cannot allocate memory\n" );
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "HDcalloc failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "HDcalloc failed");
} /* end if */
for(u = 0; u < nelmts; u++) {
H5E_BEGIN_TRY {
@@ -191,7 +190,7 @@ int do_copy_refobjs(hid_t fidin,
if((refname = MapIdToName(refobj_id, travt)) != NULL) {
/* create the reference, -1 parameter for objects */
if(H5Rcreate(&refbuf[u], fidout, refname, H5R_OBJECT, (hid_t)-1) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Rcreate failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Rcreate failed");
if(options->verbose)
{
printf(FORMAT_OBJ,"dset",travt->objs[i].name );
@@ -209,10 +208,10 @@ int do_copy_refobjs(hid_t fidin,
*-------------------------------------------------------------------------
*/
if((dset_out = H5Dcreate2(fidout, travt->objs[i].name, mtype_id, space_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dcreate2 failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dcreate2 failed");
if(nelmts)
if(H5Dwrite(dset_out, mtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, refbuf) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dwrite failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dwrite failed");
if(buf)
HDfree(buf);
@@ -223,7 +222,7 @@ int do_copy_refobjs(hid_t fidin,
* copy attrs
*----------------------------------------------------*/
if(copy_attr(dset_in, dset_out, &named_dt_head, travt, options) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "copy_attr failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "copy_attr failed");
} /*H5T_STD_REF_OBJ*/
/*-------------------------------------------------------------------------
@@ -246,10 +245,10 @@ int do_copy_refobjs(hid_t fidin,
buf = (hdset_reg_ref_t *)HDmalloc((unsigned)(nelmts * msize));
if(buf == NULL) {
printf("cannot read into memory\n");
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "HDmalloc failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "HDmalloc failed");
} /* end if */
if(H5Dread(dset_in, mtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dread failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dread failed");
/*-------------------------------------------------------------------------
* create output
@@ -258,7 +257,7 @@ int do_copy_refobjs(hid_t fidin,
refbuf = (hdset_reg_ref_t *)HDcalloc(sizeof(hdset_reg_ref_t), (size_t)nelmts); /*init to zero */
if(refbuf == NULL) {
printf("cannot allocate memory\n");
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "HDcalloc failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "HDcalloc failed");
} /* end if */
for(u = 0; u < nelmts; u++) {
@@ -274,18 +273,15 @@ int do_copy_refobjs(hid_t fidin,
hid_t region_id; /* region id of the referenced dataset */
if((region_id = H5Rget_region(dset_in, H5R_DATASET_REGION, &buf[u])) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Rget_region failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Rget_region failed");
/* create the reference, we need the space_id */
if(H5Rcreate(&refbuf[u], fidout, refname, H5R_DATASET_REGION, region_id) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Rcreate failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Rcreate failed");
if(H5Sclose(region_id) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sclose failed");
if(options->verbose)
{
-
-
-
printf(FORMAT_OBJ,"dset",travt->objs[i].name );
printf("object <%s> region reference created to <%s>\n",
travt->objs[i].name,
@@ -301,10 +297,10 @@ int do_copy_refobjs(hid_t fidin,
*-------------------------------------------------------------------------
*/
if((dset_out = H5Dcreate2(fidout, travt->objs[i].name, mtype_id, space_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dcreate2 failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dcreate2 failed");
if(nelmts)
if(H5Dwrite(dset_out, mtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, refbuf) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dwrite failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dwrite failed");
if(buf)
HDfree(buf);
@@ -315,7 +311,7 @@ int do_copy_refobjs(hid_t fidin,
* copy attrs
*----------------------------------------------------*/
if(copy_attr(dset_in, dset_out, &named_dt_head, travt, options) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "copy_attr failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "copy_attr failed");
} /* H5T_STD_REF_DSETREG */
/*-------------------------------------------------------------------------
* not references, open previously created object in 1st traversal
@@ -323,7 +319,7 @@ int do_copy_refobjs(hid_t fidin,
*/
else {
if((dset_out = H5Dopen2(fidout, travt->objs[i].name, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dopen2 failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 failed");
} /* end else */
HDassert(dset_out != FAIL);
@@ -333,7 +329,7 @@ int do_copy_refobjs(hid_t fidin,
*-------------------------------------------------------------------------
*/
if(copy_refs_attr(dset_in, dset_out, options, travt, fidout) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "copy_refs_attr failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "copy_refs_attr failed");
/*-------------------------------------------------------------------------
* check for hard links
@@ -344,7 +340,7 @@ int do_copy_refobjs(hid_t fidin,
H5Lcreate_hard(fidout, travt->objs[i].name, H5L_SAME_LOC, travt->objs[i].links[j].new_name, H5P_DEFAULT, H5P_DEFAULT);
if(H5Dclose(dset_out) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dclose failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed");
} /*can_read*/
/*-------------------------------------------------------------------------
@@ -352,15 +348,15 @@ int do_copy_refobjs(hid_t fidin,
*-------------------------------------------------------------------------
*/
if(H5Tclose(ftype_id) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed");
if(H5Tclose(mtype_id) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed");
if(H5Pclose(dcpl_id) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
if(H5Sclose(space_id) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sclose failed");
if(H5Dclose(dset_in) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dclose failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed");
break;
/*-------------------------------------------------------------------------
@@ -369,9 +365,9 @@ int do_copy_refobjs(hid_t fidin,
*/
case H5TRAV_TYPE_NAMED_DATATYPE:
if((type_in = H5Topen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Topen2 failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Topen2 failed");
if(H5Tclose(type_in) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed");
break;
/*-------------------------------------------------------------------------
@@ -384,7 +380,7 @@ int do_copy_refobjs(hid_t fidin,
case H5TRAV_TYPE_UNKNOWN:
case H5TRAV_TYPE_UDLINK:
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5TRAV invalid type");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5TRAV invalid type");
default:
break;
@@ -397,7 +393,7 @@ int do_copy_refobjs(hid_t fidin,
*/
named_datatype_free(&named_dt_head, 0);
- return 0;
+ return ret_value;
done:
H5E_BEGIN_TRY {
@@ -413,7 +409,7 @@ done:
named_datatype_free(&named_dt_head, 0);
} H5E_END_TRY;
- return -1;
+ return ret_value;
}
@@ -469,32 +465,32 @@ static int copy_refs_attr(hid_t loc_in,
void *refbuf = NULL;
void *buf = NULL;
const char* refname = NULL;
- int *ref_comp_index = NULL;
+ unsigned *ref_comp_index = NULL;
size_t *ref_comp_size = NULL;
int ref_comp_field_n = 0;
if(H5Oget_info(loc_in, &oinfo) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Oget_info failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Oget_info failed");
for(u = 0; u < (unsigned)oinfo.num_attrs; u++) {
is_ref = is_ref_vlen = is_ref_array = is_ref_comp = 0;
/* open attribute */
if((attr_id = H5Aopen_by_idx(loc_in, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, H5P_DEFAULT, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Aopen_by_idx failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aopen_by_idx failed");
/* get the file datatype */
if((ftype_id = H5Aget_type(attr_id)) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Aget_type failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aget_type failed");
type_class = H5Tget_class(ftype_id);
if((mtype_id = h5tools_get_native_type(ftype_id)) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "h5tools_get_native_type failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "h5tools_get_native_type failed");
if((msize = H5Tget_size(mtype_id)) == 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tget_size failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_size failed");
is_ref = (type_class == H5T_REFERENCE);
@@ -518,10 +514,10 @@ static int copy_refs_attr(hid_t loc_in,
int nmembers = H5Tget_nmembers(ftype_id) ;
if (nmembers < 1)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tget_nmembers failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_nmembers failed");
- ref_comp_index = (int *)HDmalloc(nmembers*sizeof (int));
- ref_comp_size = (size_t *)HDmalloc(nmembers*sizeof(ref_comp_size));
+ ref_comp_index = (unsigned *)HDmalloc((size_t)nmembers*sizeof(unsigned));
+ ref_comp_size = (size_t *)HDmalloc((size_t)nmembers*sizeof(ref_comp_size));
ref_comp_field_n = 0;
for (i=0; i<(unsigned)nmembers; i++) {
@@ -562,15 +558,15 @@ static int copy_refs_attr(hid_t loc_in,
/* get name */
if(H5Aget_name(attr_id, 255, name) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Aget_name failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aget_name failed");
/* get the dataspace handle */
if((space_id = H5Aget_space(attr_id)) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Aget_space failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aget_space failed");
/* get dimensions */
if((rank = H5Sget_simple_extent_dims(space_id, dims, NULL)) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed");
/*-------------------------------------------------------------------------
@@ -582,8 +578,8 @@ static int copy_refs_attr(hid_t loc_in,
nelmts *= dims[j];
if (is_ref_array) {
- unsigned array_rank = 0;
- hsize_t array_size = 1;
+ unsigned array_rank = 0;
+ hsize_t array_size = 1;
hsize_t array_dims[H5S_MAX_RANK];
hid_t base_type;
@@ -591,7 +587,7 @@ static int copy_refs_attr(hid_t loc_in,
msize = H5Tget_size(base_type);
H5Tclose(base_type);
- array_rank = H5Tget_array_ndims(mtype_id);
+ array_rank = (unsigned)H5Tget_array_ndims(mtype_id);
H5Tget_array_dims2(mtype_id, array_dims);
for(j = 0; j <array_rank; j++)
array_size *= array_dims[j];
@@ -599,7 +595,7 @@ static int copy_refs_attr(hid_t loc_in,
}
if((attr_out = H5Acreate2(loc_out, name, ftype_id, space_id, H5P_DEFAULT, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Acreate2 failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Acreate2 failed");
if (nelmts>0) {
/* handle object references */
@@ -607,15 +603,15 @@ static int copy_refs_attr(hid_t loc_in,
buf = (hobj_ref_t *)HDmalloc((unsigned)(nelmts * msize));
if(buf == NULL) {
printf("cannot read into memory\n");
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "HDmalloc failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "HDmalloc failed");
} /* end if */
if(H5Aread(attr_id, mtype_id, buf) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Aread failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aread failed");
refbuf = (hobj_ref_t *)HDcalloc((unsigned)nelmts, msize);
if(refbuf == NULL) {
printf("cannot allocate memory\n");
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "HDcalloc failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "HDcalloc failed");
} /* end if */
for(i = 0; i < (unsigned)nelmts; i++) {
@@ -631,10 +627,10 @@ static int copy_refs_attr(hid_t loc_in,
if(buf == NULL) {
printf( "cannot read into memory\n" );
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "HDmalloc failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "HDmalloc failed");
} /* end if */
if(H5Aread(attr_id, mtype_id, buf) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Aread failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aread failed");
/*-------------------------------------------------------------------------
* create output
@@ -643,7 +639,7 @@ static int copy_refs_attr(hid_t loc_in,
refbuf = (hdset_reg_ref_t *)HDcalloc(sizeof(hdset_reg_ref_t), (size_t)nelmts); /*init to zero */
if(refbuf == NULL) {
printf( "cannot allocate memory\n" );
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "HDcalloc failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "HDcalloc failed");
} /* end if */
for(i = 0; i < (unsigned)nelmts; i++) {
@@ -661,11 +657,11 @@ static int copy_refs_attr(hid_t loc_in,
if(buf == NULL) {
printf( "cannot read into memory\n" );
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "HDmalloc failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "HDmalloc failed");
} /* end if */
if(H5Aread(attr_id, mtype_id, buf) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Aread failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aread failed");
if (H5R_OBJ_REF_BUF_SIZE==msize) {
hobj_ref_t ref_out;
@@ -702,41 +698,43 @@ static int copy_refs_attr(hid_t loc_in,
if(buf == NULL)
{
printf( "cannot read into memory\n" );
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "HDmalloc failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "HDmalloc failed");
} /* end if */
if(H5Aread(attr_id, mtype_id, buf) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Aread failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aread failed");
for (i=0; i<(unsigned)nelmts; i++) {
- for (j=0; j<(unsigned)ref_comp_field_n; j++) {
- if (ref_comp_size[j] == H5R_OBJ_REF_BUF_SIZE) {
- int idx = i*msize+H5Tget_member_offset( mtype_id, (unsigned)ref_comp_index[j]);
- hobj_ref_t ref_out;
- if (update_ref_value(attr_id, H5R_OBJECT, (hobj_ref_t *)(((char *)buf)+idx), fidout, &ref_out, travt)<0)
- continue;
- HDmemcpy(((char *)buf)+idx, &ref_out, ref_comp_size[j]);
- } /* if */
- else if (ref_comp_size[j] == H5R_DSET_REG_REF_BUF_SIZE) {
- int idx = i*msize+H5Tget_member_offset( mtype_id, (unsigned)ref_comp_index[j]);
- hdset_reg_ref_t ref_out;
- if (update_ref_value(attr_id, H5R_DATASET_REGION, (hdset_reg_ref_t *)(((char *)buf)+idx), fidout, &ref_out, travt)<0)
- continue;
- HDmemcpy(((char *)buf)+idx, &ref_out, ref_comp_size[j]);
- } /* else if */
- } /* j */
+ for (j=0; j<(unsigned)ref_comp_field_n; j++) {
+ if (ref_comp_size[j] == H5R_OBJ_REF_BUF_SIZE) {
+ size_t idx = (i * msize) + H5Tget_member_offset(mtype_id, ref_comp_index[j]);
+ hobj_ref_t ref_out;
+
+ if (update_ref_value(attr_id, H5R_OBJECT, (hobj_ref_t *)(((char *)buf)+idx), fidout, &ref_out, travt)<0)
+ continue;
+ HDmemcpy(((char *)buf)+idx, &ref_out, ref_comp_size[j]);
+ } /* if */
+ else if (ref_comp_size[j] == H5R_DSET_REG_REF_BUF_SIZE) {
+ size_t idx = i * msize + H5Tget_member_offset(mtype_id, ref_comp_index[j]);
+ hdset_reg_ref_t ref_out;
+
+ if (update_ref_value(attr_id, H5R_DATASET_REGION, (hdset_reg_ref_t *)(((char *)buf)+idx), fidout, &ref_out, travt)<0)
+ continue;
+ HDmemcpy(((char *)buf)+idx, &ref_out, ref_comp_size[j]);
+ } /* else if */
+ } /* j */
} /* i */
} /* else if (is_ref_comp) */
if(H5Awrite(attr_out, mtype_id, refbuf) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Awrite failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Awrite failed");
if (is_ref_vlen && buf)
H5Dvlen_reclaim (mtype_id, space_id, H5P_DEFAULT, buf);
} /* if (nelmts) */
if (refbuf == buf)
- refbuf = NULL; /* set it to NULL to avoid double free since buf and refbuf are the same. */
+ refbuf = NULL; /* set it to NULL to avoid double free since buf and refbuf are the same. */
if(buf) {
HDfree(buf);
@@ -749,39 +747,39 @@ static int copy_refs_attr(hid_t loc_in,
}
if (ref_comp_index) {
- HDfree(ref_comp_index);
- ref_comp_index = NULL;
+ HDfree(ref_comp_index);
+ ref_comp_index = NULL;
}
if (ref_comp_size) {
- HDfree(ref_comp_size);
- ref_comp_size = NULL;
+ HDfree(ref_comp_size);
+ ref_comp_size = NULL;
}
if(H5Aclose(attr_out) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Aclose failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aclose failed");
/*-------------------------------------------------------------------------
* close
*-------------------------------------------------------------------------
*/
if(H5Tclose(ftype_id) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed");
if(H5Tclose(mtype_id) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed");
if(H5Sclose(space_id) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sclose failed");
if(H5Aclose(attr_id) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Aclose failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aclose failed");
} /* for(u = 0; u < (unsigned)oinfo.num_attrs; u++) */
- return 0;
+ return ret_value;
done:
- if(refbuf)
- HDfree(refbuf);
- if(buf)
- HDfree(buf);
+ if(refbuf)
+ HDfree(refbuf);
+ if(buf)
+ HDfree(buf);
if (ref_comp_index)
HDfree(ref_comp_index);
@@ -797,7 +795,7 @@ done:
H5Aclose(attr_out);
} H5E_END_TRY;
- return -1;
+ return ret_value;
}
/*-------------------------------------------------------------------------
@@ -848,30 +846,25 @@ static herr_t update_ref_value(hid_t obj_id, H5R_type_t ref_type, void *ref_in,
hid_t fid_out, void *ref_out, trav_table_t *travt)
{
int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */
- herr_t ret = -1;
- const char* ref_obj_name;
- hid_t space_id=-1, ref_obj_id=-1;
+ const char* ref_obj_name;
+ hid_t space_id=-1, ref_obj_id=-1;
ref_obj_id = H5Rdereference2(obj_id, H5P_DEFAULT, ref_type, ref_in);
- if (ref_obj_id<0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Rdereference2 failed");
+ if (ref_obj_id < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Rdereference2 failed");
- ref_obj_name = MapIdToName(ref_obj_id, travt);
- if (ref_obj_name == NULL)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "MapIdToName failed");
+ ref_obj_name = MapIdToName(ref_obj_id, travt);
+ if (ref_obj_name == NULL)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "MapIdToName failed");
- if (ref_type == H5R_DATASET_REGION) {
- space_id = H5Rget_region(obj_id, H5R_DATASET_REGION, ref_in);
- if (space_id < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Rget_region failed");
+ if (ref_type == H5R_DATASET_REGION) {
+ space_id = H5Rget_region(obj_id, H5R_DATASET_REGION, ref_in);
+ if (space_id < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Rget_region failed");
}
- ret = H5Rcreate(ref_out, fid_out, ref_obj_name, ref_type, space_id);
-
- if (ret < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Rcreate failed");
-
- ret = 0;
+ if(H5Rcreate(ref_out, fid_out, ref_obj_name, ref_type, space_id) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Rcreate failed");
done:
H5E_BEGIN_TRY {
@@ -879,6 +872,6 @@ done:
H5Oclose(ref_obj_id);
} H5E_END_TRY;
- return ret;
+ return ret_value;
}
diff --git a/tools/h5repack/h5repack_verify.c b/tools/h5repack/h5repack_verify.c
index 9565ce3..6765c49 100644
--- a/tools/h5repack/h5repack_verify.c
+++ b/tools/h5repack/h5repack_verify.c
@@ -80,20 +80,20 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options
*-------------------------------------------------------------------------
*/
if((did = H5Dopen2(fidout, name, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dopen2 failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 failed");
if((sid = H5Dget_space(did)) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dget_space failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_space failed");
if((pid = H5Dget_create_plist(did)) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dget_create_plist failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_create_plist failed");
if((tid = H5Dget_type(did)) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dget_type failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_type failed");
/*-------------------------------------------------------------------------
* filter check
*-------------------------------------------------------------------------
*/
if(verify_filters(pid, tid, obj->nfilters, obj->filter) <= 0)
- ok = 0;
+ ok = 0;
/*-------------------------------------------------------------------------
@@ -108,13 +108,13 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options
*-------------------------------------------------------------------------
*/
if(H5Pclose(pid) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
if (H5Sclose(sid) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sclose failed");
if (H5Dclose(did) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dclose failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed");
if (H5Tclose(tid) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed");
}
@@ -132,7 +132,7 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options
/* get the list of objects in the file */
if(h5trav_gettable(fidout, travt) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "h5trav_gettable failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "h5trav_gettable failed");
for(i = 0; i < travt->nobjs; i++)
{
@@ -146,13 +146,13 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options
*-------------------------------------------------------------------------
*/
if((did = H5Dopen2(fidout, name, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dopen2 failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 failed");
if((sid = H5Dget_space(did)) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dget_space failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_space failed");
if((pid = H5Dget_create_plist(did)) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dget_create_plist failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_create_plist failed");
if((tid = H5Dget_type(did)) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dget_type failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_type failed");
/*-------------------------------------------------------------------------
* filter check
@@ -160,7 +160,6 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options
*/
if(options->all_filter == 1)
{
-
if(verify_filters(pid, tid, options->n_filter_g, options->filter_g) <= 0)
ok = 0;
}
@@ -172,6 +171,7 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options
if(options->all_layout == 1)
{
pack_info_t pack;
+
init_packobject(&pack);
pack.layout = options->layout_g;
pack.chunk = options->chunk_g;
@@ -185,13 +185,13 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options
*-------------------------------------------------------------------------
*/
if (H5Pclose(pid) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
if (H5Sclose(sid) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sclose failed");
if (H5Dclose(did) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dclose failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed");
if (H5Tclose(tid) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed");
} /* if */
} /* i */
@@ -208,31 +208,31 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options
/* open the input file */
if((fidin = H5Fopen(in_fname, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0 )
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Fopen failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Fopen failed");
/* Get file creation property list for input file */
if((fcpl_in = H5Fget_create_plist(fidin)) < 0) {
error_msg("failed to retrieve file creation property list\n");
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Fget_create_plist failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Fget_create_plist failed");
}
/* Get file space management info for input file */
if(H5Pget_file_space(fcpl_in, &in_strat, &in_thresh) < 0) {
error_msg("failed to retrieve file space strategy & threshold\n");
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pget_file_space failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_file_space failed");
}
/* Output file is already opened */
/* Get file creation property list for output file */
if((fcpl_out = H5Fget_create_plist(fidout)) < 0) {
error_msg("failed to retrieve file creation property list\n");
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Fget_create_plist failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Fget_create_plist failed");
}
/* Get file space management info for output file */
if(H5Pget_file_space(fcpl_out, &out_strat, &out_thresh) < 0) {
error_msg("failed to retrieve file space strategy & threshold\n");
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pget_file_space failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_file_space failed");
}
/*
@@ -245,12 +245,12 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options
*/
if(!options->fs_strategy && out_strat != in_strat) {
error_msg("file space strategy not set as unexpected\n");
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "file space strategy not set as unexpected");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "file space strategy not set as unexpected");
}
else if(options->fs_strategy && out_strat!= options->fs_strategy) {
error_msg("file space strategy not set as unexpected\n");
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "file space strategy not set as unexpected");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "file space strategy not set as unexpected");
}
/*
@@ -263,22 +263,22 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options
*/
if(!options->fs_threshold && out_thresh != in_thresh) {
error_msg("free space threshold not set as unexpected\n");
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "free space threshold not set as unexpected");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "free space threshold not set as unexpected");
}
else if(options->fs_threshold && out_thresh != options->fs_threshold) {
error_msg("free space threshold not set as unexpected\n");
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "free space threshold not set as unexpected");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "free space threshold not set as unexpected");
}
/* Closing */
if (H5Pclose(fcpl_in) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
if (H5Pclose(fcpl_out) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
if (H5Fclose(fidin) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Fclose failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Fclose failed");
if (H5Fclose(fidout) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Fclose failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Fclose failed");
return ok;
@@ -294,7 +294,8 @@ done:
if (travt)
trav_table_free(travt);
} H5E_END_TRY;
- return -1;
+
+ return ret_value;
} /* h5repack_verify() */
@@ -397,12 +398,12 @@ int h5repack_cmp_pl(const char *fname1,
{
/* Open the files */
- if ((fid1=H5Fopen(fname1,H5F_ACC_RDONLY,H5P_DEFAULT)) < 0 )
+ if ((fid1 = H5Fopen(fname1,H5F_ACC_RDONLY,H5P_DEFAULT)) < 0 )
{
error_msg("<%s>: %s\n", fname1, H5FOPENERROR );
return -1;
}
- if ((fid2=H5Fopen(fname2,H5F_ACC_RDONLY,H5P_DEFAULT)) < 0 )
+ if ((fid2 = H5Fopen(fname2,H5F_ACC_RDONLY,H5P_DEFAULT)) < 0 )
{
error_msg("<%s>: %s\n", fname2, H5FOPENERROR );
H5Fclose(fid1);
@@ -417,7 +418,7 @@ int h5repack_cmp_pl(const char *fname1,
*/
trav_table_init(&trav);
if(h5trav_gettable(fid1, trav) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "h5trav_gettable failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "h5trav_gettable failed");
/*-------------------------------------------------------------------------
* traverse the suppplied object list
@@ -430,30 +431,30 @@ int h5repack_cmp_pl(const char *fname1,
{
if ((gid = H5Gopen2(fid1, trav->objs[i].name, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Gopen2 failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gopen2 failed");
if ((gcplid = H5Gget_create_plist(gid)) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Gget_create_plist failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gget_create_plist failed");
if (H5Pget_link_creation_order(gcplid, &crt_order_flag1) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pget_link_creation_order failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_link_creation_order failed");
if (H5Pclose(gcplid) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
if (H5Gclose(gid) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Gclose failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gclose failed");
if ((gid = H5Gopen2(fid2, trav->objs[i].name, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Gopen2 failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gopen2 failed");
if ((gcplid = H5Gget_create_plist(gid)) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Gget_create_plist failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gget_create_plist failed");
if (H5Pget_link_creation_order(gcplid, &crt_order_flag2) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pget_link_creation_order failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_link_creation_order failed");
if (H5Pclose(gcplid) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
if (H5Gclose(gid) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Gclose failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gclose failed");
if (crt_order_flag1 != crt_order_flag2) {
error_msg("property lists for <%s> are different\n",trav->objs[i].name);
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "property lists failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "property lists failed");
}
}
@@ -463,24 +464,24 @@ int h5repack_cmp_pl(const char *fname1,
else if(trav->objs[i].type == H5TRAV_TYPE_DATASET)
{
if((dset1 = H5Dopen2(fid1, trav->objs[i].name, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dopen2 failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 failed");
if((dset2 = H5Dopen2(fid2, trav->objs[i].name, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dopen2 failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 failed");
if((dcpl1 = H5Dget_create_plist(dset1)) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dget_create_plist failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_create_plist failed");
if((dcpl2 = H5Dget_create_plist(dset2)) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dget_create_plist failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_create_plist failed");
/*-------------------------------------------------------------------------
* compare the property lists
*-------------------------------------------------------------------------
*/
if((ret = H5Pequal(dcpl1, dcpl2)) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pequal failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pequal failed");
if(ret == 0) {
error_msg("property lists for <%s> are different\n",trav->objs[i].name);
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "property lists failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "property lists failed");
}
/*-------------------------------------------------------------------------
@@ -488,13 +489,13 @@ int h5repack_cmp_pl(const char *fname1,
*-------------------------------------------------------------------------
*/
if(H5Pclose(dcpl1) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
if(H5Pclose(dcpl2) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
if(H5Dclose(dset1) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dclose failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed");
if(H5Dclose(dset2) < 0)
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dclose failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed");
} /*if*/
} /*i*/
@@ -512,13 +513,13 @@ int h5repack_cmp_pl(const char *fname1,
H5Fclose(fid1);
H5Fclose(fid2);
- return ret;
- /*-------------------------------------------------------------------------
- * error
- *-------------------------------------------------------------------------
- */
+ return ret;
+/*-------------------------------------------------------------------------
+* error
+*-------------------------------------------------------------------------
+*/
done:
H5E_BEGIN_TRY
{
@@ -532,8 +533,8 @@ done:
H5Gclose(gid);
trav_table_free(trav);
} H5E_END_TRY;
- return -1;
+ return ret_value;
}
@@ -602,100 +603,71 @@ int verify_filters(hid_t pid, hid_t tid, int nfilters, filter_info_t *filter)
switch (filtn)
{
- case H5Z_FILTER_NONE:
+ case H5Z_FILTER_NONE:
break;
- case H5Z_FILTER_SHUFFLE:
-
- /* 1 private client value is returned by DCPL */
- if ( cd_nelmts != H5Z_SHUFFLE_TOTAL_NPARMS && filter[i].cd_nelmts != H5Z_SHUFFLE_USER_NPARMS )
- return 0;
-
- /* get dataset's type size */
- if((size = H5Tget_size(tid)) <= 0)
- return -1;
-
- /* the private client value holds the dataset's type size */
- if ( size != cd_values[0] )
- return 0;
-
-
- break;
-
- case H5Z_FILTER_SZIP:
-
- /* 4 private client values are returned by DCPL */
- if ( cd_nelmts != H5Z_SZIP_TOTAL_NPARMS && filter[i].cd_nelmts != H5Z_SZIP_USER_NPARMS )
- return 0;
-
- /* "User" parameter for pixels-per-block (index 1) */
- if ( cd_values[H5Z_SZIP_PARM_PPB] != filter[i].cd_values[H5Z_SZIP_PARM_PPB] )
- return 0;
-
-
- break;
-
- case H5Z_FILTER_NBIT:
-
- /* only client data values number of values checked */
- if ( H5Z_NBIT_USER_NPARMS != filter[i].cd_nelmts)
- return 0;
-
-
-
- break;
+ case H5Z_FILTER_SHUFFLE:
+ /* 1 private client value is returned by DCPL */
+ if ( cd_nelmts != H5Z_SHUFFLE_TOTAL_NPARMS && filter[i].cd_nelmts != H5Z_SHUFFLE_USER_NPARMS )
+ return 0;
- case H5Z_FILTER_SCALEOFFSET:
+ /* get dataset's type size */
+ if((size = H5Tget_size(tid)) <= 0)
+ return -1;
- /* only client data values checked */
- for( j = 0; j < H5Z_SCALEOFFSET_USER_NPARMS; j++)
- {
- if (cd_values[j] != filter[i].cd_values[j])
- {
+ /* the private client value holds the dataset's type size */
+ if ( size != cd_values[0] )
return 0;
- }
- }
+ break;
+ case H5Z_FILTER_SZIP:
+ /* 4 private client values are returned by DCPL */
+ if ( cd_nelmts != H5Z_SZIP_TOTAL_NPARMS && filter[i].cd_nelmts != H5Z_SZIP_USER_NPARMS )
+ return 0;
- break;
-
- /* for these filters values must match, no local values set in DCPL */
- case H5Z_FILTER_FLETCHER32:
- case H5Z_FILTER_DEFLATE:
+ /* "User" parameter for pixels-per-block (index 1) */
+ if ( cd_values[H5Z_SZIP_PARM_PPB] != filter[i].cd_values[H5Z_SZIP_PARM_PPB] )
+ return 0;
- if ( cd_nelmts != filter[i].cd_nelmts)
- return 0;
+ break;
- for( j = 0; j < cd_nelmts; j++)
- {
- if (cd_values[j] != filter[i].cd_values[j])
- {
+ case H5Z_FILTER_NBIT:
+ /* only client data values number of values checked */
+ if ( H5Z_NBIT_USER_NPARMS != filter[i].cd_nelmts)
return 0;
- }
+ break;
- }
+ case H5Z_FILTER_SCALEOFFSET:
+ /* only client data values checked */
+ for( j = 0; j < H5Z_SCALEOFFSET_USER_NPARMS; j++)
+ if (cd_values[j] != filter[i].cd_values[j])
+ return 0;
+ break;
+ /* for these filters values must match, no local values set in DCPL */
+ case H5Z_FILTER_FLETCHER32:
+ case H5Z_FILTER_DEFLATE:
+ if ( cd_nelmts != filter[i].cd_nelmts)
+ return 0;
- break;
+ for( j = 0; j < cd_nelmts; j++)
+ if (cd_values[j] != filter[i].cd_values[j])
+ return 0;
- default:
- if ( cd_nelmts != filter[i].cd_nelmts)
- return 0;
+ break;
- for( j = 0; j < cd_nelmts; j++)
- {
- if (cd_values[j] != filter[i].cd_values[j])
- {
- return 0;
- }
+ default:
+ if ( cd_nelmts != filter[i].cd_nelmts)
+ return 0;
- }
- break;
+ for( j = 0; j < cd_nelmts; j++)
+ if (cd_values[j] != filter[i].cd_values[j])
+ return 0;
+ break;
} /* switch */
-
}
return 1;
diff --git a/tools/lib/h5diff.c b/tools/lib/h5diff.c
index b1637a8..79dc51f 100644
--- a/tools/lib/h5diff.c
+++ b/tools/lib/h5diff.c
@@ -30,7 +30,8 @@
* 2) when diff was found (normal mode)
*-------------------------------------------------------------------------
*/
-int print_objname (diff_opt_t * options, hsize_t nfound)
+H5_ATTR_PURE int
+print_objname (diff_opt_t * options, hsize_t nfound)
{
return ((options->m_verbose || nfound) && !options->m_quiet) ? 1 : 0;
}
diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c
index d592528..7897e49 100644
--- a/tools/lib/h5diff_array.c
+++ b/tools/lib/h5diff_array.c
@@ -106,9 +106,9 @@ static hbool_t not_comparable;
per = -1; \
not_comparable = FALSE; \
both_zero = FALSE; \
- if(H5_DBL_ABS_EQUAL(0,A) && H5_DBL_ABS_EQUAL(0,B)) \
+ if(H5_DBL_ABS_EQUAL(0, (double)A) && H5_DBL_ABS_EQUAL(0, (double)B)) \
both_zero = TRUE; \
- if(!H5_DBL_ABS_EQUAL(0,A)) \
+ if(!H5_DBL_ABS_EQUAL(0, (double)A)) \
per = (double)ABS((double)((B) - (A)) / (double)(A)); \
else \
not_comparable = TRUE; \
@@ -119,9 +119,9 @@ static hbool_t not_comparable;
per = -1; \
not_comparable = FALSE; \
both_zero = FALSE; \
- if(H5_DBL_ABS_EQUAL(0,A) && H5_DBL_ABS_EQUAL(0,B)) \
+ if(H5_DBL_ABS_EQUAL(0, (double)A) && H5_DBL_ABS_EQUAL(0, (double)B)) \
both_zero = TRUE; \
- if(!H5_DBL_ABS_EQUAL(0,A)) \
+ if(!H5_DBL_ABS_EQUAL(0, (double)A)) \
per = ABS((double)((TYPE)((B) - (A))) / (double)(A)) ; \
else \
not_comparable = TRUE; \
@@ -597,7 +597,6 @@ static hsize_t diff_datum(void *_mem1,
hid_t obj2_id;
hsize_t nfound=0; /* differences found */
int ret=0; /* check return error */
- float f1, f2;
double per;
hbool_t both_zero;
@@ -1856,210 +1855,6 @@ static hsize_t diff_datum(void *_mem1,
} /*H5T_NATIVE_ULONG*/
- /*-------------------------------------------------------------------------
- * H5T_NATIVE_LLONG
- *-------------------------------------------------------------------------
- */
-
- else if (type_size==8 && type_sign!=H5T_SGN_NONE)
- {
- long long temp1_llong;
- long long temp2_llong;
- HDassert(type_size==sizeof(long long));
-
- HDmemcpy(&temp1_llong, mem1, sizeof(long long));
- HDmemcpy(&temp2_llong, mem2, sizeof(long long));
- /* -d and !-p */
- if (options->d && !options->p)
- {
- if (ABS(temp1_llong-temp2_llong) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LLI_FORMAT,temp1_llong,temp2_llong,ABS(temp1_llong-temp2_llong));
- }
- nfound++;
- }
- }
- /* !-d and -p */
- else if (!options->d && options->p)
- {
- PER(temp1_llong,temp2_llong);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LLI_FORMAT_P_NOTCOMP,temp1_llong,temp2_llong,ABS(temp1_llong-temp2_llong));
- }
- nfound++;
- }
-
- else
-
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LLI_FORMAT_P,temp1_llong,temp2_llong,ABS(temp1_llong-temp2_llong),per);
- }
- nfound++;
- }
- }
- /* -d and -p */
- else if ( options->d && options->p)
- {
- PER(temp1_llong,temp2_llong);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LLI_FORMAT_P_NOTCOMP,temp1_llong,temp2_llong,ABS(temp1_llong-temp2_llong));
- }
- nfound++;
- }
-
- else
-
- if ( per > options->percent && ABS(temp1_llong-temp2_llong) > options->delta )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LLI_FORMAT_P,temp1_llong,temp2_llong,ABS(temp1_llong-temp2_llong),per);
- }
- nfound++;
- }
- }
- else if (temp1_llong != temp2_llong)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LLI_FORMAT,temp1_llong,temp2_llong,ABS(temp1_llong-temp2_llong));
- }
- nfound++;
- }
-
- } /*H5T_NATIVE_LLONG*/
-
- /*-------------------------------------------------------------------------
- * H5T_NATIVE_ULLONG
- *-------------------------------------------------------------------------
- */
-
- else if (type_size==8 && type_sign==H5T_SGN_NONE)
- {
- unsigned long long temp1_ullong;
- unsigned long long temp2_ullong;
- HDassert(type_size==sizeof(unsigned long long));
-
- HDmemcpy(&temp1_ullong, mem1, sizeof(unsigned long long));
- HDmemcpy(&temp2_ullong, mem2, sizeof(unsigned long long));
- /* -d and !-p */
- if (options->d && !options->p)
- {
- if ( PDIFF(temp1_ullong,temp2_ullong) > (unsigned long long)options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(ULLI_FORMAT,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong));
- }
- nfound++;
- }
- }
- /* !-d and -p */
- else if (!options->d && options->p)
- {
- ull2float(temp1_ullong,&f1);
- ull2float(temp2_ullong,&f2);
- PER(f1,f2);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(ULLI_FORMAT_P_NOTCOMP,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong));
- }
- nfound++;
- }
-
- else
-
- if ( per > options->percent )
- {
-
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(ULLI_FORMAT_P,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong),per);
- }
- nfound++;
- }
- }
- /* -d and -p */
- else if ( options->d && options->p)
- {
- ull2float(temp1_ullong,&f1);
- ull2float(temp2_ullong,&f2);
- PER(f1,f2);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(ULLI_FORMAT_P_NOTCOMP,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong));
- }
- nfound++;
- }
-
- else
-
- if ( per > options->percent && PDIFF(temp1_ullong,temp2_ullong) > (unsigned long long)options->delta )
- {
-
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
-
- parallel_print(SPACES);
- parallel_print(ULLI_FORMAT_P,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong),per);
- }
- nfound++;
- }
- }
- else if (temp1_ullong != temp2_ullong)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(ULLI_FORMAT,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong));
- }
- nfound++;
- }
-
- } /*H5T_NATIVE_ULLONG*/
-
-
break; /* H5T_INTEGER class */
@@ -2495,7 +2290,7 @@ static hsize_t diff_datum(void *_mem1,
}
} /*H5T_NATIVE_DOUBLE*/
-#if H5_SIZEOF_LONG_DOUBLE !=0
+#if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE
/*-------------------------------------------------------------------------
@@ -2503,7 +2298,7 @@ static hsize_t diff_datum(void *_mem1,
*-------------------------------------------------------------------------
*/
- else if (type_size==8)
+ else if (type_size == H5_SIZEOF_LONG_DOUBLE)
{
long double temp1_double;
long double temp2_double;
@@ -2511,7 +2306,7 @@ static hsize_t diff_datum(void *_mem1,
hbool_t isnan2 = FALSE;
- HDassert(type_size==sizeof(long double));
+ HDassert(type_size == sizeof(long double));
HDmemcpy(&temp1_double, mem1, sizeof(long double));
HDmemcpy(&temp2_double, mem2, sizeof(long double));
@@ -2706,9 +2501,7 @@ static hsize_t diff_datum(void *_mem1,
}
nfound++;
}
- } /*H5T_NATIVE_DOUBLE*/
-
-
+ } /*H5T_NATIVE_LDOUBLE*/
#endif /* H5_SIZEOF_LONG_DOUBLE */
@@ -3986,158 +3779,153 @@ static hsize_t diff_schar(unsigned char *mem1,
int *ph)
{
- hsize_t nfound=0; /* number of differences found */
- char temp1_char;
- char temp2_char;
- hsize_t i;
- double per;
- hbool_t both_zero;
-
- h5difftrace("diff_schar start\n");
-
- /* -d and !-p */
- if (options->d && !options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_char, mem1, sizeof(char));
- HDmemcpy(&temp2_char, mem2, sizeof(char));
-
- if (ABS(temp1_char-temp2_char) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT,temp1_char,temp2_char,ABS(temp1_char-temp2_char));
- }
- nfound++;
- }
- mem1+=sizeof(char);
- mem2+=sizeof(char);
- if (options->n && nfound>=options->count)
- return nfound;
- }
- }
-
- /* !-d and -p */
- else if (!options->d && options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_char, mem1, sizeof(char));
- HDmemcpy(&temp2_char, mem2, sizeof(char));
-
- PER(temp1_char,temp2_char);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP,temp1_char,temp2_char,
- ABS(temp1_char-temp2_char));
- }
- nfound++;
- }
-
- else
-
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P,temp1_char,temp2_char,
- ABS(temp1_char-temp2_char),
- per);
- }
- nfound++;
- }
- mem1+=sizeof(char);
- mem2+=sizeof(char);
- if (options->n && nfound>=options->count)
- return nfound;
- }
- }
-
- /* -d and -p */
- else if ( options->d && options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_char, mem1, sizeof(char));
- HDmemcpy(&temp2_char, mem2, sizeof(char));
-
- PER(temp1_char,temp2_char);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP,temp1_char,temp2_char,
- ABS(temp1_char-temp2_char));
- }
- nfound++;
- }
-
- else
-
- if ( per > options->percent && ABS(temp1_char-temp2_char) > options->delta )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P,temp1_char,temp2_char,
- ABS(temp1_char-temp2_char),
- per);
- }
- nfound++;
- }
- mem1+=sizeof(char);
- mem2+=sizeof(char);
- if (options->n && nfound>=options->count)
- return nfound;
- }
-
- }
- else
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_char, mem1, sizeof(char));
- HDmemcpy(&temp2_char, mem2, sizeof(char));
-
- if (temp1_char != temp2_char)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT,temp1_char,temp2_char,ABS(temp1_char-temp2_char));
- }
- nfound++;
- }
-
- mem1+=sizeof(char);
- mem2+=sizeof(char);
- if (options->n && nfound>=options->count)
- return nfound;
- } /* nelmts */
-
- }
- h5difftrace("diff_schar finish\n");
+ hsize_t nfound=0; /* number of differences found */
+ char temp1_char;
+ char temp2_char;
+ hsize_t i;
+ double per;
+ hbool_t both_zero;
- return nfound;
+ h5difftrace("diff_schar start\n");
+
+ /* -d and !-p */
+ if (options->d && !options->p)
+ {
+
+ for ( i = 0; i < nelmts; i++)
+ {
+ HDmemcpy(&temp1_char, mem1, sizeof(char));
+ HDmemcpy(&temp2_char, mem2, sizeof(char));
+
+ if (ABS(temp1_char-temp2_char) > options->delta)
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT,temp1_char,temp2_char,ABS(temp1_char-temp2_char));
+ }
+ nfound++;
+ }
+ mem1+=sizeof(char);
+ mem2+=sizeof(char);
+ if (options->n && nfound>=options->count)
+ return nfound;
+ }
+ }
+
+ /* !-d and -p */
+ else if (!options->d && options->p)
+ {
+
+ for ( i = 0; i < nelmts; i++)
+ {
+ HDmemcpy(&temp1_char, mem1, sizeof(char));
+ HDmemcpy(&temp2_char, mem2, sizeof(char));
+
+ PER(temp1_char,temp2_char);
+
+ if (not_comparable && !both_zero) /* not comparable */
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT_P_NOTCOMP,temp1_char,temp2_char,
+ ABS(temp1_char-temp2_char));
+ }
+ nfound++;
+ }
+ else
+ if ( per > options->percent )
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT_P,temp1_char,temp2_char,
+ ABS(temp1_char-temp2_char),
+ per);
+ }
+ nfound++;
+ }
+ mem1+=sizeof(char);
+ mem2+=sizeof(char);
+ if (options->n && nfound>=options->count)
+ return nfound;
+ }
+ }
+
+ /* -d and -p */
+ else if ( options->d && options->p)
+ {
+
+ for ( i = 0; i < nelmts; i++)
+ {
+ HDmemcpy(&temp1_char, mem1, sizeof(char));
+ HDmemcpy(&temp2_char, mem2, sizeof(char));
+
+ PER(temp1_char,temp2_char);
+
+ if (not_comparable && !both_zero) /* not comparable */
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT_P_NOTCOMP,temp1_char,temp2_char,
+ ABS(temp1_char-temp2_char));
+ }
+ nfound++;
+ }
+ else
+ if ( per > options->percent && ABS(temp1_char-temp2_char) > options->delta )
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT_P,temp1_char,temp2_char,
+ ABS(temp1_char-temp2_char),
+ per);
+ }
+ nfound++;
+ }
+ mem1+=sizeof(char);
+ mem2+=sizeof(char);
+ if (options->n && nfound>=options->count)
+ return nfound;
+ }
+
+ }
+ else
+ {
+ for ( i = 0; i < nelmts; i++)
+ {
+ HDmemcpy(&temp1_char, mem1, sizeof(char));
+ HDmemcpy(&temp2_char, mem2, sizeof(char));
+
+ if (temp1_char != temp2_char)
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT,temp1_char,temp2_char,ABS(temp1_char-temp2_char));
+ }
+ nfound++;
+ }
+
+ mem1+=sizeof(char);
+ mem2+=sizeof(char);
+ if (options->n && nfound>=options->count)
+ return nfound;
+ } /* nelmts */
+
+ }
+ h5difftrace("diff_schar finish\n");
+
+ return nfound;
}
@@ -4165,159 +3953,149 @@ static hsize_t diff_uchar(unsigned char *mem1,
int *ph)
{
- hsize_t nfound=0; /* number of differences found */
- unsigned char temp1_uchar;
- unsigned char temp2_uchar;
- hsize_t i;
- double per;
- hbool_t both_zero;
-
- h5difftrace("diff_uchar start\n");
-
- /* -d and !-p */
- if (options->d && !options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_uchar, mem1, sizeof(unsigned char));
- HDmemcpy(&temp2_uchar, mem2, sizeof(unsigned char));
-
- if ( PDIFF(temp1_uchar,temp2_uchar) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT,temp1_uchar,temp2_uchar,PDIFF(temp1_uchar,temp2_uchar));
- }
- nfound++;
- }
- mem1+=sizeof(unsigned char);
- mem2+=sizeof(unsigned char);
- if (options->n && nfound>=options->count)
- return nfound;
- }
-
- }
-
- /* !-d and -p */
- else if (!options->d && options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_uchar, mem1, sizeof(unsigned char));
- HDmemcpy(&temp2_uchar, mem2, sizeof(unsigned char));
-
- PER_UNSIGN(signed char,temp1_uchar,temp2_uchar);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP,temp1_uchar,temp2_uchar,
- PDIFF(temp1_uchar,temp2_uchar));
- }
- nfound++;
- }
-
- else
-
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P,temp1_uchar,temp2_uchar,
- PDIFF(temp1_uchar,temp2_uchar),
- per);
- }
- nfound++;
- }
- mem1+=sizeof(unsigned char);
- mem2+=sizeof(unsigned char);
- if (options->n && nfound>=options->count)
- return nfound;
- }
- }
-
- /* -d and -p */
- else if ( options->d && options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_uchar, mem1, sizeof(unsigned char));
- HDmemcpy(&temp2_uchar, mem2, sizeof(unsigned char));
-
- PER_UNSIGN(signed char,temp1_uchar,temp2_uchar);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP,temp1_uchar,temp2_uchar,
- PDIFF(temp1_uchar,temp2_uchar));
- }
- nfound++;
- }
-
- else
-
- if ( per > options->percent && PDIFF(temp1_uchar,temp2_uchar) > options->delta )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P,temp1_uchar,temp2_uchar,
- PDIFF(temp1_uchar,temp2_uchar),
- per);
- }
- nfound++;
- }
- mem1+=sizeof(unsigned char);
- mem2+=sizeof(unsigned char);
- if (options->n && nfound>=options->count)
- return nfound;
- }
-
- }
- else
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_uchar, mem1, sizeof(unsigned char));
- HDmemcpy(&temp2_uchar, mem2, sizeof(unsigned char));
-
- if (temp1_uchar != temp2_uchar)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT,temp1_uchar,temp2_uchar,PDIFF(temp1_uchar,temp2_uchar));
- }
- nfound++;
- }
-
- mem1+=sizeof(unsigned char);
- mem2+=sizeof(unsigned char);
- if (options->n && nfound>=options->count)
- return nfound;
- } /* nelmts */
-
- }
- h5difftrace("diff_uchar finish\n");
+ hsize_t nfound=0; /* number of differences found */
+ unsigned char temp1_uchar;
+ unsigned char temp2_uchar;
+ hsize_t i;
+ double per;
+ hbool_t both_zero;
- return nfound;
+ h5difftrace("diff_uchar start\n");
+
+ /* -d and !-p */
+ if (options->d && !options->p)
+ {
+ for ( i = 0; i < nelmts; i++)
+ {
+ HDmemcpy(&temp1_uchar, mem1, sizeof(unsigned char));
+ HDmemcpy(&temp2_uchar, mem2, sizeof(unsigned char));
+
+ if ( PDIFF(temp1_uchar,temp2_uchar) > options->delta)
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT,temp1_uchar,temp2_uchar,PDIFF(temp1_uchar,temp2_uchar));
+ }
+ nfound++;
+ }
+ mem1+=sizeof(unsigned char);
+ mem2+=sizeof(unsigned char);
+ if (options->n && nfound>=options->count)
+ return nfound;
+ }
+ }
+
+ /* !-d and -p */
+ else if (!options->d && options->p)
+ {
+ for ( i = 0; i < nelmts; i++)
+ {
+ HDmemcpy(&temp1_uchar, mem1, sizeof(unsigned char));
+ HDmemcpy(&temp2_uchar, mem2, sizeof(unsigned char));
+
+ PER_UNSIGN(signed char,temp1_uchar,temp2_uchar);
+
+ if (not_comparable && !both_zero) /* not comparable */
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT_P_NOTCOMP,temp1_uchar,temp2_uchar,
+ PDIFF(temp1_uchar,temp2_uchar));
+ }
+ nfound++;
+ }
+ else
+ if ( per > options->percent )
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT_P,temp1_uchar,temp2_uchar,
+ PDIFF(temp1_uchar,temp2_uchar),
+ per);
+ }
+ nfound++;
+ }
+ mem1+=sizeof(unsigned char);
+ mem2+=sizeof(unsigned char);
+ if (options->n && nfound>=options->count)
+ return nfound;
+ }
+ }
+
+ /* -d and -p */
+ else if ( options->d && options->p)
+ {
+ for ( i = 0; i < nelmts; i++)
+ {
+ HDmemcpy(&temp1_uchar, mem1, sizeof(unsigned char));
+ HDmemcpy(&temp2_uchar, mem2, sizeof(unsigned char));
+
+ PER_UNSIGN(signed char,temp1_uchar,temp2_uchar);
+
+ if (not_comparable && !both_zero) /* not comparable */
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT_P_NOTCOMP,temp1_uchar,temp2_uchar,
+ PDIFF(temp1_uchar,temp2_uchar));
+ }
+ nfound++;
+ }
+ else
+ if ( per > options->percent && PDIFF(temp1_uchar,temp2_uchar) > options->delta )
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT_P,temp1_uchar,temp2_uchar,
+ PDIFF(temp1_uchar,temp2_uchar),
+ per);
+ }
+ nfound++;
+ }
+ mem1+=sizeof(unsigned char);
+ mem2+=sizeof(unsigned char);
+ if (options->n && nfound>=options->count)
+ return nfound;
+ }
+ }
+ else
+ {
+ for ( i = 0; i < nelmts; i++)
+ {
+ HDmemcpy(&temp1_uchar, mem1, sizeof(unsigned char));
+ HDmemcpy(&temp2_uchar, mem2, sizeof(unsigned char));
+
+ if (temp1_uchar != temp2_uchar)
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT,temp1_uchar,temp2_uchar,PDIFF(temp1_uchar,temp2_uchar));
+ }
+ nfound++;
+ }
+
+ mem1+=sizeof(unsigned char);
+ mem2+=sizeof(unsigned char);
+ if (options->n && nfound>=options->count)
+ return nfound;
+ } /* nelmts */
+
+ }
+ h5difftrace("diff_uchar finish\n");
+
+ return nfound;
}
/*-------------------------------------------------------------------------
@@ -4343,160 +4121,147 @@ static hsize_t diff_short(unsigned char *mem1,
int *ph)
{
- hsize_t nfound=0; /* number of differences found */
- short temp1_short;
- short temp2_short;
- hsize_t i;
- double per;
- hbool_t both_zero;
-
- h5difftrace("diff_short start\n");
- /* -d and !-p */
- if (options->d && !options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_short, mem1, sizeof(short));
- HDmemcpy(&temp2_short, mem2, sizeof(short));
-
- if (ABS(temp1_short-temp2_short) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT,temp1_short,temp2_short,ABS(temp1_short-temp2_short));
- }
- nfound++;
- }
- mem1+=sizeof(short);
- mem2+=sizeof(short);
- if (options->n && nfound>=options->count)
- return nfound;
- }
-
- }
-
- /* !-d and -p */
- else if (!options->d && options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_short, mem1, sizeof(short));
- HDmemcpy(&temp2_short, mem2, sizeof(short));
-
- PER(temp1_short,temp2_short);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP,temp1_short,temp2_short,
- ABS(temp1_short-temp2_short));
- }
- nfound++;
- }
-
- else
-
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P,temp1_short,temp2_short,
- ABS(temp1_short-temp2_short),
- per);
- }
- nfound++;
- }
- mem1+=sizeof(short);
- mem2+=sizeof(short);
- if (options->n && nfound>=options->count)
- return nfound;
- }
-
-
- }
-
- /* -d and -p */
- else if ( options->d && options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_short, mem1, sizeof(short));
- HDmemcpy(&temp2_short, mem2, sizeof(short));
-
- PER(temp1_short,temp2_short);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP,temp1_short,temp2_short,
- ABS(temp1_short-temp2_short));
- }
- nfound++;
- }
-
- else
-
- if ( per > options->percent && ABS(temp1_short-temp2_short) > options->delta )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P,temp1_short,temp2_short,
- ABS(temp1_short-temp2_short),
- per);
- }
- nfound++;
- }
- mem1+=sizeof(short);
- mem2+=sizeof(short);
- if (options->n && nfound>=options->count)
- return nfound;
- }
-
- }
- else
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_short, mem1, sizeof(short));
- HDmemcpy(&temp2_short, mem2, sizeof(short));
-
- if (temp1_short != temp2_short)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT,temp1_short,temp2_short,ABS(temp1_short-temp2_short));
- }
- nfound++;
- }
-
- mem1+=sizeof(short);
- mem2+=sizeof(short);
- if (options->n && nfound>=options->count)
- return nfound;
- } /* nelmts */
-
- }
- h5difftrace("diff_short finish\n");
+ hsize_t nfound=0; /* number of differences found */
+ short temp1_short;
+ short temp2_short;
+ hsize_t i;
+ double per;
+ hbool_t both_zero;
- return nfound;
+ h5difftrace("diff_short start\n");
+ /* -d and !-p */
+ if (options->d && !options->p)
+ {
+ for ( i = 0; i < nelmts; i++)
+ {
+ HDmemcpy(&temp1_short, mem1, sizeof(short));
+ HDmemcpy(&temp2_short, mem2, sizeof(short));
+
+ if (ABS(temp1_short-temp2_short) > options->delta)
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT,temp1_short,temp2_short,ABS(temp1_short-temp2_short));
+ }
+ nfound++;
+ }
+ mem1+=sizeof(short);
+ mem2+=sizeof(short);
+ if (options->n && nfound>=options->count)
+ return nfound;
+ }
+ }
+
+ /* !-d and -p */
+ else if (!options->d && options->p)
+ {
+ for ( i = 0; i < nelmts; i++)
+ {
+ HDmemcpy(&temp1_short, mem1, sizeof(short));
+ HDmemcpy(&temp2_short, mem2, sizeof(short));
+
+ PER(temp1_short,temp2_short);
+
+ if (not_comparable && !both_zero) /* not comparable */
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT_P_NOTCOMP,temp1_short,temp2_short,
+ ABS(temp1_short-temp2_short));
+ }
+ nfound++;
+ }
+ else
+ if ( per > options->percent )
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT_P,temp1_short,temp2_short,
+ ABS(temp1_short-temp2_short),
+ per);
+ }
+ nfound++;
+ }
+ mem1+=sizeof(short);
+ mem2+=sizeof(short);
+ if (options->n && nfound>=options->count)
+ return nfound;
+ }
+ }
+
+ /* -d and -p */
+ else if ( options->d && options->p)
+ {
+ for ( i = 0; i < nelmts; i++)
+ {
+ HDmemcpy(&temp1_short, mem1, sizeof(short));
+ HDmemcpy(&temp2_short, mem2, sizeof(short));
+
+ PER(temp1_short,temp2_short);
+
+ if (not_comparable && !both_zero) /* not comparable */
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT_P_NOTCOMP,temp1_short,temp2_short,
+ ABS(temp1_short-temp2_short));
+ }
+ nfound++;
+ }
+ else
+ if ( per > options->percent && ABS(temp1_short-temp2_short) > options->delta )
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT_P,temp1_short,temp2_short,
+ ABS(temp1_short-temp2_short),
+ per);
+ }
+ nfound++;
+ }
+ mem1+=sizeof(short);
+ mem2+=sizeof(short);
+ if (options->n && nfound>=options->count)
+ return nfound;
+ }
+ }
+ else
+ {
+ for ( i = 0; i < nelmts; i++)
+ {
+ HDmemcpy(&temp1_short, mem1, sizeof(short));
+ HDmemcpy(&temp2_short, mem2, sizeof(short));
+
+ if (temp1_short != temp2_short)
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT,temp1_short,temp2_short,ABS(temp1_short-temp2_short));
+ }
+ nfound++;
+ }
+
+ mem1+=sizeof(short);
+ mem2+=sizeof(short);
+ if (options->n && nfound>=options->count)
+ return nfound;
+ } /* nelmts */
+ }
+ h5difftrace("diff_short finish\n");
+
+ return nfound;
}
@@ -4523,162 +4288,147 @@ static hsize_t diff_ushort(unsigned char *mem1,
int *ph)
{
- hsize_t nfound=0; /* number of differences found */
- unsigned short temp1_ushort;
- unsigned short temp2_ushort;
- hsize_t i;
- double per;
- hbool_t both_zero;
-
- h5difftrace("diff_ushort start\n");
- /* -d and !-p */
- if (options->d && !options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_ushort, mem1, sizeof(unsigned short));
- HDmemcpy(&temp2_ushort, mem2, sizeof(unsigned short));
-
- if ( PDIFF(temp1_ushort,temp2_ushort) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT,temp1_ushort,temp2_ushort,PDIFF(temp1_ushort,temp2_ushort));
- }
- nfound++;
- }
- mem1+=sizeof(unsigned short);
- mem2+=sizeof(unsigned short);
- if (options->n && nfound>=options->count)
- return nfound;
- }
-
- }
-
- /* !-d and -p */
- else if (!options->d && options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_ushort, mem1, sizeof(unsigned short));
- HDmemcpy(&temp2_ushort, mem2, sizeof(unsigned short));
-
- PER_UNSIGN(signed short,temp1_ushort,temp2_ushort);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP,temp1_ushort,temp2_ushort,
- PDIFF(temp1_ushort,temp2_ushort));
- }
- nfound++;
- }
-
- else
-
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P,temp1_ushort,temp2_ushort,
- PDIFF(temp1_ushort,temp2_ushort),
- per);
- }
- nfound++;
- }
- mem1+=sizeof(unsigned short);
- mem2+=sizeof(unsigned short);
- if (options->n && nfound>=options->count)
- return nfound;
- }
-
-
- }
-
- /* -d and -p */
- else if ( options->d && options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_ushort, mem1, sizeof(unsigned short));
- HDmemcpy(&temp2_ushort, mem2, sizeof(unsigned short));
-
- PER_UNSIGN(signed short,temp1_ushort,temp2_ushort);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP,temp1_ushort,temp2_ushort,
- PDIFF(temp1_ushort,temp2_ushort));
- }
- nfound++;
- }
-
- else
-
- if ( per > options->percent && PDIFF(temp1_ushort,temp2_ushort) > options->delta )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P,temp1_ushort,temp2_ushort,
- PDIFF(temp1_ushort,temp2_ushort),
- per);
- }
- nfound++;
- }
- mem1+=sizeof(unsigned short);
- mem2+=sizeof(unsigned short);
- if (options->n && nfound>=options->count)
- return nfound;
- }
-
- }
- else
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_ushort, mem1, sizeof(unsigned short));
- HDmemcpy(&temp2_ushort, mem2, sizeof(unsigned short));
-
- if (temp1_ushort != temp2_ushort)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT,temp1_ushort,temp2_ushort,PDIFF(temp1_ushort,temp2_ushort));
- }
- nfound++;
- }
-
- mem1+=sizeof(unsigned short);
- mem2+=sizeof(unsigned short);
- if (options->n && nfound>=options->count)
- return nfound;
- } /* nelmts */
-
- }
- h5difftrace("diff_ushort finish\n");
+ hsize_t nfound=0; /* number of differences found */
+ unsigned short temp1_ushort;
+ unsigned short temp2_ushort;
+ hsize_t i;
+ double per;
+ hbool_t both_zero;
+
+ h5difftrace("diff_ushort start\n");
+ /* -d and !-p */
+ if (options->d && !options->p)
+ {
+ for ( i = 0; i < nelmts; i++)
+ {
+ HDmemcpy(&temp1_ushort, mem1, sizeof(unsigned short));
+ HDmemcpy(&temp2_ushort, mem2, sizeof(unsigned short));
- return nfound;
-}
+ if ( PDIFF(temp1_ushort,temp2_ushort) > options->delta)
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT,temp1_ushort,temp2_ushort,PDIFF(temp1_ushort,temp2_ushort));
+ }
+ nfound++;
+ }
+ mem1+=sizeof(unsigned short);
+ mem2+=sizeof(unsigned short);
+ if (options->n && nfound>=options->count)
+ return nfound;
+ }
+ }
+ /* !-d and -p */
+ else if (!options->d && options->p)
+ {
+ for ( i = 0; i < nelmts; i++)
+ {
+ HDmemcpy(&temp1_ushort, mem1, sizeof(unsigned short));
+ HDmemcpy(&temp2_ushort, mem2, sizeof(unsigned short));
+
+ PER_UNSIGN(signed short,temp1_ushort,temp2_ushort);
+
+ if (not_comparable && !both_zero) /* not comparable */
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT_P_NOTCOMP,temp1_ushort,temp2_ushort,
+ PDIFF(temp1_ushort,temp2_ushort));
+ }
+ nfound++;
+ }
+ else
+ if ( per > options->percent )
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT_P,temp1_ushort,temp2_ushort,
+ PDIFF(temp1_ushort,temp2_ushort),
+ per);
+ }
+ nfound++;
+ }
+ mem1+=sizeof(unsigned short);
+ mem2+=sizeof(unsigned short);
+ if (options->n && nfound>=options->count)
+ return nfound;
+ }
+ }
+ /* -d and -p */
+ else if ( options->d && options->p)
+ {
+ for ( i = 0; i < nelmts; i++)
+ {
+ HDmemcpy(&temp1_ushort, mem1, sizeof(unsigned short));
+ HDmemcpy(&temp2_ushort, mem2, sizeof(unsigned short));
+
+ PER_UNSIGN(signed short,temp1_ushort,temp2_ushort);
+
+ if (not_comparable && !both_zero) /* not comparable */
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT_P_NOTCOMP,temp1_ushort,temp2_ushort,
+ PDIFF(temp1_ushort,temp2_ushort));
+ }
+ nfound++;
+ }
+ else
+ if ( per > options->percent && PDIFF(temp1_ushort,temp2_ushort) > options->delta )
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT_P,temp1_ushort,temp2_ushort,
+ PDIFF(temp1_ushort,temp2_ushort),
+ per);
+ }
+ nfound++;
+ }
+ mem1+=sizeof(unsigned short);
+ mem2+=sizeof(unsigned short);
+ if (options->n && nfound>=options->count)
+ return nfound;
+ }
+ }
+ else
+ {
+ for ( i = 0; i < nelmts; i++)
+ {
+ HDmemcpy(&temp1_ushort, mem1, sizeof(unsigned short));
+ HDmemcpy(&temp2_ushort, mem2, sizeof(unsigned short));
+ if (temp1_ushort != temp2_ushort)
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT,temp1_ushort,temp2_ushort,PDIFF(temp1_ushort,temp2_ushort));
+ }
+ nfound++;
+ }
+
+ mem1+=sizeof(unsigned short);
+ mem2+=sizeof(unsigned short);
+ if (options->n && nfound>=options->count)
+ return nfound;
+ } /* nelmts */
+
+ }
+ h5difftrace("diff_ushort finish\n");
+
+ return nfound;
+}
/*-------------------------------------------------------------------------
@@ -4704,162 +4454,147 @@ static hsize_t diff_int(unsigned char *mem1,
int *ph)
{
- hsize_t nfound=0; /* number of differences found */
- int temp1_int;
- int temp2_int;
- hsize_t i;
- double per;
- hbool_t both_zero;
-
- h5difftrace("diff_int start\n");
- /* -d and !-p */
- if (options->d && !options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_int, mem1, sizeof(int));
- HDmemcpy(&temp2_int, mem2, sizeof(int));
-
- if (ABS(temp1_int-temp2_int) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT,temp1_int,temp2_int,ABS(temp1_int-temp2_int));
- }
- nfound++;
- }
- mem1+=sizeof(int);
- mem2+=sizeof(int);
- if (options->n && nfound>=options->count)
- return nfound;
- }
-
- }
-
- /* !-d and -p */
- else if (!options->d && options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_int, mem1, sizeof(int));
- HDmemcpy(&temp2_int, mem2, sizeof(int));
-
- PER(temp1_int,temp2_int);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP,temp1_int,temp2_int,
- ABS(temp1_int-temp2_int));
- }
- nfound++;
- }
-
- else
-
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P,temp1_int,temp2_int,
- ABS(temp1_int-temp2_int),
- per);
- }
- nfound++;
- }
- mem1+=sizeof(int);
- mem2+=sizeof(int);
- if (options->n && nfound>=options->count)
- return nfound;
- }
-
-
- }
-
- /* -d and -p */
- else if ( options->d && options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_int, mem1, sizeof(int));
- HDmemcpy(&temp2_int, mem2, sizeof(int));
-
- PER(temp1_int,temp2_int);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP,temp1_int,temp2_int,
- ABS(temp1_int-temp2_int));
- }
- nfound++;
- }
-
- else
-
- if ( per > options->percent && ABS(temp1_int-temp2_int) > options->delta )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P,temp1_int,temp2_int,
- ABS(temp1_int-temp2_int),
- per);
- }
- nfound++;
- }
- mem1+=sizeof(int);
- mem2+=sizeof(int);
- if (options->n && nfound>=options->count)
- return nfound;
- }
-
- }
- else
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_int, mem1, sizeof(int));
- HDmemcpy(&temp2_int, mem2, sizeof(int));
-
- if (temp1_int != temp2_int)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT,temp1_int,temp2_int,ABS(temp1_int-temp2_int));
- }
- nfound++;
- }
-
- mem1+=sizeof(int);
- mem2+=sizeof(int);
- if (options->n && nfound>=options->count)
- return nfound;
- } /* nelmts */
-
- }
- h5difftrace("diff_int finish\n");
+ hsize_t nfound=0; /* number of differences found */
+ int temp1_int;
+ int temp2_int;
+ hsize_t i;
+ double per;
+ hbool_t both_zero;
- return nfound;
-}
+ h5difftrace("diff_int start\n");
+ /* -d and !-p */
+ if (options->d && !options->p)
+ {
+ for ( i = 0; i < nelmts; i++)
+ {
+ HDmemcpy(&temp1_int, mem1, sizeof(int));
+ HDmemcpy(&temp2_int, mem2, sizeof(int));
+
+ if (ABS(temp1_int-temp2_int) > options->delta)
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT,temp1_int,temp2_int,ABS(temp1_int-temp2_int));
+ }
+ nfound++;
+ }
+ mem1+=sizeof(int);
+ mem2+=sizeof(int);
+ if (options->n && nfound>=options->count)
+ return nfound;
+ }
+ }
+ /* !-d and -p */
+ else if (!options->d && options->p)
+ {
+ for ( i = 0; i < nelmts; i++)
+ {
+ HDmemcpy(&temp1_int, mem1, sizeof(int));
+ HDmemcpy(&temp2_int, mem2, sizeof(int));
+
+ PER(temp1_int,temp2_int);
+
+ if (not_comparable && !both_zero) /* not comparable */
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT_P_NOTCOMP,temp1_int,temp2_int,
+ ABS(temp1_int-temp2_int));
+ }
+ nfound++;
+ }
+ else
+ if ( per > options->percent )
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT_P,temp1_int,temp2_int,
+ ABS(temp1_int-temp2_int),
+ per);
+ }
+ nfound++;
+ }
+ mem1+=sizeof(int);
+ mem2+=sizeof(int);
+ if (options->n && nfound>=options->count)
+ return nfound;
+ }
+ }
+ /* -d and -p */
+ else if ( options->d && options->p)
+ {
+ for ( i = 0; i < nelmts; i++)
+ {
+ HDmemcpy(&temp1_int, mem1, sizeof(int));
+ HDmemcpy(&temp2_int, mem2, sizeof(int));
+
+ PER(temp1_int,temp2_int);
+
+ if (not_comparable && !both_zero) /* not comparable */
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT_P_NOTCOMP,temp1_int,temp2_int,
+ ABS(temp1_int-temp2_int));
+ }
+ nfound++;
+ }
+ else
+ if ( per > options->percent && ABS(temp1_int-temp2_int) > options->delta )
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT_P,temp1_int,temp2_int,
+ ABS(temp1_int-temp2_int),
+ per);
+ }
+ nfound++;
+ }
+ mem1+=sizeof(int);
+ mem2+=sizeof(int);
+ if (options->n && nfound>=options->count)
+ return nfound;
+ }
+ }
+ else
+ {
+ for ( i = 0; i < nelmts; i++)
+ {
+ HDmemcpy(&temp1_int, mem1, sizeof(int));
+ HDmemcpy(&temp2_int, mem2, sizeof(int));
+
+ if (temp1_int != temp2_int)
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT,temp1_int,temp2_int,ABS(temp1_int-temp2_int));
+ }
+ nfound++;
+ }
+
+ mem1+=sizeof(int);
+ mem2+=sizeof(int);
+ if (options->n && nfound>=options->count)
+ return nfound;
+ } /* nelmts */
+ }
+ h5difftrace("diff_int finish\n");
+
+ return nfound;
+}
/*-------------------------------------------------------------------------
@@ -4885,160 +4620,144 @@ static hsize_t diff_uint(unsigned char *mem1,
int *ph)
{
- hsize_t nfound=0; /* number of differences found */
- unsigned int temp1_uint;
- unsigned int temp2_uint;
- hsize_t i;
- double per;
- hbool_t both_zero;
-
- h5difftrace("diff_uint start\n");
- /* -d and !-p */
- if (options->d && !options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_uint, mem1, sizeof(unsigned int));
- HDmemcpy(&temp2_uint, mem2, sizeof(unsigned int));
-
- if ( PDIFF(temp1_uint,temp2_uint) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT,temp1_uint,temp2_uint,PDIFF(temp1_uint,temp2_uint));
- }
- nfound++;
- }
- mem1+=sizeof(unsigned int);
- mem2+=sizeof(unsigned int);
- if (options->n && nfound>=options->count)
- return nfound;
- }
-
- }
-
- /* !-d and -p */
- else if (!options->d && options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_uint, mem1, sizeof(unsigned int));
- HDmemcpy(&temp2_uint, mem2, sizeof(unsigned int));
-
- PER_UNSIGN(signed int,temp1_uint,temp2_uint);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP,temp1_uint,temp2_uint,PDIFF(temp1_uint,temp2_uint));
- }
- nfound++;
- }
-
- else
-
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P,temp1_uint,temp2_uint,
- PDIFF(temp1_uint,temp2_uint),
- per);
- }
- nfound++;
- }
- mem1+=sizeof(unsigned int);
- mem2+=sizeof(unsigned int);
- if (options->n && nfound>=options->count)
- return nfound;
- }
-
-
- }
-
- /* -d and -p */
- else if ( options->d && options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_uint, mem1, sizeof(unsigned int));
- HDmemcpy(&temp2_uint, mem2, sizeof(unsigned int));
-
- PER_UNSIGN(signed int,temp1_uint,temp2_uint);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP,temp1_uint,temp2_uint,PDIFF(temp1_uint,temp2_uint));
- }
- nfound++;
- }
-
- else
-
- if ( per > options->percent && PDIFF(temp1_uint,temp2_uint) > options->delta )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P,temp1_uint,temp2_uint,
- PDIFF(temp1_uint,temp2_uint),
- per);
- }
- nfound++;
- }
- mem1+=sizeof(unsigned int);
- mem2+=sizeof(unsigned int);
- if (options->n && nfound>=options->count)
- return nfound;
- }
-
- }
- else
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_uint, mem1, sizeof(unsigned int));
- HDmemcpy(&temp2_uint, mem2, sizeof(unsigned int));
-
- if (temp1_uint != temp2_uint)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT,temp1_uint,temp2_uint,PDIFF(temp1_uint,temp2_uint));
- }
- nfound++;
- }
-
- mem1+=sizeof(unsigned int);
- mem2+=sizeof(unsigned int);
- if (options->n && nfound>=options->count)
- return nfound;
- } /* nelmts */
-
- }
- h5difftrace("diff_uint finish\n");
+ hsize_t nfound=0; /* number of differences found */
+ unsigned int temp1_uint;
+ unsigned int temp2_uint;
+ hsize_t i;
+ double per;
+ hbool_t both_zero;
+
+ h5difftrace("diff_uint start\n");
+ /* -d and !-p */
+ if (options->d && !options->p)
+ {
+ for ( i = 0; i < nelmts; i++)
+ {
+ HDmemcpy(&temp1_uint, mem1, sizeof(unsigned int));
+ HDmemcpy(&temp2_uint, mem2, sizeof(unsigned int));
- return nfound;
-}
+ if ( PDIFF(temp1_uint,temp2_uint) > options->delta)
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT,temp1_uint,temp2_uint,PDIFF(temp1_uint,temp2_uint));
+ }
+ nfound++;
+ }
+ mem1+=sizeof(unsigned int);
+ mem2+=sizeof(unsigned int);
+ if (options->n && nfound>=options->count)
+ return nfound;
+ }
+ }
+ /* !-d and -p */
+ else if (!options->d && options->p)
+ {
+ for ( i = 0; i < nelmts; i++)
+ {
+ HDmemcpy(&temp1_uint, mem1, sizeof(unsigned int));
+ HDmemcpy(&temp2_uint, mem2, sizeof(unsigned int));
+
+ PER_UNSIGN(signed int,temp1_uint,temp2_uint);
+
+ if (not_comparable && !both_zero) /* not comparable */
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT_P_NOTCOMP,temp1_uint,temp2_uint,PDIFF(temp1_uint,temp2_uint));
+ }
+ nfound++;
+ }
+ else
+ if ( per > options->percent )
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT_P,temp1_uint,temp2_uint,
+ PDIFF(temp1_uint,temp2_uint),
+ per);
+ }
+ nfound++;
+ }
+ mem1+=sizeof(unsigned int);
+ mem2+=sizeof(unsigned int);
+ if (options->n && nfound>=options->count)
+ return nfound;
+ }
+ }
+ /* -d and -p */
+ else if ( options->d && options->p)
+ {
+ for ( i = 0; i < nelmts; i++)
+ {
+ HDmemcpy(&temp1_uint, mem1, sizeof(unsigned int));
+ HDmemcpy(&temp2_uint, mem2, sizeof(unsigned int));
+ PER_UNSIGN(signed int,temp1_uint,temp2_uint);
+
+ if (not_comparable && !both_zero) /* not comparable */
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT_P_NOTCOMP,temp1_uint,temp2_uint,PDIFF(temp1_uint,temp2_uint));
+ }
+ nfound++;
+ }
+ else
+ if ( per > options->percent && PDIFF(temp1_uint,temp2_uint) > options->delta )
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT_P,temp1_uint,temp2_uint,
+ PDIFF(temp1_uint,temp2_uint),
+ per);
+ }
+ nfound++;
+ }
+ mem1+=sizeof(unsigned int);
+ mem2+=sizeof(unsigned int);
+ if (options->n && nfound>=options->count)
+ return nfound;
+ }
+ }
+ else
+ {
+ for ( i = 0; i < nelmts; i++)
+ {
+ HDmemcpy(&temp1_uint, mem1, sizeof(unsigned int));
+ HDmemcpy(&temp2_uint, mem2, sizeof(unsigned int));
+
+ if (temp1_uint != temp2_uint)
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(I_FORMAT,temp1_uint,temp2_uint,PDIFF(temp1_uint,temp2_uint));
+ }
+ nfound++;
+ }
+
+ mem1+=sizeof(unsigned int);
+ mem2+=sizeof(unsigned int);
+ if (options->n && nfound>=options->count)
+ return nfound;
+ } /* nelmts */
+ }
+ h5difftrace("diff_uint finish\n");
+
+ return nfound;
+}
/*-------------------------------------------------------------------------
@@ -5064,166 +4783,150 @@ static hsize_t diff_long(unsigned char *mem1,
int *ph)
{
- hsize_t nfound=0; /* number of differences found */
- long temp1_long;
- long temp2_long;
- hsize_t i;
- double per;
- hbool_t both_zero;
-
- h5difftrace("diff_long start\n");
- /* -d and !-p */
- if (options->d && !options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_long, mem1, sizeof(long));
- HDmemcpy(&temp2_long, mem2, sizeof(long));
-
- if (ABS(temp1_long-temp2_long) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LI_FORMAT,temp1_long,temp2_long,ABS(temp1_long-temp2_long));
- }
- nfound++;
- }
- mem1+=sizeof(long);
- mem2+=sizeof(long);
- if (options->n && nfound>=options->count)
- return nfound;
- }
- }
- }
-
- /* !-d and -p */
- else if (!options->d && options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_long, mem1, sizeof(long));
- HDmemcpy(&temp2_long, mem2, sizeof(long));
-
- PER(temp1_long,temp2_long);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LI_FORMAT_P_NOTCOMP,temp1_long,temp2_long,
- ABS(temp1_long-temp2_long));
- }
- nfound++;
- }
-
- else
-
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LI_FORMAT_P,temp1_long,temp2_long,
- ABS(temp1_long-temp2_long),
- per);
- }
- nfound++;
- }
- mem1+=sizeof(long);
- mem2+=sizeof(long);
- if (options->n && nfound>=options->count)
- return nfound;
- }
-
-
- }
-
- /* -d and -p */
- else if ( options->d && options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_long, mem1, sizeof(long));
- HDmemcpy(&temp2_long, mem2, sizeof(long));
-
- PER(temp1_long,temp2_long);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LI_FORMAT_P_NOTCOMP,temp1_long,temp2_long,
- ABS(temp1_long-temp2_long));
- }
- nfound++;
- }
-
- else
-
- if ( per > options->percent && ABS(temp1_long-temp2_long) > options->delta )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LI_FORMAT_P,temp1_long,temp2_long,
- ABS(temp1_long-temp2_long),
- per);
- }
- nfound++;
- }
- mem1+=sizeof(long);
- mem2+=sizeof(long);
- if (options->n && nfound>=options->count)
- return nfound;
- }
-
- }
- else
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_long, mem1, sizeof(long));
- HDmemcpy(&temp2_long, mem2, sizeof(long));
-
- if (temp1_long != temp2_long)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LI_FORMAT,temp1_long,temp2_long,ABS(temp1_long-temp2_long));
- }
- nfound++;
- }
-
- mem1+=sizeof(long);
- mem2+=sizeof(long);
- if (options->n && nfound>=options->count)
- return nfound;
- } /* nelmts */
-
- }
- h5difftrace("diff_long finish\n");
+ hsize_t nfound=0; /* number of differences found */
+ long temp1_long;
+ long temp2_long;
+ hsize_t i;
+ double per;
+ hbool_t both_zero;
- return nfound;
-}
+ h5difftrace("diff_long start\n");
+ /* -d and !-p */
+ if (options->d && !options->p)
+ {
+ for ( i = 0; i < nelmts; i++)
+ {
+ for ( i = 0; i < nelmts; i++)
+ {
+ HDmemcpy(&temp1_long, mem1, sizeof(long));
+ HDmemcpy(&temp2_long, mem2, sizeof(long));
+
+ if (ABS(temp1_long-temp2_long) > options->delta)
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(LI_FORMAT,temp1_long,temp2_long,ABS(temp1_long-temp2_long));
+ }
+ nfound++;
+ }
+ mem1+=sizeof(long);
+ mem2+=sizeof(long);
+ if (options->n && nfound>=options->count)
+ return nfound;
+ }
+ }
+ }
+ /* !-d and -p */
+ else if (!options->d && options->p)
+ {
+ for ( i = 0; i < nelmts; i++)
+ {
+ HDmemcpy(&temp1_long, mem1, sizeof(long));
+ HDmemcpy(&temp2_long, mem2, sizeof(long));
+
+ PER(temp1_long,temp2_long);
+ if (not_comparable && !both_zero) /* not comparable */
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(LI_FORMAT_P_NOTCOMP,temp1_long,temp2_long,
+ ABS(temp1_long-temp2_long));
+ }
+ nfound++;
+ }
+ else
+ if ( per > options->percent )
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(LI_FORMAT_P,temp1_long,temp2_long,
+ ABS(temp1_long-temp2_long),
+ per);
+ }
+ nfound++;
+ }
+ mem1+=sizeof(long);
+ mem2+=sizeof(long);
+ if (options->n && nfound>=options->count)
+ return nfound;
+ }
+ }
+ /* -d and -p */
+ else if ( options->d && options->p)
+ {
+ for ( i = 0; i < nelmts; i++)
+ {
+ HDmemcpy(&temp1_long, mem1, sizeof(long));
+ HDmemcpy(&temp2_long, mem2, sizeof(long));
+
+ PER(temp1_long,temp2_long);
+
+ if (not_comparable && !both_zero) /* not comparable */
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(LI_FORMAT_P_NOTCOMP,temp1_long,temp2_long,
+ ABS(temp1_long-temp2_long));
+ }
+ nfound++;
+ }
+ else
+ if ( per > options->percent && ABS(temp1_long-temp2_long) > options->delta )
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(LI_FORMAT_P,temp1_long,temp2_long,
+ ABS(temp1_long-temp2_long),
+ per);
+ }
+ nfound++;
+ }
+ mem1+=sizeof(long);
+ mem2+=sizeof(long);
+ if (options->n && nfound>=options->count)
+ return nfound;
+ }
+ }
+ else
+ {
+ for ( i = 0; i < nelmts; i++)
+ {
+ HDmemcpy(&temp1_long, mem1, sizeof(long));
+ HDmemcpy(&temp2_long, mem2, sizeof(long));
+ if (temp1_long != temp2_long)
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(LI_FORMAT,temp1_long,temp2_long,ABS(temp1_long-temp2_long));
+ }
+ nfound++;
+ }
+
+ mem1+=sizeof(long);
+ mem2+=sizeof(long);
+ if (options->n && nfound>=options->count)
+ return nfound;
+ } /* nelmts */
+
+ }
+ h5difftrace("diff_long finish\n");
+
+ return nfound;
+}
/*-------------------------------------------------------------------------
@@ -5249,166 +4952,148 @@ static hsize_t diff_ulong(unsigned char *mem1,
int *ph)
{
- hsize_t nfound=0; /* number of differences found */
- unsigned long temp1_ulong;
- unsigned long temp2_ulong;
- hsize_t i;
- double per;
- hbool_t both_zero;
-
- h5difftrace("diff_ulong start\n");
-
- /* -d and !-p */
- if (options->d && !options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_ulong, mem1, sizeof(unsigned long));
- HDmemcpy(&temp2_ulong, mem2, sizeof(unsigned long));
-
- if ( PDIFF(temp1_ulong,temp2_ulong) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LI_FORMAT,temp1_ulong,temp2_ulong,PDIFF(temp1_ulong,temp2_ulong));
- }
- nfound++;
- }
- mem1+=sizeof(unsigned long);
- mem2+=sizeof(unsigned long);
- if (options->n && nfound>=options->count)
- return nfound;
- }
-
- }
-
- }
-
- /* !-d and -p */
- else if (!options->d && options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_ulong, mem1, sizeof(unsigned long));
- HDmemcpy(&temp2_ulong, mem2, sizeof(unsigned long));
-
- PER_UNSIGN(signed long,temp1_ulong,temp2_ulong);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(ULI_FORMAT_P_NOTCOMP,temp1_ulong,temp2_ulong,PDIFF(temp1_ulong,temp2_ulong));
- }
- nfound++;
- }
-
- else
-
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LI_FORMAT_P,temp1_ulong,temp2_ulong,
- PDIFF(temp1_ulong,temp2_ulong),
- per);
- }
- nfound++;
- }
- mem1+=sizeof(unsigned long);
- mem2+=sizeof(unsigned long);
- if (options->n && nfound>=options->count)
- return nfound;
- }
-
-
- }
-
- /* -d and -p */
- else if ( options->d && options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_ulong, mem1, sizeof(unsigned long));
- HDmemcpy(&temp2_ulong, mem2, sizeof(unsigned long));
-
- PER_UNSIGN(signed long,temp1_ulong,temp2_ulong);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(ULI_FORMAT_P_NOTCOMP,temp1_ulong,temp2_ulong,PDIFF(temp1_ulong,temp2_ulong));
- }
- nfound++;
- }
-
- else
-
- if ( per > options->percent && PDIFF(temp1_ulong,temp2_ulong) > options->delta )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LI_FORMAT_P,temp1_ulong,temp2_ulong,
- PDIFF(temp1_ulong,temp2_ulong),
- per);
- }
- nfound++;
- }
- mem1+=sizeof(unsigned long);
- mem2+=sizeof(unsigned long);
- if (options->n && nfound>=options->count)
- return nfound;
- }
-
- }
- else
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_ulong, mem1, sizeof(unsigned long));
- HDmemcpy(&temp2_ulong, mem2, sizeof(unsigned long));
-
- if (temp1_ulong != temp2_ulong)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LI_FORMAT,temp1_ulong,temp2_ulong,PDIFF(temp1_ulong,temp2_ulong));
- }
- nfound++;
- }
-
- mem1+=sizeof(unsigned long);
- mem2+=sizeof(unsigned long);
- if (options->n && nfound>=options->count)
- return nfound;
- } /* nelmts */
-
- }
- h5difftrace("diff_ulong finish\n");
+ hsize_t nfound=0; /* number of differences found */
+ unsigned long temp1_ulong;
+ unsigned long temp2_ulong;
+ hsize_t i;
+ double per;
+ hbool_t both_zero;
- return nfound;
-}
+ h5difftrace("diff_ulong start\n");
+ /* -d and !-p */
+ if (options->d && !options->p)
+ {
+ for ( i = 0; i < nelmts; i++)
+ {
+ for ( i = 0; i < nelmts; i++)
+ {
+ HDmemcpy(&temp1_ulong, mem1, sizeof(unsigned long));
+ HDmemcpy(&temp2_ulong, mem2, sizeof(unsigned long));
+
+ if ( PDIFF(temp1_ulong,temp2_ulong) > options->delta)
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(LI_FORMAT,temp1_ulong,temp2_ulong,PDIFF(temp1_ulong,temp2_ulong));
+ }
+ nfound++;
+ }
+ mem1+=sizeof(unsigned long);
+ mem2+=sizeof(unsigned long);
+ if (options->n && nfound>=options->count)
+ return nfound;
+ }
+ }
+ }
+ /* !-d and -p */
+ else if (!options->d && options->p)
+ {
+ for ( i = 0; i < nelmts; i++)
+ {
+ HDmemcpy(&temp1_ulong, mem1, sizeof(unsigned long));
+ HDmemcpy(&temp2_ulong, mem2, sizeof(unsigned long));
+
+ PER_UNSIGN(signed long,temp1_ulong,temp2_ulong);
+
+ if (not_comparable && !both_zero) /* not comparable */
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(ULI_FORMAT_P_NOTCOMP,temp1_ulong,temp2_ulong,PDIFF(temp1_ulong,temp2_ulong));
+ }
+ nfound++;
+ }
+ else
+ if ( per > options->percent )
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(LI_FORMAT_P,temp1_ulong,temp2_ulong,
+ PDIFF(temp1_ulong,temp2_ulong),
+ per);
+ }
+ nfound++;
+ }
+ mem1+=sizeof(unsigned long);
+ mem2+=sizeof(unsigned long);
+ if (options->n && nfound>=options->count)
+ return nfound;
+ }
+ }
+ /* -d and -p */
+ else if ( options->d && options->p)
+ {
+ for ( i = 0; i < nelmts; i++)
+ {
+ HDmemcpy(&temp1_ulong, mem1, sizeof(unsigned long));
+ HDmemcpy(&temp2_ulong, mem2, sizeof(unsigned long));
+
+ PER_UNSIGN(signed long,temp1_ulong,temp2_ulong);
+
+ if (not_comparable && !both_zero) /* not comparable */
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(ULI_FORMAT_P_NOTCOMP,temp1_ulong,temp2_ulong,PDIFF(temp1_ulong,temp2_ulong));
+ }
+ nfound++;
+ }
+ else
+ if ( per > options->percent && PDIFF(temp1_ulong,temp2_ulong) > options->delta )
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(LI_FORMAT_P,temp1_ulong,temp2_ulong,
+ PDIFF(temp1_ulong,temp2_ulong),
+ per);
+ }
+ nfound++;
+ }
+ mem1+=sizeof(unsigned long);
+ mem2+=sizeof(unsigned long);
+ if (options->n && nfound>=options->count)
+ return nfound;
+ }
+ }
+ else
+ {
+ for ( i = 0; i < nelmts; i++)
+ {
+ HDmemcpy(&temp1_ulong, mem1, sizeof(unsigned long));
+ HDmemcpy(&temp2_ulong, mem2, sizeof(unsigned long));
+
+ if (temp1_ulong != temp2_ulong)
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(LI_FORMAT,temp1_ulong,temp2_ulong,PDIFF(temp1_ulong,temp2_ulong));
+ }
+ nfound++;
+ }
+
+ mem1+=sizeof(unsigned long);
+ mem2+=sizeof(unsigned long);
+ if (options->n && nfound>=options->count)
+ return nfound;
+ } /* nelmts */
+ }
+ h5difftrace("diff_ulong finish\n");
+
+ return nfound;
+}
/*-------------------------------------------------------------------------
@@ -5434,156 +5119,140 @@ static hsize_t diff_llong(unsigned char *mem1,
int *ph)
{
- hsize_t nfound=0; /* number of differences found */
- long long temp1_llong;
- long long temp2_llong;
- hsize_t i;
- double per;
- hbool_t both_zero;
-
- h5difftrace("diff_llong start\n");
- /* -d and !-p */
- if (options->d && !options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_llong, mem1, sizeof(long long));
- HDmemcpy(&temp2_llong, mem2, sizeof(long long));
-
- if (ABS( temp1_llong-temp2_llong) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LLI_FORMAT,temp1_llong,temp2_llong,ABS(temp1_llong-temp2_llong));
- }
- nfound++;
- }
- mem1+=sizeof(long long);
- mem2+=sizeof(long long);
- if (options->n && nfound>=options->count)
- return nfound;
- }
-
- }
-
- /* !-d and -p */
- else if (!options->d && options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_llong, mem1, sizeof(long long));
- HDmemcpy(&temp2_llong, mem2, sizeof(long long));
-
- PER(temp1_llong,temp2_llong);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LLI_FORMAT_P_NOTCOMP,temp1_llong,temp2_llong,ABS(temp1_llong-temp2_llong));
- }
- nfound++;
- }
-
- else
-
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LLI_FORMAT_P,temp1_llong,temp2_llong,ABS(temp1_llong-temp2_llong),per);
- }
- nfound++;
- }
- mem1+=sizeof(long long);
- mem2+=sizeof(long long);
- if (options->n && nfound>=options->count)
- return nfound;
- }
-
-
- }
-
- /* -d and -p */
- else if ( options->d && options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_llong, mem1, sizeof(long long));
- HDmemcpy(&temp2_llong, mem2, sizeof(long long));
-
- PER(temp1_llong,temp2_llong);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LLI_FORMAT_P_NOTCOMP,temp1_llong,temp2_llong,ABS(temp1_llong-temp2_llong));
- }
- nfound++;
- }
-
- else
-
- if ( per > options->percent && ABS(temp1_llong-temp2_llong) > options->delta )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LLI_FORMAT_P,temp1_llong,temp2_llong,ABS(temp1_llong-temp2_llong),per);
- }
- nfound++;
- }
- mem1+=sizeof(long long);
- mem2+=sizeof(long long);
- if (options->n && nfound>=options->count)
- return nfound;
- }
-
- }
- else
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_llong, mem1, sizeof(long long));
- HDmemcpy(&temp2_llong, mem2, sizeof(long long));
-
- if (temp1_llong != temp2_llong)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LLI_FORMAT,temp1_llong,temp2_llong,ABS(temp1_llong-temp2_llong));
- }
- nfound++;
- }
-
- mem1+=sizeof(long long);
- mem2+=sizeof(long long);
- if (options->n && nfound>=options->count)
- return nfound;
- } /* nelmts */
-
- }
- h5difftrace("diff_llong finish\n");
+ hsize_t nfound=0; /* number of differences found */
+ long long temp1_llong;
+ long long temp2_llong;
+ hsize_t i;
+ double per;
+ hbool_t both_zero;
- return nfound;
-}
+ h5difftrace("diff_llong start\n");
+ /* -d and !-p */
+ if (options->d && !options->p)
+ {
+ for ( i = 0; i < nelmts; i++)
+ {
+ HDmemcpy(&temp1_llong, mem1, sizeof(long long));
+ HDmemcpy(&temp2_llong, mem2, sizeof(long long));
+ if (ABS( temp1_llong-temp2_llong) > options->delta)
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(LLI_FORMAT,temp1_llong,temp2_llong,ABS(temp1_llong-temp2_llong));
+ }
+ nfound++;
+ }
+ mem1+=sizeof(long long);
+ mem2+=sizeof(long long);
+ if (options->n && nfound>=options->count)
+ return nfound;
+ }
+ }
+ /* !-d and -p */
+ else if (!options->d && options->p)
+ {
+ for ( i = 0; i < nelmts; i++)
+ {
+ HDmemcpy(&temp1_llong, mem1, sizeof(long long));
+ HDmemcpy(&temp2_llong, mem2, sizeof(long long));
+
+ PER(temp1_llong,temp2_llong);
+
+ if (not_comparable && !both_zero) /* not comparable */
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(LLI_FORMAT_P_NOTCOMP,temp1_llong,temp2_llong,ABS(temp1_llong-temp2_llong));
+ }
+ nfound++;
+ }
+ else
+ if ( per > options->percent )
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(LLI_FORMAT_P,temp1_llong,temp2_llong,ABS(temp1_llong-temp2_llong),per);
+ }
+ nfound++;
+ }
+ mem1+=sizeof(long long);
+ mem2+=sizeof(long long);
+ if (options->n && nfound>=options->count)
+ return nfound;
+ }
+ }
+ /* -d and -p */
+ else if ( options->d && options->p)
+ {
+ for ( i = 0; i < nelmts; i++)
+ {
+ HDmemcpy(&temp1_llong, mem1, sizeof(long long));
+ HDmemcpy(&temp2_llong, mem2, sizeof(long long));
+
+ PER(temp1_llong,temp2_llong);
+
+ if (not_comparable && !both_zero) /* not comparable */
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(LLI_FORMAT_P_NOTCOMP,temp1_llong,temp2_llong,ABS(temp1_llong-temp2_llong));
+ }
+ nfound++;
+ }
+ else
+ if ( per > options->percent && ABS(temp1_llong-temp2_llong) > options->delta )
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(LLI_FORMAT_P,temp1_llong,temp2_llong,ABS(temp1_llong-temp2_llong),per);
+ }
+ nfound++;
+ }
+ mem1+=sizeof(long long);
+ mem2+=sizeof(long long);
+ if (options->n && nfound>=options->count)
+ return nfound;
+ }
+ }
+ else
+ {
+ for ( i = 0; i < nelmts; i++)
+ {
+ HDmemcpy(&temp1_llong, mem1, sizeof(long long));
+ HDmemcpy(&temp2_llong, mem2, sizeof(long long));
+
+ if (temp1_llong != temp2_llong)
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(LLI_FORMAT,temp1_llong,temp2_llong,ABS(temp1_llong-temp2_llong));
+ }
+ nfound++;
+ }
+
+ mem1+=sizeof(long long);
+ mem2+=sizeof(long long);
+ if (options->n && nfound>=options->count)
+ return nfound;
+ } /* nelmts */
+ }
+ h5difftrace("diff_llong finish\n");
+
+ return nfound;
+}
/*-------------------------------------------------------------------------
@@ -5609,161 +5278,145 @@ static hsize_t diff_ullong(unsigned char *mem1,
int *ph)
{
- hsize_t nfound=0; /* number of differences found */
- unsigned long long temp1_ullong;
- unsigned long long temp2_ullong;
- hsize_t i;
- float f1, f2;
- double per;
- hbool_t both_zero;
-
- h5difftrace("diff_ullong start\n");
- /* -d and !-p */
- if (options->d && !options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_ullong, mem1, sizeof(unsigned long long));
- HDmemcpy(&temp2_ullong, mem2, sizeof(unsigned long long));
-
- if ( PDIFF(temp1_ullong,temp2_ullong) > (unsigned long long) options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(ULLI_FORMAT,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong));
- }
- nfound++;
- }
- mem1+=sizeof(unsigned long long);
- mem2+=sizeof(unsigned long long);
- if (options->n && nfound>=options->count)
- return nfound;
- }
-
- }
-
- /* !-d and -p */
- else if (!options->d && options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_ullong, mem1, sizeof(unsigned long long));
- HDmemcpy(&temp2_ullong, mem2, sizeof(unsigned long long));
-
- ull2float(temp1_ullong,&f1);
- ull2float(temp2_ullong,&f2);
- PER(f1,f2);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(ULLI_FORMAT_P_NOTCOMP,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong));
- }
- nfound++;
- }
-
- else
-
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(ULLI_FORMAT_P,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong),per);
- }
- nfound++;
- }
- mem1+=sizeof(unsigned long long);
- mem2+=sizeof(unsigned long long);
- if (options->n && nfound>=options->count)
- return nfound;
- }
-
-
- }
-
- /* -d and -p */
- else if ( options->d && options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_ullong, mem1, sizeof(unsigned long long));
- HDmemcpy(&temp2_ullong, mem2, sizeof(unsigned long long));
-
- ull2float(temp1_ullong,&f1);
- ull2float(temp2_ullong,&f2);
- PER(f1,f2);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(ULLI_FORMAT_P_NOTCOMP,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong));
- }
- nfound++;
- }
-
- else
-
- if ( per > options->percent && PDIFF(temp1_ullong,temp2_ullong) > (unsigned long long)options->delta )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(ULLI_FORMAT_P,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong),per);
- }
- nfound++;
- }
- mem1+=sizeof(unsigned long long);
- mem2+=sizeof(unsigned long long);
- if (options->n && nfound>=options->count)
- return nfound;
- }
-
- }
- else
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_ullong, mem1, sizeof(unsigned long long));
- HDmemcpy(&temp2_ullong, mem2, sizeof(unsigned long long));
-
- if (temp1_ullong != temp2_ullong)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(ULLI_FORMAT,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong));
- }
- nfound++;
- }
-
- mem1+=sizeof(unsigned long long);
- mem2+=sizeof(unsigned long long);
- if (options->n && nfound>=options->count)
- return nfound;
- } /* nelmts */
-
- }
- h5difftrace("diff_ullong finish\n");
+ hsize_t nfound=0; /* number of differences found */
+ unsigned long long temp1_ullong;
+ unsigned long long temp2_ullong;
+ hsize_t i;
+ float f1, f2;
+ double per;
+ hbool_t both_zero;
+
+ h5difftrace("diff_ullong start\n");
+ /* -d and !-p */
+ if (options->d && !options->p)
+ {
+ for ( i = 0; i < nelmts; i++)
+ {
+ HDmemcpy(&temp1_ullong, mem1, sizeof(unsigned long long));
+ HDmemcpy(&temp2_ullong, mem2, sizeof(unsigned long long));
- return nfound;
-}
+ if ( PDIFF(temp1_ullong,temp2_ullong) > (unsigned long long) options->delta)
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(ULLI_FORMAT,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong));
+ }
+ nfound++;
+ }
+ mem1+=sizeof(unsigned long long);
+ mem2+=sizeof(unsigned long long);
+ if (options->n && nfound>=options->count)
+ return nfound;
+ }
+ }
+ /* !-d and -p */
+ else if (!options->d && options->p)
+ {
+ for ( i = 0; i < nelmts; i++)
+ {
+ HDmemcpy(&temp1_ullong, mem1, sizeof(unsigned long long));
+ HDmemcpy(&temp2_ullong, mem2, sizeof(unsigned long long));
+ ull2float(temp1_ullong,&f1);
+ ull2float(temp2_ullong,&f2);
+ PER(f1,f2);
+
+ if (not_comparable && !both_zero) /* not comparable */
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(ULLI_FORMAT_P_NOTCOMP,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong));
+ }
+ nfound++;
+ }
+ else
+ if ( per > options->percent )
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(ULLI_FORMAT_P,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong),per);
+ }
+ nfound++;
+ }
+ mem1+=sizeof(unsigned long long);
+ mem2+=sizeof(unsigned long long);
+ if (options->n && nfound>=options->count)
+ return nfound;
+ }
+ }
+ /* -d and -p */
+ else if ( options->d && options->p)
+ {
+ for ( i = 0; i < nelmts; i++)
+ {
+ HDmemcpy(&temp1_ullong, mem1, sizeof(unsigned long long));
+ HDmemcpy(&temp2_ullong, mem2, sizeof(unsigned long long));
+
+ ull2float(temp1_ullong,&f1);
+ ull2float(temp2_ullong,&f2);
+ PER(f1,f2);
+
+ if (not_comparable && !both_zero) /* not comparable */
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(ULLI_FORMAT_P_NOTCOMP,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong));
+ }
+ nfound++;
+ }
+ else
+ if ( per > options->percent && PDIFF(temp1_ullong,temp2_ullong) > (unsigned long long)options->delta )
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(ULLI_FORMAT_P,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong),per);
+ }
+ nfound++;
+ }
+ mem1+=sizeof(unsigned long long);
+ mem2+=sizeof(unsigned long long);
+ if (options->n && nfound>=options->count)
+ return nfound;
+ }
+ }
+ else
+ {
+ for ( i = 0; i < nelmts; i++)
+ {
+ HDmemcpy(&temp1_ullong, mem1, sizeof(unsigned long long));
+ HDmemcpy(&temp2_ullong, mem2, sizeof(unsigned long long));
+
+ if (temp1_ullong != temp2_ullong)
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(ULLI_FORMAT,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong));
+ }
+ nfound++;
+ }
+
+ mem1+=sizeof(unsigned long long);
+ mem2+=sizeof(unsigned long long);
+ if (options->n && nfound>=options->count)
+ return nfound;
+ } /* nelmts */
+ }
+ h5difftrace("diff_ullong finish\n");
+
+ return nfound;
+}
/*-------------------------------------------------------------------------
@@ -5781,44 +5434,44 @@ static hsize_t diff_ullong(unsigned char *mem1,
static
int ull2float(unsigned long long ull_value, float *f_value)
{
- hid_t dxpl_id;
- unsigned char *buf = NULL;
- size_t src_size;
- size_t dst_size;
+ hid_t dxpl_id;
+ unsigned char *buf = NULL;
+ size_t src_size;
+ size_t dst_size;
- h5difftrace("ull2float start\n");
- if((dxpl_id = H5Pcreate(H5P_DATASET_XFER))<0)
- goto error;
+ h5difftrace("ull2float start\n");
+ if((dxpl_id = H5Pcreate(H5P_DATASET_XFER))<0)
+ goto error;
- src_size = H5Tget_size(H5T_NATIVE_ULLONG);
- dst_size = H5Tget_size(H5T_NATIVE_FLOAT);
- buf = (unsigned char*)HDcalloc((size_t)1, MAX(src_size, dst_size));
- if(!buf)
- goto error;
+ src_size = H5Tget_size(H5T_NATIVE_ULLONG);
+ dst_size = H5Tget_size(H5T_NATIVE_FLOAT);
+ buf = (unsigned char*)HDcalloc((size_t)1, MAX(src_size, dst_size));
+ if(!buf)
+ goto error;
- HDmemcpy(buf, &ull_value, src_size);
+ HDmemcpy(buf, &ull_value, src_size);
- /* do conversion */
- if(H5Tconvert(H5T_NATIVE_ULLONG, H5T_NATIVE_FLOAT, (size_t)1, buf, NULL, dxpl_id)<0)
- goto error;
+ /* do conversion */
+ if(H5Tconvert(H5T_NATIVE_ULLONG, H5T_NATIVE_FLOAT, (size_t)1, buf, NULL, dxpl_id)<0)
+ goto error;
- HDmemcpy(f_value, buf, dst_size);
+ HDmemcpy(f_value, buf, dst_size);
- if(buf)
- HDfree(buf);
- h5difftrace("ull2float finish\n");
+ if(buf)
+ HDfree(buf);
+ h5difftrace("ull2float finish\n");
- return 0;
+ return 0;
error:
- H5E_BEGIN_TRY {
- H5Pclose(dxpl_id);
- } H5E_END_TRY;
- if(buf)
- HDfree(buf);
- h5difftrace("ull2float errored\n");
-
- return -1;
+ H5E_BEGIN_TRY {
+ H5Pclose(dxpl_id);
+ } H5E_END_TRY;
+ if(buf)
+ HDfree(buf);
+ h5difftrace("ull2float errored\n");
+
+ return -1;
}
diff --git a/tools/lib/h5diff_util.c b/tools/lib/h5diff_util.c
index 14fbcaa..985a47d 100644
--- a/tools/lib/h5diff_util.c
+++ b/tools/lib/h5diff_util.c
@@ -186,21 +186,21 @@ void print_type(hid_t type)
*
*-------------------------------------------------------------------------
*/
-const char*
+H5_ATTR_PURE const char*
diff_basename(const char *name)
{
size_t i;
- if (name==NULL)
+ if (name == NULL)
return NULL;
/* Find the end of the base name */
i = HDstrlen(name);
- while (i>0 && '/'==name[i-1])
+ while (i > 0 && '/' == name[i - 1])
--i;
/* Skip backward over base name */
- while (i>0 && '/'!=name[i-1])
+ while (i > 0 && '/' != name[i - 1])
--i;
return(name+i);
@@ -217,20 +217,25 @@ diff_basename(const char *name)
*
*-------------------------------------------------------------------------
*/
-const char*
+H5_ATTR_PURE H5_ATTR_CONST const char*
get_type(h5trav_type_t type)
{
switch(type) {
case H5TRAV_TYPE_DATASET:
return("H5G_DATASET");
+
case H5TRAV_TYPE_GROUP:
return("H5G_GROUP");
+
case H5TRAV_TYPE_NAMED_DATATYPE:
return("H5G_TYPE");
+
case H5TRAV_TYPE_LINK:
return("H5G_LINK");
+
case H5TRAV_TYPE_UDLINK:
return("H5G_UDLINK");
+
case H5TRAV_TYPE_UNKNOWN:
default:
return("unknown type");
@@ -250,19 +255,23 @@ get_type(h5trav_type_t type)
*
*-------------------------------------------------------------------------
*/
-const char*
+H5_ATTR_PURE const char*
get_sign(H5T_sign_t sign)
{
switch (sign)
{
case H5T_SGN_NONE:
return "H5T_SGN_NONE";
+
case H5T_SGN_2:
return "H5T_SGN_2";
+
case H5T_SGN_ERROR:
return "H5T_SGN_ERROR";
+
case H5T_NSGN:
return "H5T_NSGN";
+
default:
HDassert(0);
return "unknown sign value";
@@ -281,38 +290,48 @@ get_sign(H5T_sign_t sign)
*
*-------------------------------------------------------------------------
*/
-const char*
+H5_ATTR_PURE const char*
get_class(H5T_class_t tclass)
{
- switch (tclass)
- {
- case H5T_TIME:
- return("H5T_TIME");
- case H5T_INTEGER:
- return("H5T_INTEGER");
- case H5T_FLOAT:
- return("H5T_FLOAT");
- case H5T_STRING:
- return("H5T_STRING");
- case H5T_BITFIELD:
- return("H5T_BITFIELD");
- case H5T_OPAQUE:
- return("H5T_OPAQUE");
- case H5T_COMPOUND:
- return("H5T_COMPOUND");
- case H5T_REFERENCE:
- return("H5T_REFERENCE");
- case H5T_ENUM:
- return("H5T_ENUM");
- case H5T_VLEN:
- return("H5T_VLEN");
- case H5T_ARRAY:
- return("H5T_ARRAY");
- case H5T_NO_CLASS:
- case H5T_NCLASSES:
- default:
- HDassert(0);
- return("Invalid class");
+ switch (tclass) {
+ case H5T_TIME:
+ return("H5T_TIME");
+
+ case H5T_INTEGER:
+ return("H5T_INTEGER");
+
+ case H5T_FLOAT:
+ return("H5T_FLOAT");
+
+ case H5T_STRING:
+ return("H5T_STRING");
+
+ case H5T_BITFIELD:
+ return("H5T_BITFIELD");
+
+ case H5T_OPAQUE:
+ return("H5T_OPAQUE");
+
+ case H5T_COMPOUND:
+ return("H5T_COMPOUND");
+
+ case H5T_REFERENCE:
+ return("H5T_REFERENCE");
+
+ case H5T_ENUM:
+ return("H5T_ENUM");
+
+ case H5T_VLEN:
+ return("H5T_VLEN");
+
+ case H5T_ARRAY:
+ return("H5T_ARRAY");
+
+ case H5T_NO_CLASS:
+ case H5T_NCLASSES:
+ default:
+ HDassert(0);
+ return("Invalid class");
} /* end switch */
} /* end get_class() */
@@ -325,10 +344,10 @@ get_class(H5T_class_t tclass)
*/
void print_found(hsize_t nfound)
{
- if(g_Parallel)
- parallel_print("%"H5_PRINTF_LL_WIDTH"u differences found\n", (unsigned long long)nfound);
- else
- HDfprintf(stdout,"%Hu differences found\n",nfound);
+ if(g_Parallel)
+ parallel_print("%"H5_PRINTF_LL_WIDTH"u differences found\n", (unsigned long long)nfound);
+ else
+ HDfprintf(stdout,"%Hu differences found\n",nfound);
}
@@ -375,3 +394,4 @@ herr_t match_up_memsize (hid_t f_tid1_id, hid_t f_tid2_id,
out:
return ret;
}
+
diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c
index 22c611f..bfcbfb8 100644
--- a/tools/lib/h5tools.c
+++ b/tools/lib/h5tools.c
@@ -47,9 +47,9 @@ int region_output; /* region output */
int oid_output; /* oid output */
int data_output; /* data output */
int attr_data_output; /* attribute data output */
-int packed_bits_num; /* number of packed bits to display */
-int packed_data_offset; /* offset of packed bits to display */
-int packed_data_length; /* lengtht of packed bits to display */
+unsigned packed_bits_num; /* number of packed bits to display */
+unsigned packed_data_offset; /* offset of packed bits to display */
+unsigned packed_data_length; /* length of packed bits to display */
unsigned long long packed_data_mask; /* mask in which packed bits to display */
int enable_error_stack= FALSE; /* re-enable error stack */
@@ -670,7 +670,7 @@ done:
* Modifications:
*-------------------------------------------------------------------------
*/
-static size_t
+H5_ATTR_PURE static size_t
h5tools_count_ncols(const char *s)
{
register size_t i;
@@ -806,7 +806,7 @@ h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info,
h5tools_str_t prefix;
h5tools_str_t str; /*temporary for indentation */
size_t templength = 0;
- int i, indentlevel = 0;
+ unsigned u, indentlevel = 0;
if (stream == NULL)
return;
@@ -828,10 +828,9 @@ h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info,
h5tools_str_prefix(&prefix, info, elmtno, ctx->ndims, ctx);
/* Write new prefix to output */
- if (ctx->indent_level >= 0) {
+ if (ctx->indent_level > 0)
indentlevel = ctx->indent_level;
- }
- else {
+ else
/*
* This is because sometimes we don't print out all the header
* info for the data (like the tattr-2.ddl example). If that happens
@@ -839,29 +838,23 @@ h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info,
* just print out the default indent levels.
*/
indentlevel = ctx->default_indent_level;
- }
/* when printing array indices, print the indentation before the prefix
the prefix is printed one indentation level before */
- if (info->pindex) {
- for (i = 0; i < indentlevel - 1; i++) {
+ if (info->pindex)
+ for (u = 0; u < indentlevel - 1; u++)
PUTSTREAM(h5tools_str_fmt(&str, (size_t)0, info->line_indent), stream);
- }
- }
- if (elmtno == 0 && secnum == 0 && info->line_1st) {
+ if (elmtno == 0 && secnum == 0 && info->line_1st)
PUTSTREAM(h5tools_str_fmt(&prefix, (size_t)0, info->line_1st), stream);
- }
- else if (secnum && info->line_cont) {
+ else if (secnum && info->line_cont)
PUTSTREAM(h5tools_str_fmt(&prefix, (size_t)0, info->line_cont), stream);
- }
- else {
+ else
PUTSTREAM(h5tools_str_fmt(&prefix, (size_t)0, info->line_pre), stream);
- }
templength = h5tools_str_len(&prefix);
- for (i = 0; i < indentlevel; i++) {
+ for (u = 0; u < indentlevel; u++)
/*we already made the indent for the array indices case */
if (!info->pindex) {
PUTSTREAM(h5tools_str_fmt(&prefix, (size_t)0, info->line_indent), stream);
@@ -871,7 +864,6 @@ h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info,
/*we cannot count the prefix for the array indices case */
templength += h5tools_str_len(&str);
}
- }
ctx->cur_column = ctx->prev_prefix_len = templength;
ctx->cur_elmt = 0;
@@ -901,7 +893,7 @@ h5tools_region_simple_prefix(FILE *stream, const h5tool_format_t *info,
h5tools_str_t prefix;
h5tools_str_t str; /*temporary for indentation */
size_t templength = 0;
- int i, indentlevel = 0;
+ unsigned u, indentlevel = 0;
if (stream == NULL)
return;
@@ -923,7 +915,7 @@ h5tools_region_simple_prefix(FILE *stream, const h5tool_format_t *info,
h5tools_str_region_prefix(&prefix, info, elmtno, ptdata, ctx->ndims, ctx->p_max_idx, ctx);
/* Write new prefix to output */
- if (ctx->indent_level >= 0)
+ if (ctx->indent_level > 0)
indentlevel = ctx->indent_level;
else
/*
@@ -937,20 +929,19 @@ h5tools_region_simple_prefix(FILE *stream, const h5tool_format_t *info,
/* when printing array indices, print the indentation before the prefix
the prefix is printed one indentation level before */
if (info->pindex)
- for (i = 0; i < indentlevel - 1; i++) {
+ for (u = 0; u < indentlevel - 1; u++)
PUTSTREAM(h5tools_str_fmt(&str, (size_t)0, info->line_indent), stream);
- }
- if (elmtno == 0 && secnum == 0 && info->line_1st) {
+ if (elmtno == 0 && secnum == 0 && info->line_1st)
PUTSTREAM(h5tools_str_fmt(&prefix, (size_t)0, info->line_1st), stream);
- } else if (secnum && info->line_cont) {
+ else if (secnum && info->line_cont)
PUTSTREAM(h5tools_str_fmt(&prefix, (size_t)0, info->line_cont), stream);
- } else
+ else
PUTSTREAM(h5tools_str_fmt(&prefix, (size_t)0, info->line_pre), stream);
templength = h5tools_str_len(&prefix);
- for (i = 0; i < indentlevel; i++) {
+ for (u = 0; u < indentlevel; u++)
/*we already made the indent for the array indices case */
if (!info->pindex) {
PUTSTREAM(h5tools_str_fmt(&prefix, (size_t)0, info->line_indent), stream);
@@ -960,7 +951,6 @@ h5tools_region_simple_prefix(FILE *stream, const h5tool_format_t *info,
/*we cannot count the prefix for the array indices case */
templength += h5tools_str_len(&str);
}
- }
ctx->cur_column = ctx->prev_prefix_len = templength;
ctx->cur_elmt = 0;
@@ -1300,9 +1290,8 @@ init_acc_pos(h5tools_context_t *ctx, hsize_t *dims)
HDassert(ctx->ndims);
ctx->acc[ctx->ndims - 1] = 1;
- for (i = (ctx->ndims - 2); i >= 0; i--) {
+ for (i = ((int)ctx->ndims - 2); i >= 0; i--)
ctx->acc[i] = ctx->acc[i + 1] * dims[i + 1];
- }
for (j = 0; j < ctx->ndims; j++)
ctx->pos[j] = 0;
}
@@ -1537,18 +1526,18 @@ CATCH
*/
int
render_bin_output_region_data_blocks(hid_t region_id, FILE *stream,
- hid_t container, int ndims, hid_t type_id, hssize_t nblocks, hsize_t *ptdata)
+ hid_t container, unsigned ndims, hid_t type_id, hsize_t nblocks, hsize_t *ptdata)
{
hsize_t *dims1 = NULL;
hsize_t *start = NULL;
hsize_t *count = NULL;
hsize_t numelem;
hsize_t total_size[H5S_MAX_RANK];
- int jndx;
+ unsigned jndx;
size_t type_size;
hid_t mem_space = -1;
void *region_buf = NULL;
- int blkndx;
+ hsize_t blkndx;
hid_t sid1 = -1;
int ret_value = SUCCEED;
@@ -1568,7 +1557,7 @@ render_bin_output_region_data_blocks(hid_t region_id, FILE *stream,
}
/* Create dataspace for reading buffer */
- if((mem_space = H5Screate_simple(ndims, dims1, NULL)) < 0)
+ if((mem_space = H5Screate_simple((int)ndims, dims1, NULL)) < 0)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Screate_simple failed");
if((type_size = H5Tget_size(type_id)) == 0)
@@ -1641,7 +1630,8 @@ render_bin_output_region_blocks(hid_t region_space, hid_t region_id,
hsize_t nblocks;
hsize_t alloc_size;
hsize_t *ptdata;
- int ndims;
+ int sndims;
+ unsigned ndims;
hid_t dtype = -1;
hid_t type_id = -1;
@@ -1650,16 +1640,16 @@ render_bin_output_region_blocks(hid_t region_space, hid_t region_id,
nblocks = (hsize_t)snblocks;
/* Print block information */
- if((ndims = H5Sget_simple_extent_ndims(region_space)) < 0)
+ if((sndims = H5Sget_simple_extent_ndims(region_space)) < 0)
H5E_THROW(FALSE, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed");
+ ndims = (unsigned)sndims;
alloc_size = nblocks * ndims * 2 * sizeof(ptdata[0]);
HDassert(alloc_size == (hsize_t) ((size_t) alloc_size)); /*check for overflow*/
if((ptdata = (hsize_t*) HDmalloc((size_t) alloc_size)) == NULL)
HGOTO_ERROR(FALSE, H5E_tools_min_id_g, "Could not allocate buffer for ptdata");
- H5_CHECK_OVERFLOW(nblocks, hssize_t, hsize_t);
- if(H5Sget_select_hyper_blocklist(region_space, (hsize_t) 0, (hsize_t) nblocks, ptdata) < 0)
+ if(H5Sget_select_hyper_blocklist(region_space, (hsize_t) 0, nblocks, ptdata) < 0)
HGOTO_ERROR(FALSE, H5E_tools_min_id_g, "H5Rget_select_hyper_blocklist failed");
if((dtype = H5Dget_type(region_id)) < 0)
@@ -1706,10 +1696,10 @@ render_bin_output_region_blocks(hid_t region_space, hid_t region_id,
int
render_bin_output_region_data_points(hid_t region_space, hid_t region_id,
FILE *stream, hid_t container,
- int ndims, hid_t type_id, hssize_t npoints)
+ unsigned ndims, hid_t type_id, hsize_t npoints)
{
hsize_t *dims1 = NULL;
- int type_size;
+ size_t type_size;
hid_t mem_space = -1;
void *region_buf = NULL;
int ret_value = SUCCEED;
@@ -1764,17 +1754,21 @@ render_bin_output_region_points(hid_t region_space, hid_t region_id,
FILE *stream, hid_t container)
{
HERR_INIT(hbool_t, TRUE)
- hssize_t npoints;
- int ndims;
+ hssize_t snpoints;
+ hsize_t npoints;
+ int sndims;
+ unsigned ndims;
hid_t dtype = -1;
hid_t type_id = -1;
- if((npoints = H5Sget_select_elem_npoints(region_space)) <= 0)
+ if((snpoints = H5Sget_select_elem_npoints(region_space)) <= 0)
H5E_THROW(FALSE, H5E_tools_min_id_g, "H5Sget_select_elem_npoints failed");
+ npoints = (hsize_t)snpoints;
/* Allocate space for the dimension array */
- if((ndims = H5Sget_simple_extent_ndims(region_space)) < 0)
+ if((sndims = H5Sget_simple_extent_ndims(region_space)) < 0)
H5E_THROW(FALSE, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed");
+ ndims = (unsigned)sndims;
if((dtype = H5Dget_type(region_id)) < 0)
HGOTO_ERROR(FALSE, H5E_tools_min_id_g, "H5Dget_type failed");
@@ -1805,7 +1799,7 @@ CATCH
* Return: TRUE if all bytes are zero; FALSE otherwise
*-------------------------------------------------------------------------
*/
-hbool_t
+H5_ATTR_PURE hbool_t
h5tools_is_zero(const void *_mem, size_t size)
{
const unsigned char *mem = (const unsigned char *) _mem;
diff --git a/tools/lib/h5tools.h b/tools/lib/h5tools.h
index ca2b39a..ed93a46 100644
--- a/tools/lib/h5tools.h
+++ b/tools/lib/h5tools.h
@@ -40,7 +40,7 @@
#define FLUSHSTREAM(S) if(S != NULL) HDfflush(S)
#define PRINTSTREAM(S, F, ...) if(S != NULL) HDfprintf(S, F, __VA_ARGS__)
#define PRINTVALSTREAM(S, V) if(S != NULL) HDfprintf(S, V)
-#define PUTSTREAM(X,S) if(S != NULL) HDfputs(X, S);
+#define PUTSTREAM(X,S) do { if(S != NULL) HDfputs(X, S); } while(0)
/*
* Strings for output - these were duplicated from the h5dump.h
@@ -294,7 +294,7 @@ typedef struct h5tool_format_t {
const char *fmt_float;
int ascii;
int str_locale;
- int str_repeat;
+ unsigned str_repeat;
/*
* Fields associated with compound array members.
@@ -510,9 +510,9 @@ typedef struct h5tools_context_t {
hsize_t size_last_dim; /*the size of the last dimension,
*needed so we can break after each
*row */
- int indent_level; /*the number of times we need some
+ unsigned indent_level; /*the number of times we need some
*extra indentation */
- int default_indent_level; /*this is used when the indent level gets changed */
+ unsigned default_indent_level; /*this is used when the indent level gets changed */
hsize_t acc[H5S_MAX_RANK]; /* accumulator position */
hsize_t pos[H5S_MAX_RANK]; /* matrix position */
hsize_t sm_pos; /* current stripmine element position */
@@ -545,9 +545,9 @@ H5TOOLS_DLLVAR const h5tools_dump_header_t* h5tools_dump_header_format;
extern "C" {
#endif
-H5TOOLS_DLLVAR int packed_bits_num; /* number of packed bits to display */
-H5TOOLS_DLLVAR int packed_data_offset; /* offset of packed bits to display */
-H5TOOLS_DLLVAR int packed_data_length; /* lengtht of packed bits to display */
+H5TOOLS_DLLVAR unsigned packed_bits_num; /* number of packed bits to display */
+H5TOOLS_DLLVAR unsigned packed_data_offset; /* offset of packed bits to display */
+H5TOOLS_DLLVAR unsigned packed_data_length; /* length of packed bits to display */
H5TOOLS_DLLVAR unsigned long long packed_data_mask; /* mask in which packed bits to display */
H5TOOLS_DLLVAR FILE *rawattrstream; /* output stream for raw attribute data */
H5TOOLS_DLLVAR FILE *rawdatastream; /* output stream for raw data */
@@ -597,11 +597,11 @@ H5TOOLS_DLL void h5tools_region_simple_prefix(FILE *stream, const h5tool_form
H5TOOLS_DLL int render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t nelmts);
H5TOOLS_DLL int render_bin_output_region_data_blocks(hid_t region_id, FILE *stream,
- hid_t container, int ndims, hid_t type_id, hssize_t nblocks, hsize_t *ptdata);
+ hid_t container, unsigned ndims, hid_t type_id, hsize_t nblocks, hsize_t *ptdata);
H5TOOLS_DLL hbool_t render_bin_output_region_blocks(hid_t region_space, hid_t region_id,
FILE *stream, hid_t container);
H5TOOLS_DLL int render_bin_output_region_data_points(hid_t region_space, hid_t region_id,
- FILE* stream, hid_t container, int ndims, hid_t type_id, hssize_t npoints);
+ FILE* stream, hid_t container, unsigned ndims, hid_t type_id, hsize_t npoints);
H5TOOLS_DLL hbool_t render_bin_output_region_points(hid_t region_space, hid_t region_id,
FILE *stream, hid_t container);
diff --git a/tools/lib/h5tools_dump.c b/tools/lib/h5tools_dump.c
index 5fb35bf..cae3107 100644
--- a/tools/lib/h5tools_dump.c
+++ b/tools/lib/h5tools_dump.c
@@ -207,10 +207,10 @@ hbool_t h5tools_dump_region_data_points(hid_t region_space, hid_t region_id,
size_t ncols, hsize_t region_elmt_counter/*element counter*/,
hsize_t elmt_counter);
-int h5tools_print_region_data_points(hid_t region_space, hid_t region_id,
+static int h5tools_print_region_data_points(hid_t region_space, hid_t region_id,
FILE *stream, const h5tool_format_t *info, h5tools_context_t *cur_ctx,
h5tools_str_t *buffer, size_t ncols,
- int ndims, hid_t type_id, hssize_t npoints, hsize_t *ptdata);
+ unsigned ndims, hid_t type_id, hsize_t npoints, hsize_t *ptdata);
hbool_t h5tools_dump_region_data_blocks(hid_t region_space, hid_t region_id,
FILE *stream, const h5tool_format_t *info,
@@ -650,10 +650,10 @@ h5tools_dump_region_data_blocks(hid_t region_space, hid_t region_id,
alloc_size = nblocks * ndims * 2 * sizeof(ptdata[0]);
HDassert(alloc_size == (hsize_t) ((size_t) alloc_size)); /*check for overflow*/
if((ptdata = (hsize_t*) HDmalloc((size_t) alloc_size)) == NULL)
-{
+ {
HERROR(H5E_tools_g, H5E_tools_min_id_g, "Could not allocate buffer for ptdata");
HGOTO_DONE(dimension_break);
-}
+ }
if(H5Sget_select_hyper_blocklist(region_space, (hsize_t)0, nblocks, ptdata) < 0)
HGOTO_ERROR(dimension_break, H5E_tools_min_id_g, "H5Rget_select_hyper_blocklist failed");
@@ -795,20 +795,20 @@ h5tools_dump_region_data_blocks(hid_t region_space, hid_t region_id,
* hssize_t npoints is the number of points in the region
*-------------------------------------------------------------------------
*/
-int
+static int
h5tools_print_region_data_points(hid_t region_space, hid_t region_id,
FILE *stream, const h5tool_format_t *info, h5tools_context_t *cur_ctx,
h5tools_str_t *buffer, size_t ncols,
- int ndims, hid_t type_id, hssize_t npoints, hsize_t *ptdata)
+ unsigned ndims, hid_t type_id, hsize_t npoints, hsize_t *ptdata)
{
hbool_t dimension_break = TRUE;
hsize_t *dims1 = NULL;
hsize_t elmtno; /* elemnt index */
hsize_t curr_pos = 0;
hsize_t total_size[H5S_MAX_RANK];
- size_t jndx;
+ hsize_t jndx;
unsigned indx;
- int type_size;
+ size_t type_size;
int ret_value = SUCCEED;
unsigned int region_flags; /* buffer extent flags */
hid_t mem_space = -1;
@@ -823,7 +823,7 @@ h5tools_print_region_data_points(hid_t region_space, hid_t region_id,
HDmemset(&ctx, 0, sizeof(ctx));
/* Allocate space for the dimension array */
- if((dims1 = (hsize_t *) HDmalloc(sizeof(hsize_t) * (size_t)ndims)) == NULL)
+ if((dims1 = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) == NULL)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for dims");
dims1[0] = npoints;
@@ -857,7 +857,7 @@ h5tools_print_region_data_points(hid_t region_space, hid_t region_id,
HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed");
/* assume entire data space to be printed */
- for (indx = 0; indx < (size_t) ctx.ndims; indx++)
+ for (indx = 0; indx < ctx.ndims; indx++)
ctx.p_min_idx[indx] = 0;
init_acc_pos(&ctx, total_size);
@@ -866,13 +866,12 @@ h5tools_print_region_data_points(hid_t region_space, hid_t region_id,
if (jndx == npoints - 1)
region_flags |= END_OF_DATA;
- for (indx = 0; indx < (size_t)ctx.ndims; indx++)
+ for (indx = 0; indx < ctx.ndims; indx++)
ctx.p_max_idx[indx] = cur_ctx->p_max_idx[indx];
ctx.sm_pos = jndx * ndims;
- if (ctx.ndims > 0) {
- ctx.size_last_dim = (int) (ctx.p_max_idx[ctx.ndims - 1]);
- }
+ if (ctx.ndims > 0)
+ ctx.size_last_dim = ctx.p_max_idx[ctx.ndims - 1];
else
ctx.size_last_dim = 0;
@@ -938,11 +937,13 @@ h5tools_dump_region_data_points(hid_t region_space, hid_t region_id,
hsize_t elmt_counter) {
HERR_INIT(hbool_t, TRUE)
hbool_t dimension_break = TRUE;
- hssize_t npoints;
+ hssize_t snpoints;
+ hsize_t npoints;
hsize_t alloc_size;
hsize_t *ptdata;
- int ndims;
- hssize_t indx;
+ int sndims;
+ unsigned ndims;
+ hsize_t indx;
hid_t dtype = -1;
hid_t type_id = -1;
@@ -950,12 +951,14 @@ h5tools_dump_region_data_points(hid_t region_space, hid_t region_id,
HDassert(ctx);
HDassert(buffer);
- if((npoints = H5Sget_select_elem_npoints(region_space)) <= 0)
+ if((snpoints = H5Sget_select_elem_npoints(region_space)) <= 0)
H5E_THROW(dimension_break, H5E_tools_min_id_g, "H5Sget_select_elem_npoints failed");
+ npoints = (hsize_t)snpoints;
/* Allocate space for the dimension array */
- if((ndims = H5Sget_simple_extent_ndims(region_space)) < 0)
+ if((sndims = H5Sget_simple_extent_ndims(region_space)) < 0)
H5E_THROW(dimension_break, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed");
+ ndims = (unsigned)sndims;
/* Render the region { element begin */
h5tools_str_reset(buffer);
@@ -976,12 +979,11 @@ h5tools_dump_region_data_points(hid_t region_space, hid_t region_id,
if(NULL == (ptdata = (hsize_t *)HDmalloc((size_t) alloc_size)))
HGOTO_ERROR(dimension_break, H5E_tools_min_id_g, "Could not allocate buffer for ptdata");
- H5_CHECK_OVERFLOW(npoints, hssize_t, hsize_t);
- if(H5Sget_select_elem_pointlist(region_space, (hsize_t) 0, (hsize_t) npoints, ptdata) < 0)
+ if(H5Sget_select_elem_pointlist(region_space, (hsize_t) 0, npoints, ptdata) < 0)
HGOTO_ERROR(dimension_break, H5E_tools_min_id_g, "H5Sget_select_elem_pointlist failed");
for (indx = 0; indx < npoints; indx++) {
- int loop_indx;
+ unsigned loop_indx;
h5tools_str_append(buffer, info->dset_ptformat_pre,
indx ? "," OPTIONAL_LINE_BREAK " " : "", (unsigned long) indx);
@@ -1349,7 +1351,7 @@ h5tools_display_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools
}
/* initialize temporary start, count and maximum start */
- for (i = 0; i < (size_t) ctx->ndims; i++) {
+ for (i = 0; i < ctx->ndims; i++) {
temp_start[i] = sset->start.data[i];
temp_count[i] = sset->count.data[i];
temp_block[i] = sset->block.data[i];
@@ -1391,12 +1393,11 @@ h5tools_display_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools
if (ctx->ndims > 2) {
/* dimension for start */
- current_outer_dim = (ctx->ndims - 2) - 1;
+ current_outer_dim = (int)(ctx->ndims - 2) - 1;
/* set start to original from current_outer_dim up */
- for (i = current_outer_dim + 1; i < ctx->ndims; i++) {
+ for (i = (size_t)(current_outer_dim + 1); i < ctx->ndims; i++)
temp_start[i] = sset->start.data[i];
- }
/* increment start dimension */
do {
@@ -1516,6 +1517,7 @@ h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info, h5tools_cont
hid_t f_space = -1; /* file data space */
hsize_t elmtno; /* counter */
size_t i; /* counter */
+ int sndims; /* rank of dataspace */
int carry; /* counter carry value */
hsize_t zero[8]; /* vector of zeros */
unsigned int flags; /* buffer extent flags */
@@ -1545,11 +1547,13 @@ h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info, h5tools_cont
if (f_space == FAIL)
H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Dget_space failed");
- ctx->ndims = H5Sget_simple_extent_ndims(f_space);
+ sndims = H5Sget_simple_extent_ndims(f_space);
+ if(sndims < 0)
+ H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Dget_simple_extent_ndims failed");
+ ctx->ndims = (unsigned)sndims;
- if ((size_t)ctx->ndims > NELMTS(sm_size)) {
+ if ((size_t)ctx->ndims > NELMTS(sm_size))
H5E_THROW(FAIL, H5E_tools_min_id_g, "ctx->ndims > NELMTS(sm_size) failed");
- }
/* Assume entire data space to be printed */
if (ctx->ndims > 0)
@@ -1691,10 +1695,14 @@ h5tools_dump_simple_mem(FILE *stream, const h5tool_format_t *info, h5tools_conte
hid_t type, hid_t space, void *mem)
{
HERR_INIT(herr_t, SUCCEED)
+ int sndims; /* rank of dataspace */
unsigned i; /*counters */
hsize_t nelmts; /*total selected elmts */
- ctx->ndims = H5Sget_simple_extent_ndims(space);
+ sndims = H5Sget_simple_extent_ndims(space);
+ if(sndims < 0)
+ H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Dget_simple_extent_ndims failed");
+ ctx->ndims = (unsigned)sndims;
if ((size_t) ctx->ndims > NELMTS(ctx->p_min_idx))
H5E_THROW(FAIL, H5E_tools_min_id_g, "ctx->ndims > NELMTS(ctx->p_min_idx) failed");
@@ -1712,7 +1720,7 @@ h5tools_dump_simple_mem(FILE *stream, const h5tool_format_t *info, h5tools_conte
H5_LEAVE(SUCCEED); /* nothing to print */
if (ctx->ndims > 0) {
HDassert(ctx->p_max_idx[ctx->ndims - 1] == (hsize_t) ((int) ctx->p_max_idx[ctx->ndims - 1]));
- ctx->size_last_dim = (int) (ctx->p_max_idx[ctx->ndims - 1]);
+ ctx->size_last_dim = ctx->p_max_idx[ctx->ndims - 1];
} /* end if */
else
ctx->size_last_dim = 0;
@@ -2599,7 +2607,6 @@ h5tools_print_enum(FILE *stream, h5tools_str_t *buffer, const h5tool_format_t *i
unsigned i;
unsigned nmembs = 0; /*number of members */
int snmembs;
- int nchars; /*number of output characters */
hid_t super = -1; /*enum base integer type */
hid_t native = -1; /*native integer datatype */
H5T_sign_t sign_type; /*sign of value type */
@@ -2666,12 +2673,14 @@ h5tools_print_enum(FILE *stream, h5tools_str_t *buffer, const h5tool_format_t *i
/* Print members */
for (i = 0; i < nmembs; i++) {
+ int nchars; /*number of output characters */
+
ctx->need_prefix = TRUE;
h5tools_simple_prefix(stream, info, ctx, (hsize_t)0, 0);
h5tools_str_reset(buffer);
h5tools_str_append(buffer, "\"%s\"", name[i]);
- nchars = HDstrlen(name[i]);
+ nchars = (int)HDstrlen(name[i]);
h5tools_str_append(buffer, "%*s ", MAX(0, 16 - nchars), "");
if (native < 0) {
@@ -2923,6 +2932,8 @@ h5tools_print_virtual_selection(hid_t vspace,
h5tools_str_reset(buffer);
h5tools_str_append(buffer, "%s", VDS_ALL);
break;
+ case H5S_SEL_ERROR:
+ case H5S_SEL_N:
default:
h5tools_str_append(buffer, "Unknown Selection");
}
@@ -3632,7 +3643,7 @@ h5tools_dump_comment(FILE *stream, const h5tool_format_t *info,
if (cmt_bufsize > 0) {
comment = (char *)HDmalloc((size_t)(cmt_bufsize+1)); /* new_size including null terminator */
if(comment) {
- cmt_bufsize = H5Oget_comment(obj_id, comment, cmt_bufsize);
+ cmt_bufsize = H5Oget_comment(obj_id, comment, (size_t)cmt_bufsize);
if(cmt_bufsize > 0) {
comment[cmt_bufsize] = '\0'; /* necessary because null char is not returned */
@@ -3771,49 +3782,39 @@ h5tools_print_dims(h5tools_str_t *buffer, hsize_t *s, int dims)
void
h5tools_print_packed_bits(h5tools_str_t *buffer, hid_t type)
{
- int packed_bits_size = 0;
-
+ unsigned packed_bits_size = 0;
hid_t n_type = h5tools_get_native_type(type);
- if(H5Tget_class(n_type)==H5T_INTEGER) {
- if(H5Tequal(n_type, H5T_NATIVE_SCHAR) == TRUE) {
+
+ if(H5Tget_class(n_type) == H5T_INTEGER) {
+ if(H5Tequal(n_type, H5T_NATIVE_SCHAR) == TRUE)
packed_bits_size = 8 * sizeof(char);
- }
- else if(H5Tequal(n_type, H5T_NATIVE_UCHAR) == TRUE) {
+ else if(H5Tequal(n_type, H5T_NATIVE_UCHAR) == TRUE)
packed_bits_size = 8 * sizeof(unsigned char);
- }
- else if(H5Tequal(n_type, H5T_NATIVE_SHORT) == TRUE) {
+ else if(H5Tequal(n_type, H5T_NATIVE_SHORT) == TRUE)
packed_bits_size = 8 * sizeof(short);
- }
- else if(H5Tequal(n_type, H5T_NATIVE_USHORT) == TRUE) {
+ else if(H5Tequal(n_type, H5T_NATIVE_USHORT) == TRUE)
packed_bits_size = 8 * sizeof(unsigned short);
- }
- else if(H5Tequal(n_type, H5T_NATIVE_INT) == TRUE) {
+ else if(H5Tequal(n_type, H5T_NATIVE_INT) == TRUE)
packed_bits_size = 8 * sizeof(int);
- }
- else if(H5Tequal(n_type, H5T_NATIVE_UINT) == TRUE) {
+ else if(H5Tequal(n_type, H5T_NATIVE_UINT) == TRUE)
packed_bits_size = 8 * sizeof(unsigned int);
- }
- else if(H5Tequal(n_type, H5T_NATIVE_LONG) == TRUE) {
+ else if(H5Tequal(n_type, H5T_NATIVE_LONG) == TRUE)
packed_bits_size = 8 * sizeof(long);
- }
- else if(H5Tequal(n_type, H5T_NATIVE_ULONG) == TRUE) {
+ else if(H5Tequal(n_type, H5T_NATIVE_ULONG) == TRUE)
packed_bits_size = 8 * sizeof(unsigned long);
- }
- else if(H5Tequal(n_type, H5T_NATIVE_LLONG) == TRUE) {
+ else if(H5Tequal(n_type, H5T_NATIVE_LLONG) == TRUE)
packed_bits_size = 8 * sizeof(long long);
- }
- else if(H5Tequal(n_type, H5T_NATIVE_ULLONG) == TRUE) {
+ else if(H5Tequal(n_type, H5T_NATIVE_ULLONG) == TRUE)
packed_bits_size = 8 * sizeof(unsigned long long);
- }
else
error_msg("Packed Bit not valid for this datatype");
}
- if ((packed_bits_size>0) && (packed_data_offset + packed_data_length) > packed_bits_size) {
- error_msg("Packed Bit offset+length value(%d) too large. Max is %d\n", packed_data_offset+packed_data_length, packed_bits_size);
+ if((packed_bits_size > 0) && (packed_data_offset + packed_data_length) > packed_bits_size) {
+ error_msg("Packed Bit offset+length value(%u) too large. Max is %d\n", packed_data_offset + packed_data_length, packed_bits_size);
packed_data_mask = 0;
};
- h5tools_str_append(buffer, "%s %s=%d %s=%d", PACKED_BITS, PACKED_OFFSET, packed_data_offset, PACKED_LENGTH, packed_data_length);
+ h5tools_str_append(buffer, "%s %s=%u %s=%u", PACKED_BITS, PACKED_OFFSET, packed_data_offset, PACKED_LENGTH, packed_data_length);
}
/*-------------------------------------------------------------------------
diff --git a/tools/lib/h5tools_filters.c b/tools/lib/h5tools_filters.c
index ccdba26..748eb78 100644
--- a/tools/lib/h5tools_filters.c
+++ b/tools/lib/h5tools_filters.c
@@ -147,58 +147,65 @@ int h5tools_canreadf(const char* name, /* object name, serves also as boolean pr
*
*-------------------------------------------------------------------------
*/
-int h5tools_can_encode(H5Z_filter_t filtn) {
- switch (filtn) {
+int
+h5tools_can_encode(H5Z_filter_t filtn) {
+ switch (filtn) {
/* user defined filter */
default:
- return 0;
+ return 0;
case H5Z_FILTER_DEFLATE:
#ifndef H5_HAVE_FILTER_DEFLATE
- return 0;
+ return 0;
#endif
- break;
+ break;
+
case H5Z_FILTER_SZIP:
#ifndef H5_HAVE_FILTER_SZIP
- return 0;
+ return 0;
#else
{
- unsigned int filter_config_flags;
+ unsigned int filter_config_flags;
- if (H5Zget_filter_info(filtn, &filter_config_flags) < 0)
- return -1;
- if ((filter_config_flags
- & (H5Z_FILTER_CONFIG_ENCODE_ENABLED | H5Z_FILTER_CONFIG_DECODE_ENABLED)) == 0) {
- /* filter present but neither encode nor decode is supported (???) */
- return -1;
- }
- else if ((filter_config_flags
- & (H5Z_FILTER_CONFIG_ENCODE_ENABLED | H5Z_FILTER_CONFIG_DECODE_ENABLED)) == H5Z_FILTER_CONFIG_DECODE_ENABLED) {
- /* decoder only: read but not write */
- return 0;
- }
- else if ((filter_config_flags
- & (H5Z_FILTER_CONFIG_ENCODE_ENABLED | H5Z_FILTER_CONFIG_DECODE_ENABLED)) == H5Z_FILTER_CONFIG_ENCODE_ENABLED) {
- /* encoder only: write but not read (???) */
- return -1;
- }
- else if ((filter_config_flags
- & (H5Z_FILTER_CONFIG_ENCODE_ENABLED | H5Z_FILTER_CONFIG_DECODE_ENABLED))
- == (H5Z_FILTER_CONFIG_ENCODE_ENABLED | H5Z_FILTER_CONFIG_DECODE_ENABLED)) {
- return 1;
- }
+ if (H5Zget_filter_info(filtn, &filter_config_flags) < 0)
+ return -1;
+ if ((filter_config_flags
+ & (H5Z_FILTER_CONFIG_ENCODE_ENABLED | H5Z_FILTER_CONFIG_DECODE_ENABLED)) == 0) {
+ /* filter present but neither encode nor decode is supported (???) */
+ return -1;
+ }
+ else if ((filter_config_flags
+ & (H5Z_FILTER_CONFIG_ENCODE_ENABLED | H5Z_FILTER_CONFIG_DECODE_ENABLED)) == H5Z_FILTER_CONFIG_DECODE_ENABLED) {
+ /* decoder only: read but not write */
+ return 0;
+ }
+ else if ((filter_config_flags
+ & (H5Z_FILTER_CONFIG_ENCODE_ENABLED | H5Z_FILTER_CONFIG_DECODE_ENABLED)) == H5Z_FILTER_CONFIG_ENCODE_ENABLED) {
+ /* encoder only: write but not read (???) */
+ return -1;
+ }
+ else if ((filter_config_flags
+ & (H5Z_FILTER_CONFIG_ENCODE_ENABLED | H5Z_FILTER_CONFIG_DECODE_ENABLED))
+ == (H5Z_FILTER_CONFIG_ENCODE_ENABLED | H5Z_FILTER_CONFIG_DECODE_ENABLED)) {
+ return 1;
+ }
}
#endif
- break;
+ break;
+
case H5Z_FILTER_SHUFFLE:
- break;
+ break;
+
case H5Z_FILTER_FLETCHER32:
- break;
+ break;
+
case H5Z_FILTER_NBIT:
- break;
+ break;
+
case H5Z_FILTER_SCALEOFFSET:
- break;
- }/*switch*/
+ break;
+ }/*switch*/
- return 1;
+ return 1;
}
+
diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c
index 13c6a20..6d9a041 100644
--- a/tools/lib/h5tools_str.c
+++ b/tools/lib/h5tools_str.c
@@ -91,7 +91,7 @@ h5tools_str_close(h5tools_str_t *str)
*
*-------------------------------------------------------------------------
*/
-size_t
+H5_ATTR_PURE size_t
h5tools_str_len(h5tools_str_t *str)
{
return str->len;
@@ -126,14 +126,12 @@ h5tools_str_append(h5tools_str_t *str/*in,out*/, const char *fmt, ...)
va_list ap;
/* Make sure we have some memory into which to print */
- if (!str->s || str->nalloc <= 0) {
+ if (!str->s || str->nalloc <= 0)
h5tools_str_reset(str);
- }
- if (HDstrlen(fmt) == 0) {
+ if (HDstrlen(fmt) == 0)
/* nothing to print */
return str->s;
- }
/* Format the arguments and append to the value already in `str' */
while (1) {
@@ -156,19 +154,18 @@ h5tools_str_append(h5tools_str_t *str/*in,out*/, const char *fmt, ...)
* to lack of buffer size, so try one more time after realloc more
* buffer size before return NULL.
*/
- if (nchars < 0) {
+ if (nchars < 0)
/* failure, such as bad format */
return NULL;
- }
- if (nchars < 0 || (size_t) nchars >= avail || (0 == nchars && (HDstrcmp(fmt, "%s")))) {
+ if ((size_t) nchars >= avail || (0 == nchars && (HDstrcmp(fmt, "%s")))) {
/* Truncation return value as documented by C99, or zero return value with either of the
* following conditions, each of which indicates that the proper C99 return value probably
* should have been positive when the format string is
* something other than "%s"
* Alocate at least twice as much space and try again.
*/
- size_t newsize = MAX(str->len + nchars + 1, 2 * str->nalloc);
+ size_t newsize = MAX(str->len + (size_t)nchars + 1, 2 * str->nalloc);
HDassert(newsize > str->nalloc); /*overflow*/
str->s = (char*)HDrealloc(str->s, newsize);
HDassert(str->s);
@@ -176,7 +173,7 @@ h5tools_str_append(h5tools_str_t *str/*in,out*/, const char *fmt, ...)
}
else {
/* Success */
- str->len += nchars;
+ str->len += (size_t)nchars;
break;
}
}
@@ -498,41 +495,42 @@ void
h5tools_str_dump_space_blocks(h5tools_str_t *str, hid_t rspace,
const h5tool_format_t *info)
{
- hssize_t nblocks;
- hsize_t alloc_size;
- hsize_t *ptdata;
- int ndims = H5Sget_simple_extent_ndims(rspace);
+ hssize_t snblocks;
/*
* This function fails if the rspace does not have blocks.
*/
H5E_BEGIN_TRY {
- nblocks = H5Sget_select_hyper_nblocks(rspace);
+ snblocks = H5Sget_select_hyper_nblocks(rspace);
} H5E_END_TRY;
/* Print block information */
- if (nblocks > 0) {
- int i;
-
+ if (snblocks > 0) {
+ hsize_t nblocks;
+ hsize_t *ptdata;
+ hsize_t alloc_size;
+ unsigned ndims = (unsigned)H5Sget_simple_extent_ndims(rspace);
+ hsize_t u;
+
+ nblocks = (hsize_t)snblocks;
alloc_size = nblocks * ndims * 2 * sizeof(ptdata[0]);
HDassert(alloc_size == (hsize_t) ((size_t) alloc_size)); /*check for overflow*/
ptdata = (hsize_t *)HDmalloc((size_t) alloc_size);
- H5_CHECK_OVERFLOW(nblocks, hssize_t, hsize_t);
- H5Sget_select_hyper_blocklist(rspace, (hsize_t)0, (hsize_t)nblocks, ptdata);
+ H5Sget_select_hyper_blocklist(rspace, (hsize_t)0, nblocks, ptdata);
- for (i = 0; i < nblocks; i++) {
- int j;
+ for (u = 0; u < nblocks; u++) {
+ unsigned v;
- h5tools_str_append(str, info->dset_blockformat_pre, i ? "," OPTIONAL_LINE_BREAK " " : "", (unsigned long)i);
+ h5tools_str_append(str, info->dset_blockformat_pre, u ? "," OPTIONAL_LINE_BREAK " " : "", (unsigned long)u);
/* Start coordinates and opposite corner */
- for (j = 0; j < ndims; j++)
- h5tools_str_append(str, "%s" HSIZE_T_FORMAT, j ? "," : "(",
- ptdata[i * 2 * ndims + j]);
+ for (v = 0; v < ndims; v++)
+ h5tools_str_append(str, "%s" HSIZE_T_FORMAT, v ? "," : "(",
+ ptdata[u * 2 * ndims + v]);
- for (j = 0; j < ndims; j++)
- h5tools_str_append(str, "%s" HSIZE_T_FORMAT, j ? "," : ")-(",
- ptdata[i * 2 * ndims + j + ndims]);
+ for (v = 0; v < ndims; v++)
+ h5tools_str_append(str, "%s" HSIZE_T_FORMAT, v ? "," : ")-(",
+ ptdata[u * 2 * ndims + v + ndims]);
h5tools_str_append(str, ")");
}
@@ -557,37 +555,38 @@ void
h5tools_str_dump_space_points(h5tools_str_t *str, hid_t rspace,
const h5tool_format_t *info)
{
- hssize_t npoints;
- hsize_t alloc_size;
- hsize_t *ptdata;
- int ndims = H5Sget_simple_extent_ndims(rspace);
+ hssize_t snpoints;
/*
* This function fails if the rspace does not have points.
*/
H5E_BEGIN_TRY {
- npoints = H5Sget_select_elem_npoints(rspace);
+ snpoints = H5Sget_select_elem_npoints(rspace);
} H5E_END_TRY;
/* Print point information */
- if (npoints > 0) {
- int i;
-
+ if (snpoints > 0) {
+ hsize_t npoints;
+ hsize_t alloc_size;
+ hsize_t *ptdata;
+ unsigned ndims = (unsigned)H5Sget_simple_extent_ndims(rspace);
+ hsize_t u;
+
+ npoints = (hsize_t)snpoints;
alloc_size = npoints * ndims * sizeof(ptdata[0]);
HDassert(alloc_size == (hsize_t) ((size_t) alloc_size)); /*check for overflow*/
ptdata = (hsize_t *)HDmalloc((size_t) alloc_size);
- H5_CHECK_OVERFLOW(npoints, hssize_t, hsize_t);
- H5Sget_select_elem_pointlist(rspace, (hsize_t)0, (hsize_t)npoints, ptdata);
+ H5Sget_select_elem_pointlist(rspace, (hsize_t)0, npoints, ptdata);
- for (i = 0; i < npoints; i++) {
- int j;
+ for (u = 0; u < npoints; u++) {
+ unsigned v;
- h5tools_str_append(str, info->dset_ptformat_pre, i ? "," OPTIONAL_LINE_BREAK " " : "",
- (unsigned long)i);
+ h5tools_str_append(str, info->dset_ptformat_pre, u ? "," OPTIONAL_LINE_BREAK " " : "",
+ (unsigned long)u);
- for (j = 0; j < ndims; j++)
- h5tools_str_append(str, "%s" HSIZE_T_FORMAT, j ? "," : "(",
- (ptdata[i * ndims + j]));
+ for (v = 0; v < ndims; v++)
+ h5tools_str_append(str, "%s" HSIZE_T_FORMAT, v ? "," : "(",
+ (ptdata[u * ndims + v]));
h5tools_str_append(str, ")");
}
@@ -676,13 +675,12 @@ void
h5tools_str_indent(h5tools_str_t *str, const h5tool_format_t *info,
h5tools_context_t *ctx)
{
- int i, indentlevel = 0;
+ unsigned u, indentlevel = 0;
/* Write new prefix */
- if (ctx->indent_level >= 0) {
+ if (ctx->indent_level > 0)
indentlevel = ctx->indent_level;
- }
- else {
+ else
/*
* This is because sometimes we don't print out all the header
* info for the data (like the tattr-2.ddl example). If that happens
@@ -690,11 +688,9 @@ h5tools_str_indent(h5tools_str_t *str, const h5tool_format_t *info,
* just print out the default indent levels.
*/
indentlevel = ctx->default_indent_level;
- }
- for (i = 0; i < indentlevel; i++) {
+ for (u = 0; u < indentlevel; u++)
h5tools_str_append(str, "%s", OPT(info->line_indent, ""));
- }
}
/*-------------------------------------------------------------------------
@@ -753,22 +749,10 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai
unsigned char *ucp_vp = (unsigned char *)vp;
char *cp_vp = (char *)vp;
hid_t memb, obj;
- unsigned nmembs;
static char fmt_llong[8], fmt_ullong[8];
H5T_str_t pad;
H5T_class_t type_class;
- /*
- * some tempvars to store the value before we append it to the string to
- * get rid of the memory alignment problem
- */
- unsigned long long tempullong;
- long long templlong;
- unsigned long tempulong;
- long templong;
- unsigned int tempuint;
- int tempint;
-
/* Build default formats for long long types */
if (!fmt_llong[0]) {
HDsnprintf(fmt_llong, sizeof(fmt_llong), "%%%sd", H5_PRINTF_LL_WIDTH);
@@ -823,6 +807,7 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai
#endif
}
break;
+
case H5T_STRING:
{
unsigned int i;
@@ -843,12 +828,11 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai
pad = H5Tget_strpad(type);
/* Check for NULL pointer for string */
- if (s == NULL) {
+ if (s == NULL)
h5tools_str_append(str, "NULL");
- }
else {
for (i = 0; i < size && (s[i] || pad != H5T_STR_NULLTERM); i++) {
- int j = 1;
+ unsigned j = 1;
/*
* Count how many times the next character repeats. If the
@@ -865,7 +849,8 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai
* in it's own quote.
*/
if (info->str_repeat > 0 && j > info->str_repeat) {
- if (quote) h5tools_str_append(str, "%c", quote);
+ if (quote)
+ h5tools_str_append(str, "%c", quote);
quote = '\'';
h5tools_str_append(str, "%s%c", i ? " " : "", quote);
@@ -888,10 +873,10 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai
quote = '\0';
i += j - 1;
}
-
}
- if (quote) h5tools_str_append(str, "%c", quote);
+ if (quote)
+ h5tools_str_append(str, "%c", quote);
if (i == 0)
/*empty string*/
@@ -899,64 +884,64 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai
} /* end else */
}
break;
+
case H5T_INTEGER:
if (sizeof(char) == nsize) {
- /* if ((H5Tequal(type, H5T_NATIVE_SCHAR) || H5Tequal(type, H5T_NATIVE_UCHAR))) */
- if (info->ascii) {
+ if (info->ascii)
h5tools_print_char(str, info, (char) (*ucp_vp));
- }
else if(H5T_SGN_NONE == nsign) {
- /* if (H5Tequal(type, H5T_NATIVE_UCHAR)) */
unsigned char tempuchar;
+
HDmemcpy(&tempuchar, ucp_vp, sizeof(unsigned char));
if (packed_bits_num) {
if (packed_data_offset >= 8 * sizeof(unsigned char))
tempuchar = 0;
else
- tempuchar = (tempuchar >> packed_data_offset) & packed_data_mask;
+ tempuchar = (unsigned char)((unsigned long long)(tempuchar >> packed_data_offset) & packed_data_mask);
}
- h5tools_str_append(str, OPT(info->fmt_uchar, "%u"), tempuchar);
+ h5tools_str_append(str, OPT(info->fmt_uchar, "%hhu"), tempuchar);
}
else {
- /* if (H5Tequal(type, H5T_NATIVE_SCHAR)) */
signed char tempchar;
+
HDmemcpy(&tempchar, cp_vp, sizeof(char));
if (packed_bits_num) {
if (packed_data_offset >= 8 * sizeof(char))
tempchar = 0;
else
- tempchar = (tempchar >> packed_data_offset) & packed_data_mask;
+ tempchar = (signed char)((unsigned long long)(tempchar >> packed_data_offset) & packed_data_mask);
}
h5tools_str_append(str, OPT(info->fmt_schar, "%hhd"), tempchar);
}
} /* end if (sizeof(char) == nsize) */
else if (sizeof(int) == nsize) {
if(H5T_SGN_NONE == nsign) {
- /* if (H5Tequal(type, H5T_NATIVE_UINT)) */
+ unsigned int tempuint;
+
HDmemcpy(&tempuint, vp, sizeof(unsigned int));
if (packed_bits_num) {
if (packed_data_offset >= 8 * sizeof(unsigned int))
tempuint = 0;
else
- tempuint = (tempuint >> packed_data_offset) & packed_data_mask;
+ tempuint = (unsigned)((tempuint >> packed_data_offset) & packed_data_mask);
}
h5tools_str_append(str, OPT(info->fmt_uint, "%u"), tempuint);
}
else {
- /* if (H5Tequal(type, H5T_NATIVE_INT)) */
+ int tempint;
+
HDmemcpy(&tempint, vp, sizeof(int));
if (packed_bits_num) {
if (packed_data_offset >= 8 * sizeof(int))
tempint = 0;
else
- tempint = (tempint >> packed_data_offset) & packed_data_mask;
+ tempint = (int)((unsigned long long)(tempint >> packed_data_offset) & packed_data_mask);
}
h5tools_str_append(str, OPT(info->fmt_int, "%d"), tempint);
}
} /* end if (sizeof(int) == nsize) */
else if (sizeof(short) == nsize) {
if(H5T_SGN_NONE == nsign) {
- /* if (H5Tequal(type, H5T_NATIVE_USHORT)) */
unsigned short tempushort;
HDmemcpy(&tempushort, vp, sizeof(unsigned short));
@@ -964,12 +949,11 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai
if (packed_data_offset >= 8 * sizeof(unsigned short))
tempushort = 0;
else
- tempushort = (tempushort >> packed_data_offset) & packed_data_mask;
+ tempushort = (unsigned short)((unsigned long long)(tempushort >> packed_data_offset) & packed_data_mask);
}
- h5tools_str_append(str, OPT(info->fmt_ushort, "%u"), tempushort);
+ h5tools_str_append(str, OPT(info->fmt_ushort, "%hu"), tempushort);
}
else {
- /* if (H5Tequal(type, H5T_NATIVE_SHORT)) */
short tempshort;
HDmemcpy(&tempshort, vp, sizeof(short));
@@ -977,14 +961,15 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai
if (packed_data_offset >= 8 * sizeof(short))
tempshort = 0;
else
- tempshort = (tempshort >> packed_data_offset) & packed_data_mask;
+ tempshort = (short)((unsigned long long)(tempshort >> packed_data_offset) & packed_data_mask);
}
- h5tools_str_append(str, OPT(info->fmt_short, "%d"), tempshort);
+ h5tools_str_append(str, OPT(info->fmt_short, "%hd"), tempshort);
}
} /* end if (sizeof(short) == nsize) */
else if (sizeof(long) == nsize) {
if(H5T_SGN_NONE == nsign) {
- /* if (H5Tequal(type, H5T_NATIVE_ULONG)) */
+ unsigned long tempulong;
+
HDmemcpy(&tempulong, vp, sizeof(unsigned long));
if (packed_bits_num) {
if (packed_data_offset >= 8 * sizeof(unsigned long))
@@ -995,20 +980,23 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai
h5tools_str_append(str, OPT(info->fmt_ulong, "%lu"), tempulong);
}
else {
- /* if (H5Tequal(type, H5T_NATIVE_LONG)) */
+ long templong;
+
HDmemcpy(&templong, vp, sizeof(long));
if (packed_bits_num) {
if (packed_data_offset >= 8 * sizeof(long))
templong = 0;
else
- templong = (templong >> packed_data_offset) & packed_data_mask;
+ templong = (long)((unsigned long long)(templong >> packed_data_offset) & packed_data_mask);
}
h5tools_str_append(str, OPT(info->fmt_long, "%ld"), templong);
}
} /* end if (sizeof(long) == nsize) */
+#if H5_SIZEOF_LONG != H5_SIZEOF_LONG_LONG
else if (sizeof(long long) == nsize) {
if(H5T_SGN_NONE == nsign) {
- /* if (H5Tequal(type, H5T_NATIVE_ULLONG)) */
+ unsigned long long tempullong;
+
HDmemcpy(&tempullong, vp, sizeof(unsigned long long));
if (packed_bits_num) {
if (packed_data_offset >= 8 * sizeof(unsigned long long))
@@ -1019,7 +1007,8 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai
h5tools_str_append(str, OPT(info->fmt_ullong, fmt_ullong), tempullong);
}
else {
- /* if (H5Tequal(type, H5T_NATIVE_LLONG)) */
+ long long templlong;
+
HDmemcpy(&templlong, vp, sizeof(long long));
if (packed_bits_num) {
if (packed_data_offset >= 8 * sizeof(long long))
@@ -1030,12 +1019,15 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai
h5tools_str_append(str, OPT(info->fmt_llong, fmt_llong), templlong);
}
} /* end if (sizeof(long long) == nsize) */
+#endif /* H5_SIZEOF_LONG != H5_SIZEOF_LONG_LONG */
break;
+
case H5T_COMPOUND:
{
+ unsigned nmembs;
unsigned j;
- nmembs = H5Tget_nmembers(type);
+ nmembs = (unsigned)H5Tget_nmembers(type);
h5tools_str_append(str, "%s", OPT(info->cmpd_pre, "{"));
ctx->indent_level++;
@@ -1046,7 +1038,8 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai
else
h5tools_str_append(str, "%s", OPT(info->cmpd_end, ""));
- if (info->arr_linebreak) h5tools_str_indent(str, info, ctx);
+ if (info->arr_linebreak)
+ h5tools_str_indent(str, info, ctx);
/* The name */
name = H5Tget_member_name(type, j);
@@ -1068,9 +1061,9 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai
h5tools_str_indent(str, info, ctx);
}
h5tools_str_append(str, "%s", OPT(info->cmpd_suf, "}"));
-
}
break;
+
case H5T_ENUM:
{
char enum_name[1024];
@@ -1090,10 +1083,10 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai
}
}
break;
+
case H5T_REFERENCE:
- if (h5tools_str_is_zero(vp, nsize)) {
+ if (h5tools_str_is_zero(vp, nsize))
h5tools_str_append(str, "NULL");
- }
else {
if (nsize == H5R_DSET_REG_REF_BUF_SIZE) {
/* if (H5Tequal(type, H5T_STD_REF_DSETREG)) */
@@ -1149,6 +1142,7 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai
} /* end else if (H5Tequal(type, H5T_STD_REF_OBJ)) */
}
break;
+
case H5T_ARRAY:
{
int k, ndims;
@@ -1175,7 +1169,8 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai
ctx->indent_level++;
for (i = 0; i < nelmts; i++) {
- if (i) h5tools_str_append(str, "%s", OPT(info->arr_sep, "," OPTIONAL_LINE_BREAK));
+ if (i)
+ h5tools_str_append(str, "%s", OPT(info->arr_sep, "," OPTIONAL_LINE_BREAK));
if (info->arr_linebreak && i && i % dims[ndims - 1] == 0) {
h5tools_str_append(str, "%s", "\n");
@@ -1210,6 +1205,7 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai
H5Tclose(memb);
}
break;
+
case H5T_VLEN:
{
unsigned int i;
@@ -1459,31 +1455,33 @@ h5tools_str_is_zero(const void *_mem, size_t size)
char *
h5tools_str_replace ( const char *string, const char *substr, const char *replacement )
{
- char *tok = NULL;
- char *newstr = NULL;
- char *oldstr = NULL;
- char *head = NULL;
-
- if ( substr == NULL || replacement == NULL )
- return HDstrdup (string);
- newstr = HDstrdup (string);
- head = newstr;
- while ( (tok = HDstrstr ( head, substr ))){
- oldstr = newstr;
- newstr = (char *)HDmalloc( HDstrlen( oldstr ) - HDstrlen( substr ) + HDstrlen( replacement ) + 1 );
-
- if ( newstr == NULL ){
- HDfree (oldstr);
+ char *tok = NULL;
+ char *newstr = NULL;
+ char *head = NULL;
+
+ if(substr == NULL || replacement == NULL)
+ return HDstrdup(string);
+ newstr = HDstrdup(string);
+ head = newstr;
+ while((tok = HDstrstr(head, substr))) {
+ char *oldstr;
+
+ oldstr = newstr;
+ newstr = (char *)HDmalloc(HDstrlen(oldstr) - HDstrlen(substr) + HDstrlen(replacement) + 1);
+
+ if(newstr == NULL) {
+ HDfree(oldstr);
return NULL;
}
- HDmemcpy ( newstr, oldstr, tok - oldstr );
- HDmemcpy ( newstr + (tok - oldstr), replacement, HDstrlen ( replacement ) );
- HDmemcpy ( newstr + (tok - oldstr) + HDstrlen( replacement ), tok + HDstrlen ( substr ), HDstrlen ( oldstr ) - HDstrlen ( substr ) - ( tok - oldstr ) );
- HDmemset ( newstr + HDstrlen ( oldstr ) - HDstrlen ( substr ) + HDstrlen ( replacement ) , 0, 1 );
+ HDmemcpy(newstr, oldstr, (size_t)(tok - oldstr));
+ HDmemcpy(newstr + (tok - oldstr), replacement, HDstrlen(replacement));
+ HDmemcpy(newstr + (tok - oldstr) + HDstrlen(replacement), tok + HDstrlen(substr), HDstrlen(oldstr) - HDstrlen(substr) - (size_t)(tok - oldstr));
+ HDmemset(newstr + HDstrlen (oldstr) - HDstrlen(substr) + HDstrlen(replacement) , 0, 1);
/* move back head right after the last replacement */
- head = newstr + (tok - oldstr) + HDstrlen( replacement );
- HDfree (oldstr);
+ head = newstr + (tok - oldstr) + HDstrlen(replacement);
+ HDfree(oldstr);
}
return newstr;
}
+
diff --git a/tools/lib/h5tools_utils.c b/tools/lib/h5tools_utils.c
index b87abf6..0884945 100644
--- a/tools/lib/h5tools_utils.c
+++ b/tools/lib/h5tools_utils.c
@@ -34,7 +34,7 @@
#include "h5trav.h"
/* global variables */
-int h5tools_nCols = 80;
+unsigned h5tools_nCols = 80;
/* ``get_option'' variables */
int opt_err = 1; /*get_option prints errors if this is on */
int opt_ind = 1; /*token pointer */
@@ -57,7 +57,7 @@ hsize_t H5TOOLS_BUFSIZE = ( 32 * 1024 * 1024); /* 32 MB */
/* ``parallel_print'' variables */
unsigned char g_Parallel = 0; /*0 for serial, 1 for parallel */
char outBuff[OUTBUFF_SIZE];
-int outBuffOffset;
+unsigned outBuffOffset;
FILE* overflow_file = NULL;
/* local functions */
@@ -89,11 +89,11 @@ void parallel_print(const char* format, ...)
HDvprintf(format, ap);
else {
if(overflow_file == NULL) /*no overflow has occurred yet */ {
- bytes_written = HDvsnprintf(outBuff+outBuffOffset, OUTBUFF_SIZE-outBuffOffset, format, ap);
+ bytes_written = HDvsnprintf(outBuff + outBuffOffset, OUTBUFF_SIZE - outBuffOffset, format, ap);
HDva_end(ap);
HDva_start(ap, format);
- if((bytes_written < 0) || (bytes_written >= (OUTBUFF_SIZE - outBuffOffset))) {
+ if((bytes_written < 0) || ((unsigned)bytes_written >= (OUTBUFF_SIZE - outBuffOffset))) {
/* Terminate the outbuff at the end of the previous output */
outBuff[outBuffOffset] = '\0';
@@ -104,7 +104,7 @@ void parallel_print(const char* format, ...)
bytes_written = HDvfprintf(overflow_file, format, ap);
}
else
- outBuffOffset += bytes_written;
+ outBuffOffset += (unsigned)bytes_written;
}
else
bytes_written = HDvfprintf(overflow_file, format, ap);
@@ -376,7 +376,7 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti
*-------------------------------------------------------------------------
*/
void
-indentation(int x)
+indentation(unsigned x)
{
if (x < h5tools_nCols) {
while (x-- > 0)
@@ -408,7 +408,7 @@ print_version(const char *progname)
{
PRINTSTREAM(rawoutstream, "%s: Version %u.%u.%u%s%s\n",
progname, H5_VERS_MAJOR, H5_VERS_MINOR, H5_VERS_RELEASE,
- ((char *)H5_VERS_SUBRELEASE)[0] ? "-" : "", H5_VERS_SUBRELEASE);
+ ((const char *)H5_VERS_SUBRELEASE)[0] ? "-" : "", H5_VERS_SUBRELEASE);
}
@@ -532,7 +532,7 @@ dump_tables(find_objs_t *info)
*
*-------------------------------------------------------------------------
*/
-obj_t *
+H5_ATTR_PURE obj_t *
search_obj(table_t *table, haddr_t objno)
{
unsigned u;
@@ -680,7 +680,7 @@ init_objs(hid_t fid, find_objs_t *info, table_t **group_table,
static void
add_obj(table_t *table, haddr_t objno, const char *objname, hbool_t record)
{
- unsigned u;
+ size_t u;
/* See if we need to make table larger */
if(table->nobjs == table->size) {
@@ -883,12 +883,14 @@ void h5tools_setstatus(int D_status)
h5tools_d_status = D_status;
}
-const char*h5tools_getprogname(void)
+H5_ATTR_PURE const char *
+h5tools_getprogname(void)
{
return h5tools_progname;
}
-int h5tools_getstatus(void)
+H5_ATTR_PURE int
+h5tools_getstatus(void)
{
return h5tools_d_status;
}
@@ -912,7 +914,6 @@ int h5tools_getenv_update_hyperslab_bufsize(void)
hyperslab_bufsize_mb = HDstrtol(env_str, (char**)NULL, 10);
if (errno != 0 || hyperslab_bufsize_mb <= 0)
{
-
/* TODO: later when pubilshed
HDfprintf(rawerrorstream,"Error: Invalid environment variable \"H5TOOLS_BUFSIZE\" : %s\n", env_str);
*/
@@ -922,13 +923,14 @@ int h5tools_getenv_update_hyperslab_bufsize(void)
/* convert MB to byte */
- H5TOOLS_BUFSIZE = hyperslab_bufsize_mb * 1024 * 1024;
+ H5TOOLS_BUFSIZE = (hsize_t)hyperslab_bufsize_mb * 1024 * 1024;
H5TOOLS_MALLOCSIZE = MAX(H5TOOLS_BUFSIZE, H5TOOLS_MALLOCSIZE);
}
-
return (1);
+
error:
return (-1);
}
+
diff --git a/tools/lib/h5tools_utils.h b/tools/lib/h5tools_utils.h
index 3285278..f7ab65b 100644
--- a/tools/lib/h5tools_utils.h
+++ b/tools/lib/h5tools_utils.h
@@ -35,7 +35,7 @@ extern "C" {
H5TOOLS_DLLVAR int g_nTasks;
H5TOOLS_DLLVAR unsigned char g_Parallel;
H5TOOLS_DLLVAR char outBuff[];
-H5TOOLS_DLLVAR int outBuffOffset;
+H5TOOLS_DLLVAR unsigned outBuffOffset;
H5TOOLS_DLLVAR FILE * overflow_file;
/* Maximum size used in a call to malloc for a dataset */
@@ -119,10 +119,10 @@ typedef struct find_objs_t {
table_t *dset_table;
} find_objs_t;
-H5TOOLS_DLLVAR int h5tools_nCols; /*max number of columns for outputting */
+H5TOOLS_DLLVAR unsigned h5tools_nCols; /*max number of columns for outputting */
/* Definitions of useful routines */
-H5TOOLS_DLL void indentation(int);
+H5TOOLS_DLL void indentation(unsigned);
H5TOOLS_DLL void print_version(const char *progname);
H5TOOLS_DLL void parallel_print(const char* format, ... );
H5TOOLS_DLL void error_msg(const char *fmt, ...);
diff --git a/tools/lib/h5trav.c b/tools/lib/h5trav.c
index 86e60c3..66beb0d 100644
--- a/tools/lib/h5trav.c
+++ b/tools/lib/h5trav.c
@@ -161,7 +161,7 @@ trav_addr_add(trav_addr_t *visited, haddr_t addr, const char *path)
*
*-------------------------------------------------------------------------
*/
-static const char *
+H5_ATTR_PURE static const char *
trav_addr_visited(trav_addr_t *visited, haddr_t addr)
{
size_t u; /* Local index variable */
@@ -490,7 +490,7 @@ h5trav_getinfo(hid_t file_id, trav_info_t *info)
*-------------------------------------------------------------------------
*/
-ssize_t
+H5_ATTR_PURE ssize_t
h5trav_getindex(const trav_info_t *info, const char *obj)
{
size_t u; /* Local index variable */
@@ -681,7 +681,7 @@ h5trav_gettable(hid_t fid, trav_table_t *table)
*-------------------------------------------------------------------------
*/
-int
+H5_ATTR_PURE int
h5trav_getindext(const char *name, const trav_table_t *table)
{
unsigned int i;
@@ -1235,7 +1235,7 @@ symlink_visit_add(symlink_trav_t *visited, H5L_type_t type, const char *file, co
*
*-------------------------------------------------------------------------
*/
-hbool_t
+H5_ATTR_PURE hbool_t
symlink_is_visited(symlink_trav_t *visited, H5L_type_t type, const char *file, const char *path)
{
size_t u; /* Local index variable */
diff --git a/tools/lib/io_timer.c b/tools/lib/io_timer.c
index b85133d..4d79a9b 100644
--- a/tools/lib/io_timer.c
+++ b/tools/lib/io_timer.c
@@ -222,7 +222,7 @@ set_time(io_time_t *pt, timer_type t, int start_stop)
* Programmer: Bill Wendling, 01. October 2001
* Modifications:
*/
-double
+H5_ATTR_PURE double
get_time(io_time_t *pt, timer_type t)
{
return pt->total_time[t];
diff --git a/tools/misc/h5repart.c b/tools/misc/h5repart.c
index 37d505a..8657cbc 100644
--- a/tools/misc/h5repart.c
+++ b/tools/misc/h5repart.c
@@ -252,9 +252,9 @@ main (int argc, char *argv[])
} /* end while */
/* allocate names */
- if(NULL == (src_name = HDcalloc((size_t)NAMELEN, sizeof(char))))
+ if(NULL == (src_name = (char *)HDcalloc((size_t)NAMELEN, sizeof(char))))
exit(EXIT_FAILURE);
- if(NULL == (dst_name = HDcalloc((size_t)NAMELEN, sizeof(char))))
+ if(NULL == (dst_name = (char *)HDcalloc((size_t)NAMELEN, sizeof(char))))
exit(EXIT_FAILURE);
/*