From 147522bb6118ec82f087208d5caa046f57ff801d Mon Sep 17 00:00:00 2001 From: Vailin Choi Date: Tue, 30 Jul 2013 16:41:23 -0500 Subject: [svn-r23948] Bring revisions #23670 - 23713 from trunk to revise_chunks. h5committested. --- CMakeLists.txt | 46 ++-- README.txt | 2 +- bin/checkapi | 66 +++-- bin/checkposix | 145 +++++++---- c++/src/Makefile.in | 2 +- config/lt_vers.am | 2 +- configure | 22 +- configure.ac | 2 +- fortran/src/Makefile.in | 2 +- hl/c++/src/Makefile.in | 2 +- hl/fortran/src/Makefile.in | 2 +- hl/src/Makefile.in | 2 +- hl/test/test_image.c | 186 ++++++++++---- release_docs/RELEASE.txt | 2 +- src/H5.c | 4 +- src/H5C.c | 10 +- src/H5CS.c | 14 +- src/H5D.c | 47 ++-- src/H5Dchunk.c | 10 +- src/H5Dint.c | 12 +- src/H5Dio.c | 7 +- src/H5Dmpio.c | 39 ++- src/H5Dpkg.h | 11 +- src/H5F.c | 21 +- src/H5FD.c | 10 +- src/H5FDcore.c | 2 +- src/H5FDdirect.c | 90 +++---- src/H5FDfamily.c | 16 +- src/H5FDint.c | 2 +- src/H5FDlog.c | 2 +- src/H5FDmpi.c | 34 ++- src/H5FDmpio.c | 52 ++-- src/H5FDmpiposix.c | 4 +- src/H5FO.c | 28 +- src/H5Fmpi.c | 6 +- src/H5Fpkg.h | 1 - src/H5Fprivate.h | 1 + src/H5Gname.c | 14 +- src/H5HG.c | 45 ++-- src/H5HP.c | 134 +++++----- src/H5I.c | 42 +-- src/H5Iprivate.h | 1 - src/H5MM.c | 4 +- src/H5Ocopy.c | 27 +- src/H5Oefl.c | 4 +- src/H5Olayout.c | 2 +- src/H5Oname.c | 14 +- src/H5Ostab.c | 16 +- src/H5PL.c | 4 +- src/H5Pdcpl.c | 21 +- src/H5Pfapl.c | 2 +- src/H5Pint.c | 2 +- src/H5Pocpl.c | 2 +- src/H5R.c | 10 +- src/H5S.c | 10 +- src/H5SL.c | 42 +-- src/H5Sall.c | 54 ++-- src/H5Sselect.c | 52 ++-- src/H5T.c | 74 +++--- src/H5Tconv.c | 627 +++++++++++++++++++++++++-------------------- src/H5Tenum.c | 20 +- src/H5Tfields.c | 12 +- src/H5Tfixed.c | 2 +- src/H5Tnative.c | 53 ++-- src/H5Toffset.c | 12 +- src/H5Tprecis.c | 12 +- src/H5Tvlen.c | 10 +- src/H5V.c | 146 +++++------ src/H5Vprivate.h | 2 +- src/H5Z.c | 372 ++++++++++++++++++--------- src/H5Zfletcher32.c | 2 +- src/H5Zprivate.h | 3 +- src/H5Zscaleoffset.c | 4 +- src/H5Zszip.c | 20 +- src/H5Ztrans.c | 68 ++--- src/H5detect.c | 98 +++---- src/H5make_libsettings.c | 6 +- src/H5private.h | 9 +- src/H5public.h | 4 +- src/H5system.c | 4 +- src/H5timer.c | 10 +- src/H5trace.c | 10 +- src/Makefile.in | 2 +- test/CMakeLists.txt | 4 + test/H5srcdir.h | 11 +- test/file_image.c | 3 + test/h5test.c | 20 +- test/links_env.c | 1 - test/unregister.c | 6 +- tools/h5jam/getub.c | 2 +- tools/h5stat/h5stat.c | 337 ++++++++++++------------ tools/lib/h5diff_array.c | 6 +- tools/lib/h5tools.c | 16 +- tools/lib/h5tools_dump.c | 88 ++++--- vms/src/h5pubconf.h | 15 +- vms/src/make.com | 2 +- 96 files changed, 1920 insertions(+), 1581 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b536980..8f7a2fe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -964,36 +964,46 @@ IF (NOT HDF5_EXTERNALLY_CONFIGURED) ) IF (EXISTS "${HDF5_SOURCE_DIR}/release_docs" AND IS_DIRECTORY "${HDF5_SOURCE_DIR}/release_docs") SET (release_files - ${HDF5_SOURCE_DIR}/release_docs/INSTALL_CMake.txt ${HDF5_SOURCE_DIR}/release_docs/USING_HDF5_CMake.txt ${HDF5_SOURCE_DIR}/release_docs/COPYING - ${HDF5_SOURCE_DIR}/release_docs/HISTORY-1_9.txt - ${HDF5_SOURCE_DIR}/release_docs/INSTALL ${HDF5_SOURCE_DIR}/release_docs/RELEASE.txt ) IF (WIN32 AND NOT CYGWIN) SET (release_files ${release_files} - ${HDF5_SOURCE_DIR}/release_docs/INSTALL_Windows.txt - ) - ELSE (WIN32 AND NOT CYGWIN) - SET (release_files - ${release_files} - ${HDF5_SOURCE_DIR}/release_docs/INSTALL_Cygwin.txt - ${HDF5_SOURCE_DIR}/release_docs/INSTALL_VMS.txt + ${HDF5_SOURCE_DIR}/release_docs/USING_HDF5_VS.txt ) ENDIF (WIN32 AND NOT CYGWIN) - IF (HDF5_ENABLE_PARALLEL) + IF (HDF5_PACK_INSTALL_DOCS) SET (release_files ${release_files} - ${HDF5_SOURCE_DIR}/release_docs/INSTALL_parallel + ${HDF5_SOURCE_DIR}/release_docs/INSTALL_CMake.txt + ${HDF5_SOURCE_DIR}/release_docs/HISTORY-1_8.txt + ${HDF5_SOURCE_DIR}/release_docs/INSTALL ) - ENDIF (HDF5_ENABLE_PARALLEL) - INSTALL ( - FILES ${release_files} - DESTINATION ${HDF5_INSTALL_DATA_DIR}/release_docs - COMPONENT hdfdocuments - ) + IF (WIN32 AND NOT CYGWIN) + SET (release_files + ${release_files} + ${HDF5_SOURCE_DIR}/release_docs/INSTALL_Windows.txt + ) + ELSE (WIN32 AND NOT CYGWIN) + SET (release_files + ${release_files} + ${HDF5_SOURCE_DIR}/release_docs/INSTALL_Cygwin.txt + ) + ENDIF (WIN32 AND NOT CYGWIN) + IF (HDF5_ENABLE_PARALLEL) + SET (release_files + ${release_files} + ${HDF5_SOURCE_DIR}/release_docs/INSTALL_parallel + ) + ENDIF (HDF5_ENABLE_PARALLEL) + INSTALL ( + FILES ${release_files} + DESTINATION ${HDF5_INSTALL_DATA_DIR}/release_docs + COMPONENT hdfdocuments + ) + ENDIF (HDF5_PACK_INSTALL_DOCS) ENDIF (EXISTS "${HDF5_SOURCE_DIR}/release_docs" AND IS_DIRECTORY "${HDF5_SOURCE_DIR}/release_docs") ENDIF (NOT HDF5_EXTERNALLY_CONFIGURED) diff --git a/README.txt b/README.txt index 97235cb..cc239fb 100644 --- a/README.txt +++ b/README.txt @@ -1,4 +1,4 @@ -HDF5 version 1.9.151-FA_a5 currently under development +HDF5 version 1.9.152-FA_a5 currently under development Please refer to the release_docs/INSTALL file for installation instructions. ------------------------------------------------------------------------------ diff --git a/bin/checkapi b/bin/checkapi index d21863b..b4a08e8 100755 --- a/bin/checkapi +++ b/bin/checkapi @@ -17,33 +17,51 @@ require 5.003; # Purpose: insures that API functions aren't called internally. # Usage: checkapi H5*.c -my $comment = 0; -while (<>) { +my $filename = ""; +my $lastname = ""; - # Remove comments within the line. - s/\/\*.*?\*\///g; +if(<>) { + while (<>) { + if($ARGV =~ /\//) { + ($filename) = ($ARGV =~ /^.*\/([A-Za-z0-9_]*)\.c$/); + } else { + ($filename) = ($ARGV =~ /([A-Za-z0-9_]*)\.c$/); + } - # Process comment begin and end tokens on this line. - $comment-- if /\*\//; # count comment ends - next if $comment; # skip line if in comment - $comment++ if /\/\*/; # count comment starts - s/(.*)\/\*.*/$1/; # remove comments that begin on this line + if($filename =~ /H5FDmulti|H5FDstdio/) { + if($filename ne $lastname) { + print "$ARGV is exempt from checking\n"; + $lastname = $filename; + } + } else { + # Get rid of comments by removing the inside part. + s|/\*.*?\*/||g; + if ($in_comment) { + if (/\*\//) { + s|.*?\*/||; + $in_comment = 0; + } else { + $_="\n"; + } + } elsif (m|/\*|) { + s|/\*.*||; + $in_comment = 1; + } - # Remove character strings - s/\\.//g; # remove escaped characters - s/\".*?\"//g; # remove string constants + # Remove character strings + s/\\.//g; # remove escaped characters + s/\".*?\"//g; # remove string constants - # Disregard the following hits - next if /^H5/; - next if /^\#/; - next if /FUNC_ENTER(_NOINIT)*/; + # Disregard the following hits + next if /^H5/; + next if /^\#/; + next if /FUNC_ENTER(_NOINIT)*/; - next unless /(H5[A-Z]{1,2}[a-z]\w*)/; - print "$ARGV:$.: $1\n"; -} continue { - if (eof) { - print "$ARGV:$.: bad comment nesting\n" if $comment; - $comment = 0; - close ARGV; # reset line number - } + next unless /(H5[A-Z]{1,2}[a-z]\w*)/; + print "$ARGV:$.: $1\n"; + } + } continue { + close ARGV if eof; # reset line number + } } + diff --git a/bin/checkposix b/bin/checkposix index b295d7d..e3617e5 100755 --- a/bin/checkposix +++ b/bin/checkposix @@ -27,60 +27,93 @@ require 5.003; # use `next-error' (usually bound to M-`) to find each name # violation. -while (<>) { - - # Get rid of comments by removing the inside part. - s|/\*.*?\*/||g; - if ($in_comment) { - if (/\*\//) { - s|.*?\*/||; - $in_comment = 0; - } else { - $_="\n"; - } - } elsif (m|/\*|) { - s|/\*.*||; - $in_comment = 1; - } - - # Get rid of string constants if they begin and end on this line. - s/([\'\"])([^\1]|\\\1)*?\1/$1$1/g; - - # Get rid of preprocessor directives - s/^\#.*//; - - # Now find all function calls on this line - while (($name)=/\b([a-gi-z_A-GI-Z]\w*)\s*\(/) { - $_ = $'; - - # Ignore C statements that look sort of like function - # calls. - next if $name =~ /^(if|for|return|sizeof|switch|while|void)$/; - - # Ignore things that get misdetected because of the simplified - # parsing that takes place here. - next if $name =~ /^int$/; - - # These are really HDF5 functions/macros even though they don't - # start with `h' or `H'. - next if $name =~ /^FUNC_(ENTER|LEAVE)(_INIT)?$/; - next if $name =~ /^U?INT(8|16|32|64)(ENCODE|DECODE)$/; - next if $name =~ /^(MIN3?|MAX3?|NELMTS|BOUND|CONSTR)$/; - next if $name =~ /^IS_H5FD_MPIO$/; - next if $name =~ /^addr_defined$/; - - # These functions/macros are exempt. - next if $name =~ /^(assert|main|[fs]?printf|va_(start|arg|end))$/; - - # These are MPI function calls. Ignore them. - next if $name =~ /^MPI_/; - - # These are POSIX threads function calls. Ignore them. - next if $name =~ /^pthread_/; - - print "$ARGV:$.: $name\n"; - } - -} continue { - close ARGV if eof; +if(<>) { + if($ARGV =~ /\//) { + ($filename) = ($ARGV =~ /^.*\/([A-Za-z0-9_]*)\.c$/); + } else { + ($filename) = ($ARGV =~ /([A-Za-z0-9_]*)\.c$/); + } + + if($filename =~ /H5FDmulti|H5FDstdio/) { + print "$ARGV is exempt from using Standard library macro wrappers\n"; + } else { + while (<>) { + + # Get rid of comments by removing the inside part. + s|/\*.*?\*/||g; + if ($in_comment) { + if (/\*\//) { + s|.*?\*/||; + $in_comment = 0; + } else { + $_="\n"; + } + } elsif (m|/\*|) { + s|/\*.*||; + $in_comment = 1; + } + + # Get rid of string constants if they begin and end on this line. + s/([\'\"])([^\1]|\\\1)*?\1/$1$1/g; + + # Get rid of preprocessor directives + s/^\#.*//; + + # Skip callbacks invoked as methods in a struct + next if $_ =~ /\b(\)?->|\.)\(?([a-z_A-Z]\w*)\s*\(/; + + # Now find all function calls on this line which don't start with 'H' + while (($name)=/\b([a-z_A-GI-Z]\w*)\s*\(/) { + $_ = $'; + + # Ignore C statements that look sort of like function + # calls. + next if $name =~ /^(if|for|offsetof|return|sizeof|switch|while|void)$/; + + # Ignore things that get misdetected because of the simplified + # parsing that takes place here. + next if $name =~ /^(int|herr_t|_term_interface)$/; + + # These are really HDF5 functions/macros even though they don't + # start with `h' or `H'. + next if $name =~ /^FUNC_(ENTER|LEAVE)(_(NO)?API|_PACKAGE|_STATIC)?(_NOFS|_NOCLEAR|_NOINIT)?(_NOFUNC|_TAG)?$/; + next if $name =~ /^(BEGIN|END)_FUNC$/; + next if $name =~ /^U?INT(8|16|32|64)(ENCODE|DECODE)(_VAR)?$/; + next if $name =~ /^CI_(PRINT_STATS|INC_SRC|INC_DST)$/; + next if $name =~ /^(ABS|ADDR_OVERFLOW|ALL_MEMBERS|BOUND|CONSTR|DETECT_[I|F|M]|DOWN)$/; + next if $name =~ /^(MIN3?|MAX3?|NELMTS|POWER_OF_TWO|REGION_OVERFLOW)$/; + next if $name =~ /^(UNIQUE_MEMBERS)$/; + next if $name =~ /^(IS_H5FD_MPIO|IS_H5FD_MPIPOSIX)$/; + next if $name =~ /^addr_defined$/; + + # These functions/macros are exempt. + next if $name =~ /^(main|[fs]?printf|va_(start|arg|end))$/; + + # These are Windows system calls. Ignore them. + next if $name =~ /^(_get_osfhandle|GetFileInformationByHandle|SetFilePointer|GetLastError|SetEndOfFile)$/; + next if $name =~ /^(FindNextFile|FindClose|_tzset|Wgettimeofday|GetSystemTimeAsFileTime|Wgetlogin|GetUserName)$/; + + # These are GPFS function calls. Ignore them. + next if $name =~ /^gpfs_fcntl$/; + + # These are MPI function calls. Ignore them. + next if $name =~ /^(MPI_|MPE_)/; + + # These are POSIX threads function calls. Ignore them. + next if $name =~ /^pthread_/; + + # These are Windows threads function calls. Ignore them. + next if $name =~ /^(_beginthread|(Initialize|Enter|Leave)CriticalSection|TlsAlloc)$/; + + # These are zlib & szlib function calls. Ignore them. + next if $name =~ /^(inflate|SZ_)/; + next if $name =~ /^compress2$/; + + print "$ARGV:$.: $name\n"; + } + + } continue { + close ARGV if eof; # reset line number + } + } } diff --git a/c++/src/Makefile.in b/c++/src/Makefile.in index 103da91..d86c4b7 100644 --- a/c++/src/Makefile.in +++ b/c++/src/Makefile.in @@ -467,7 +467,7 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog # Add libtool shared library version numbers to the HDF5 library # See libtool versioning documentation online. LT_VERS_INTERFACE = 6 -LT_VERS_REVISION = 141 +LT_VERS_REVISION = 142 LT_VERS_AGE = 0 # Include src directory diff --git a/config/lt_vers.am b/config/lt_vers.am index ac9fc70..b6533b3 100644 --- a/config/lt_vers.am +++ b/config/lt_vers.am @@ -17,7 +17,7 @@ # Add libtool shared library version numbers to the HDF5 library # See libtool versioning documentation online. LT_VERS_INTERFACE = 6 -LT_VERS_REVISION = 141 +LT_VERS_REVISION = 142 LT_VERS_AGE = 0 ## If the API changes *at all*, increment LT_VERS_INTERFACE and diff --git a/configure b/configure index 333db5d..bbf89d2 100755 --- a/configure +++ b/configure @@ -1,7 +1,7 @@ #! /bin/sh # From configure.ac Id: configure.ac 22697 2012-08-19 14:35:47Z hdftest . # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for HDF5 1.9.151-FA_a5. +# Generated by GNU Autoconf 2.69 for HDF5 1.9.152-FA_a5. # # Report bugs to . # @@ -591,8 +591,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='HDF5' PACKAGE_TARNAME='hdf5' -PACKAGE_VERSION='1.9.151-FA_a5' -PACKAGE_STRING='HDF5 1.9.151-FA_a5' +PACKAGE_VERSION='1.9.152-FA_a5' +PACKAGE_STRING='HDF5 1.9.152-FA_a5' PACKAGE_BUGREPORT='help@hdfgroup.org' PACKAGE_URL='' @@ -1486,7 +1486,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures HDF5 1.9.151-FA_a5 to adapt to many kinds of systems. +\`configure' configures HDF5 1.9.152-FA_a5 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1556,7 +1556,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of HDF5 1.9.151-FA_a5:";; + short | recursive ) echo "Configuration of HDF5 1.9.152-FA_a5:";; esac cat <<\_ACEOF @@ -1752,7 +1752,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -HDF5 configure 1.9.151-FA_a5 +HDF5 configure 1.9.152-FA_a5 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2846,7 +2846,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by HDF5 $as_me 1.9.151-FA_a5, which was +It was created by HDF5 $as_me 1.9.152-FA_a5, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -3678,7 +3678,7 @@ fi # Define the identity of the package. PACKAGE='hdf5' - VERSION='1.9.151-FA_a5' + VERSION='1.9.152-FA_a5' cat >>confdefs.h <<_ACEOF @@ -31632,7 +31632,7 @@ Usage: $0 [OPTIONS] Report bugs to ." lt_cl_version="\ -HDF5 config.lt 1.9.151-FA_a5 +HDF5 config.lt 1.9.152-FA_a5 configured by $0, generated by GNU Autoconf 2.69. Copyright (C) 2011 Free Software Foundation, Inc. @@ -33762,7 +33762,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by HDF5 $as_me 1.9.151-FA_a5, which was +This file was extended by HDF5 $as_me 1.9.152-FA_a5, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -33828,7 +33828,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -HDF5 config.status 1.9.151-FA_a5 +HDF5 config.status 1.9.152-FA_a5 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index 8e6b057..d519730 100644 --- a/configure.ac +++ b/configure.ac @@ -26,7 +26,7 @@ AC_PREREQ([2.69]) ## NOTE: Do not forget to change the version number here when we do a ## release!!! ## -AC_INIT([HDF5], [1.9.151-FA_a5], [help@hdfgroup.org]) +AC_INIT([HDF5], [1.9.152-FA_a5], [help@hdfgroup.org]) AC_CONFIG_SRCDIR([src/H5.c]) AC_CONFIG_HEADER([src/H5config.h]) diff --git a/fortran/src/Makefile.in b/fortran/src/Makefile.in index bae0cae..f47a11e 100644 --- a/fortran/src/Makefile.in +++ b/fortran/src/Makefile.in @@ -518,7 +518,7 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog # Add libtool shared library version numbers to the HDF5 library # See libtool versioning documentation online. LT_VERS_INTERFACE = 6 -LT_VERS_REVISION = 141 +LT_VERS_REVISION = 142 LT_VERS_AGE = 0 # Include src directory in both Fortran and C flags (C compiler is used diff --git a/hl/c++/src/Makefile.in b/hl/c++/src/Makefile.in index 717e0ae..2abf918 100644 --- a/hl/c++/src/Makefile.in +++ b/hl/c++/src/Makefile.in @@ -458,7 +458,7 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog # Add libtool shared library version numbers to the HDF5 library # See libtool versioning documentation online. LT_VERS_INTERFACE = 6 -LT_VERS_REVISION = 141 +LT_VERS_REVISION = 142 LT_VERS_AGE = 0 # Include src directory diff --git a/hl/fortran/src/Makefile.in b/hl/fortran/src/Makefile.in index ff77de7..4e00046 100644 --- a/hl/fortran/src/Makefile.in +++ b/hl/fortran/src/Makefile.in @@ -474,7 +474,7 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog # Add libtool shared library version numbers to the HDF5 library # See libtool versioning documentation online. LT_VERS_INTERFACE = 6 -LT_VERS_REVISION = 141 +LT_VERS_REVISION = 142 LT_VERS_AGE = 0 INCLUDES = -I$(top_srcdir)/src -I$(top_srcdir)/hl/src -I$(top_builddir)/hl/src \ -I$(top_srcdir)/fortran/src -I$(top_builddir)/fortran/src diff --git a/hl/src/Makefile.in b/hl/src/Makefile.in index a2a47ad..409538e 100644 --- a/hl/src/Makefile.in +++ b/hl/src/Makefile.in @@ -457,7 +457,7 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog # Add libtool shared library version numbers to the HDF5 library # See libtool versioning documentation online. LT_VERS_INTERFACE = 6 -LT_VERS_REVISION = 141 +LT_VERS_REVISION = 142 LT_VERS_AGE = 0 # This library is our main target. diff --git a/hl/test/test_image.c b/hl/test/test_image.c index a4a10e4..38f1830 100644 --- a/hl/test/test_image.c +++ b/hl/test/test_image.c @@ -100,24 +100,34 @@ static int test_simple(void) hssize_t npals; /* 8-bit image */ - unsigned char buf1 [ WIDTH*HEIGHT ]; + unsigned char *buf1 = NULL; unsigned char pal[ PAL_ENTRIES * 3 ]; /* palette array */ hsize_t pal_dims[2] = {PAL_ENTRIES,3}; /* palette dimensions */ /* 24-bit image */ - unsigned char buf2 [ WIDTH*HEIGHT*3 ]; + unsigned char *buf2 = NULL; /* read data */ - unsigned char buf1_out [ WIDTH*HEIGHT ]; - unsigned char buf2_out [ WIDTH*HEIGHT*3 ]; + unsigned char *buf1_out = NULL; + unsigned char *buf2_out = NULL; unsigned char pal_out[ PAL_ENTRIES * 3 ]; /* palette array */ hsize_t pal_dims_out[2]; /* palette dimensions */ + /* Allocate image buffers */ + buf1 = (unsigned char *)HDmalloc(WIDTH * HEIGHT); + HDassert(buf1); + buf2 = (unsigned char *)HDmalloc(WIDTH * HEIGHT * 3); + HDassert(buf2); + buf1_out = (unsigned char *)HDmalloc(WIDTH * HEIGHT); + HDassert(buf1_out); + buf2_out = (unsigned char *)HDmalloc(WIDTH * HEIGHT * 3); + HDassert(buf2_out); + /* create an image */ space = WIDTH*HEIGHT / PAL_ENTRIES; for (i=0, j=0, n=0; i < WIDTH*HEIGHT; i++, j++ ) { - buf1[i] = n; + buf1[i] = (unsigned char)n; if ( j > space ) { n++; @@ -126,17 +136,13 @@ static int test_simple(void) } - /* create an image */ space = WIDTH*HEIGHT / 256; for (i=0, j=0, n=0; i < WIDTH*HEIGHT*3; i+=3, j++ ) { - unsigned char r, g, b; - - r = n; g = 0; b = 255-n; - buf2[i] = r; - buf2[i+1] = g; - buf2[i+2] = b; + buf2[i] = (unsigned char)n; + buf2[i+1] = 0; + buf2[i+2] = (unsigned char)(255 - n); if ( j > space ) { n++; @@ -150,9 +156,9 @@ static int test_simple(void) */ for ( i=0, n=0; i INT_MAX / jmax) + goto out; + if(imax * jmax > INT_MAX / kmax) + goto out; + + n_elements = imax * jmax * kmax; + + /* Test buffer sizes for overflow */ + if(n_elements > INT_MAX / (int)sizeof(unsigned char)) + goto out; + if(n_elements > INT_MAX / (int)sizeof(float)) + goto out; + + data = (float *)HDmalloc((size_t)n_elements * sizeof( float )); + HDassert(data); + image_data = (unsigned char *)HDmalloc((size_t)n_elements * sizeof( unsigned char )); + HDassert(image_data); + + for ( i = 0; i < n_elements; i++ ) { fscanf( f, "%f ", &value ); data[i] = value; @@ -591,10 +642,8 @@ static int test_generate(void) TESTING2("make indexed image from all the data"); - for ( i = 0; i < imax * jmax * kmax; i++ ) - { + for ( i = 0; i < n_elements; i++ ) image_data[i] = (unsigned char)(( 255 * (data[i] - xmin ) ) / (xmax - xmin )); - } /* Make the image */ if ((H5IMmake_image_8bit(fid,"All data",(hsize_t)imax,(hsize_t)jmax,image_data))<0) @@ -610,7 +659,7 @@ static int test_generate(void) TESTING2("make indexed image from land data"); - for ( i = 0; i < imax * jmax * kmax; i++ ) + for ( i = 0; i < n_elements; i++ ) { if ( data[i] < 0 ) image_data[i] = 0; @@ -632,7 +681,7 @@ static int test_generate(void) TESTING2("make indexed image from sea data"); - for ( i = 0; i < imax * jmax * kmax; i++ ) + for ( i = 0; i < n_elements; i++ ) { if ( data[i] > 0 ) image_data[i] = 0; @@ -675,12 +724,21 @@ static int test_generate(void) if (H5Fclose(fid)<0) goto out; + /* Release memory buffers */ + HDfree(data); + HDfree(image_data); + /* Indicate success */ return 0; /* error zone, gracefully close */ out: - HDfree(data); + /* Release memory buffers */ + if(data) + HDfree(data); + if(image_data) + HDfree(image_data); + H5E_BEGIN_TRY { H5Fclose(fid); } H5E_END_TRY; @@ -713,51 +771,71 @@ static int read_data( const char* fname, /*IN*/ int i, n; int color_planes; char str[20]; - FILE *f; + FILE *f = NULL; int w, h; + int n_elements; const char *data_file = H5_get_srcdir_filename(fname); + int ret_val = -1; /*------------------------------------------------------------------------- * read *------------------------------------------------------------------------- */ - f = HDfopen(data_file, "r"); - if ( f == NULL ) - { + if(NULL == (f = HDfopen(data_file, "r"))) { printf( "Could not open file %s. Try set $srcdir \n", data_file ); - return -1; + goto out; } - fscanf( f, "%s", str ); - fscanf( f, "%d", &color_planes ); - fscanf( f, "%s", str ); - fscanf( f, "%d", &h); - fscanf( f, "%s", str ); - fscanf( f, "%d", &w); + fscanf(f, "%s", str); + fscanf(f, "%d", &color_planes); + fscanf(f, "%s", str); + fscanf(f, "%d", &h); + fscanf(f, "%s", str); + fscanf(f, "%d", &w); *width = (hsize_t)w; *height = (hsize_t)h; - if ( image_data ) - { - HDfree( image_data ); - image_data=NULL; - } + /* Check product for overflow */ + if(w < 1 || h < 1 || color_planes < 1) + goto out; + if(w > INT_MAX / h) + goto out; + if(w * h > INT_MAX / color_planes) + goto out; - image_data = (unsigned char*) HDmalloc (w * h * color_planes * sizeof( unsigned char )); + /* Compute buffer size */ + n_elements = w * h * color_planes; - for (i = 0; i < h * w * color_planes ; i++) - { - fscanf( f, "%d",&n ); + /* Check buffer size for overflow */ + if(n_elements > INT_MAX / (int)sizeof(unsigned char)) + goto out; + + /* Release the buffer, if it was previously allocated */ + if(image_data) { + HDfree(image_data); + image_data = NULL; + } /* end if */ + + /* Allocate the image data buffer */ + image_data = (unsigned char *)HDmalloc((size_t)n_elements * sizeof(unsigned char)); + + /* Read data elements */ + for(i = 0; i < n_elements; i++) { + fscanf(f, "%d",&n); image_data[i] = (unsigned char)n; - } - HDfclose(f); + } /* end for */ - return 1; + /* Indicate success */ + ret_val = 1; -} +out: + if(f) + HDfclose(f); + return ret_val; +} /* end read_data() */ /*------------------------------------------------------------------------- @@ -882,6 +960,6 @@ static int read_palette(const char* fname, /* close file */ HDfclose(file); - return nentries; + return (int)nentries; } diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index fb57c81..ddd29d3 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -1,4 +1,4 @@ -HDF5 version 1.9.151-FA_a5 currently under development +HDF5 version 1.9.152-FA_a5 currently under development INTRODUCTION diff --git a/src/H5.c b/src/H5.c index 25525a4..03d82a8 100644 --- a/src/H5.c +++ b/src/H5.c @@ -144,7 +144,7 @@ H5_init_library(void) MPI_Initialized(&mpi_initialized); if (mpi_initialized){ mpe_code = MPE_Init_log(); - assert(mpe_code >=0); + HDassert(mpe_code >=0); H5_MPEinit_g = TRUE; } } @@ -309,7 +309,7 @@ H5_term_library(void) MPI_Initialized(&mpi_initialized); if(mpi_initialized) { mpe_code = MPE_Finish_log("h5log"); - assert(mpe_code >=0); + HDassert(mpe_code >=0); } /* end if */ H5_MPEinit_g = FALSE; /* turn it off no matter what */ } /* end if */ diff --git a/src/H5C.c b/src/H5C.c index a653a17..a76dbc4 100644 --- a/src/H5C.c +++ b/src/H5C.c @@ -487,10 +487,10 @@ H5C_apply_candidate_list(H5F_t * f, sprintf(&(tbl_buf[0]), "candidate list = "); for ( i = 0; i < num_candidates; i++ ) { - sprintf(&(tbl_buf[strlen(tbl_buf)]), " 0x%llx", + sprintf(&(tbl_buf[HDstrlen(tbl_buf)]), " 0x%llx", (long long)(*(candidates_list_ptr + i))); } - sprintf(&(tbl_buf[strlen(tbl_buf)]), "\n"); + sprintf(&(tbl_buf[HDstrlen(tbl_buf)]), "\n"); HDfprintf(stdout, "%s", tbl_buf); #endif /* H5C_APPLY_CANDIDATE_LIST__DEBUG */ @@ -547,8 +547,8 @@ H5C_apply_candidate_list(H5F_t * f, tbl_buf[i] = '\0'; sprintf(&(tbl_buf[0]), "candidate assignment table = "); for(i = 0; i <= mpi_size; i++) - sprintf(&(tbl_buf[strlen(tbl_buf)]), " %d", candidate_assignment_table[i]); - sprintf(&(tbl_buf[strlen(tbl_buf)]), "\n"); + sprintf(&(tbl_buf[HDstrlen(tbl_buf)]), " %d", candidate_assignment_table[i]); + sprintf(&(tbl_buf[HDstrlen(tbl_buf)]), "\n"); HDfprintf(stdout, "%s", tbl_buf); HDfprintf(stdout, "%s:%d: flush entries [%d, %d].\n", @@ -822,7 +822,7 @@ H5C_apply_candidate_list(H5F_t * f, entries_cleared, entries_flushed); HDfprintf(stdout, "%s:%d: done.\n", FUNC, mpi_rank); - fsync(stdout); + HDfsync(stdout); #endif /* H5C_APPLY_CANDIDATE_LIST__DEBUG */ /* ====================================================================== * diff --git a/src/H5CS.c b/src/H5CS.c index c2ca49b..4ccd0f8 100644 --- a/src/H5CS.c +++ b/src/H5CS.c @@ -173,7 +173,7 @@ H5CS_print(FILE *stream) FUNC_ENTER_NOAPI_NOERR_NOFS /* Sanity check */ - assert(fstack); + HDassert(fstack); H5CS_print_stack(fstack, stream); @@ -205,8 +205,8 @@ H5CS_push(const char *func_name) FUNC_ENTER_NOAPI_NOERR_NOFS /* Sanity check */ - assert (fstack); - assert (func_name); + HDassert(fstack); + HDassert(func_name); /* * Push the function if there's room. Otherwise just increment count @@ -242,8 +242,8 @@ H5CS_pop(void) FUNC_ENTER_NOAPI_NOERR_NOFS /* Sanity check */ - assert (fstack); - assert (fstack->nused>0); + HDassert(fstack); + HDassert(fstack->nused>0); /* Pop the function. */ fstack->nused--; @@ -276,7 +276,7 @@ H5CS_copy_stack(H5CS_t *new_stack) FUNC_ENTER_NOAPI_NOERR_NOFS /* Sanity check */ - HDassert (old_stack); + HDassert(old_stack); /* Copy old stack to new one, duplicating the strings */ for(u = 0; u < old_stack->nused; u++) @@ -310,7 +310,7 @@ H5CS_close_stack(H5CS_t *stack) FUNC_ENTER_NOAPI_NOERR_NOFS /* Sanity check */ - HDassert (stack); + HDassert(stack); /* Free strings on stack */ for(u = 0; u < stack->nused; u++) diff --git a/src/H5D.c b/src/H5D.c index 90e5b01..0eff024 100644 --- a/src/H5D.c +++ b/src/H5D.c @@ -105,7 +105,7 @@ H5D__init_pub_interface(void) * properties (DCPL_ID). * * All arguments are copied into the dataset, so the caller is - * allowed to derive new types, data spaces, and creation + * allowed to derive new types, dataspaces, and creation * parameters from the old ones and reuse them in calls to * create other datasets. * @@ -191,7 +191,7 @@ done: * properties (DCPL_ID). * * All arguments are copied into the dataset, so the caller is - * allowed to derive new types, data spaces, and creation + * allowed to derive new types, dataspaces, and creation * parameters from the old ones and reuse them in calls to * create other datasets. * @@ -409,9 +409,9 @@ done: /*------------------------------------------------------------------------- * Function: H5Dget_space * - * Purpose: Returns a copy of the file data space for a dataset. + * Purpose: Returns a copy of the file dataspace for a dataset. * - * Return: Success: ID for a copy of the data space. The data + * Return: Success: ID for a copy of the dataspace. The data * space should be released by calling * H5Sclose(). * @@ -436,13 +436,13 @@ H5Dget_space(hid_t dset_id) if(NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") - /* Read the data space message and return a data space object */ + /* Read the dataspace message and return a dataspace object */ if(NULL == (space = H5S_copy(dset->shared->space, FALSE, TRUE))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to get data space") + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to get dataspace") /* Create an atom */ if((ret_value = H5I_register (H5I_DATASPACE, space, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register data space") + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace") done: if(ret_value < 0) { @@ -459,7 +459,7 @@ done: /*------------------------------------------------------------------------- * Function: H5Dget_space_status * - * Purpose: Returns the status of data space allocation. + * Purpose: Returns the status of dataspace allocation. * * Return: * Success: Non-negative @@ -483,7 +483,7 @@ H5Dget_space_status(hid_t dset_id, H5D_space_status_t *allocation) if(NULL==(dset=(H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") - /* Read data space address and return */ + /* Read dataspace address and return */ if(H5D__get_space_status(dset, allocation, H5AC_ind_dxpl_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to get space status") @@ -573,10 +573,6 @@ hid_t H5Dget_create_plist(hid_t dset_id) { H5D_t *dataset; /* Dataset structure */ - H5P_genplist_t *dcpl_plist; /* Dataset's DCPL */ - H5P_genplist_t *new_plist; /* Copy of dataset's DCPL */ - H5O_fill_t copied_fill; /* Fill value to tweak */ - hid_t new_dcpl_id = FAIL; hid_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1030,6 +1026,9 @@ H5Dvlen_get_buf_size(hid_t dataset_id, hid_t type_id, hid_t space_id, hsize_t *size) { H5D_vlen_bufsize_t vlen_bufsize = {0, 0, 0, 0, 0, 0, 0}; + H5D_t *dset; /* Dataset for operation */ + H5S_t *fspace = NULL; /* Dataset's dataspace */ + H5S_t *mspace = NULL; /* Memory dataspace */ char bogus; /* bogus value to pass to H5Diterate() */ H5S_t *space; /* Dataspace for iteration */ H5P_genclass_t *pclass; /* Property class */ @@ -1043,21 +1042,25 @@ H5Dvlen_get_buf_size(hid_t dataset_id, hid_t type_id, hid_t space_id, if(H5I_DATASET != H5I_get_type(dataset_id) || H5I_DATATYPE != H5I_get_type(type_id) || size == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument") + if(NULL == (dset = (H5D_t *)H5I_object(dataset_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataspace") if(!(H5S_has_extent(space))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dataspace does not have extent set") - /* Save the dataset ID */ - vlen_bufsize.dataset_id = dataset_id; + /* Save the dataset */ + vlen_bufsize.dset = dset; - /* Get a copy of the dataspace ID */ - if((vlen_bufsize.fspace_id = H5Dget_space(dataset_id)) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't copy dataspace") + /* Get a copy of the dataset's dataspace */ + if(NULL == (fspace = H5S_copy(dset->shared->space, FALSE, TRUE))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to get dataspace") + vlen_bufsize.fspace = fspace; /* Create a scalar for the memory dataspace */ - if((vlen_bufsize.mspace_id = H5Screate(H5S_SCALAR)) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't create dataspace") + if(NULL == (mspace = H5S_create(H5S_SCALAR))) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create dataspace") + vlen_bufsize.mspace = mspace; /* Grab the temporary buffers required */ if(NULL == (vlen_bufsize.fl_tbuf = H5FL_BLK_MALLOC(vlen_fl_buf, (size_t)1))) @@ -1092,9 +1095,9 @@ H5Dvlen_get_buf_size(hid_t dataset_id, hid_t type_id, hid_t space_id, *size = vlen_bufsize.size; done: - if(vlen_bufsize.fspace_id > 0 && H5I_dec_ref(vlen_bufsize.fspace_id) < 0) + if(fspace && H5S_close(fspace) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataspace") - if(vlen_bufsize.mspace_id > 0 && H5I_dec_ref(vlen_bufsize.mspace_id) < 0) + if(mspace && H5S_close(mspace) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataspace") if(vlen_bufsize.fl_tbuf != NULL) vlen_bufsize.fl_tbuf = H5FL_BLK_FREE(vlen_fl_buf, vlen_bufsize.fl_tbuf); diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index e16496c..9573268 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -1235,7 +1235,7 @@ H5D__create_chunk_file_map_hyper(H5D_chunk_map_t *fm, const H5D_io_info_t FUNC_ENTER_STATIC /* Sanity check */ - assert(fm->f_ndims>0); + HDassert(fm->f_ndims>0); /* Get number of elements selected in file */ sel_points = fm->nelmts; @@ -1412,7 +1412,7 @@ H5D__create_chunk_mem_map_hyper(const H5D_chunk_map_t *fm) FUNC_ENTER_STATIC /* Sanity check */ - assert(fm->f_ndims>0); + HDassert(fm->f_ndims>0); /* Check for all I/O going to a single chunk */ if(H5SL_count(fm->sel_chunks)==1) { @@ -1423,7 +1423,7 @@ H5D__create_chunk_mem_map_hyper(const H5D_chunk_map_t *fm) /* Get pointer to chunk's information */ chunk_info = (H5D_chunk_info_t *)H5SL_item(curr_node); - assert(chunk_info); + HDassert(chunk_info); /* Just point at the memory dataspace & selection */ /* (Casting away const OK -QAK) */ @@ -1442,7 +1442,7 @@ H5D__create_chunk_mem_map_hyper(const H5D_chunk_map_t *fm) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get file selection bound info") /* Calculate the adjustment for memory selection from file selection */ - assert(fm->m_ndims==fm->f_ndims); + HDassert(fm->m_ndims==fm->f_ndims); for(u=0; uf_ndims; u++) { H5_CHECK_OVERFLOW(file_sel_start[u],hsize_t,hssize_t); H5_CHECK_OVERFLOW(mem_sel_start[u],hsize_t,hssize_t); @@ -1456,7 +1456,7 @@ H5D__create_chunk_mem_map_hyper(const H5D_chunk_map_t *fm) /* Get pointer to chunk's information */ chunk_info = (H5D_chunk_info_t *)H5SL_item(curr_node); - assert(chunk_info); + HDassert(chunk_info); /* Copy the information */ diff --git a/src/H5Dint.c b/src/H5Dint.c index 1086c98..b156e5c 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -376,7 +376,7 @@ H5D__get_dxpl_cache(hid_t dxpl_id, H5D_dxpl_cache_t **cache) FUNC_ENTER_PACKAGE /* Check args */ - assert(cache); + HDassert(cache); /* Check for the default DXPL */ if(dxpl_id==H5P_DATASET_XFER_DEFAULT) @@ -2175,18 +2175,18 @@ H5D__vlen_get_buf_size(void UNUSED *elem, hid_t type_id, unsigned UNUSED ndim, c /* Check args */ if(NULL == (dt = (H5T_t *)H5I_object(type_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") + HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "not a datatype") /* Make certain there is enough fixed-length buffer available */ if(NULL == (vlen_bufsize->fl_tbuf = H5FL_BLK_REALLOC(vlen_fl_buf, vlen_bufsize->fl_tbuf, H5T_get_size(dt)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't resize tbuf") + HGOTO_ERROR(H5E_DATASET, H5E_NOSPACE, FAIL, "can't resize tbuf") /* Select point to read in */ - if(H5Sselect_elements(vlen_bufsize->fspace_id, H5S_SELECT_SET, (size_t)1, point) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't select point") + if(H5S_select_elements(vlen_bufsize->fspace, H5S_SELECT_SET, (size_t)1, point) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCREATE, FAIL, "can't select point") /* Read in the point (with the custom VL memory allocator) */ - if(H5Dread(vlen_bufsize->dataset_id, type_id, vlen_bufsize->mspace_id, vlen_bufsize->fspace_id, vlen_bufsize->xfer_pid, vlen_bufsize->fl_tbuf) < 0) + if(H5D__read(vlen_bufsize->dset, type_id, vlen_bufsize->mspace, vlen_bufsize->fspace, vlen_bufsize->xfer_pid, vlen_bufsize->fl_tbuf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read point") done: diff --git a/src/H5Dio.c b/src/H5Dio.c index df1c4a3..9b2f8ff 100644 --- a/src/H5Dio.c +++ b/src/H5Dio.c @@ -52,9 +52,6 @@ /********************/ /* Internal I/O routines */ -static herr_t H5D__read(H5D_t *dataset, hid_t mem_type_id, - const H5S_t *mem_space, const H5S_t *file_space, hid_t dset_xfer_plist, - void *buf/*out*/); static herr_t H5D__write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, const H5S_t *file_space, hid_t dset_xfer_plist, const void *buf); @@ -384,7 +381,7 @@ done: * *------------------------------------------------------------------------- */ -static herr_t +herr_t H5D__read(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, const H5S_t *file_space, hid_t dxpl_id, void *buf/*out*/) { @@ -416,7 +413,7 @@ H5D__read(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, H5D_dxpl_cache_t *dxpl_cache = &_dxpl_cache; /* Data transfer property cache */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_STATIC_TAG(dxpl_id, dataset->oloc.addr, FAIL) + FUNC_ENTER_PACKAGE_TAG(dxpl_id, dataset->oloc.addr, FAIL) /* check args */ HDassert(dataset && dataset->oloc.file); diff --git a/src/H5Dmpio.c b/src/H5Dmpio.c index dacce43..7b4520f 100644 --- a/src/H5Dmpio.c +++ b/src/H5Dmpio.c @@ -648,42 +648,49 @@ H5D__chunk_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *type_inf } /* end else */ #ifdef H5_HAVE_INSTRUMENTED_LIBRARY +{ + H5P_genplist_t *plist; /* Property list pointer */ htri_t check_prop; int new_value; + /* Get the dataset transfer property list */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(io_info->dxpl_id))) + HGOTO_ERROR(H5E_IO, H5E_BADTYPE, FAIL, "not a dataset transfer property list") + /*** Test collective chunk user-input optimization APIs. ***/ - check_prop = H5Pexist(io_info->dxpl_id, H5D_XFER_COLL_CHUNK_LINK_HARD_NAME); + check_prop = H5P_exist_plist(plist, H5D_XFER_COLL_CHUNK_LINK_HARD_NAME); if(check_prop > 0) { if(H5D_ONE_LINK_CHUNK_IO == io_option) { new_value = 0; - if(H5Pset(io_info->dxpl_id, H5D_XFER_COLL_CHUNK_LINK_HARD_NAME, &new_value) < 0) + if(H5P_set(plist, H5D_XFER_COLL_CHUNK_LINK_HARD_NAME, &new_value) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTSET, FAIL, "unable to set property value") } /* end if */ } /* end if */ - check_prop = H5Pexist(io_info->dxpl_id, H5D_XFER_COLL_CHUNK_MULTI_HARD_NAME); + check_prop = H5P_exist_plist(plist, H5D_XFER_COLL_CHUNK_MULTI_HARD_NAME); if(check_prop > 0) { if(H5D_MULTI_CHUNK_IO == io_option) { new_value = 0; - if(H5Pset(io_info->dxpl_id, H5D_XFER_COLL_CHUNK_MULTI_HARD_NAME, &new_value) < 0) + if(H5P_set(plist, H5D_XFER_COLL_CHUNK_MULTI_HARD_NAME, &new_value) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTSET, FAIL, "unable to set property value") } /* end if */ } /* end if */ - check_prop = H5Pexist(io_info->dxpl_id, H5D_XFER_COLL_CHUNK_LINK_NUM_TRUE_NAME); + check_prop = H5P_exist_plist(plist, H5D_XFER_COLL_CHUNK_LINK_NUM_TRUE_NAME); if(check_prop > 0) { if(H5D_ONE_LINK_CHUNK_IO_MORE_OPT == io_option) { new_value = 0; - if(H5Pset(io_info->dxpl_id, H5D_XFER_COLL_CHUNK_LINK_NUM_TRUE_NAME, &new_value) < 0) + if(H5P_set(plist, H5D_XFER_COLL_CHUNK_LINK_NUM_TRUE_NAME, &new_value) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTSET, FAIL, "unable to set property value") } /* end if */ } /* end if */ - check_prop = H5Pexist(io_info->dxpl_id, H5D_XFER_COLL_CHUNK_LINK_NUM_FALSE_NAME); + check_prop = H5P_exist_plist(plist, H5D_XFER_COLL_CHUNK_LINK_NUM_FALSE_NAME); if(check_prop > 0) { if(temp_not_link_io) { new_value = 0; - if(H5Pset(io_info->dxpl_id, H5D_XFER_COLL_CHUNK_LINK_NUM_FALSE_NAME, &new_value) < 0) + if(H5P_set(plist, H5D_XFER_COLL_CHUNK_LINK_NUM_FALSE_NAME, &new_value) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTSET, FAIL, "unable to set property value") } /* end if */ } /* end if */ +} #endif /* step 2: Go ahead to do IO.*/ @@ -1711,19 +1718,26 @@ H5D__obtain_mpio_mode(H5D_io_info_t* io_info, H5D_chunk_map_t *fm, HDmemcpy(chunk_addr, tempbuf, sizeof(haddr_t) * total_chunks); #ifdef H5_HAVE_INSTRUMENTED_LIBRARY - check_prop = H5Pexist(io_info->dxpl_id, H5D_XFER_COLL_CHUNK_MULTI_RATIO_COLL_NAME); +{ + H5P_genplist_t *plist; /* Property list pointer */ + + /* Get the dataset transfer property list */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(io_info->dxpl_id))) + HGOTO_ERROR(H5E_IO, H5E_BADTYPE, FAIL, "not a dataset transfer property list") + + check_prop = H5P_exist_plist(plist, H5D_XFER_COLL_CHUNK_MULTI_RATIO_COLL_NAME); if(check_prop > 0) { for(ic = 0; ic < total_chunks; ic++) { if(assign_io_mode[ic] == H5D_CHUNK_IO_MODE_COL) { new_value = 0; - if(H5Pset(io_info->dxpl_id,H5D_XFER_COLL_CHUNK_MULTI_RATIO_COLL_NAME,&new_value) < 0) + if(H5P_set(plist, H5D_XFER_COLL_CHUNK_MULTI_RATIO_COLL_NAME, &new_value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_UNSUPPORTED, FAIL, "unable to set property value") break; } /* end if */ } /* end for */ } /* end if */ - check_prop = H5Pexist(io_info->dxpl_id, H5D_XFER_COLL_CHUNK_MULTI_RATIO_IND_NAME); + check_prop = H5P_exist_plist(plist, H5D_XFER_COLL_CHUNK_MULTI_RATIO_IND_NAME); if(check_prop > 0) { int temp_count = 0; @@ -1735,10 +1749,11 @@ H5D__obtain_mpio_mode(H5D_io_info_t* io_info, H5D_chunk_map_t *fm, } /* end for */ if(temp_count == 0) { new_value = 0; - if(H5Pset(io_info->dxpl_id, H5D_XFER_COLL_CHUNK_MULTI_RATIO_IND_NAME, &new_value) < 0) + if(H5P_set(plist, H5D_XFER_COLL_CHUNK_MULTI_RATIO_IND_NAME, &new_value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_UNSUPPORTED, FAIL, "unable to set property value") } /* end if */ } /* end if */ +} #endif done: diff --git a/src/H5Dpkg.h b/src/H5Dpkg.h index 4fddceb..46d545d 100644 --- a/src/H5Dpkg.h +++ b/src/H5Dpkg.h @@ -512,9 +512,9 @@ typedef struct H5D_fill_buf_info_t { /* Internal data structure for computing variable-length dataset's total size */ typedef struct { - hid_t dataset_id; /* ID of the dataset we are working on */ - hid_t fspace_id; /* ID of the file dataset's dataspace we are working on */ - hid_t mspace_id; /* ID of the memory dataset's dataspace we are working on */ + H5D_t *dset; /* Dataset for operation */ + H5S_t *fspace; /* Dataset's dataspace for operation */ + H5S_t *mspace; /* Memory dataspace for operation */ void *fl_tbuf; /* Ptr to the temporary buffer we are using for fixed-length data */ void *vl_tbuf; /* Ptr to the temporary buffer we are using for VL data */ hid_t xfer_pid; /* ID of the dataset xfer property list */ @@ -608,6 +608,11 @@ H5_DLL herr_t H5D__flush_sieve_buf(H5D_t *dataset, hid_t dxpl_id); H5_DLL herr_t H5D__flush_real(H5D_t *dataset, hid_t dxpl_id); H5_DLL herr_t H5D__mark(H5D_t *dataset, hid_t dxpl_id, unsigned flags); +/* Internal I/O routines */ +H5_DLL herr_t H5D__read(H5D_t *dataset, hid_t mem_type_id, + const H5S_t *mem_space, const H5S_t *file_space, hid_t dset_xfer_plist, + void *buf/*out*/); + /* Functions that perform direct serial I/O operations */ H5_DLL herr_t H5D__select_read(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info, diff --git a/src/H5F.c b/src/H5F.c index d4371c5..e442803 100644 --- a/src/H5F.c +++ b/src/H5F.c @@ -2392,8 +2392,10 @@ H5F_build_actual_name(const H5F_t *f, const H5P_genplist_t *fapl, const char *na } /* end else */ done: - if(new_fapl_id > 0 && H5Pclose(new_fapl_id) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, FAIL, "can't close duplicated FAPL") + /* Close the property list */ + if(new_fapl_id > 0) + if(H5I_dec_app_ref(new_fapl_id) < 0) + HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, FAIL, "can't close duplicated FAPL") FUNC_LEAVE_NOAPI(ret_value) } /* H5F_build_actual_name() */ @@ -2620,16 +2622,15 @@ done: * david.pitt@bigpond.com * Apr 27, 2004 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t H5Fget_filesize(hid_t file_id, hsize_t *size) { - H5F_t *file; /* File object for file ID */ - haddr_t eof; /* End of file address */ - herr_t ret_value = SUCCEED; /* Return value */ + H5F_t *file; /* File object for file ID */ + haddr_t eof; /* End of file address */ + haddr_t base_addr; /* Base address for the file */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*h", file_id, size); @@ -2639,10 +2640,12 @@ H5Fget_filesize(hid_t file_id, hsize_t *size) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") /* Go get the actual file size */ - if(HADDR_UNDEF == (eof = H5FDget_eof(file->shared->lf))) + if(HADDR_UNDEF == (eof = H5FD_get_eof(file->shared->lf))) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get file size") + base_addr = H5FD_get_base_addr(file->shared->lf); - *size = (hsize_t)eof; + if(size) + *size = (hsize_t)(eof + base_addr); /* Convert relative base address for file to absolute address */ done: FUNC_LEAVE_API(ret_value) diff --git a/src/H5FD.c b/src/H5FD.c index b359d78..b38b904 100644 --- a/src/H5FD.c +++ b/src/H5FD.c @@ -490,7 +490,7 @@ H5FD_sb_size(H5FD_t *file) FUNC_ENTER_NOAPI(0) - assert(file && file->cls); + HDassert(file && file->cls); if(file->cls->sb_size) ret_value = (file->cls->sb_size)(file); @@ -528,7 +528,7 @@ H5FD_sb_encode(H5FD_t *file, char *name/*out*/, uint8_t *buf) FUNC_ENTER_NOAPI(FAIL) - assert(file && file->cls); + HDassert(file && file->cls); if(file->cls->sb_encode && (file->cls->sb_encode)(file, name/*out*/, buf/*out*/) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "driver sb_encode request failed") @@ -690,7 +690,7 @@ H5FD_fapl_get(H5FD_t *file) FUNC_ENTER_NOAPI(NULL) - assert(file); + HDassert(file); if(file->cls->fapl_get) ret_value = (file->cls->fapl_get)(file); @@ -1197,8 +1197,8 @@ H5FDquery(const H5FD_t *f, unsigned long *flags/*out*/) FUNC_ENTER_API(FAIL) H5TRACE2("Is", "*xx", f, flags); - assert(f); - assert(flags); + HDassert(f); + HDassert(flags); ret_value = H5FD_query(f, flags); diff --git a/src/H5FDcore.c b/src/H5FDcore.c index b51ea8c..559af82 100644 --- a/src/H5FDcore.c +++ b/src/H5FDcore.c @@ -214,7 +214,7 @@ H5FD_core_init(void) FUNC_ENTER_NOAPI(FAIL) - if(H5I_VFL != H5Iget_type(H5FD_CORE_g)) + if(H5I_VFL != H5I_get_type(H5FD_CORE_g)) H5FD_CORE_g = H5FD_register(&H5FD_core_g,sizeof(H5FD_class_t),FALSE); /* Set return value */ diff --git a/src/H5FDdirect.c b/src/H5FDdirect.c index 7dbabf5..3aa1c4f 100644 --- a/src/H5FDdirect.c +++ b/src/H5FDdirect.c @@ -107,36 +107,8 @@ typedef struct H5FD_direct_t { } H5FD_direct_t; /* - * This driver supports systems that have the lseek64() function by defining - * some macros here so we don't have to have conditional compilations later - * throughout the code. - * - * file_offset_t: The datatype for file offsets, the second argument of - * the lseek() or lseek64() call. - * - * file_seek: The function which adjusts the current file position, - * either lseek() or lseek64(). - */ -/* adding for windows NT file system support. */ - -#ifdef H5_HAVE_LSEEK64 -# define file_offset_t off64_t -# define file_seek lseek64 -# define file_truncate ftruncate64 -#elif defined (H5_HAVE_WIN32_API) -# /*MSVC*/ -# define file_offset_t __int64 -# define file_seek _lseeki64 -# define file_truncate _chsize -#else -# define file_offset_t off_t -# define file_seek lseek -# define file_truncate HDftruncate -#endif - -/* * These macros check for overflow of various quantities. These macros - * assume that file_offset_t is signed and haddr_t and size_t are unsigned. + * assume that HDoff_t is signed and haddr_t and size_t are unsigned. * * ADDR_OVERFLOW: Checks whether a file address of type `haddr_t' * is too large to be represented by the second argument @@ -149,13 +121,13 @@ typedef struct H5FD_direct_t { * which can be addressed entirely by the second * argument of the file seek function. */ -#define MAXADDR (((haddr_t)1<<(8*sizeof(file_offset_t)-1))-1) +#define MAXADDR (((haddr_t)1<<(8*sizeof(HDoff_t)-1))-1) #define ADDR_OVERFLOW(A) (HADDR_UNDEF==(A) || \ ((A) & ~(haddr_t)MAXADDR)) #define SIZE_OVERFLOW(Z) ((Z) & ~(hsize_t)MAXADDR) #define REGION_OVERFLOW(A,Z) (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || \ HADDR_UNDEF==(A)+(Z) || \ - (file_offset_t)((A)+(Z))<(file_offset_t)(A)) + (HDoff_t)((A)+(Z))<(HDoff_t)(A)) /* Prototypes */ static herr_t H5FD_direct_term(void); @@ -457,7 +429,7 @@ H5FD_direct_fapl_copy(const void *_old_fa) FUNC_ENTER_NOAPI_NOINIT_NOERR - assert(new_fa); + HDassert(new_fa); /* Copy the general information */ HDmemcpy(new_fa, old_fa, sizeof(H5FD_direct_fapl_t)); @@ -503,7 +475,7 @@ H5FD_direct_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxadd FUNC_ENTER_NOAPI_NOINIT /* Sanity check on file offsets */ - assert(sizeof(file_offset_t)>=sizeof(size_t)); + HDassert(sizeof(HDoff_t)>=sizeof(size_t)); /* Check arguments */ if (!name || !*name) @@ -571,26 +543,26 @@ H5FD_direct_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxadd HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, NULL, "HDposix_memalign failed") if(o_flags & O_CREAT) { - if(write(file->fd, (void*)buf1, sizeof(int))<0) { - if(write(file->fd, (void*)buf2, file->fa.fbsize)<0) + if(HDwrite(file->fd, (void*)buf1, sizeof(int))<0) { + if(HDwrite(file->fd, (void*)buf2, file->fa.fbsize)<0) HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, NULL, "file system may not support Direct I/O") else file->fa.must_align = TRUE; } else { file->fa.must_align = FALSE; - file_truncate(file->fd, (file_offset_t)0); + HDftruncate(file->fd, (HDoff_t)0); } } else { - if(read(file->fd, (void*)buf1, sizeof(int))<0) { - if(read(file->fd, (void*)buf2, file->fa.fbsize)<0) + if(HDread(file->fd, (void*)buf1, sizeof(int))<0) { + if(HDread(file->fd, (void*)buf2, file->fa.fbsize)<0) HGOTO_ERROR(H5E_FILE, H5E_READERROR, NULL, "file system may not support Direct I/O") else file->fa.must_align = TRUE; } else { if(o_flags & O_RDWR) { - if(file_seek(file->fd, (file_offset_t)0, SEEK_SET) < 0) + if(HDlseek(file->fd, (HDoff_t)0, SEEK_SET) < 0) HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, NULL, "unable to seek to proper position") - if(write(file->fd, (void *)buf1, sizeof(int))<0) + if(HDwrite(file->fd, (void *)buf1, sizeof(int))<0) file->fa.must_align = TRUE; else file->fa.must_align = FALSE; @@ -918,8 +890,8 @@ H5FD_direct_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, ha FUNC_ENTER_NOAPI_NOINIT - assert(file && file->pub.cls); - assert(buf); + HDassert(file && file->pub.cls); + HDassert(buf); /* Check for overflow conditions */ if (HADDR_UNDEF==addr) @@ -954,7 +926,7 @@ H5FD_direct_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, ha if(!_must_align || ((addr%_fbsize==0) && (size%_fbsize==0) && ((size_t)buf%_boundary==0))) { /* Seek to the correct location */ if ((addr!=file->pos || OP_READ!=file->op) && - file_seek(file->fd, (file_offset_t)addr, SEEK_SET)<0) + HDlseek(file->fd, (HDoff_t)addr, SEEK_SET)<0) HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") /* Read the aligned data in file first, being careful of interrupted * system calls and partial results. */ @@ -969,8 +941,8 @@ H5FD_direct_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, ha HDmemset(buf, 0, size); break; } - assert(nbytes>=0); - assert((size_t)nbytes<=size); + HDassert(nbytes>=0); + HDassert((size_t)nbytes<=size); H5_CHECK_OVERFLOW(nbytes,ssize_t,size_t); size -= (size_t)nbytes; H5_CHECK_OVERFLOW(nbytes,ssize_t,haddr_t); @@ -993,7 +965,7 @@ H5FD_direct_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, ha /* look for the aligned position for reading the data */ HDassert(!(((addr / _fbsize) * _fbsize) % _fbsize)); - if(file_seek(file->fd, (file_offset_t)((addr / _fbsize) * _fbsize), + if(HDlseek(file->fd, (HDoff_t)((addr / _fbsize) * _fbsize), SEEK_SET) < 0) HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") @@ -1112,8 +1084,8 @@ H5FD_direct_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, h FUNC_ENTER_NOAPI_NOINIT - assert(file && file->pub.cls); - assert(buf); + HDassert(file && file->pub.cls); + HDassert(buf); /* Check for overflow conditions */ if (HADDR_UNDEF==addr) @@ -1142,7 +1114,7 @@ H5FD_direct_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, h if(!_must_align || ((addr%_fbsize==0) && (size%_fbsize==0) && ((size_t)buf%_boundary==0))) { /* Seek to the correct location */ if ((addr!=file->pos || OP_WRITE!=file->op) && - file_seek(file->fd, (file_offset_t)addr, SEEK_SET)<0) + HDlseek(file->fd, (HDoff_t)addr, SEEK_SET)<0) HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") while (size>0) { @@ -1151,8 +1123,8 @@ H5FD_direct_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, h } while (-1==nbytes && EINTR==errno); if (-1==nbytes) /* error */ HSYS_GOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed") - assert(nbytes>0); - assert((size_t)nbytes<=size); + HDassert(nbytes>0); + HDassert((size_t)nbytes<=size); H5_CHECK_OVERFLOW(nbytes,ssize_t,size_t); size -= (size_t)nbytes; H5_CHECK_OVERFLOW(nbytes,ssize_t,haddr_t); @@ -1178,7 +1150,7 @@ H5FD_direct_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, h HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "HDposix_memalign failed") /* look for the right position for reading or writing the data */ - if(file_seek(file->fd, (file_offset_t)write_addr, SEEK_SET) < 0) + if(HDlseek(file->fd, (HDoff_t)write_addr, SEEK_SET) < 0) HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") p3 = buf; @@ -1220,8 +1192,8 @@ H5FD_direct_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, h /* Seek to the last block, for reading */ HDassert(!((write_addr + write_size - _fbsize) % _fbsize)); - if(file_seek(file->fd, - (file_offset_t)(write_addr + write_size - _fbsize), + if(HDlseek(file->fd, + (HDoff_t)(write_addr + write_size - _fbsize), SEEK_SET) < 0) HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") } /* end if */ @@ -1231,7 +1203,7 @@ H5FD_direct_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, h if(p1) { HDassert(!(read_size % _fbsize)); do { - nbytes = read(file->fd, p1, read_size); + nbytes = HDread(file->fd, p1, read_size); } while (-1==nbytes && EINTR==errno); if (-1==nbytes) /* error */ @@ -1258,7 +1230,7 @@ H5FD_direct_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, h /*look for the aligned position for writing the data*/ HDassert(!(write_addr % _fbsize)); - if(file_seek(file->fd, (file_offset_t)write_addr, SEEK_SET) < 0) + if(HDlseek(file->fd, (HDoff_t)write_addr, SEEK_SET) < 0) HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") /* @@ -1330,7 +1302,7 @@ H5FD_direct_truncate(H5FD_t *_file, hid_t UNUSED dxpl_id, hbool_t UNUSED closing FUNC_ENTER_NOAPI_NOINIT - assert(file); + HDassert(file); /* Extend the file to make sure it's large enough */ if (file->eoa!=file->eof) { @@ -1348,7 +1320,7 @@ H5FD_direct_truncate(H5FD_t *_file, hid_t UNUSED dxpl_id, hbool_t UNUSED closing if(SetEndOfFile((HANDLE)filehandle)==0) HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to extend file properly") #else /* H5_HAVE_WIN32_API */ - if (-1==file_truncate(file->fd, (file_offset_t)file->eoa)) + if (-1==HDftruncate(file->fd, (HDoff_t)file->eoa)) HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to extend file properly") #endif /* H5_HAVE_WIN32_API */ @@ -1363,7 +1335,7 @@ H5FD_direct_truncate(H5FD_t *_file, hid_t UNUSED dxpl_id, hbool_t UNUSED closing /*Even though eof is equal to eoa, file is still truncated because Direct I/O *write introduces some extra data for alignment. */ - if (-1==file_truncate(file->fd, (file_offset_t)file->eof)) + if (-1==HDftruncate(file->fd, (HDoff_t)file->eof)) HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to extend file properly") } diff --git a/src/H5FDfamily.c b/src/H5FDfamily.c index dc535a2..75c75ad 100644 --- a/src/H5FDfamily.c +++ b/src/H5FDfamily.c @@ -187,19 +187,19 @@ H5FD_family_init_interface(void) hid_t H5FD_family_init(void) { - hid_t ret_value=H5FD_FAMILY_g; /* Return value */ + hid_t ret_value = H5FD_FAMILY_g; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - if (H5I_VFL!=H5Iget_type(H5FD_FAMILY_g)) - H5FD_FAMILY_g = H5FD_register(&H5FD_family_g,sizeof(H5FD_class_t),FALSE); + if(H5I_VFL != H5I_get_type(H5FD_FAMILY_g)) + H5FD_FAMILY_g = H5FD_register(&H5FD_family_g, sizeof(H5FD_class_t), FALSE); /* Set return value */ - ret_value=H5FD_FAMILY_g; + ret_value = H5FD_FAMILY_g; done: FUNC_LEAVE_NOAPI(ret_value) -} +} /* H5FD_family_init() */ /*--------------------------------------------------------------------------- @@ -416,7 +416,7 @@ H5FD_family_fapl_copy(const void *_old_fa) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Copy the fields of the structure */ - memcpy(new_fa, old_fa, sizeof(H5FD_family_fapl_t)); + HDmemcpy(new_fa, old_fa, sizeof(H5FD_family_fapl_t)); /* Deep copy the property list objects in the structure */ if(old_fa->memb_fapl_id==H5P_FILE_ACCESS_DEFAULT) { @@ -1176,7 +1176,7 @@ H5FD_family_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, si tempreq = SIZET_MAX; req = MIN(size, (size_t)tempreq); - assert(unmembs); + HDassert(unmembs); if (H5FDread(file->memb[u], type, dxpl_id, sub, req, buf)<0) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "member file read failed") @@ -1245,7 +1245,7 @@ H5FD_family_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, s tempreq = SIZET_MAX; req = MIN(size, (size_t)tempreq); - assert(unmembs); + HDassert(unmembs); if (H5FDwrite(file->memb[u], type, dxpl_id, sub, req, buf)<0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "member file write failed") diff --git a/src/H5FDint.c b/src/H5FDint.c index 09af4ed..c9e9a67 100644 --- a/src/H5FDint.c +++ b/src/H5FDint.c @@ -298,7 +298,7 @@ H5FD_get_eof(const H5FD_t *file) /* Dispatch to driver */ if(file->cls->get_eof) { if(HADDR_UNDEF == (ret_value = (file->cls->get_eof)(file))) - HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, "driver get_eof request failed") + HGOTO_ERROR(H5E_VFL, H5E_CANTGET, HADDR_UNDEF, "driver get_eof request failed") } /* end if */ else ret_value = file->maxaddr; diff --git a/src/H5FDlog.c b/src/H5FDlog.c index ac55427..3941ca1 100644 --- a/src/H5FDlog.c +++ b/src/H5FDlog.c @@ -805,7 +805,7 @@ H5FD_log_close(H5FD_t *_file) if(file->fa.flags & H5FD_LOG_FLAVOR) file->flavor = (unsigned char *)H5MM_xfree(file->flavor); if(file->logfp != stderr) - fclose(file->logfp); + HDfclose(file->logfp); } /* end if */ /* Release the file info */ diff --git a/src/H5FDmpi.c b/src/H5FDmpi.c index 295e3c9f..86a5d39 100644 --- a/src/H5FDmpi.c +++ b/src/H5FDmpi.c @@ -57,10 +57,10 @@ H5FD_mpi_get_rank(const H5FD_t *file) FUNC_ENTER_NOAPI(FAIL) - assert(file); + HDassert(file); cls = (const H5FD_class_mpi_t *)(file->cls); - assert(cls); - assert(cls->get_rank); /* All MPI drivers must implement this */ + HDassert(cls); + HDassert(cls->get_rank); /* All MPI drivers must implement this */ /* Dispatch to driver */ if ((ret_value=(cls->get_rank)(file))<0) @@ -95,10 +95,10 @@ H5FD_mpi_get_size(const H5FD_t *file) FUNC_ENTER_NOAPI(FAIL) - assert(file); + HDassert(file); cls = (const H5FD_class_mpi_t *)(file->cls); - assert(cls); - assert(cls->get_size); /* All MPI drivers must implement this */ + HDassert(cls); + HDassert(cls->get_size); /* All MPI drivers must implement this */ /* Dispatch to driver */ if ((ret_value=(cls->get_size)(file))<0) @@ -133,10 +133,10 @@ H5FD_mpi_get_comm(const H5FD_t *file) FUNC_ENTER_NOAPI(MPI_COMM_NULL) - assert(file); + HDassert(file); cls = (const H5FD_class_mpi_t *)(file->cls); - assert(cls); - assert(cls->get_comm); /* All MPI drivers must implement this */ + HDassert(cls); + HDassert(cls->get_comm); /* All MPI drivers must implement this */ /* Dispatch to driver */ if ((ret_value=(cls->get_comm)(file))==MPI_COMM_NULL) @@ -217,7 +217,7 @@ H5FD_mpi_haddr_to_MPIOff(haddr_t addr, MPI_Offset *mpi_off/*out*/) FUNC_ENTER_NOAPI_NOINIT_NOERR - assert(mpi_off); + HDassert(mpi_off); /* Convert the HDF5 address into an MPI offset */ *mpi_off = (MPI_Offset)addr; @@ -373,8 +373,8 @@ H5FD_mpio_wait_for_left_neighbor(H5FD_t *_file) FUNC_ENTER_NOAPI(FAIL) - assert(file); - assert(H5FD_MPIO==file->pub.driver_id); + HDassert(file); + HDassert(H5FD_MPIO==file->pub.driver_id); /* Portably initialize MPI status variable */ HDmemset(&rcvstat,0,sizeof(MPI_Status)); @@ -427,14 +427,12 @@ H5FD_mpio_signal_right_neighbor(H5FD_t *_file) FUNC_ENTER_NOAPI(FAIL) - assert(file); - assert(H5FD_MPIO==file->pub.driver_id); + HDassert(file); + HDassert(H5FD_MPIO==file->pub.driver_id); - if (file->mpi_rank != (file->mpi_size-1)) { - if (MPI_SUCCESS != (mpi_code=MPI_Send(&msgbuf, 0/*empty msg*/, MPI_CHAR, - file->mpi_rank+1, 0, file->comm))) + if(file->mpi_rank != (file->mpi_size - 1)) + if(MPI_SUCCESS != (mpi_code=MPI_Send(&msgbuf, 0/*empty msg*/, MPI_CHAR, file->mpi_rank + 1, 0, file->comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Send failed", mpi_code) - } done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5FDmpio.c b/src/H5FDmpio.c index 878bf82..f23a3b5 100644 --- a/src/H5FDmpio.c +++ b/src/H5FDmpio.c @@ -825,10 +825,10 @@ H5FD_mpio_fapl_free(void *_fa) if (H5FD_mpio_Debug[(int)'t']) fprintf(stderr, "in H5FD_mpio_fapl_free\n"); #endif - assert(fa); + HDassert(fa); /* Free the internal communicator and INFO object */ - assert(MPI_COMM_NULL!=fa->comm); + HDassert(MPI_COMM_NULL!=fa->comm); H5FD_mpi_comm_info_free(&fa->comm, &fa->info); H5MM_xfree(fa); @@ -1167,8 +1167,8 @@ H5FD_mpio_close(H5FD_t *_file) if (H5FD_mpio_Debug[(int)'t']) fprintf(stdout, "Entering H5FD_mpio_close\n"); #endif - assert(file); - assert(H5FD_MPIO==file->pub.driver_id); + HDassert(file); + HDassert(H5FD_MPIO==file->pub.driver_id); /* MPI_File_close sets argument to MPI_FILE_NULL */ if (MPI_SUCCESS != (mpi_code=MPI_File_close(&(file->f)/*in,out*/))) @@ -1257,8 +1257,8 @@ H5FD_mpio_get_eoa(const H5FD_t *_file, H5FD_mem_t UNUSED type) FUNC_ENTER_NOAPI_NOINIT_NOERR - assert(file); - assert(H5FD_MPIO==file->pub.driver_id); + HDassert(file); + HDassert(H5FD_MPIO==file->pub.driver_id); FUNC_LEAVE_NOAPI(file->eoa) } @@ -1292,8 +1292,8 @@ H5FD_mpio_set_eoa(H5FD_t *_file, H5FD_mem_t UNUSED type, haddr_t addr) FUNC_ENTER_NOAPI_NOINIT_NOERR - assert(file); - assert(H5FD_MPIO==file->pub.driver_id); + HDassert(file); + HDassert(H5FD_MPIO==file->pub.driver_id); file->eoa = addr; @@ -1337,8 +1337,8 @@ H5FD_mpio_get_eof(const H5FD_t *_file) FUNC_ENTER_NOAPI_NOINIT_NOERR - assert(file); - assert(H5FD_MPIO==file->pub.driver_id); + HDassert(file); + HDassert(H5FD_MPIO==file->pub.driver_id); FUNC_LEAVE_NOAPI(file->eof) } @@ -1468,12 +1468,12 @@ H5FD_mpio_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t dxpl_id, haddr_t add if (H5FD_mpio_Debug[(int)'t']) fprintf(stdout, "Entering H5FD_mpio_read\n" ); #endif - assert(file); - assert(H5FD_MPIO==file->pub.driver_id); + HDassert(file); + HDassert(H5FD_MPIO==file->pub.driver_id); /* Make certain we have the correct type of property list */ - assert(H5I_GENPROP_LST==H5I_get_type(dxpl_id)); - assert(TRUE==H5P_isa_class(dxpl_id,H5P_DATASET_XFER)); - assert(buf); + HDassert(H5I_GENPROP_LST==H5I_get_type(dxpl_id)); + HDassert(TRUE==H5P_isa_class(dxpl_id,H5P_DATASET_XFER)); + HDassert(buf); /* Portably initialize MPI status variable */ HDmemset(&mpi_stat,0,sizeof(MPI_Status)); @@ -1752,12 +1752,12 @@ H5FD_mpio_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, if (H5FD_mpio_Debug[(int)'t']) fprintf(stdout, "Entering H5FD_mpio_write\n" ); #endif - assert(file); - assert(H5FD_MPIO==file->pub.driver_id); + HDassert(file); + HDassert(H5FD_MPIO==file->pub.driver_id); /* Make certain we have the correct type of property list */ - assert(H5I_GENPROP_LST==H5I_get_type(dxpl_id)); - assert(TRUE==H5P_isa_class(dxpl_id,H5P_DATASET_XFER)); - assert(buf); + HDassert(H5I_GENPROP_LST==H5I_get_type(dxpl_id)); + HDassert(TRUE==H5P_isa_class(dxpl_id,H5P_DATASET_XFER)); + HDassert(buf); /* Portably initialize MPI status variable */ HDmemset(&mpi_stat, 0, sizeof(MPI_Status)); @@ -2058,8 +2058,8 @@ H5FD_mpio_mpi_rank(const H5FD_t *_file) FUNC_ENTER_NOAPI_NOINIT_NOERR - assert(file); - assert(H5FD_MPIO==file->pub.driver_id); + HDassert(file); + HDassert(H5FD_MPIO==file->pub.driver_id); FUNC_LEAVE_NOAPI(file->mpi_rank) } /* end H5FD_mpio_mpi_rank() */ @@ -2087,8 +2087,8 @@ H5FD_mpio_mpi_size(const H5FD_t *_file) FUNC_ENTER_NOAPI_NOINIT_NOERR - assert(file); - assert(H5FD_MPIO==file->pub.driver_id); + HDassert(file); + HDassert(H5FD_MPIO==file->pub.driver_id); FUNC_LEAVE_NOAPI(file->mpi_size) } /* end H5FD_mpio_mpi_size() */ @@ -2117,8 +2117,8 @@ H5FD_mpio_communicator(const H5FD_t *_file) FUNC_ENTER_NOAPI_NOINIT_NOERR - assert(file); - assert(H5FD_MPIO==file->pub.driver_id); + HDassert(file); + HDassert(H5FD_MPIO==file->pub.driver_id); FUNC_LEAVE_NOAPI(file->comm) } diff --git a/src/H5FDmpiposix.c b/src/H5FDmpiposix.c index b1d68f6..af4c847 100644 --- a/src/H5FDmpiposix.c +++ b/src/H5FDmpiposix.c @@ -266,8 +266,8 @@ H5FD_mpiposix_init(void) FUNC_ENTER_NOAPI(FAIL) - if (H5I_VFL != H5Iget_type(H5FD_MPIPOSIX_g)) - H5FD_MPIPOSIX_g = H5FD_register((const H5FD_class_t *)&H5FD_mpiposix_g,sizeof(H5FD_class_mpi_t),FALSE); + if(H5I_VFL != H5I_get_type(H5FD_MPIPOSIX_g)) + H5FD_MPIPOSIX_g = H5FD_register((const H5FD_class_t *)&H5FD_mpiposix_g, sizeof(H5FD_class_mpi_t), FALSE); /* Set return value */ ret_value = H5FD_MPIPOSIX_g; diff --git a/src/H5FO.c b/src/H5FO.c index ace66ec..a6c47cb 100644 --- a/src/H5FO.c +++ b/src/H5FO.c @@ -78,8 +78,8 @@ H5FO_create(const H5F_t *f) FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ - assert(f); - assert(f->shared); + HDassert(f); + HDassert(f->shared); /* Create container used to store open object info */ if((f->shared->open_objs = H5SL_create(H5SL_TYPE_HADDR, NULL)) == NULL) @@ -166,11 +166,11 @@ H5FO_insert(const H5F_t *f, haddr_t addr, void *obj, hbool_t delete_flag) FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ - assert(f); - assert(f->shared); - assert(f->shared->open_objs); - assert(H5F_addr_defined(addr)); - assert(obj); + HDassert(f); + HDassert(f->shared); + HDassert(f->shared->open_objs); + HDassert(H5F_addr_defined(addr)); + HDassert(obj); /* Allocate new opened object information structure */ if((open_obj=H5FL_MALLOC(H5FO_open_obj_t))==NULL) @@ -269,10 +269,10 @@ H5FO_mark(const H5F_t *f, haddr_t addr, hbool_t deleted) FUNC_ENTER_NOAPI_NOERR /* Sanity check */ - assert(f); - assert(f->shared); - assert(f->shared->open_objs); - assert(H5F_addr_defined(addr)); + HDassert(f); + HDassert(f->shared); + HDassert(f->shared->open_objs); + HDassert(H5F_addr_defined(addr)); /* Get the object node from the container */ if(NULL != (open_obj = (H5FO_open_obj_t *)H5SL_search(f->shared->open_objs, &addr))) @@ -352,9 +352,9 @@ H5FO_dest(const H5F_t *f) FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ - assert(f); - assert(f->shared); - assert(f->shared->open_objs); + HDassert(f); + HDassert(f->shared); + HDassert(f->shared->open_objs); /* Check if the object info set is empty */ if(H5SL_count(f->shared->open_objs)!=0) diff --git a/src/H5Fmpi.c b/src/H5Fmpi.c index 07d29f2..4d3ca34 100644 --- a/src/H5Fmpi.c +++ b/src/H5Fmpi.c @@ -101,7 +101,7 @@ H5F_mpi_get_rank(const H5F_t *f) FUNC_ENTER_NOAPI(FAIL) - assert(f && f->shared); + HDassert(f && f->shared); /* Dispatch to driver */ if ((ret_value=H5FD_mpi_get_rank(f->shared->lf)) < 0) @@ -135,7 +135,7 @@ H5F_mpi_get_comm(const H5F_t *f) FUNC_ENTER_NOAPI(MPI_COMM_NULL) - assert(f && f->shared); + HDassert(f && f->shared); /* Dispatch to driver */ if ((ret_value=H5FD_mpi_get_comm(f->shared->lf))==MPI_COMM_NULL) @@ -169,7 +169,7 @@ H5F_mpi_get_size(const H5F_t *f) FUNC_ENTER_NOAPI(FAIL) - assert(f && f->shared); + HDassert(f && f->shared); /* Dispatch to driver */ if ((ret_value=H5FD_mpi_get_size(f->shared->lf)) < 0) diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h index e6553ff..59e50e3 100644 --- a/src/H5Fpkg.h +++ b/src/H5Fpkg.h @@ -303,7 +303,6 @@ H5_DLL herr_t H5F_flush(H5F_t *f, hid_t dxpl_id, hbool_t closing); H5_DLL herr_t H5F_close_mounts(H5F_t *f); H5_DLL int H5F_term_unmount_cb(void *obj_ptr, hid_t obj_id, void *key); H5_DLL herr_t H5F_mount_count_ids(H5F_t *f, unsigned *nopen_files, unsigned *nopen_objs); -H5_DLL herr_t H5F_flush_mounts(H5F_t *f, hid_t dxpl_id); /* Superblock related routines */ H5_DLL herr_t H5F_super_init(H5F_t *f, hid_t dxpl_id); diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index 9dbbba4..ee478c2 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -617,6 +617,7 @@ H5_DLL herr_t H5F_get_vfd_handle(const H5F_t *file, hid_t fapl, H5_DLL hbool_t H5F_is_mount(const H5F_t *file); H5_DLL hbool_t H5F_has_mount(const H5F_t *file); H5_DLL herr_t H5F_traverse_mount(struct H5O_loc_t *oloc/*in,out*/); +H5_DLL herr_t H5F_flush_mounts(H5F_t *f, hid_t dxpl_id); /* Functions that operate on blocks of bytes wrt super block */ H5_DLL herr_t H5F_block_read(const H5F_t *f, H5FD_mem_t type, haddr_t addr, diff --git a/src/H5Gname.c b/src/H5Gname.c index 72da498..1d2644b 100644 --- a/src/H5Gname.c +++ b/src/H5Gname.c @@ -135,7 +135,7 @@ H5G__component(const char *name, size_t *size_p) { FUNC_ENTER_PACKAGE_NOERR - assert(name); + HDassert(name); while ('/' == *name) name++; @@ -236,13 +236,13 @@ H5G_common_path(const H5RS_str_t *fullpath_r, const H5RS_str_t *prefix_r) /* Get component of each name */ fullpath=H5RS_get_str(fullpath_r); - assert(fullpath); + HDassert(fullpath); fullpath=H5G__component(fullpath,&nchars1); - assert(fullpath); + HDassert(fullpath); prefix=H5RS_get_str(prefix_r); - assert(prefix); + HDassert(prefix); prefix=H5G__component(prefix,&nchars2); - assert(prefix); + HDassert(prefix); /* Check if we have a real string for each component */ while(*fullpath && *prefix) { @@ -256,9 +256,9 @@ H5G_common_path(const H5RS_str_t *fullpath_r, const H5RS_str_t *prefix_r) /* Get next component of each name */ fullpath=H5G__component(fullpath,&nchars1); - assert(fullpath); + HDassert(fullpath); prefix=H5G__component(prefix,&nchars2); - assert(prefix); + HDassert(prefix); } /* end if */ else HGOTO_DONE(FALSE) diff --git a/src/H5HG.c b/src/H5HG.c index 5b9c53c..4bb8670 100644 --- a/src/H5HG.c +++ b/src/H5HG.c @@ -191,7 +191,7 @@ HDmemset(heap->chunk, 0, size); /* The freespace object */ heap->obj[0].size = size - H5HG_SIZEOF_HDR(f); - assert(H5HG_ISALIGNED(heap->obj[0].size)); + HDassert(H5HG_ISALIGNED(heap->obj[0].size)); heap->obj[0].nrefs = 0; heap->obj[0].begin = p; UINT16ENCODE(p, 0); /*object ID*/ @@ -360,29 +360,28 @@ H5HG_alloc(H5F_t *f, H5HG_heap_t *heap, size_t size, unsigned *heap_flags_ptr) heap->obj[0].size = 0; heap->obj[0].begin = NULL; } /* end if */ - //else if(heap->obj[0].size - need >= H5HG_SIZEOF_OBJHDR(f)) { - else if(heap->obj[0].size >= need + H5HG_SIZEOF_OBJHDR(f)) { - /* - * Some free space remains and it's larger than a heap object header, - * so write the new free heap object header to the heap. - */ - heap->obj[0].size -= need; - heap->obj[0].begin += need; - p = heap->obj[0].begin; - UINT16ENCODE(p, 0); /*id*/ - UINT16ENCODE(p, 0); /*nrefs*/ - UINT32ENCODE(p, 0); /*reserved*/ - H5F_ENCODE_LENGTH (f, p, heap->obj[0].size); - HDassert(H5HG_ISALIGNED(heap->obj[0].size)); + else if(heap->obj[0].size-need >= H5HG_SIZEOF_OBJHDR (f)) { + /* + * Some free space remains and it's larger than a heap object header, + * so write the new free heap object header to the heap. + */ + heap->obj[0].size -= need; + heap->obj[0].begin += need; + p = heap->obj[0].begin; + UINT16ENCODE(p, 0); /*id*/ + UINT16ENCODE(p, 0); /*nrefs*/ + UINT32ENCODE(p, 0); /*reserved*/ + H5F_ENCODE_LENGTH (f, p, heap->obj[0].size); + HDassert(H5HG_ISALIGNED(heap->obj[0].size)); } /* end else-if */ else { - /* - * Some free space remains but it's smaller than a heap object header, - * so we don't write the header. - */ - heap->obj[0].size -= need; - heap->obj[0].begin += need; - HDassert(H5HG_ISALIGNED(heap->obj[0].size)); + /* + * Some free space remains but it's smaller than a heap object header, + * so we don't write the header. + */ + heap->obj[0].size -= need; + heap->obj[0].begin += need; + HDassert(H5HG_ISALIGNED(heap->obj[0].size)); } /* Mark the heap as dirty */ @@ -476,7 +475,7 @@ HDmemset(new_chunk + heap->size, 0, need); UINT16ENCODE(p, 0); /*nrefs*/ UINT32ENCODE(p, 0); /*reserved*/ H5F_ENCODE_LENGTH(f, p, heap->obj[0].size); - assert(H5HG_ISALIGNED(heap->obj[0].size)); + HDassert(H5HG_ISALIGNED(heap->obj[0].size)); /* Resize the heap in the cache */ if(H5AC_resize_entry(heap, heap->size) < 0) diff --git a/src/H5HP.c b/src/H5HP.c index 335fde2..f6fb20c 100644 --- a/src/H5HP.c +++ b/src/H5HP.c @@ -342,7 +342,7 @@ H5HP_create(H5HP_type_t heap_type) FUNC_ENTER_NOAPI(NULL) /* Check args */ - assert(heap_type==H5HP_MIN_HEAP || heap_type==H5HP_MAX_HEAP); + HDassert(heap_type==H5HP_MIN_HEAP || heap_type==H5HP_MAX_HEAP); /* Allocate ref-counted string structure */ if((new_heap=H5FL_MALLOC(H5HP_t))==NULL) @@ -416,15 +416,15 @@ H5HP_count(const H5HP_t *heap) FUNC_ENTER_NOAPI_NOINIT_NOERR /* Check args */ - assert(heap); + HDassert(heap); /* Check internal consistency */ /* (Pre-condition) */ - assert(heap->nobjsnalloc); - assert(heap->heap); - assert((heap->type==H5HP_MAX_HEAP && heap->heap[0].val==INT_MAX) || + HDassert(heap->nobjsnalloc); + HDassert(heap->heap); + HDassert((heap->type==H5HP_MAX_HEAP && heap->heap[0].val==INT_MAX) || (heap->type==H5HP_MIN_HEAP && heap->heap[0].val==INT_MIN)); - assert(heap->heap[0].obj==NULL); + HDassert(heap->heap[0].obj==NULL); /* Return the number of objects in the heap */ H5_CHECK_OVERFLOW(heap->nobjs,size_t,ssize_t); @@ -463,16 +463,16 @@ H5HP_insert(H5HP_t *heap, int val, void *obj) FUNC_ENTER_NOAPI(FAIL) /* Check args */ - assert(heap); - assert(obj); + HDassert(heap); + HDassert(obj); /* Check internal consistency */ /* (Pre-condition) */ - assert(heap->nobjsnalloc); - assert(heap->heap); - assert((heap->type==H5HP_MAX_HEAP && heap->heap[0].val==INT_MAX) || + HDassert(heap->nobjsnalloc); + HDassert(heap->heap); + HDassert((heap->type==H5HP_MAX_HEAP && heap->heap[0].val==INT_MAX) || (heap->type==H5HP_MIN_HEAP && heap->heap[0].val==INT_MIN)); - assert(heap->heap[0].obj==NULL); + HDassert(heap->heap[0].obj==NULL); /* Increment number of objects in heap */ heap->nobjs++; @@ -507,11 +507,11 @@ done: /* Check internal consistency */ /* (Post-condition) */ - assert(heap->nobjsnalloc); - assert(heap->heap); - assert((heap->type==H5HP_MAX_HEAP && heap->heap[0].val==INT_MAX) || + HDassert(heap->nobjsnalloc); + HDassert(heap->heap); + HDassert((heap->type==H5HP_MAX_HEAP && heap->heap[0].val==INT_MAX) || (heap->type==H5HP_MIN_HEAP && heap->heap[0].val==INT_MIN)); - assert(heap->heap[0].obj==NULL); + HDassert(heap->heap[0].obj==NULL); FUNC_LEAVE_NOAPI(ret_value); } /* end H5HP_insert() */ @@ -542,16 +542,16 @@ H5HP_top(const H5HP_t *heap, int *val) FUNC_ENTER_NOAPI_NOINIT_NOERR /* Check args */ - assert(heap); - assert(val); + HDassert(heap); + HDassert(val); /* Check internal consistency */ /* (Pre-condition) */ - assert(heap->nobjsnalloc); - assert(heap->heap); - assert((heap->type==H5HP_MAX_HEAP && heap->heap[0].val==INT_MAX) || + HDassert(heap->nobjsnalloc); + HDassert(heap->heap); + HDassert((heap->type==H5HP_MAX_HEAP && heap->heap[0].val==INT_MAX) || (heap->type==H5HP_MIN_HEAP && heap->heap[0].val==INT_MIN)); - assert(heap->heap[0].obj==NULL); + HDassert(heap->heap[0].obj==NULL); /* Get value of the top object in the heap */ *val=heap->heap[1].val; @@ -589,24 +589,24 @@ H5HP_remove(H5HP_t *heap, int *val, void **obj) FUNC_ENTER_NOAPI(FAIL) /* Check args */ - assert(heap); - assert(val); - assert(obj); + HDassert(heap); + HDassert(val); + HDassert(obj); /* Check internal consistency */ /* (Pre-condition) */ - assert(heap->nobjsnalloc); - assert(heap->heap); - assert((heap->type==H5HP_MAX_HEAP && heap->heap[0].val==INT_MAX) || + HDassert(heap->nobjsnalloc); + HDassert(heap->heap); + HDassert((heap->type==H5HP_MAX_HEAP && heap->heap[0].val==INT_MAX) || (heap->type==H5HP_MIN_HEAP && heap->heap[0].val==INT_MIN)); - assert(heap->heap[0].obj==NULL); + HDassert(heap->heap[0].obj==NULL); /* Check if there are any objects on the heap to remove */ if(heap->nobjs==0) HGOTO_ERROR(H5E_HEAP, H5E_NOTFOUND, FAIL, "heap is empty"); /* Get the information for the top object on the heap */ - assert(heap->heap[1].obj->heap_loc==1); + HDassert(heap->heap[1].obj->heap_loc==1); *val=heap->heap[1].val; *obj=heap->heap[1].obj; @@ -634,11 +634,11 @@ done: /* Check internal consistency */ /* (Post-condition) */ - assert(heap->nobjsnalloc); - assert(heap->heap); - assert((heap->type==H5HP_MAX_HEAP && heap->heap[0].val==INT_MAX) || + HDassert(heap->nobjsnalloc); + HDassert(heap->heap); + HDassert((heap->type==H5HP_MAX_HEAP && heap->heap[0].val==INT_MAX) || (heap->type==H5HP_MIN_HEAP && heap->heap[0].val==INT_MIN)); - assert(heap->heap[0].obj==NULL); + HDassert(heap->heap[0].obj==NULL); FUNC_LEAVE_NOAPI(ret_value); } /* end H5HP_remove() */ @@ -675,20 +675,20 @@ H5HP_change(H5HP_t *heap, int val, void *_obj) FUNC_ENTER_NOAPI(FAIL) /* Check args */ - assert(heap); - assert(obj); + HDassert(heap); + HDassert(obj); /* Check internal consistency */ /* (Pre-condition) */ - assert(heap->nobjsnalloc); - assert(heap->heap); - assert((heap->type==H5HP_MAX_HEAP && heap->heap[0].val==INT_MAX) || + HDassert(heap->nobjsnalloc); + HDassert(heap->heap); + HDassert((heap->type==H5HP_MAX_HEAP && heap->heap[0].val==INT_MAX) || (heap->type==H5HP_MIN_HEAP && heap->heap[0].val==INT_MIN)); - assert(heap->heap[0].obj==NULL); + HDassert(heap->heap[0].obj==NULL); /* Get the location of the object in the heap */ obj_loc=obj->heap_loc; - assert(obj_loc>0 && obj_loc<=heap->nobjs); + HDassert(obj_loc>0 && obj_loc<=heap->nobjs); /* Change the heap object's priority */ old_val=heap->heap[obj_loc].val; @@ -720,11 +720,11 @@ done: /* Check internal consistency */ /* (Post-condition) */ - assert(heap->nobjsnalloc); - assert(heap->heap); - assert((heap->type==H5HP_MAX_HEAP && heap->heap[0].val==INT_MAX) || + HDassert(heap->nobjsnalloc); + HDassert(heap->heap); + HDassert((heap->type==H5HP_MAX_HEAP && heap->heap[0].val==INT_MAX) || (heap->type==H5HP_MIN_HEAP && heap->heap[0].val==INT_MIN)); - assert(heap->heap[0].obj==NULL); + HDassert(heap->heap[0].obj==NULL); FUNC_LEAVE_NOAPI(ret_value); } /* end H5HP_change() */ @@ -760,20 +760,20 @@ H5HP_incr(H5HP_t *heap, unsigned amt, void *_obj) FUNC_ENTER_NOAPI(FAIL) /* Check args */ - assert(heap); - assert(obj); + HDassert(heap); + HDassert(obj); /* Check internal consistency */ /* (Pre-condition) */ - assert(heap->nobjsnalloc); - assert(heap->heap); - assert((heap->type==H5HP_MAX_HEAP && heap->heap[0].val==INT_MAX) || + HDassert(heap->nobjsnalloc); + HDassert(heap->heap); + HDassert((heap->type==H5HP_MAX_HEAP && heap->heap[0].val==INT_MAX) || (heap->type==H5HP_MIN_HEAP && heap->heap[0].val==INT_MIN)); - assert(heap->heap[0].obj==NULL); + HDassert(heap->heap[0].obj==NULL); /* Get the location of the object in the heap */ obj_loc = obj->heap_loc; - assert(obj_loc > 0 && obj_loc <= heap->nobjs); + HDassert(obj_loc > 0 && obj_loc <= heap->nobjs); /* Change the heap object's priority */ heap->heap[obj_loc].val += (int)amt; @@ -792,11 +792,11 @@ done: /* Check internal consistency */ /* (Post-condition) */ - assert(heap->nobjsnalloc); - assert(heap->heap); - assert((heap->type==H5HP_MAX_HEAP && heap->heap[0].val==INT_MAX) || + HDassert(heap->nobjsnalloc); + HDassert(heap->heap); + HDassert((heap->type==H5HP_MAX_HEAP && heap->heap[0].val==INT_MAX) || (heap->type==H5HP_MIN_HEAP && heap->heap[0].val==INT_MIN)); - assert(heap->heap[0].obj==NULL); + HDassert(heap->heap[0].obj==NULL); FUNC_LEAVE_NOAPI(ret_value); } /* end H5HP_incr() */ @@ -832,20 +832,20 @@ H5HP_decr(H5HP_t *heap, unsigned amt, void *_obj) FUNC_ENTER_NOAPI(FAIL) /* Check args */ - assert(heap); - assert(obj); + HDassert(heap); + HDassert(obj); /* Check internal consistency */ /* (Pre-condition) */ - assert(heap->nobjsnalloc); - assert(heap->heap); - assert((heap->type==H5HP_MAX_HEAP && heap->heap[0].val==INT_MAX) || + HDassert(heap->nobjsnalloc); + HDassert(heap->heap); + HDassert((heap->type==H5HP_MAX_HEAP && heap->heap[0].val==INT_MAX) || (heap->type==H5HP_MIN_HEAP && heap->heap[0].val==INT_MIN)); - assert(heap->heap[0].obj==NULL); + HDassert(heap->heap[0].obj==NULL); /* Get the location of the object in the heap */ obj_loc=obj->heap_loc; - assert(obj_loc>0 && obj_loc<=heap->nobjs); + HDassert(obj_loc>0 && obj_loc<=heap->nobjs); /* Change the heap object's priority */ heap->heap[obj_loc].val-=amt; @@ -864,11 +864,11 @@ done: /* Check internal consistency */ /* (Post-condition) */ - assert(heap->nobjsnalloc); - assert(heap->heap); - assert((heap->type==H5HP_MAX_HEAP && heap->heap[0].val==INT_MAX) || + HDassert(heap->nobjsnalloc); + HDassert(heap->heap); + HDassert((heap->type==H5HP_MAX_HEAP && heap->heap[0].val==INT_MAX) || (heap->type==H5HP_MIN_HEAP && heap->heap[0].val==INT_MIN)); - assert(heap->heap[0].obj==NULL); + HDassert(heap->heap[0].obj==NULL); FUNC_LEAVE_NOAPI(ret_value); } /* end H5HP_decr() */ diff --git a/src/H5I.c b/src/H5I.c index ffdbcdf..465e607 100644 --- a/src/H5I.c +++ b/src/H5I.c @@ -2079,55 +2079,21 @@ H5Isearch(H5I_type_t type, H5I_search_func_t func, void *key) if(H5I_IS_LIB_TYPE(type)) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, NULL, "cannot call public function on library type") - if((ret_value = H5I_search(type, func, key)) == NULL) - HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, NULL, "cannot call public function on library type") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5Isearch() */ - - -/*------------------------------------------------------------------------- - * Function: H5I_search - * - * Purpose: Private function for H5Isearch - * - * Return: Success: The first object in the type for which FUNC - * returns non-zero. NULL if FUNC returned zero - * for every object in the type. - * - * Failure: NULL - * - * Programmer: James Laird - * Nathaniel Furrer - * Friday, April 23, 2004 - * - *------------------------------------------------------------------------- - */ -void * -H5I_search(H5I_type_t _type, H5I_search_func_t _func, void *_key) -{ - H5I_search_ud_t udata; /* Context for iteration */ - void *ret_value; /* Return value */ - - FUNC_ENTER_NOAPI(NULL) - /* Set up udata struct */ - udata.app_cb = _func; - udata.app_key = _key; + udata.app_cb = func; + udata.app_key = key; udata.ret_obj = NULL; /* Note that H5I_iterate returns an error code. We ignore it * here, as we can't do anything with it without revising the API. */ - if(H5I_iterate(_type, H5I_search_cb, &udata, TRUE) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, NULL, "cannot call public function on library type") + H5I_iterate(type, H5I_search_cb, &udata, TRUE); /* Set return value */ ret_value = udata.ret_obj; done: - FUNC_LEAVE_NOAPI(ret_value) + FUNC_LEAVE_API(ret_value) } /* end H5Isearch() */ diff --git a/src/H5Iprivate.h b/src/H5Iprivate.h index 42810f5..125c3f6 100644 --- a/src/H5Iprivate.h +++ b/src/H5Iprivate.h @@ -79,7 +79,6 @@ H5_DLL H5I_type_t H5I_get_type(hid_t id); H5_DLL hid_t H5I_get_file_id(hid_t obj_id, hbool_t app_ref); H5_DLL void *H5I_remove(hid_t id); H5_DLL void *H5I_remove_verify(hid_t id, H5I_type_t id_type); -H5_DLL void *H5I_search(H5I_type_t _type, H5I_search_func_t _func, void *_key); H5_DLL herr_t H5I_iterate(H5I_type_t type, H5I_search_func_t func, void *udata, hbool_t app_ref); H5_DLL int H5I_get_ref(hid_t id, hbool_t app_ref); H5_DLL int H5I_inc_ref(hid_t id, hbool_t app_ref); diff --git a/src/H5MM.c b/src/H5MM.c index feceb51..c44222c 100644 --- a/src/H5MM.c +++ b/src/H5MM.c @@ -54,7 +54,7 @@ H5MM_malloc(size_t size) /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOERR - assert(size); + HDassert(size); FUNC_LEAVE_NOAPI(HDmalloc(size)); } /* end H5MM_malloc() */ @@ -84,7 +84,7 @@ H5MM_calloc(size_t size) /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOERR - assert(size); + HDassert(size); FUNC_LEAVE_NOAPI(HDcalloc(1,size)); } /* end H5MM_calloc() */ diff --git a/src/H5Ocopy.c b/src/H5Ocopy.c index f131be2..24eed35 100644 --- a/src/H5Ocopy.c +++ b/src/H5Ocopy.c @@ -286,9 +286,9 @@ H5Ocopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, done: if(loc_found && H5G_loc_free(&src_loc) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location") - if(obj_open) - H5O_close(&src_oloc); + HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't free location") + if(obj_open && H5O_close(&src_oloc) < 0) + HDONE_ERROR(H5E_OHDR, H5E_CLOSEERROR, FAIL, "unable to release object header") FUNC_LEAVE_API(ret_value) } /* end H5Ocopy() */ @@ -678,7 +678,7 @@ H5O_copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, } /* end if */ /* Add in destination's object header size now */ - dst_oh_size += H5O_SIZEOF_HDR(oh_dst); + dst_oh_size += (uint64_t)H5O_SIZEOF_HDR(oh_dst); /* Allocate space for chunk in destination file */ if(HADDR_UNDEF == (oh_dst->chunk[0].addr = H5MF_alloc(oloc_dst->file, H5FD_MEM_OHDR, dxpl_id, (hsize_t)dst_oh_size))) @@ -1293,7 +1293,8 @@ H5O_copy_expand_ref(H5F_t *file_src, void *_src_ref, hid_t dxpl_id, H5O_loc_t dst_oloc; /* Copied object object location */ H5O_loc_t src_oloc; /* Temporary object location for source object */ H5G_loc_t dst_root_loc; /* The location of root group of the destination file */ - uint8_t *p; /* Pointer to OID to store */ + const uint8_t *q; /* Pointer to source OID to store */ + uint8_t *p; /* Pointer to destination OID to store */ size_t i; /* Local index variable */ herr_t ret_value = SUCCEED; @@ -1327,8 +1328,8 @@ H5O_copy_expand_ref(H5F_t *file_src, void *_src_ref, hid_t dxpl_id, /* Making equivalent references in the destination file */ for(i = 0; i < ref_count; i++) { /* Set up for the object copy for the reference */ - p = (uint8_t *)(&src_ref[i]); - H5F_addr_decode(src_oloc.file, (const uint8_t **)&p, &(src_oloc.addr)); + q = (uint8_t *)(&src_ref[i]); + H5F_addr_decode(src_oloc.file, (const uint8_t **)&q, &(src_oloc.addr)); dst_oloc.addr = HADDR_UNDEF; /* Attempt to copy object from source to destination file */ @@ -1356,9 +1357,9 @@ H5O_copy_expand_ref(H5F_t *file_src, void *_src_ref, hid_t dxpl_id, /* Making equivalent references in the destination file */ for(i = 0; i < ref_count; i++) { /* Get the heap ID for the dataset region */ - p = (uint8_t *)(&src_ref[i]); - H5F_addr_decode(src_oloc.file, (const uint8_t **)&p, &(hobjid.addr)); - INT32DECODE(p, hobjid.idx); + q = (const uint8_t *)(&src_ref[i]); + H5F_addr_decode(src_oloc.file, (const uint8_t **)&q, &(hobjid.addr)); + UINT32DECODE(q, hobjid.idx); if(hobjid.addr != (haddr_t)0) { /* Get the dataset region from the heap (allocate inside routine) */ @@ -1366,8 +1367,8 @@ H5O_copy_expand_ref(H5F_t *file_src, void *_src_ref, hid_t dxpl_id, HGOTO_ERROR(H5E_REFERENCE, H5E_READERROR, FAIL, "Unable to read dataset region information") /* Get the object oid for the dataset */ - p = (uint8_t *)buf; - H5F_addr_decode(src_oloc.file, (const uint8_t **)&p, &(src_oloc.addr)); + q = (const uint8_t *)buf; + H5F_addr_decode(src_oloc.file, (const uint8_t **)&q, &(src_oloc.addr)); dst_oloc.addr = HADDR_UNDEF; /* copy the object pointed by the ref to the destination */ @@ -1393,7 +1394,7 @@ H5O_copy_expand_ref(H5F_t *file_src, void *_src_ref, hid_t dxpl_id, /* Set the dataset region reference info for the destination file */ p = (uint8_t *)(&dst_ref[i]); H5F_addr_encode(dst_oloc.file, &p, hobjid.addr); - INT32ENCODE(p, hobjid.idx); + UINT32ENCODE(p, hobjid.idx); /* Free the buffer allocated in H5HG_read() */ H5MM_xfree(buf); diff --git a/src/H5Oefl.c b/src/H5Oefl.c index 14f9089..df1f07a 100644 --- a/src/H5Oefl.c +++ b/src/H5Oefl.c @@ -118,9 +118,9 @@ H5O_efl_decode(H5F_t *f, hid_t dxpl_id, H5O_t UNUSED *open_oh, /* Number of slots */ UINT16DECODE(p, mesg->nalloc); - assert(mesg->nalloc>0); + HDassert(mesg->nalloc>0); UINT16DECODE(p, mesg->nused); - assert(mesg->nused <= mesg->nalloc); + HDassert(mesg->nused <= mesg->nalloc); /* Heap address */ H5F_addr_decode(f, &p, &(mesg->heap_addr)); diff --git a/src/H5Olayout.c b/src/H5Olayout.c index ad0a7277..fb0a4b8 100644 --- a/src/H5Olayout.c +++ b/src/H5Olayout.c @@ -131,7 +131,7 @@ H5O_layout_decode(H5F_t *f, hid_t UNUSED dxpl_id, H5O_t UNUSED *open_oh, /* Layout class */ mesg->type = (H5D_layout_t)*p++; - assert(H5D_CONTIGUOUS == mesg->type || H5D_CHUNKED == mesg->type || H5D_COMPACT == mesg->type); + HDassert(H5D_CONTIGUOUS == mesg->type || H5D_CHUNKED == mesg->type || H5D_COMPACT == mesg->type); /* Set the storage type */ mesg->storage.type = mesg->type; diff --git a/src/H5Oname.c b/src/H5Oname.c index c1cb8c8..5ca05e1 100644 --- a/src/H5Oname.c +++ b/src/H5Oname.c @@ -228,8 +228,8 @@ H5O_name_size(const H5F_t UNUSED *f, hbool_t UNUSED disable_shared, const void * FUNC_ENTER_NOAPI_NOINIT_NOERR /* check args */ - assert(f); - assert(mesg); + HDassert(f); + HDassert(mesg); ret_value = mesg->s ? HDstrlen(mesg->s) + 1 : 0; @@ -294,11 +294,11 @@ H5O_name_debug(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *_mesg, FILE *s FUNC_ENTER_NOAPI_NOINIT_NOERR /* check args */ - assert(f); - assert(mesg); - assert(stream); - assert(indent >= 0); - assert(fwidth >= 0); + HDassert(f); + HDassert(mesg); + HDassert(stream); + HDassert(indent >= 0); + HDassert(fwidth >= 0); fprintf(stream, "%*s%-*s `%s'\n", indent, "", fwidth, "Name:", diff --git a/src/H5Ostab.c b/src/H5Ostab.c index 5619a1b..264e3a1 100644 --- a/src/H5Ostab.c +++ b/src/H5Ostab.c @@ -149,9 +149,9 @@ H5O_stab_encode(H5F_t *f, hbool_t UNUSED disable_shared, uint8_t *p, const void FUNC_ENTER_NOAPI_NOINIT_NOERR /* check args */ - assert(f); - assert(p); - assert(stab); + HDassert(f); + HDassert(p); + HDassert(stab); /* encode */ H5F_addr_encode(f, &p, stab->btree_addr); @@ -433,11 +433,11 @@ H5O_stab_debug(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *_mesg, FILE * FUNC_ENTER_NOAPI_NOINIT_NOERR /* check args */ - assert(f); - assert(stab); - assert(stream); - assert(indent >= 0); - assert(fwidth >= 0); + HDassert(f); + HDassert(stab); + HDassert(stream); + HDassert(indent >= 0); + HDassert(fwidth >= 0); HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, "B-tree address:", stab->btree_addr); diff --git a/src/H5PL.c b/src/H5PL.c index 07e90af..7a8a296 100644 --- a/src/H5PL.c +++ b/src/H5PL.c @@ -415,7 +415,7 @@ H5PL__find(H5PL_type_t plugin_type, int type_id, char *dir, const void **info) /* Get info for directory entry */ if(HDstat(pathname, &my_stat) == -1) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't stat file: %s", strerror(errno)) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't stat file: %s", HDstrerror(errno)) /* If it is a directory, skip it */ if(S_ISDIR(my_stat.st_mode)) @@ -437,7 +437,7 @@ H5PL__find(H5PL_type_t plugin_type, int type_id, char *dir, const void **info) done: if(dirp) if(HDclosedir(dirp) < 0) - HDONE_ERROR(H5E_FILE, H5E_CLOSEERROR, FAIL, "can't close directory: %s", strerror(errno)) + HDONE_ERROR(H5E_FILE, H5E_CLOSEERROR, FAIL, "can't close directory: %s", HDstrerror(errno)) if(pathname) pathname = (char *)H5MM_xfree(pathname); diff --git a/src/H5Pdcpl.c b/src/H5Pdcpl.c index 8a15863..2bf34b0 100644 --- a/src/H5Pdcpl.c +++ b/src/H5Pdcpl.c @@ -1808,13 +1808,6 @@ done: * Programmer: Kent Yang * Tuesday, April 1, 2003 * - * Modifications: - * - * Nat Furrer and James Laird - * June 30, 2004 - * Now ensures that SZIP encoding is enabled - * SZIP defaults to k13 compression - * *------------------------------------------------------------------------- */ herr_t @@ -1824,22 +1817,22 @@ H5Pset_szip(hid_t plist_id, unsigned options_mask, unsigned pixels_per_block) H5P_genplist_t *plist; /* Property list pointer */ unsigned cd_values[2]; /* Filter parameters */ unsigned int config_flags; - herr_t ret_value=SUCCEED; /* return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "iIuIu", plist_id, options_mask, pixels_per_block); - if(H5Zget_filter_info(H5Z_FILTER_SZIP, &config_flags) < 0) + if(H5Z_get_filter_info(H5Z_FILTER_SZIP, &config_flags) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "can't get filter info") - if(! (config_flags & H5Z_FILTER_CONFIG_ENCODE_ENABLED)) + if(!(config_flags & H5Z_FILTER_CONFIG_ENCODE_ENABLED)) HGOTO_ERROR(H5E_PLINE, H5E_NOENCODER, FAIL, "Filter present but encoding is disabled.") /* Check arguments */ - if ((pixels_per_block%2)==1) - HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "pixels_per_block is not even") - if (pixels_per_block>H5_SZIP_MAX_PIXELS_PER_BLOCK) - HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "pixels_per_block is too large") + if((pixels_per_block % 2) == 1) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "pixels_per_block is not even") + if(pixels_per_block > H5_SZIP_MAX_PIXELS_PER_BLOCK) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "pixels_per_block is too large") /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE))) diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c index befec84..a416b00 100644 --- a/src/H5Pfapl.c +++ b/src/H5Pfapl.c @@ -2289,7 +2289,7 @@ H5P_file_image_info_del(hid_t UNUSED prop_id, const char UNUSED *name, size_t UN HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "image_free callback failed") } /* end if */ else - free(info.buffer); + HDfree(info.buffer); } /* end if */ /* Free udata if it exists */ diff --git a/src/H5Pint.c b/src/H5Pint.c index 88c3247..13cc3c1 100644 --- a/src/H5Pint.c +++ b/src/H5Pint.c @@ -2681,7 +2681,7 @@ done: PURPOSE Internal routine to query the existance of a property in a property list. USAGE - herr_t H5P_exist_plist(plist, name) + htri_t H5P_exist_plist(plist, name) const H5P_genplist_t *plist; IN: Property list to check const char *name; IN: Name of property to check for RETURNS diff --git a/src/H5Pocpl.c b/src/H5Pocpl.c index f80e4e7..2166020 100644 --- a/src/H5Pocpl.c +++ b/src/H5Pocpl.c @@ -1453,7 +1453,7 @@ H5P_get_filter(const H5Z_filter_info_t *filter, unsigned int *flags/*out*/, /* Filter configuration (assume filter ID has already been checked) */ if(filter_config) - H5Zget_filter_info(filter->id, filter_config); + H5Z_get_filter_info(filter->id, filter_config); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P_get_filter() */ diff --git a/src/H5R.c b/src/H5R.c index d45947b..bf8ffba 100644 --- a/src/H5R.c +++ b/src/H5R.c @@ -295,7 +295,7 @@ H5R_create(void *_ref, H5G_loc_t *loc, const char *name, H5R_type_t ref_type, H5 /* Serialize the heap ID and index for storage in the file */ p = (uint8_t *)ref; H5F_addr_encode(loc->oloc->file, &p, hobjid.addr); - INT32ENCODE(p, hobjid.idx); + UINT32ENCODE(p, hobjid.idx); /* Free the buffer we serialized data in */ H5MM_xfree(buf); @@ -439,7 +439,7 @@ H5R_dereference(H5F_t *file, hid_t oapl_id, hid_t dxpl_id, H5R_type_t ref_type, /* Get the heap ID for the dataset region */ p = (const uint8_t *)_ref; H5F_addr_decode(oloc.file, &p, &(hobjid.addr)); - INT32DECODE(p, hobjid.idx); + UINT32DECODE(p, hobjid.idx); /* Get the dataset region from the heap (allocate inside routine) */ if(NULL == (buf = (uint8_t *)H5HG_read(oloc.file, dxpl_id, &hobjid, NULL, NULL))) @@ -637,7 +637,7 @@ H5R_get_region(H5F_t *file, hid_t dxpl_id, const void *_ref) /* Get the heap ID for the dataset region */ p = (const uint8_t *)_ref; H5F_addr_decode(oloc.file, &p, &(hobjid.addr)); - INT32DECODE(p, hobjid.idx); + UINT32DECODE(p, hobjid.idx); /* Get the dataset region from the heap (allocate inside routine) */ if((buf = (uint8_t *)H5HG_read(oloc.file, dxpl_id, &hobjid, NULL, NULL)) == NULL) @@ -772,7 +772,7 @@ H5R_get_obj_type(H5F_t *file, hid_t dxpl_id, H5R_type_t ref_type, /* Get the heap ID for the dataset region */ p = (const uint8_t *)_ref; H5F_addr_decode(oloc.file, &p, &(hobjid.addr)); - INT32DECODE(p, hobjid.idx); + UINT32DECODE(p, hobjid.idx); /* Get the dataset region from the heap (allocate inside routine) */ if((buf = (uint8_t *)H5HG_read(oloc.file, dxpl_id, &hobjid, NULL, NULL)) == NULL) @@ -916,7 +916,7 @@ H5R_get_name(H5F_t *f, hid_t lapl_id, hid_t dxpl_id, hid_t id, H5R_type_t ref_ty /* Get the heap ID for the dataset region */ p = (const uint8_t *)_ref; H5F_addr_decode(oloc.file, &p, &(hobjid.addr)); - INT32DECODE(p, hobjid.idx); + UINT32DECODE(p, hobjid.idx); /* Get the dataset region from the heap (allocate inside routine) */ if((buf = (uint8_t *)H5HG_read(oloc.file, dxpl_id, &hobjid, NULL, NULL)) == NULL) diff --git a/src/H5S.c b/src/H5S.c index 7ef1da4..2eebba4 100644 --- a/src/H5S.c +++ b/src/H5S.c @@ -324,7 +324,7 @@ H5S_extent_release(H5S_extent_t *extent) FUNC_ENTER_NOAPI(FAIL) - assert(extent); + HDassert(extent); /* Release extent */ if(extent->type == H5S_SIMPLE) { @@ -725,7 +725,7 @@ H5S_get_npoints_max(const H5S_t *ds) FUNC_ENTER_NOAPI(0) /* check args */ - assert(ds); + HDassert(ds); switch (H5S_GET_EXTENT_TYPE(ds)) { case H5S_NULL: @@ -755,7 +755,7 @@ H5S_get_npoints_max(const H5S_t *ds) case H5S_NO_CLASS: default: - assert("unknown dataspace class" && 0); + HDassert("unknown dataspace class" && 0); HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, 0, "internal error (unknown dataspace class)") } @@ -1434,7 +1434,7 @@ H5S_create_simple(unsigned rank, const hsize_t dims[/*rank*/], FUNC_ENTER_NOAPI(NULL) /* Check arguments */ - assert(rank <=H5S_MAX_RANK); + HDassert(rank <=H5S_MAX_RANK); /* Create the space and set the extent */ if(NULL==(ret_value=H5S_create(H5S_SIMPLE))) @@ -1712,7 +1712,7 @@ H5S_get_simple_extent_type(const H5S_t *space) FUNC_ENTER_NOAPI(H5S_NO_CLASS) - assert(space); + HDassert(space); ret_value=H5S_GET_EXTENT_TYPE(space); diff --git a/src/H5SL.c b/src/H5SL.c index 7581858..5c46fd4 100644 --- a/src/H5SL.c +++ b/src/H5SL.c @@ -754,7 +754,7 @@ H5SL_release_common(H5SL_t *slist, H5SL_operator_t op, void *op_data) FUNC_ENTER_NOAPI_NOINIT /* Check args */ - assert(slist); + HDassert(slist); /* Check internal consistency */ /* (Pre-condition) */ @@ -940,7 +940,7 @@ H5SL_count(H5SL_t *slist) FUNC_ENTER_NOAPI_NOINIT_NOERR /* Check args */ - assert(slist); + HDassert(slist); /* Check internal consistency */ /* (Pre-condition) */ @@ -978,8 +978,8 @@ H5SL_insert(H5SL_t *slist, void *item, const void *key) FUNC_ENTER_NOAPI_NOINIT /* Check args */ - assert(slist); - assert(key); + HDassert(slist); + HDassert(key); /* Check internal consistency */ /* (Pre-condition) */ @@ -1025,8 +1025,8 @@ H5SL_add(H5SL_t *slist, void *item, const void *key) FUNC_ENTER_NOAPI_NOINIT /* Check args */ - assert(slist); - assert(key); + HDassert(slist); + HDassert(key); /* Check internal consistency */ /* (Pre-condition) */ @@ -1252,8 +1252,8 @@ H5SL_search(H5SL_t *slist, const void *key) FUNC_ENTER_NOAPI_NOINIT_NOERR /* Check args */ - assert(slist); - assert(key); + HDassert(slist); + HDassert(key); /* Check internal consistency */ /* (Pre-condition) */ @@ -1341,8 +1341,8 @@ H5SL_less(H5SL_t *slist, const void *key) FUNC_ENTER_NOAPI_NOINIT_NOERR /* Check args */ - assert(slist); - assert(key); + HDassert(slist); + HDassert(key); /* Check internal consistency */ /* (Pre-condition) */ @@ -1535,8 +1535,8 @@ H5SL_find(H5SL_t *slist, const void *key) FUNC_ENTER_NOAPI_NOINIT_NOERR /* Check args */ - assert(slist); - assert(key); + HDassert(slist); + HDassert(key); /* Check internal consistency */ /* (Pre-condition) */ @@ -1806,7 +1806,7 @@ H5SL_first(H5SL_t *slist) FUNC_ENTER_NOAPI_NOINIT_NOERR /* Check args */ - assert(slist); + HDassert(slist); /* Check internal consistency */ /* (Pre-condition) */ @@ -1840,7 +1840,7 @@ H5SL_next(H5SL_node_t *slist_node) FUNC_ENTER_NOAPI_NOINIT_NOERR /* Check args */ - assert(slist_node); + HDassert(slist_node); /* Check internal consistency */ /* (Pre-condition) */ @@ -1874,7 +1874,7 @@ H5SL_prev(H5SL_node_t *slist_node) FUNC_ENTER_NOAPI_NOINIT_NOERR /* Check args */ - assert(slist_node); + HDassert(slist_node); /* Check internal consistency */ /* (Pre-condition) */ @@ -1909,7 +1909,7 @@ H5SL_last(H5SL_t *slist) FUNC_ENTER_NOAPI_NOINIT_NOERR /* Check args */ - assert(slist); + HDassert(slist); /* Check internal consistency */ /* (Pre-condition) */ @@ -1943,7 +1943,7 @@ H5SL_item(H5SL_node_t *slist_node) FUNC_ENTER_NOAPI_NOINIT_NOERR /* Check args */ - assert(slist_node); + HDassert(slist_node); /* Check internal consistency */ /* (Pre-condition) */ @@ -2040,7 +2040,7 @@ H5SL_release(H5SL_t *slist) FUNC_ENTER_NOAPI_NOINIT_NOERR /* Check args */ - assert(slist); + HDassert(slist); /* Check internal consistency */ /* (Pre-condition) */ @@ -2086,7 +2086,7 @@ H5SL_free(H5SL_t *slist, H5SL_operator_t op, void *op_data) FUNC_ENTER_NOAPI_NOINIT_NOERR /* Check args */ - assert(slist); + HDassert(slist); /* Check internal consistency */ /* (Pre-condition) */ @@ -2132,7 +2132,7 @@ H5SL_destroy(H5SL_t *slist, H5SL_operator_t op, void *op_data) FUNC_ENTER_NOAPI_NOINIT_NOERR /* Check args */ - assert(slist); + HDassert(slist); /* Check internal consistency */ /* (Pre-condition) */ @@ -2169,7 +2169,7 @@ H5SL_close(H5SL_t *slist) FUNC_ENTER_NOAPI_NOINIT_NOERR /* Check args */ - assert(slist); + HDassert(slist); /* Check internal consistency */ /* (Pre-condition) */ diff --git a/src/H5Sall.c b/src/H5Sall.c index 8d56c80..19d1efc 100644 --- a/src/H5Sall.c +++ b/src/H5Sall.c @@ -118,8 +118,8 @@ H5S_all_iter_init (H5S_sel_iter_t *iter, const H5S_t *space) FUNC_ENTER_NOAPI_NOINIT_NOERR /* Check args */ - assert (space && H5S_SEL_ALL==H5S_GET_SELECT_TYPE(space)); - assert (iter); + HDassert (space && H5S_SEL_ALL==H5S_GET_SELECT_TYPE(space)); + HDassert (iter); /* Initialize the number of elements to iterate over */ iter->elmt_left=H5S_GET_SELECT_NPOINTS(space); @@ -158,8 +158,8 @@ H5S_all_iter_coords (const H5S_sel_iter_t *iter, hsize_t *coords) FUNC_ENTER_NOAPI_NOINIT /* Check args */ - assert (iter); - assert (coords); + HDassert (iter); + HDassert (coords); /* Calculate the coordinates for the current iterator offset */ if(H5V_array_calc(iter->u.all.elmt_offset,iter->rank,iter->dims,coords)<0) @@ -193,9 +193,9 @@ H5S_all_iter_block (const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end) FUNC_ENTER_NOAPI_NOINIT_NOERR /* Check args */ - assert (iter); - assert (start); - assert (end); + HDassert (iter); + HDassert (start); + HDassert (end); for(u=0; urank; u++) { /* Set the start of the 'all' block */ @@ -231,7 +231,7 @@ H5S_all_iter_nelmts (const H5S_sel_iter_t *iter) FUNC_ENTER_NOAPI_NOINIT_NOERR /* Check args */ - assert (iter); + HDassert (iter); FUNC_LEAVE_NOAPI(iter->elmt_left) } /* H5S_all_iter_nelmts() */ @@ -260,7 +260,7 @@ H5S_all_iter_has_next_block (const H5S_sel_iter_t UNUSED *iter) FUNC_ENTER_NOAPI_NOINIT_NOERR /* Check args */ - assert (iter); + HDassert (iter); FUNC_LEAVE_NOAPI(FALSE) } /* H5S_all_iter_has_next_block() */ @@ -290,8 +290,8 @@ H5S_all_iter_next(H5S_sel_iter_t *iter, size_t nelem) FUNC_ENTER_NOAPI_NOINIT_NOERR /* Check args */ - assert (iter); - assert (nelem>0); + HDassert (iter); + HDassert (nelem>0); /* Increment the iterator */ iter->u.all.elmt_offset+=nelem; @@ -324,7 +324,7 @@ H5S_all_iter_next_block(H5S_sel_iter_t UNUSED *iter) FUNC_ENTER_NOAPI_NOINIT_NOERR /* Check args */ - assert (iter); + HDassert (iter); FUNC_LEAVE_NOAPI(FAIL) } /* H5S_all_iter_next_block() */ @@ -353,7 +353,7 @@ H5S_all_iter_release (H5S_sel_iter_t UNUSED * iter) FUNC_ENTER_NOAPI_NOINIT_NOERR /* Check args */ - assert (iter); + HDassert (iter); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5S_all_iter_release() */ @@ -450,7 +450,7 @@ H5S_all_is_valid (const H5S_t UNUSED *space) { FUNC_ENTER_NOAPI_NOINIT_NOERR - assert(space); + HDassert(space); FUNC_LEAVE_NOAPI(TRUE) } /* end H5S_all_is_valid() */ @@ -480,7 +480,7 @@ H5S_all_serial_size (const H5S_t UNUSED *space) { FUNC_ENTER_NOAPI_NOINIT_NOERR - assert(space); + HDassert(space); /* Basic number of bytes required to serialize point selection: * + + + @@ -514,7 +514,7 @@ H5S_all_serialize (const H5S_t *space, uint8_t *buf) { FUNC_ENTER_NOAPI_NOINIT_NOERR - assert(space); + HDassert(space); /* Store the preamble information */ UINT32ENCODE(buf, (uint32_t)H5S_GET_SELECT_TYPE(space)); /* Store the type of selection */ @@ -671,7 +671,7 @@ H5S_all_is_contiguous(const H5S_t UNUSED *space) { FUNC_ENTER_NOAPI_NOINIT_NOERR - assert(space); + HDassert(space); FUNC_LEAVE_NOAPI(TRUE) } /* H5S_all_is_contiguous() */ @@ -700,7 +700,7 @@ H5S_all_is_single(const H5S_t UNUSED *space) { FUNC_ENTER_NOAPI_NOINIT_NOERR - assert(space); + HDassert(space); FUNC_LEAVE_NOAPI(TRUE) } /* H5S_all_is_single() */ @@ -731,7 +731,7 @@ H5S_all_is_regular(const H5S_t UNUSED *space) FUNC_ENTER_NOAPI_NOINIT_NOERR /* Check args */ - assert(space); + HDassert(space); FUNC_LEAVE_NOAPI(TRUE) } /* H5S_all_is_regular() */ @@ -955,14 +955,14 @@ H5S_all_get_seq_list(const H5S_t UNUSED *space, unsigned UNUSED flags, H5S_sel_i FUNC_ENTER_NOAPI_NOINIT_NOERR /* Check args */ - assert(space); - assert(iter); - assert(maxseq>0); - assert(maxelem>0); - assert(nseq); - assert(nelem); - assert(off); - assert(len); + HDassert(space); + HDassert(iter); + HDassert(maxseq>0); + HDassert(maxelem>0); + HDassert(nseq); + HDassert(nelem); + HDassert(off); + HDassert(len); /* Determine the actual number of elements to use */ H5_CHECK_OVERFLOW(iter->elmt_left,hsize_t,size_t); diff --git a/src/H5Sselect.c b/src/H5Sselect.c index 9a993a5..1eb0cbc 100644 --- a/src/H5Sselect.c +++ b/src/H5Sselect.c @@ -112,8 +112,8 @@ H5S_select_copy (H5S_t *dst, const H5S_t *src, hbool_t share_selection) FUNC_ENTER_NOAPI(FAIL) /* Check args */ - assert(dst); - assert(src); + HDassert(dst); + HDassert(src); /* Copy regular fields */ dst->select=src->select; @@ -152,7 +152,7 @@ H5S_select_release(H5S_t *ds) FUNC_ENTER_NOAPI_NOINIT_NOERR - assert(ds); + HDassert(ds); /* Call the selection type's release function */ ret_value=(*ds->select.type->release)(ds); @@ -224,7 +224,7 @@ H5S_select_serial_size(const H5S_t *space) FUNC_ENTER_NOAPI_NOINIT_NOERR - assert(space); + HDassert(space); /* Call the selection type's serial_size function */ ret_value=(*space->select.type->serial_size)(space); @@ -262,8 +262,8 @@ H5S_select_serialize(const H5S_t *space, uint8_t *buf) FUNC_ENTER_NOAPI_NOINIT_NOERR - assert(space); - assert(buf); + HDassert(space); + HDassert(buf); /* Call the selection type's serialize function */ ret_value=(*space->select.type->serialize)(space,buf); @@ -413,7 +413,7 @@ H5S_select_valid(const H5S_t *space) FUNC_ENTER_NOAPI_NOINIT_NOERR - assert(space); + HDassert(space); ret_value = (*space->select.type->is_valid)(space); @@ -452,7 +452,7 @@ H5S_select_deserialize (H5S_t *space, const uint8_t *buf) FUNC_ENTER_NOAPI(FAIL) - assert(space); + HDassert(space); tbuf=buf; UINT32DECODE(tbuf, sel_type); @@ -571,9 +571,9 @@ H5S_get_select_bounds(const H5S_t *space, hsize_t *start, hsize_t *end) FUNC_ENTER_NOAPI_NOINIT_NOERR /* Check args */ - assert(space); - assert(start); - assert(end); + HDassert(space); + HDassert(start); + HDassert(end); ret_value = (*space->select.type->bounds)(space,start,end); @@ -650,7 +650,7 @@ H5S_select_is_contiguous(const H5S_t *space) FUNC_ENTER_NOAPI_NOINIT_NOERR /* Check args */ - assert(space); + HDassert(space); ret_value = (*space->select.type->is_contiguous)(space); @@ -687,7 +687,7 @@ H5S_select_is_single(const H5S_t *space) FUNC_ENTER_NOAPI_NOINIT_NOERR /* Check args */ - assert(space); + HDassert(space); ret_value = (*space->select.type->is_single)(space); @@ -724,7 +724,7 @@ H5S_select_is_regular(const H5S_t *space) FUNC_ENTER_NOAPI_NOINIT_NOERR /* Check args */ - assert(space); + HDassert(space); ret_value = (*space->select.type->is_regular)(space); @@ -929,8 +929,8 @@ H5S_select_iter_coords (const H5S_sel_iter_t *sel_iter, hsize_t *coords) FUNC_ENTER_NOAPI_NOINIT_NOERR /* Check args */ - assert(sel_iter); - assert(coords); + HDassert(sel_iter); + HDassert(coords); /* Call iter_coords routine for selection type */ ret_value = (*sel_iter->type->iter_coords)(sel_iter,coords); @@ -971,9 +971,9 @@ H5S_select_iter_block (const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end) FUNC_ENTER_NOAPI_NOINIT_NOINIT_NOERR /* Check args */ - assert(iter); - assert(start); - assert(end); + HDassert(iter); + HDassert(start); + HDassert(end); /* Call iter_block routine for selection type */ ret_value = (*iter->type->iter_block)(iter,start,end); @@ -1011,7 +1011,7 @@ H5S_select_iter_nelmts (const H5S_sel_iter_t *sel_iter) FUNC_ENTER_NOAPI_NOINIT_NOERR /* Check args */ - assert(sel_iter); + HDassert(sel_iter); /* Call iter_nelmts routine for selection type */ ret_value = (*sel_iter->type->iter_nelmts)(sel_iter); @@ -1050,7 +1050,7 @@ H5S_select_iter_has_next_block (const H5S_sel_iter_t *iter) FUNC_ENTER_NOAPI_NOINIT_NOINIT_NOERR /* Check args */ - assert(iter); + HDassert(iter); /* Call iter_has_next_block routine for selection type */ ret_value = (*iter->type->iter_has_next_block)(iter); @@ -1090,8 +1090,8 @@ H5S_select_iter_next(H5S_sel_iter_t *iter, size_t nelem) FUNC_ENTER_NOAPI_NOINIT_NOERR /* Check args */ - assert(iter); - assert(nelem>0); + HDassert(iter); + HDassert(nelem>0); /* Call iter_next routine for selection type */ ret_value = (*iter->type->iter_next)(iter,nelem); @@ -1135,7 +1135,7 @@ H5S_select_iter_next_block(H5S_sel_iter_t *iter) FUNC_ENTER_NOAPI_NOINIT_NOERR /* Check args */ - assert(iter); + HDassert(iter); /* Call iter_next_block routine for selection type */ ret_value = (*iter->type->iter_next_block)(iter); @@ -1173,7 +1173,7 @@ H5S_select_iter_release(H5S_sel_iter_t *sel_iter) FUNC_ENTER_NOAPI_NOINIT_NOERR /* Check args */ - assert(sel_iter); + HDassert(sel_iter); /* Call selection type-specific release routine */ ret_value = (*sel_iter->type->iter_release)(sel_iter); @@ -1387,7 +1387,7 @@ H5S_get_select_type(const H5S_t *space) FUNC_ENTER_NOAPI_NOINIT_NOERR /* Check args */ - assert(space); + HDassert(space); /* Set return value */ ret_value=H5S_GET_SELECT_TYPE(space); diff --git a/src/H5T.c b/src/H5T.c index e2e04a8..79682b5 100644 --- a/src/H5T.c +++ b/src/H5T.c @@ -1349,7 +1349,7 @@ H5T_init_interface(void) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to register conversion function(s)") /* ========== Datatype Creation Property Class Initialization ============*/ - assert(H5P_CLS_DATATYPE_CREATE_g!=-1); + HDassert(H5P_CLS_DATATYPE_CREATE_g!=-1); /* Get the pointer to group creation class */ if(NULL == (crt_pclass = (H5P_genclass_t *)H5I_object(H5P_CLS_DATATYPE_CREATE_g))) @@ -1914,7 +1914,7 @@ H5T_get_class(const H5T_t *dt, htri_t internal) FUNC_ENTER_NOAPI(H5T_NO_CLASS) - assert(dt); + HDassert(dt); /* Externally, a VL string is a string; internally, a VL string is a VL. */ if(internal) { @@ -2271,7 +2271,7 @@ H5T_get_super(const H5T_t *dt) FUNC_ENTER_NOAPI(NULL) - assert(dt); + HDassert(dt); if (!dt->shared->parent) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "not a derived data type"); @@ -2319,11 +2319,11 @@ H5T_register(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst, FUNC_ENTER_NOAPI_NOINIT /* Check args */ - assert(src); - assert(dst); - assert(func); - assert(H5T_PERS_HARD==pers || H5T_PERS_SOFT==pers); - assert(name && *name); + HDassert(src); + HDassert(dst); + HDassert(func); + HDassert(H5T_PERS_HARD==pers || H5T_PERS_SOFT==pers); + HDassert(name && *name); if(H5T_PERS_HARD == pers) { /* Only bother to register the path if it's not a no-op path (for this machine) */ @@ -2369,7 +2369,7 @@ H5T_register(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst, */ for (i=1; iis_hard || @@ -3435,7 +3435,7 @@ H5T_lock (H5T_t *dt, hbool_t immutable) FUNC_ENTER_NOAPI(FAIL) - assert (dt); + HDassert (dt); switch (dt->shared->state) { case H5T_STATE_TRANSIENT: @@ -3709,10 +3709,10 @@ H5T_set_size(H5T_t *dt, size_t size) FUNC_ENTER_NOAPI_NOINIT /* Check args */ - assert(dt); - assert(size!=0); - assert(H5T_REFERENCE!=dt->shared->type); - assert(!(H5T_ENUM==dt->shared->type && 0==dt->shared->u.enumer.nmembs)); + HDassert(dt); + HDassert(size!=0); + HDassert(H5T_REFERENCE!=dt->shared->type); + HDassert(!(H5T_ENUM==dt->shared->type && 0==dt->shared->u.enumer.nmembs)); if (dt->shared->parent) { if (H5T_set_size(dt->shared->parent, size)<0) @@ -3841,12 +3841,12 @@ H5T_set_size(H5T_t *dt, size_t size) case H5T_VLEN: case H5T_ARRAY: case H5T_REFERENCE: - assert("can't happen" && 0); + HDassert("can't happen" && 0); case H5T_NO_CLASS: case H5T_NCLASSES: - assert("invalid type" && 0); + HDassert("invalid type" && 0); default: - assert("not implemented yet" && 0); + HDassert("not implemented yet" && 0); } /* Commit (if we didn't convert this type to a VL string) */ @@ -3893,7 +3893,7 @@ H5T_get_size(const H5T_t *dt) FUNC_ENTER_NOAPI_NOINIT_NOERR /* check args */ - assert(dt); + HDassert(dt); FUNC_LEAVE_NOAPI(dt->shared->size) } @@ -3999,9 +3999,9 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2, hbool_t superset) #ifdef H5T_DEBUG /* I don't quite trust the code above yet :-) --RPM */ for (u=0; ushared->u.compnd.nmembs-1; u++) { - assert(HDstrcmp(dt1->shared->u.compnd.memb[idx1[u]].name, + HDassert(HDstrcmp(dt1->shared->u.compnd.memb[idx1[u]].name, dt1->shared->u.compnd.memb[idx1[u + 1]].name)); - assert(HDstrcmp(dt2->shared->u.compnd.memb[idx2[u]].name, + HDassert(HDstrcmp(dt2->shared->u.compnd.memb[idx2[u]].name, dt2->shared->u.compnd.memb[idx2[u + 1]].name)); } #endif @@ -4079,9 +4079,9 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2, hbool_t superset) #ifdef H5T_DEBUG /* I don't quite trust the code above yet :-) --RPM */ for (u=0; ushared->u.enumer.nmembs-1; u++) { - assert(HDstrcmp(dt1->shared->u.enumer.name[idx1[u]], + HDassert(HDstrcmp(dt1->shared->u.enumer.name[idx1[u]], dt1->shared->u.enumer.name[idx1[u+1]])); - assert(HDstrcmp(dt2->shared->u.enumer.name[idx2[u]], + HDassert(HDstrcmp(dt2->shared->u.enumer.name[idx2[u]], dt2->shared->u.enumer.name[idx2[u+1]])); } #endif @@ -4137,10 +4137,10 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2, hbool_t superset) break; case H5T_VLEN: - assert(dt1->shared->u.vlen.type>H5T_VLEN_BADTYPE && dt1->shared->u.vlen.typeshared->u.vlen.type>H5T_VLEN_BADTYPE && dt2->shared->u.vlen.typeshared->u.vlen.loc>=H5T_LOC_BADLOC && dt1->shared->u.vlen.locshared->u.vlen.loc>=H5T_LOC_BADLOC && dt2->shared->u.vlen.locshared->u.vlen.type>H5T_VLEN_BADTYPE && dt1->shared->u.vlen.typeshared->u.vlen.type>H5T_VLEN_BADTYPE && dt2->shared->u.vlen.typeshared->u.vlen.loc>=H5T_LOC_BADLOC && dt1->shared->u.vlen.locshared->u.vlen.loc>=H5T_LOC_BADLOC && dt2->shared->u.vlen.locshared->u.vlen.type==H5T_VLEN_SEQUENCE && @@ -4300,14 +4300,14 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2, hbool_t superset) case H5R_BADTYPE: case H5R_MAXTYPE: - assert("invalid type" && 0); + HDassert("invalid type" && 0); default: - assert("not implemented yet" && 0); + HDassert("not implemented yet" && 0); } break; default: - assert("not implemented yet" && 0); + HDassert("not implemented yet" && 0); } break; } /* end switch */ @@ -4633,7 +4633,7 @@ H5T_path_noop(const H5T_path_t *p) { FUNC_ENTER_NOAPI_NOINIT_NOERR - assert(p); + HDassert(p); FUNC_LEAVE_NOAPI(p->is_noop || (p->is_hard && 0==H5T_cmp(p->src, p->dst, FALSE))) } /* end H5T_path_noop() */ @@ -4702,7 +4702,7 @@ H5T_path_bkg(const H5T_path_t *p) { FUNC_ENTER_NOAPI_NOINIT_NOERR - assert(p); + HDassert(p); FUNC_LEAVE_NOAPI(p->cdata.need_bkg) } /* end H5T_path_bkg() */ @@ -4918,7 +4918,7 @@ H5T_is_immutable(const H5T_t *dt) FUNC_ENTER_NOAPI(FAIL) - assert(dt); + HDassert(dt); if(dt->shared->state == H5T_STATE_IMMUTABLE) ret_value = TRUE; @@ -4951,7 +4951,7 @@ H5T_is_named(const H5T_t *dt) FUNC_ENTER_NOAPI(FAIL) - assert(dt); + HDassert(dt); if(dt->shared->state == H5T_STATE_OPEN || dt->shared->state == H5T_STATE_NAMED) ret_value = TRUE; @@ -4988,7 +4988,7 @@ H5T_get_ref_type(const H5T_t *dt) FUNC_ENTER_NOAPI(H5R_BADTYPE) - assert(dt); + HDassert(dt); if(dt->shared->type==H5T_REFERENCE) ret_value=dt->shared->u.atomic.u.r.rtype; @@ -5022,7 +5022,7 @@ H5T_is_sensible(const H5T_t *dt) FUNC_ENTER_NOAPI(FAIL) - assert(dt); + HDassert(dt); switch(dt->shared->type) { case H5T_COMPOUND: @@ -5087,8 +5087,8 @@ H5T_set_loc(H5T_t *dt, H5F_t *f, H5T_loc_t loc) FUNC_ENTER_NOAPI(FAIL) - assert(dt); - assert(loc>=H5T_LOC_BADLOC && loc=H5T_LOC_BADLOC && locshared->force_conv) { diff --git a/src/H5Tconv.c b/src/H5Tconv.c index b732817..9ff0f00 100644 --- a/src/H5Tconv.c +++ b/src/H5Tconv.c @@ -189,7 +189,7 @@ * to the destination. SLU - 2005/06/29 */ #define H5T_CONV_Xx_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ - if (*(S) > (DT)(D_MAX)) { \ + if (*(S) > (ST)(D_MAX)) { \ H5T_conv_ret_t except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, \ src_id, dst_id, S, D, cb_struct.user_data); \ if(except_ret == H5T_CONV_UNHANDLED) \ @@ -198,7 +198,7 @@ else if(except_ret == H5T_CONV_ABORT) \ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ - } else if (*(S) < (DT)(D_MIN)) { \ + } else if (*(S) < (ST)(D_MIN)) { \ H5T_conv_ret_t except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_LOW, \ src_id, dst_id, S, D, cb_struct.user_data); \ if(except_ret == H5T_CONV_UNHANDLED) \ @@ -211,16 +211,16 @@ *(D) = (DT)(*(S)); \ } #define H5T_CONV_Xx_NOEX_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ - if (*(S) > (DT)(D_MAX)) { \ + if (*(S) > (ST)(D_MAX)) { \ *(D) = (DT)(D_MAX); \ - } else if (*(S) < (DT)(D_MIN)) { \ + } else if (*(S) < (ST)(D_MIN)) { \ *(D) = (DT)(D_MIN); \ } else \ *(D) = (DT)(*(S)); \ } #define H5T_CONV_Ux_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ - if (*(S) > (DT)(D_MAX)) { \ + if (*(S) > (ST)(D_MAX)) { \ H5T_conv_ret_t except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, \ src_id, dst_id, S, D, cb_struct.user_data); \ if(except_ret == H5T_CONV_UNHANDLED) \ @@ -233,7 +233,7 @@ *(D) = (DT)(*(S)); \ } #define H5T_CONV_Ux_NOEX_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ - if (*(S) > (DT)(D_MAX)) { \ + if (*(S) > (ST)(D_MAX)) { \ *(D) = (DT)(D_MAX); \ } else \ *(D) = (DT)(*(S)); \ @@ -241,7 +241,7 @@ #define H5T_CONV_sS(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ HDcompile_assert(sizeof(ST)<=sizeof(DT)); \ - H5T_CONV(H5T_CONV_xX, STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ + H5T_CONV(H5T_CONV_xX, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \ } #define H5T_CONV_sU_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ @@ -266,7 +266,7 @@ #define H5T_CONV_sU(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ HDcompile_assert(sizeof(ST)<=sizeof(DT)); \ - H5T_CONV(H5T_CONV_sU, STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ + H5T_CONV(H5T_CONV_sU, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \ } #define H5T_CONV_uS_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ @@ -283,7 +283,7 @@ *(D) = (DT)(*(S)); \ } #define H5T_CONV_uS_NOEX_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ - if (sizeof(ST)==sizeof(DT) && *(S) > (D_MAX)) { \ + if (sizeof(ST)==sizeof(DT) && *(S) > (DT)(D_MAX)) { \ *(D) = (D_MAX); \ } else \ *(D) = (DT)(*(S)); \ @@ -291,17 +291,17 @@ #define H5T_CONV_uS(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ HDcompile_assert(sizeof(ST)<=sizeof(DT)); \ - H5T_CONV(H5T_CONV_uS, STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ + H5T_CONV(H5T_CONV_uS, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \ } #define H5T_CONV_uU(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ HDcompile_assert(sizeof(ST)<=sizeof(DT)); \ - H5T_CONV(H5T_CONV_xX, STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ + H5T_CONV(H5T_CONV_xX, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \ } #define H5T_CONV_Ss(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ HDcompile_assert(sizeof(ST)>=sizeof(DT)); \ - H5T_CONV(H5T_CONV_Xx, STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ + H5T_CONV(H5T_CONV_Xx, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \ } #define H5T_CONV_Su_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ @@ -314,7 +314,7 @@ else if(except_ret == H5T_CONV_ABORT) \ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ - } else if (sizeof(ST)>sizeof(DT) && *(S) > (DT)(D_MAX)) { \ + } else if (sizeof(ST)>sizeof(DT) && *(S) > (ST)(D_MAX)) { \ H5T_conv_ret_t except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, \ src_id, dst_id, S, D, cb_struct.user_data); \ if(except_ret == H5T_CONV_UNHANDLED) \ @@ -329,7 +329,7 @@ #define H5T_CONV_Su_NOEX_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ if(*(S) < 0) \ *(D) = 0; \ - else if (sizeof(ST)>sizeof(DT) && *(S) > (DT)(D_MAX)) \ + else if (sizeof(ST)>sizeof(DT) && *(S) > (ST)(D_MAX)) \ *(D) = (DT)(D_MAX); \ else \ *(D) = (DT)(*(S)); \ @@ -337,17 +337,17 @@ #define H5T_CONV_Su(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ HDcompile_assert(sizeof(ST)>=sizeof(DT)); \ - H5T_CONV(H5T_CONV_Su, STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ + H5T_CONV(H5T_CONV_Su, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \ } #define H5T_CONV_Us(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ HDcompile_assert(sizeof(ST)>=sizeof(DT)); \ - H5T_CONV(H5T_CONV_Ux, STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ + H5T_CONV(H5T_CONV_Ux, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \ } #define H5T_CONV_Uu(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ HDcompile_assert(sizeof(ST)>=sizeof(DT)); \ - H5T_CONV(H5T_CONV_Ux, STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ + H5T_CONV(H5T_CONV_Ux, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \ } #define H5T_CONV_su_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ @@ -374,12 +374,12 @@ #define H5T_CONV_su(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ HDcompile_assert(sizeof(ST)==sizeof(DT)); \ - H5T_CONV(H5T_CONV_su, STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ + H5T_CONV(H5T_CONV_su, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \ } #define H5T_CONV_us_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ /* Assumes memory format of unsigned & signed integers is same */ \ - if (*(S) > (DT)(D_MAX)) { \ + if (*(S) > (ST)(D_MAX)) { \ H5T_conv_ret_t except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, \ src_id, dst_id, S, D, cb_struct.user_data); \ if(except_ret == H5T_CONV_UNHANDLED) \ @@ -393,7 +393,7 @@ } #define H5T_CONV_us_NOEX_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ /* Assumes memory format of unsigned & signed integers is same */ \ - if(*(S) > (DT)(D_MAX)) \ + if(*(S) > (ST)(D_MAX)) \ *(D) = (DT)(D_MAX); \ else \ *(D) = (DT)(*(S)); \ @@ -401,19 +401,19 @@ #define H5T_CONV_us(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ HDcompile_assert(sizeof(ST)==sizeof(DT)); \ - H5T_CONV(H5T_CONV_us, STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ + H5T_CONV(H5T_CONV_us, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \ } #define H5T_CONV_fF(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ HDcompile_assert(sizeof(ST)<=sizeof(DT)); \ - H5T_CONV(H5T_CONV_xX, STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ + H5T_CONV(H5T_CONV_xX, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \ } /* Same as H5T_CONV_Xx_CORE, except that instead of using D_MAX and D_MIN * when an overflow occurs, use the 'float' infinity values. */ #define H5T_CONV_Ff_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ - if(*(S) > (DT)(D_MAX)) { \ + if(*(S) > (ST)(D_MAX)) { \ H5T_conv_ret_t except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, \ src_id, dst_id, S, D, cb_struct.user_data); \ if(except_ret == H5T_CONV_UNHANDLED) \ @@ -422,7 +422,7 @@ else if(except_ret == H5T_CONV_ABORT) \ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ - } else if (*(S) < (DT)(D_MIN)) { \ + } else if (*(S) < (ST)(D_MIN)) { \ H5T_conv_ret_t except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_LOW, \ src_id, dst_id, S, D, cb_struct.user_data); \ if(except_ret == H5T_CONV_UNHANDLED) \ @@ -435,9 +435,9 @@ *(D) = (DT)(*(S)); \ } #define H5T_CONV_Ff_NOEX_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ - if(*(S) > (DT)(D_MAX)) \ + if(*(S) > (ST)(D_MAX)) \ *(D) = (H5T_NATIVE_FLOAT_POS_INF_g); \ - else if (*(S) < (DT)(D_MIN)) \ + else if (*(S) < (ST)(D_MIN)) \ *(D) = (H5T_NATIVE_FLOAT_NEG_INF_g); \ else \ *(D) = (DT)(*(S)); \ @@ -445,7 +445,7 @@ #define H5T_CONV_Ff(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ HDcompile_assert(sizeof(ST)>=sizeof(DT)); \ - H5T_CONV(H5T_CONV_Ff, STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ + H5T_CONV(H5T_CONV_Ff, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \ } #define H5T_HI_LO_BIT_SET(TYP, V, LO, HI) { \ @@ -455,8 +455,8 @@ \ count = 0; \ for(u = 0; u < sizeof(TYP); u++) { \ - count = ((sizeof(TYP) - 1) - u) * 8; \ - p = ((V) >> count) & 0xff; \ + count = (((unsigned)sizeof(TYP) - 1) - u) * 8; \ + p = (unsigned char)((V) >> count); \ if(p > 0) { \ if(p & 0x80) \ count += 7; \ @@ -480,7 +480,7 @@ \ count = 0; \ for(u = 0; u < sizeof(TYP); u++) { \ - p = ((V) >> (u * 8)) & 0xff; \ + p = (unsigned char)((V) >> (u * 8)); \ if(p > 0) { \ count = u * 8; \ \ @@ -536,7 +536,7 @@ } #define H5T_CONV_xF(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ - H5T_CONV(H5T_CONV_xF, STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ + H5T_CONV(H5T_CONV_xF, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, Y) \ } /* Quincey added the condition branch (else if (*(S) != (ST)((DT)(*(S))))). @@ -544,11 +544,11 @@ * of "INT_MAX". Compilers do roundup making this value "INT_MAX+1". This branch * is to check that situation and return exception for some compilers, mainly GCC. * The branch if (*(S) > (DT)(D_MAX) || (sprec < dprec && *(S) == - * (DT)(D_MAX))) is for some compilers like Sun, HP, IBM, and SGI where under + * (ST)(D_MAX))) is for some compilers like Sun, HP, IBM, and SGI where under * the same situation the "int" doesn't overflow. SLU - 2005/9/12 */ #define H5T_CONV_Fx_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ - if(*(S) > (DT)(D_MAX) || (sprec < dprec && *(S) == (DT)(D_MAX))) { \ + if(*(S) > (ST)(D_MAX) || (sprec < dprec && *(S) == (ST)(D_MAX))) { \ H5T_conv_ret_t except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, \ src_id, dst_id, S, D, cb_struct.user_data); \ if(except_ret == H5T_CONV_UNHANDLED) \ @@ -557,7 +557,7 @@ else if(except_ret == H5T_CONV_ABORT) \ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ - } else if (*(S) < (DT)(D_MIN)) { \ + } else if (*(S) < (ST)(D_MIN)) { \ H5T_conv_ret_t except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_LOW, \ src_id, dst_id, S, D, cb_struct.user_data); \ if(except_ret == H5T_CONV_UNHANDLED) \ @@ -580,28 +580,31 @@ *(D) = (DT)(*(S)); \ } #define H5T_CONV_Fx_NOEX_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ - if(*(S) > (DT)(D_MAX)) \ + if(*(S) > (ST)(D_MAX)) \ *(D) = (DT)(D_MAX); \ - else if(*(S) < (DT)(D_MIN)) \ + else if(*(S) < (ST)(D_MIN)) \ *(D) = (DT)(D_MIN); \ else \ *(D) = (DT)(*(S)); \ } #define H5T_CONV_Fx(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ - H5T_CONV(H5T_CONV_Fx, STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ + H5T_CONV(H5T_CONV_Fx, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, Y) \ } /* Since all "no exception" cores do the same thing (assign the value in the * source location to the destination location, using casting), use one "core" * to do them all. */ +#ifndef H5_WANT_DCONV_EXCEPTION #define H5T_CONV_NO_EXCEPT_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ *(D) = (DT)(*(S)); \ } +#endif /* H5_WANT_DCONV_EXCEPTION */ + /* The main part of every integer hardware conversion macro */ -#define H5T_CONV(GUTS,STYPE,DTYPE,ST,DT,D_MIN,D_MAX) \ +#define H5T_CONV(GUTS,STYPE,DTYPE,ST,DT,D_MIN,D_MAX,PREC) \ { \ herr_t ret_value=SUCCEED; /* Return value */ \ \ @@ -609,13 +612,11 @@ \ { \ size_t elmtno; /*element number */ \ - size_t sprec; /*source precision */ \ - size_t dprec; /*destination precision */ \ + H5T_CONV_DECL_PREC(PREC) /*declare precision variables, or not */ \ uint8_t *src_buf; /*'raw' source buffer */ \ uint8_t *dst_buf; /*'raw' destination buffer */ \ ST *src, *s; /*source buffer */ \ DT *dst, *d; /*destination buffer */ \ - H5T_class_t tclass; /*datatype's class */ \ H5T_t *st, *dt; /*datatype descriptors */ \ ST src_aligned; /*source aligned type */ \ DT dst_aligned; /*destination aligned type */ \ @@ -647,8 +648,8 @@ case H5T_CONV_CONV: \ /* Initialize source & destination strides */ \ if (buf_stride) { \ - assert(buf_stride>=sizeof(ST)); \ - assert(buf_stride>=sizeof(DT)); \ + HDassert(buf_stride >= sizeof(ST)); \ + HDassert(buf_stride >= sizeof(DT)); \ s_stride = d_stride = (ssize_t)buf_stride; \ } else { \ s_stride = sizeof(ST); \ @@ -659,11 +660,11 @@ s_mv = H5T_NATIVE_##STYPE##_ALIGN_g>1 && \ ((size_t)buf%H5T_NATIVE_##STYPE##_ALIGN_g || \ /* Cray */ ((size_t)((ST*)buf)!=(size_t)buf) || \ - s_stride%H5T_NATIVE_##STYPE##_ALIGN_g); \ + (size_t)s_stride%H5T_NATIVE_##STYPE##_ALIGN_g); \ d_mv = H5T_NATIVE_##DTYPE##_ALIGN_g>1 && \ ((size_t)buf%H5T_NATIVE_##DTYPE##_ALIGN_g || \ /* Cray */ ((size_t)((DT*)buf)!=(size_t)buf) || \ - d_stride%H5T_NATIVE_##DTYPE##_ALIGN_g); \ + (size_t)d_stride%H5T_NATIVE_##DTYPE##_ALIGN_g); \ CI_INC_SRC(s_mv) \ CI_INC_DST(d_mv) \ \ @@ -679,19 +680,7 @@ if(NULL == (st = (H5T_t *)H5I_object(src_id)) || NULL == (dt = (H5T_t *)H5I_object(dst_id))) \ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to dereference datatype object ID") \ \ - /* Get source & destination precisions into a variable */ \ - tclass = st->shared->type; \ - HDassert(tclass == H5T_INTEGER || tclass == H5T_FLOAT); \ - if(tclass == H5T_INTEGER) \ - sprec = st->shared->u.atomic.prec; \ - else \ - sprec = 1 + st->shared->u.atomic.u.f.msize; \ - tclass = dt->shared->type; \ - HDassert(tclass == H5T_INTEGER || tclass == H5T_FLOAT); \ - if(tclass == H5T_INTEGER) \ - dprec = dt->shared->u.atomic.prec; \ - else \ - dprec = 1 + dt->shared->u.atomic.u.f.msize; \ + H5T_CONV_SET_PREC(PREC) /*init precision variables, or not */ \ \ /* The outer loop of the type conversion macro, controlling which */ \ /* direction the buffer is walked */ \ @@ -701,21 +690,21 @@ /* Compute the number of "safe" destination elements at */ \ /* the end of the buffer (Those which don't overlap with */ \ /* any source elements at the beginning of the buffer) */ \ - safe=nelmts-(((nelmts*s_stride)+(d_stride-1))/d_stride); \ + safe = nelmts - (((nelmts * (size_t)s_stride) + (size_t)(d_stride - 1)) / (size_t)d_stride); \ \ /* If we're down to the last few elements, just wrap up */ \ /* with a "real" reverse copy */ \ if(safe<2) { \ - src = (ST *)(src_buf = (uint8_t*)buf+(nelmts-1)*s_stride); \ - dst = (DT *)(dst_buf = (uint8_t*)buf+(nelmts-1)*d_stride); \ + src = (ST *)(src_buf = (uint8_t *)buf + (nelmts - 1) * (size_t)s_stride); \ + dst = (DT *)(dst_buf = (uint8_t *)buf + (nelmts - 1) * (size_t)d_stride); \ s_stride = -s_stride; \ d_stride = -d_stride; \ \ safe=nelmts; \ } /* end if */ \ else { \ - src = (ST *)(src_buf = (uint8_t*)buf+(nelmts-safe)*s_stride); \ - dst = (DT *)(dst_buf = (uint8_t*)buf+(nelmts-safe)*d_stride); \ + src = (ST *)(src_buf = (uint8_t *)buf + (nelmts - safe) * (size_t)s_stride); \ + dst = (DT *)(dst_buf = (uint8_t *)buf + (nelmts - safe) * (size_t)d_stride); \ } /* end else */ \ } /* end if */ \ else { \ @@ -757,6 +746,36 @@ done: \ FUNC_LEAVE_NOAPI(ret_value) \ } +/* Declare the source & destination precision variables */ +#define H5T_CONV_DECL_PREC(PREC) H5_GLUE(H5T_CONV_DECL_PREC_, PREC) + +#define H5T_CONV_DECL_PREC_Y \ + size_t sprec; /*source precision */ \ + size_t dprec; /*destination precision */ \ + H5T_class_t tclass; /*datatype's class */ + +#define H5T_CONV_DECL_PREC_N /*no precision variables */ + +/* Initialize the source & destination precision variables */ +#define H5T_CONV_SET_PREC(PREC) H5_GLUE(H5T_CONV_SET_PREC_, PREC) + +#define H5T_CONV_SET_PREC_Y \ + /* Get source & destination precisions into a variable */ \ + tclass = st->shared->type; \ + HDassert(tclass == H5T_INTEGER || tclass == H5T_FLOAT); \ + if(tclass == H5T_INTEGER) \ + sprec = st->shared->u.atomic.prec; \ + else \ + sprec = 1 + st->shared->u.atomic.u.f.msize; \ + tclass = dt->shared->type; \ + HDassert(tclass == H5T_INTEGER || tclass == H5T_FLOAT); \ + if(tclass == H5T_INTEGER) \ + dprec = dt->shared->u.atomic.prec; \ + else \ + dprec = 1 + dt->shared->u.atomic.u.f.msize; + +#define H5T_CONV_SET_PREC_N /*don't init precision variables */ + /* Macro defining action on source data which needs to be aligned (before main action) */ #define H5T_CONV_LOOP_PRE_SALIGN(ST) { \ HDmemcpy(&src_aligned, src, sizeof(ST)); \ @@ -903,7 +922,7 @@ typedef struct H5T_conv_struct_t { /* Conversion data for H5T__conv_enum() */ typedef struct H5T_enum_struct_t { int base; /*lowest `in' value */ - int length; /*num elements in arrays */ + unsigned length; /*num elements in arrays */ int *src2dst; /*map from src to dst index */ } H5T_enum_struct_t; @@ -1085,6 +1104,15 @@ H5T__conv_order_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "conversion not supported") break; + case H5T_NO_CLASS: + case H5T_TIME: + case H5T_STRING: + case H5T_OPAQUE: + case H5T_COMPOUND: + case H5T_ENUM: + case H5T_VLEN: + case H5T_ARRAY: + case H5T_NCLASSES: default: HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "conversion not supported") } @@ -1402,6 +1430,9 @@ H5T__conv_order_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, H5_SWAP_BYTES(buf, 7, 8); } /* end for */ break; + + default: + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "invalid conversion size") } /* end switch */ break; @@ -1487,6 +1518,16 @@ H5T__conv_order(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, } /* end if */ break; + case H5T_NO_CLASS: + case H5T_TIME: + case H5T_STRING: + case H5T_OPAQUE: + case H5T_COMPOUND: + case H5T_REFERENCE: + case H5T_ENUM: + case H5T_VLEN: + case H5T_ARRAY: + case H5T_NCLASSES: default: HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "conversion not supported") } /* end switch */ @@ -1543,7 +1584,7 @@ H5T__conv_b_b(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, { uint8_t *buf = (uint8_t*)_buf; H5T_t *src = NULL, *dst = NULL; /*source and dest datatypes */ - int direction; /*direction of traversal */ + ssize_t direction; /*direction of traversal */ size_t elmtno; /*element number */ size_t olap; /*num overlapping elements */ size_t half_size; /*1/2 of total size for swapping*/ @@ -1620,6 +1661,9 @@ H5T__conv_b_b(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, src_rev = (uint8_t *)H5MM_calloc(src->shared->size); /* The conversion loop */ + H5_CHECK_OVERFLOW(buf_stride, size_t, ssize_t); + H5_CHECK_OVERFLOW(src->shared->size, size_t, ssize_t); + H5_CHECK_OVERFLOW(dst->shared->size, size_t, ssize_t); for(elmtno = 0; elmtno < nelmts; elmtno++) { /* @@ -1703,6 +1747,9 @@ H5T__conv_b_b(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, H5T__bit_set(d, (size_t)0, dst->shared->u.atomic.offset, TRUE); break; + case H5T_PAD_ERROR: + case H5T_PAD_BACKGROUND: + case H5T_NPAD: default: HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported LSB padding") } /* end switch */ @@ -1715,6 +1762,10 @@ H5T__conv_b_b(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, case H5T_PAD_ONE: H5T__bit_set(d, msb_pad_offset, 8 * dst->shared->size - msb_pad_offset, TRUE); break; + + case H5T_PAD_ERROR: + case H5T_PAD_BACKGROUND: + case H5T_NPAD: default: HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported MSB padding") } /* end switch */ @@ -1739,12 +1790,12 @@ H5T__conv_b_b(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, if(d == dbuf) HDmemcpy(dp, d, dst->shared->size); if(buf_stride) { - sp += direction * buf_stride; - dp += direction * buf_stride; + sp += direction * (ssize_t)buf_stride; /* Note that cast is checked with H5_CHECK_OVERFLOW, above */ + dp += direction * (ssize_t)buf_stride; /* Note that cast is checked with H5_CHECK_OVERFLOW, above */ } /* end if */ else { - sp += direction * src->shared->size; - dp += direction * dst->shared->size; + sp += direction * (ssize_t)src->shared->size; /* Note that cast is checked with H5_CHECK_OVERFLOW, above */ + dp += direction * (ssize_t)dst->shared->size; /* Note that cast is checked with H5_CHECK_OVERFLOW, above */ } /* end else */ } /* end for */ @@ -2062,20 +2113,6 @@ H5T__conv_struct_subset(const H5T_cdata_t *cdata) * Programmer: Robb Matzke * Thursday, January 22, 1998 * - * Modifications: - * Robb Matzke, 1999-06-16 - * Added support for non-zero strides. If BUF_STRIDE is - * non-zero then convert one value at each memory location - * advancing BUF_STRIDE bytes each time; otherwise assume - * both source and destination values are packed. - * - * Robb Matzke, 2000-05-17 - * Added the BKG_STRIDE argument to fix a design bug. If - * BUF_STRIDE and BKG_STRIDE are both non-zero then each - * data element converted will be placed temporarily at a - * multiple of BKG_STRIDE in the BKG buffer; otherwise the - * BKG buffer is assumed to be a packed array of destination - * datatype. *------------------------------------------------------------------------- */ herr_t @@ -2091,7 +2128,8 @@ H5T__conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, H5T_cmemb_t *src_memb = NULL; /*source struct member descript.*/ H5T_cmemb_t *dst_memb = NULL; /*destination struct memb desc. */ size_t offset; /*byte offset wrt struct */ - size_t src_delta; /*source stride */ + ssize_t src_delta; /*source stride */ + ssize_t bkg_delta; /*background stride */ size_t elmtno; unsigned u; /*counters */ int i; /*counters */ @@ -2149,17 +2187,22 @@ H5T__conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * Direction of conversion and striding through background. */ if(buf_stride) { - src_delta = buf_stride; - if(!bkg_stride) - bkg_stride = dst->shared->size; + H5_ASSIGN_OVERFLOW(src_delta, buf_stride, size_t, ssize_t); + if(!bkg_stride) { + H5_ASSIGN_OVERFLOW(bkg_delta, dst->shared->size, size_t, ssize_t); + } /* end if */ + else + H5_ASSIGN_OVERFLOW(bkg_delta, bkg_stride, size_t, ssize_t); } /* end if */ else if(dst->shared->size <= src->shared->size) { - src_delta = src->shared->size; - bkg_stride = dst->shared->size; + H5_ASSIGN_OVERFLOW(src_delta, src->shared->size, size_t, ssize_t); + H5_ASSIGN_OVERFLOW(bkg_delta, dst->shared->size, size_t, ssize_t); } /* end else-if */ else { - src_delta = -(int)src->shared->size; /*overflow shouldn't be possible*/ - bkg_stride = -(int)dst->shared->size; /*overflow shouldn't be possible*/ + H5_CHECK_OVERFLOW(src->shared->size, size_t, ssize_t); + src_delta = -(ssize_t)src->shared->size; + H5_CHECK_OVERFLOW(dst->shared->size, size_t, ssize_t); + bkg_delta = -(ssize_t)dst->shared->size; xbuf += (nelmts - 1) * src->shared->size; xbkg += (nelmts - 1) * dst->shared->size; } /* end else */ @@ -2204,7 +2247,8 @@ H5T__conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * yet). Then copy the member to the destination offset in the * background buffer. */ - for(i = src->shared->u.compnd.nmembs - 1; i >= 0; --i) { + H5_CHECK_OVERFLOW(src->shared->u.compnd.nmembs, size_t, int); + for(i = (int)src->shared->u.compnd.nmembs - 1; i >= 0; --i) { if(src2dst[i] < 0) continue; /*subsetting*/ src_memb = src->shared->u.compnd.memb + i; @@ -2229,12 +2273,12 @@ H5T__conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * Update pointers */ xbuf += src_delta; - xbkg += bkg_stride; + xbkg += bkg_delta; } /* end for */ - /* If the bkg_stride was set to -(dst->shared->size), make it positive now */ + /* If the bkg_delta was set to -(dst->shared->size), make it positive now */ if(buf_stride == 0 && dst->shared->size > src->shared->size) - bkg_stride = dst->shared->size; + H5_ASSIGN_OVERFLOW(bkg_delta, dst->shared->size, size_t, ssize_t); /* * Copy the background buffer back into the in-place conversion @@ -2243,7 +2287,7 @@ H5T__conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, for(xbuf = buf, xbkg = bkg, elmtno = 0; elmtno < nelmts; elmtno++) { HDmemmove(xbuf, xbkg, dst->shared->size); xbuf += buf_stride ? buf_stride : dst->shared->size; - xbkg += bkg_stride; + xbkg += bkg_delta; } /* end for */ break; @@ -2390,7 +2434,8 @@ H5T__conv_struct_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, if(dst_memb->size > src_memb->size) offset += src_memb->size; } /* end for */ - for(i = src->shared->u.compnd.nmembs - 1; i >= 0; --i) { + H5_CHECK_OVERFLOW(src->shared->u.compnd.nmembs, size_t, int); + for(i = (int)src->shared->u.compnd.nmembs - 1; i >= 0; --i) { if(src2dst[i] < 0) continue; src_memb = src->shared->u.compnd.memb + i; @@ -2509,7 +2554,8 @@ H5T__conv_struct_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * is larger than the source) and them to their final position in the * bkg buffer. */ - for(i = src->shared->u.compnd.nmembs - 1; i >= 0; --i) { + H5_CHECK_OVERFLOW(src->shared->u.compnd.nmembs, size_t, int); + for(i = (int)src->shared->u.compnd.nmembs - 1; i >= 0; --i) { if(src2dst[i] < 0) continue; src_memb = src->shared->u.compnd.memb + i; @@ -2605,7 +2651,7 @@ H5T_conv_enum_init(H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata) j++; if(j >= dst->shared->u.enumer.nmembs) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "source type is not a subset of destination type") - priv->src2dst[i] = j; + priv->src2dst[i] = (int)j; } /* end for */ /* @@ -2634,45 +2680,44 @@ H5T_conv_enum_init(H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata) * Because this is the optimized code, we won't fix it. It should still work in some * situations. SLU - 2011/5/24) */ - if (1==src->shared->size || sizeof(short)==src->shared->size || sizeof(int)==src->shared->size) { - for (i=0; ishared->u.enumer.nmembs; i++) { - if (1==src->shared->size) { - n = *((signed char*)(src->shared->u.enumer.value+i)); - } else if (sizeof(short)==src->shared->size) { - n = *((short*)(src->shared->u.enumer.value+i*src->shared->size)); - } else { - n = *((int*)(src->shared->u.enumer.value+i*src->shared->size)); - } - if (0==i) { + if(1 == src->shared->size || sizeof(short) == src->shared->size || sizeof(int) == src->shared->size) { + for(i = 0; i < src->shared->u.enumer.nmembs; i++) { + if(1 == src->shared->size) + n = *((signed char *)(src->shared->u.enumer.value + i)); + else if (sizeof(short) == src->shared->size) + n = *((short *)(src->shared->u.enumer.value + i * src->shared->size)); + else + n = *((int *)(src->shared->u.enumer.value + i * src->shared->size)); + if(0 == i) { domain[0] = domain[1] = n; } else { domain[0] = MIN(domain[0], n); domain[1] = MAX(domain[1], n); } - } + } /* end for */ - length = (domain[1]-domain[0])+1; - if (src->shared->u.enumer.nmembs<2 || - (double)length/src->shared->u.enumer.nmembs<1.2) { + HDassert(domain[1] >= domain[0]); + length = (unsigned)(domain[1] - domain[0]) + 1; + if(src->shared->u.enumer.nmembs < 2 || + (double)length / src->shared->u.enumer.nmembs < (double)(1.2f)) { priv->base = domain[0]; priv->length = length; - if (NULL==(map=(int *)H5MM_malloc(length*sizeof(int)))) + if(NULL == (map = (int *)H5MM_malloc(length * sizeof(int)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - for (i=0; ishared->u.enumer.nmembs; i++) { - if (1==src->shared->size) { - n = *((signed char*)(src->shared->u.enumer.value+i)); - } else if (sizeof(short)==src->shared->size) { - n = *((short*)(src->shared->u.enumer.value+i*src->shared->size)); - } else { - n = *((int*)(src->shared->u.enumer.value+i*src->shared->size)); - } + for(i = 0; i < src->shared->u.enumer.nmembs; i++) { + if(1 == src->shared->size) + n = *((signed char *)(src->shared->u.enumer.value + i)); + else if(sizeof(short) == src->shared->size) + n = *((short *)(src->shared->u.enumer.value + i * src->shared->size)); + else + n = *((int *)(src->shared->u.enumer.value + i * src->shared->size)); n -= priv->base; - assert(n>=0 && nlength); - assert(map[n]<0); + HDassert(n >= 0 && (unsigned)n < priv->length); + HDassert(map[n] < 0); map[n] = priv->src2dst[i]; - } + } /* end for */ /* * Replace original src2dst array with our new one. The original @@ -2718,9 +2763,8 @@ H5T__conv_enum(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, { uint8_t *buf = (uint8_t*)_buf; /*cast for pointer arithmetic */ H5T_t *src = NULL, *dst = NULL; /*src and dst datatypes */ - H5T_t *src_super = NULL, *dst_super = NULL; /*parent types for src and dst*/ uint8_t *s = NULL, *d = NULL; /*src and dst BUF pointers */ - int src_delta, dst_delta; /*conversion strides */ + ssize_t src_delta, dst_delta; /*conversion strides */ int n; /*src value cast as native int */ H5T_enum_struct_t *priv = (H5T_enum_struct_t*)(cdata->priv); H5P_genplist_t *plist; /*property list pointer */ @@ -2785,17 +2829,20 @@ H5T__conv_enum(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * Direction of conversion. */ if(buf_stride) { - src_delta = dst_delta = (int)buf_stride; + H5_CHECK_OVERFLOW(buf_stride, size_t, ssize_t); + src_delta = dst_delta = (ssize_t)buf_stride; s = d = buf; } else if(dst->shared->size <= src->shared->size) { - src_delta = (int)src->shared->size; /*overflow shouldn't be possible*/ - dst_delta = (int)dst->shared->size; /*overflow shouldn't be possible*/ + H5_ASSIGN_OVERFLOW(src_delta, src->shared->size, size_t, ssize_t); + H5_ASSIGN_OVERFLOW(dst_delta, dst->shared->size, size_t, ssize_t); s = d = buf; } else { - src_delta = -(int)src->shared->size; /*overflow shouldn't be possible*/ - dst_delta = -(int)dst->shared->size; /*overflow shouldn't be possible*/ - s = buf + (nelmts-1) * src->shared->size; - d = buf + (nelmts-1) * dst->shared->size; + H5_CHECK_OVERFLOW(src->shared->size, size_t, ssize_t); + H5_CHECK_OVERFLOW(dst->shared->size, size_t, ssize_t); + src_delta = -(ssize_t)src->shared->size; + dst_delta = -(ssize_t)dst->shared->size; + s = buf + (nelmts - 1) * src->shared->size; + d = buf + (nelmts - 1) * dst->shared->size; } /* Get the plist structure */ @@ -2822,28 +2869,29 @@ H5T__conv_enum(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, else n = *((int*)s); n -= priv->base; - if(n < 0 || n >= priv->length || priv->src2dst[n] < 0) { + if(n < 0 || (unsigned)n >= priv->length || priv->src2dst[n] < 0) { /*overflow*/ except_ret = H5T_CONV_UNHANDLED; - if(cb_struct.func) { /*If user's exception handler is present, use it*/ + /*If user's exception handler is present, use it*/ + if(cb_struct.func) except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, s, d, cb_struct.user_data); - } - if(except_ret == H5T_CONV_UNHANDLED) { + if(except_ret == H5T_CONV_UNHANDLED) HDmemset(d, 0xff, dst->shared->size); - } else if(except_ret == H5T_CONV_ABORT) + else if(except_ret == H5T_CONV_ABORT) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") - } else { + } else HDmemcpy(d, - dst->shared->u.enumer.value+priv->src2dst[n]*dst->shared->size, + dst->shared->u.enumer.value + (unsigned)priv->src2dst[n] * dst->shared->size, dst->shared->size); - } - } else { + } /* end if */ + else { /* Use O(log N) lookup */ - int lt = 0; - int rt = src->shared->u.enumer.nmembs; - int md, cmp; + unsigned lt = 0; + unsigned rt = src->shared->u.enumer.nmembs; + unsigned md; + int cmp; while(lt < rt) { md = (lt + rt) / 2; @@ -2858,22 +2906,23 @@ H5T__conv_enum(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, } /* end while */ if(lt >= rt) { except_ret = H5T_CONV_UNHANDLED; - if(cb_struct.func) { /*If user's exception handler is present, use it*/ + /*If user's exception handler is present, use it*/ + if(cb_struct.func) except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, src, d, cb_struct.user_data); - } - if(except_ret == H5T_CONV_UNHANDLED) { + if(except_ret == H5T_CONV_UNHANDLED) HDmemset(d, 0xff, dst->shared->size); - } else if(except_ret == H5T_CONV_ABORT) + else if(except_ret == H5T_CONV_ABORT) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") } /* end if */ else { + HDassert(priv->src2dst[md] >= 0); HDmemcpy(d, - dst->shared->u.enumer.value+priv->src2dst[md]*dst->shared->size, + dst->shared->u.enumer.value + (unsigned)priv->src2dst[md] * dst->shared->size, dst->shared->size); } /* end else */ - } + } /* end else */ } break; @@ -2906,7 +2955,7 @@ done: */ herr_t H5T__conv_enum_numeric(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t UNUSED bkg_stride, void *_buf, + size_t UNUSED buf_stride, size_t UNUSED bkg_stride, void *_buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { H5T_t *src, *dst; /*src and dst datatypes */ @@ -3017,7 +3066,7 @@ H5T__conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, H5T_path_t *tpath = NULL; /* Type conversion path */ hbool_t noop_conv = FALSE; /* Flag to indicate a noop conversion */ hbool_t write_to_file = FALSE; /* Flag to indicate writing to file */ - hbool_t parent_is_vlen; /* Flag to indicate parent is vlen datatyp */ + htri_t parent_is_vlen; /* Flag to indicate parent is vlen datatyp */ hid_t tsrc_id = -1, tdst_id = -1;/*temporary type atoms */ H5T_t *src = NULL; /*source datatype */ H5T_t *dst = NULL; /*destination datatype */ @@ -3028,7 +3077,6 @@ H5T__conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, ssize_t s_stride, d_stride; /*src and dst strides */ ssize_t b_stride; /*bkg stride */ size_t safe; /*how many elements are safe to process in each pass */ - ssize_t seq_len; /*the number of elements in the current sequence*/ size_t bg_seq_len = 0; size_t src_base_size, dst_base_size;/*source & destination base size*/ void *conv_buf = NULL; /*temporary conversion buffer */ @@ -3116,12 +3164,13 @@ H5T__conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, noop_conv = TRUE; /* Check if we need a temporary buffer for this conversion */ - parent_is_vlen = H5T_detect_class(dst->shared->parent, H5T_VLEN, FALSE); + if((parent_is_vlen = H5T_detect_class(dst->shared->parent, H5T_VLEN, FALSE)) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_SYSTEM, FAIL, "internal error when detecting variable-length class") if(tpath->cdata.need_bkg || parent_is_vlen) { /* Set up initial background buffer */ tmp_buf_size = MAX(src_base_size, dst_base_size); if(NULL == (tmp_buf = H5FL_BLK_CALLOC(vlen_seq,tmp_buf_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion") + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "memory allocation failed for type conversion") } /* end if */ /* Get the allocation info */ @@ -3141,17 +3190,22 @@ H5T__conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, while(nelmts > 0) { /* Check if we need to go backwards through the buffer */ if(d_stride > s_stride) { + /* Sanity check */ + HDassert(s_stride > 0); + HDassert(d_stride > 0); + HDassert(b_stride >= 0); + /* Compute the number of "safe" destination elements at */ /* the end of the buffer (Those which don't overlap with */ /* any source elements at the beginning of the buffer) */ - safe = nelmts - (((nelmts * s_stride) + (d_stride - 1)) / d_stride); + safe = nelmts - (((nelmts * (size_t)s_stride) + ((size_t)d_stride - 1)) / (size_t)d_stride); /* If we're down to the last few elements, just wrap up */ /* with a "real" reverse copy */ if(safe < 2) { - s = (uint8_t *)buf + (nelmts - 1) * s_stride; - d = (uint8_t *)buf + (nelmts - 1) * d_stride; - b = (uint8_t *)bkg + (nelmts - 1) * b_stride; + s = (uint8_t *)buf + (nelmts - 1) * (size_t)s_stride; + d = (uint8_t *)buf + (nelmts - 1) * (size_t)d_stride; + b = (uint8_t *)bkg + (nelmts - 1) * (size_t)b_stride; s_stride = -s_stride; d_stride = -d_stride; b_stride = -b_stride; @@ -3159,9 +3213,9 @@ H5T__conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, safe = nelmts; } /* end if */ else { - s = (uint8_t *)buf + (nelmts - safe) * s_stride; - d = (uint8_t *)buf + (nelmts - safe) * d_stride; - b = (uint8_t *)bkg + (nelmts - safe) * b_stride; + s = (uint8_t *)buf + (nelmts - safe) * (size_t)s_stride; + d = (uint8_t *)buf + (nelmts - safe) * (size_t)d_stride; + b = (uint8_t *)bkg + (nelmts - safe) * (size_t)b_stride; } /* end else */ } /* end if */ else { @@ -3179,9 +3233,13 @@ H5T__conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, HGOTO_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL, "can't set VL data to 'nil'") } /* end if */ else { + ssize_t sseq_len; /* (signed) The number of elements in the current sequence*/ + size_t seq_len; /* The number of elements in the current sequence*/ + /* Get length of element sequences */ - if((seq_len = (*(src->shared->u.vlen.getlen))(s)) < 0) + if((sseq_len = (*(src->shared->u.vlen.getlen))(s)) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "incorrect length") + seq_len = (size_t)sseq_len; /* If we are reading from memory and there is no conversion, just get the pointer to sequence */ if(write_to_file && noop_conv) { @@ -3230,7 +3288,7 @@ H5T__conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, /* If we are writing and there is a nested VL type, read * the sequence into the background buffer */ if(nested) { - uint8_t *tmp = b; + const uint8_t *tmp = b; UINT32DECODE(tmp, bg_seq_len); if(bg_seq_len > 0) { @@ -3240,40 +3298,40 @@ H5T__conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion") HDmemset(tmp_buf, 0, tmp_buf_size); } /* end if */ - H5F_addr_decode(dst->shared->u.vlen.f, (const uint8_t **)&tmp, &(bg_hobjid.addr)); - INT32DECODE(tmp, bg_hobjid.idx); + H5F_addr_decode(dst->shared->u.vlen.f, &tmp, &(bg_hobjid.addr)); + UINT32DECODE(tmp, bg_hobjid.idx); if(NULL == H5HG_read(dst->shared->u.vlen.f, dxpl_id, &bg_hobjid, tmp_buf, NULL)) HGOTO_ERROR(H5E_DATATYPE, H5E_READERROR, FAIL, "can't read VL sequence into background buffer") } /* end if */ /* If the sequence gets shorter, pad out the original sequence with zeros */ - if((ssize_t)bg_seq_len < seq_len) + if(bg_seq_len < seq_len) HDmemset((uint8_t *)tmp_buf + dst_base_size * bg_seq_len, 0, (seq_len - bg_seq_len) * dst_base_size); } /* end if */ /* Convert VL sequence */ - if(H5T_convert(tpath, tsrc_id, tdst_id, (size_t)seq_len, (size_t)0, (size_t)0, conv_buf, tmp_buf, dxpl_id) < 0) + if(H5T_convert(tpath, tsrc_id, tdst_id, seq_len, (size_t)0, (size_t)0, conv_buf, tmp_buf, dxpl_id) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "datatype conversion failed") } /* end if */ /* Write sequence to destination location */ - if((*(dst->shared->u.vlen.write))(dst->shared->u.vlen.f, dxpl_id, vl_alloc_info, d, conv_buf, b, (size_t)seq_len, dst_base_size) < 0) + if((*(dst->shared->u.vlen.write))(dst->shared->u.vlen.f, dxpl_id, vl_alloc_info, d, conv_buf, b, seq_len, dst_base_size) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL, "can't write VL data") if(!noop_conv) { /* For nested VL case, free leftover heap objects from the deeper level if the length of new data elements is shorter than the old data elements.*/ - if(nested && seq_len < (ssize_t)bg_seq_len) { + if(nested && seq_len < bg_seq_len) { size_t parent_seq_len; - uint8_t *tmp_p; + const uint8_t *tmp; size_t u; /* TMP_P is reset each time in the loop because DST_BASE_SIZE may include some data in addition to VL info. - SLU */ for(u = seq_len; u < bg_seq_len; u++) { - tmp_p = (uint8_t*)tmp_buf + u * dst_base_size; - UINT32DECODE(tmp_p, parent_seq_len); + tmp = (uint8_t *)tmp_buf + u * dst_base_size; + UINT32DECODE(tmp, parent_seq_len); if(parent_seq_len > 0) { - H5F_addr_decode(dst->shared->u.vlen.f, (const uint8_t **)&tmp_p, &(parent_hobjid.addr)); - INT32DECODE(tmp_p, parent_hobjid.idx); + H5F_addr_decode(dst->shared->u.vlen.f, &tmp, &(parent_hobjid.addr)); + UINT32DECODE(tmp, parent_hobjid.idx); if(H5HG_remove(dst->shared->u.vlen.f, dxpl_id, &parent_hobjid) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL, "Unable to remove heap object") } /* end if */ @@ -3343,7 +3401,7 @@ H5T__conv_array(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, H5T_t *src = NULL; /*source datatype */ H5T_t *dst = NULL; /*destination datatype */ uint8_t *sp, *dp; /*source and dest traversal ptrs */ - size_t src_delta, dst_delta; /*source & destination stride */ + ssize_t src_delta, dst_delta; /*source & destination stride */ int direction; /*direction of traversal */ size_t elmtno; /*element number counter */ unsigned u; /* local index variable */ @@ -3408,8 +3466,11 @@ H5T__conv_array(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, /* * Direction & size of buffer traversal. */ - src_delta = direction * (buf_stride ? buf_stride : src->shared->size); - dst_delta = direction * (buf_stride ? buf_stride : dst->shared->size); + H5_CHECK_OVERFLOW(buf_stride, size_t, ssize_t); + H5_CHECK_OVERFLOW(src->shared->size, size_t, ssize_t); + H5_CHECK_OVERFLOW(dst->shared->size, size_t, ssize_t); + src_delta = (ssize_t)direction * (ssize_t)(buf_stride ? buf_stride : src->shared->size); + dst_delta = (ssize_t)direction * (ssize_t)(buf_stride ? buf_stride : dst->shared->size); /* Set up conversion path for base elements */ if(NULL == (tpath = H5T_path_find(src->shared->parent, dst->shared->parent, NULL, NULL, dxpl_id, FALSE))) { @@ -3499,6 +3560,7 @@ H5T__conv_i_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, { H5T_t *src = NULL; /*source datatype */ H5T_t *dst = NULL; /*destination datatype */ + ssize_t src_delta, dst_delta; /*source & destination stride */ int direction; /*direction of traversal */ size_t elmtno; /*element number */ size_t half_size; /*half the type size */ @@ -3563,6 +3625,15 @@ H5T__conv_i_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, direction = -1; } + /* + * Direction & size of buffer traversal. + */ + H5_CHECK_OVERFLOW(buf_stride, size_t, ssize_t); + H5_CHECK_OVERFLOW(src->shared->size, size_t, ssize_t); + H5_CHECK_OVERFLOW(dst->shared->size, size_t, ssize_t); + src_delta = (ssize_t)direction * (ssize_t)(buf_stride ? buf_stride : src->shared->size); + dst_delta = (ssize_t)direction * (ssize_t)(buf_stride ? buf_stride : dst->shared->size); + /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(dxpl_id, H5P_DATASET_XFER))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find property list for ID") @@ -3575,25 +3646,25 @@ H5T__conv_i_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, src_rev = (uint8_t*)H5MM_calloc(src->shared->size); /* The conversion loop */ - for (elmtno=0; elmtno0) { + if(direction > 0) { s = sp; - d = elmtno= nelmts ? dbuf : dp; + d = elmtno + olap >= nelmts ? dbuf : dp; } #ifndef NDEBUG /* I don't quite trust the overlap calculations yet --rpm */ if (d==dbuf) { - assert ((dp>=sp && dpshared->size) || (sp>=dp && spshared->size)); + HDassert((dp>=sp && dpshared->size) || (sp>=dp && spshared->size)); } else { - assert ((dpshared->size<=sp) || (spshared->size<=dp)); + HDassert((dpshared->size<=sp) || (spshared->size<=dp)); } #endif @@ -3817,11 +3888,11 @@ H5T__conv_i_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * Set padding areas in destination. */ if (dst->shared->u.atomic.offset>0) { - assert(H5T_PAD_ZERO==dst->shared->u.atomic.lsb_pad || H5T_PAD_ONE==dst->shared->u.atomic.lsb_pad); + HDassert(H5T_PAD_ZERO==dst->shared->u.atomic.lsb_pad || H5T_PAD_ONE==dst->shared->u.atomic.lsb_pad); H5T__bit_set(d, (size_t)0, dst->shared->u.atomic.offset, (hbool_t)(H5T_PAD_ONE==dst->shared->u.atomic.lsb_pad)); } if (dst->shared->u.atomic.offset+dst->shared->u.atomic.prec!=8*dst->shared->size) { - assert (H5T_PAD_ZERO==dst->shared->u.atomic.msb_pad || H5T_PAD_ONE==dst->shared->u.atomic.msb_pad); + HDassert(H5T_PAD_ZERO==dst->shared->u.atomic.msb_pad || H5T_PAD_ONE==dst->shared->u.atomic.msb_pad); H5T__bit_set (d, dst->shared->u.atomic.offset+dst->shared->u.atomic.prec, 8*dst->shared->size - (dst->shared->u.atomic.offset+ dst->shared->u.atomic.prec), (hbool_t)(H5T_PAD_ONE==dst->shared->u.atomic.msb_pad)); @@ -3844,16 +3915,13 @@ H5T__conv_i_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * If we had used a temporary buffer for the destination then we * should copy the value to the true destination buffer. */ - if (d==dbuf) - HDmemcpy (dp, d, dst->shared->size); - if (buf_stride) { - sp += direction * buf_stride; - dp += direction * buf_stride; - } else { - sp += direction * src->shared->size; - dp += direction * dst->shared->size; - } - } + if(d==dbuf) + HDmemcpy(dp, d, dst->shared->size); + + /* Advance source & destination pointers by delta amounts */ + sp += src_delta; + dp += dst_delta; + } /* end for */ break; @@ -3909,6 +3977,7 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, H5T_t *dst_p; /*destination datatype */ H5T_atomic_t src; /*atomic source info */ H5T_atomic_t dst; /*atomic destination info */ + ssize_t src_delta, dst_delta; /*source & destination stride */ int direction; /*forward or backward traversal */ size_t elmtno; /*element number */ size_t half_size; /*half the type size */ @@ -3921,11 +3990,11 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, uint8_t tmp1, tmp2; /*temp variables for swapping bytes*/ /* Conversion-related variables */ - hssize_t expo; /*exponent */ + int64_t expo; /*exponent */ hssize_t expo_max; /*maximum possible dst exponent */ size_t msize = 0; /*useful size of mantissa in src*/ size_t mpos; /*offset to useful mant is src */ - hssize_t sign; /*source sign bit value */ + uint64_t sign; /*source sign bit value */ size_t mrsh; /*amount to right shift mantissa*/ hbool_t carry = 0; /*carry after rounding mantissa */ size_t i; /*miscellaneous counters */ @@ -3991,6 +4060,15 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, direction = -1; } + /* + * Direction & size of buffer traversal. + */ + H5_CHECK_OVERFLOW(buf_stride, size_t, ssize_t); + H5_CHECK_OVERFLOW(src_p->shared->size, size_t, ssize_t); + H5_CHECK_OVERFLOW(dst_p->shared->size, size_t, ssize_t); + src_delta = (ssize_t)direction * (ssize_t)(buf_stride ? buf_stride : src_p->shared->size); + dst_delta = (ssize_t)direction * (ssize_t)(buf_stride ? buf_stride : dst_p->shared->size); + /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(dxpl_id,H5P_DATASET_XFER))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find property list for ID") @@ -4022,10 +4100,10 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, #ifndef NDEBUG /* I don't quite trust the overlap calculations yet --rpm */ if (d==dbuf) { - assert ((dp>=sp && dpshared->size) || + HDassert((dp>=sp && dpshared->size) || (sp>=dp && spshared->size)); } else { - assert ((dpshared->size<=sp) || + HDassert((dpshared->size<=sp) || (spshared->size<=dp)); } #endif @@ -4044,7 +4122,7 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, } } else if (H5T_ORDER_VAX==src.order) { tsize = src_p->shared->size; - assert(0 == tsize % 2); + HDassert(0 == tsize % 2); for (i = 0; i < tsize; i += 4) { tmp1 = s[i]; @@ -4142,9 +4220,7 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") goto padding; -#ifdef H5_VMS - } /*Temporary solution to handle VAX special values*/ -#else /*H5_VMS*/ +#ifndef H5_VMS /*Temporary solution to handle VAX special values*/ } else if (H5T__bit_find (s, src.u.f.epos, src.u.f.esize, H5T_BIT_LSB, FALSE)<0) { /* NaN */ @@ -4169,15 +4245,15 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") goto padding; - } #endif /*H5_VMS*/ + } /* * Get the exponent as an unsigned quantity from the section of * the source bit field where it's located. Don't worry about * the exponent bias yet. */ - expo = H5T__bit_get_d(s, src.u.f.epos, src.u.f.esize); + expo = (int64_t)H5T__bit_get_d(s, src.u.f.epos, src.u.f.esize); if(expo==0) denormalized=TRUE; @@ -4189,10 +4265,9 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, implied = 1; mpos = src.u.f.mpos; mrsh = 0; - if (0==expo || H5T_NORM_NONE==src.u.f.norm) { - if ((bitno=H5T__bit_find(s, src.u.f.mpos, src.u.f.msize, - H5T_BIT_MSB, TRUE))>0) { - msize = bitno; + if(0 == expo || H5T_NORM_NONE == src.u.f.norm) { + if((bitno = H5T__bit_find(s, src.u.f.mpos, src.u.f.msize, H5T_BIT_MSB, TRUE)) > 0) { + msize = (size_t)bitno; } else if (0==bitno) { msize = 1; H5T__bit_set(s, src.u.f.mpos, (size_t)1, FALSE); @@ -4200,8 +4275,7 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, } else if (H5T_NORM_IMPLIED==src.u.f.norm) { msize = src.u.f.msize; } else { - assert("normalization method not implemented yet" && 0); - HDabort(); + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "normalization method not implemented yet") } /* @@ -4215,13 +4289,12 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * the source exponent bias. */ if (0==expo || H5T_NORM_NONE==src.u.f.norm) { - assert(bitno>=0); - expo -= (src.u.f.ebias-1) + (src.u.f.msize-bitno); + HDassert(bitno>=0); + expo -= (int64_t)((src.u.f.ebias - 1) + (src.u.f.msize - (size_t)bitno)); } else if (H5T_NORM_IMPLIED==src.u.f.norm) { - expo -= src.u.f.ebias; + expo -= (int64_t)src.u.f.ebias; } else { - assert("normalization method not implemented yet" && 0); - HDabort(); + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "normalization method not implemented yet") } /* @@ -4236,7 +4309,7 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * bias and clipping by the minimum and maximum possible * destination exponent values. */ - expo += dst.u.f.ebias; + expo += (int64_t)dst.u.f.ebias; if (expo < -(hssize_t)(dst.u.f.msize)) { /* The exponent is way too small. Result is zero. */ @@ -4250,7 +4323,7 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * accomodate that value. The mantissa of course is no * longer normalized. */ - H5_ASSIGN_OVERFLOW(mrsh,(mrsh+1-expo),hssize_t,size_t); + mrsh += (size_t)(1 - expo); expo = 0; denormalized=TRUE; } else if (expo>=expo_max) { @@ -4289,20 +4362,20 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * mantissa bit is `1', else it is `10' binary. */ if (msize>0 && mrsh<=dst.u.f.msize && mrsh+msize>dst.u.f.msize) { - bitno = (ssize_t)(mrsh+msize - dst.u.f.msize); - assert(bitno>=0 && (size_t)bitno<=msize); - /*If the 1st bit being cut off is set and source isn't denormalized.*/ - if(H5T__bit_get_d(s, (mpos + bitno) - 1, (size_t)1) && !denormalized) { - /*Don't do rounding if exponent is 111...110 and mantissa is 111...11. - *To do rounding and increment exponent in this case will create an infinity value.*/ - if((H5T__bit_find(s, mpos+bitno, msize-bitno, H5T_BIT_LSB, FALSE)>=0 || expo= 0 && (size_t)bitno <= msize); + /* If the 1st bit being cut off is set and source isn't denormalized.*/ + if(H5T__bit_get_d(s, (mpos + (size_t)bitno) - 1, (size_t)1) && !denormalized) { + /* Don't do rounding if exponent is 111...110 and mantissa is 111...11. + * To do rounding and increment exponent in this case will create an infinity value.*/ + if((H5T__bit_find(s, mpos + (size_t)bitno, msize - (size_t)bitno, H5T_BIT_LSB, FALSE) >= 0 || expo < expo_max - 1)) { + carry = (hbool_t)H5T__bit_inc(s, mpos + (size_t)bitno - 1, 1 + msize - (size_t)bitno); + if(carry) implied = 2; } - } else if(H5T__bit_get_d(s, (mpos + bitno) - 1, (size_t)1) && denormalized) - /*For either source or destination, denormalized value doesn't increment carry.*/ - H5T__bit_inc(s, mpos+bitno-1, 1+msize-bitno); + } else if(H5T__bit_get_d(s, (mpos + (size_t)bitno) - 1, (size_t)1) && denormalized) + /* For either source or destination, denormalized value doesn't increment carry.*/ + H5T__bit_inc(s, mpos + (size_t)bitno - 1, 1 + msize - (size_t)bitno); } else carry=0; @@ -4379,11 +4452,11 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * Set external padding areas */ if (dst.offset>0) { - assert (H5T_PAD_ZERO==dst.lsb_pad || H5T_PAD_ONE==dst.lsb_pad); + HDassert(H5T_PAD_ZERO==dst.lsb_pad || H5T_PAD_ONE==dst.lsb_pad); H5T__bit_set (d, (size_t)0, dst.offset, (hbool_t)(H5T_PAD_ONE==dst.lsb_pad)); } if (dst.offset+dst.prec!=8*dst_p->shared->size) { - assert (H5T_PAD_ZERO==dst.msb_pad || H5T_PAD_ONE==dst.msb_pad); + HDassert(H5T_PAD_ZERO==dst.msb_pad || H5T_PAD_ONE==dst.msb_pad); H5T__bit_set (d, dst.offset+dst.prec, 8*dst_p->shared->size - (dst.offset+dst.prec), (hbool_t)(H5T_PAD_ONE==dst.msb_pad)); } @@ -4401,7 +4474,7 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, } } else if (H5T_ORDER_VAX==dst.order && reverse) { tsize = dst_p->shared->size; - assert(0 == tsize % 2); + HDassert(0 == tsize % 2); for (i = 0; i < tsize; i += 4) { tmp1 = d[i]; @@ -4420,15 +4493,12 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * should copy the value to the true destination buffer. */ next: - if (d==dbuf) - HDmemcpy (dp, d, dst_p->shared->size); - if (buf_stride) { - sp += direction * buf_stride; - dp += direction * buf_stride; - } else { - sp += direction * src_p->shared->size; - dp += direction * dst_p->shared->size; - } + if(d == dbuf) + HDmemcpy(dp, d, dst_p->shared->size); + + /* Advance source & destination pointers by delta amounts */ + sp += src_delta; + dp += dst_delta; } break; @@ -4474,7 +4544,8 @@ H5T__conv_s_s(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, { H5T_t *src=NULL; /*source datatype */ H5T_t *dst=NULL; /*destination datatype */ - int direction; /*direction of traversal */ + ssize_t src_delta, dst_delta; /*source & destination stride */ + int direction; /*direction of traversal */ size_t elmtno; /*element number */ size_t olap; /*num overlapping elements */ size_t nchars=0; /*number of characters copied */ @@ -4499,8 +4570,8 @@ H5T__conv_s_s(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, if((H5T_CSET_ASCII == src->shared->u.atomic.u.s.cset && H5T_CSET_UTF8 == dst->shared->u.atomic.u.s.cset) || (H5T_CSET_ASCII == dst->shared->u.atomic.u.s.cset && H5T_CSET_UTF8 == src->shared->u.atomic.u.s.cset)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "The library doesn't convert between strings of ASCII and UTF") - if(src->shared->u.atomic.u.s.pad < 0 || src->shared->u.atomic.u.s.pad >= H5T_NPAD || - dst->shared->u.atomic.u.s.pad < 0 || dst->shared->u.atomic.u.s.pad >= H5T_NPAD) + if(src->shared->u.atomic.u.s.pad < 0 || src->shared->u.atomic.u.s.pad >= H5T_NSTR || + dst->shared->u.atomic.u.s.pad < 0 || dst->shared->u.atomic.u.s.pad >= H5T_NSTR) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad character padding") cdata->need_bkg = H5T_BKG_NO; break; @@ -4541,6 +4612,15 @@ H5T__conv_s_s(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, direction = -1; } + /* + * Direction & size of buffer traversal. + */ + H5_CHECK_OVERFLOW(buf_stride, size_t, ssize_t); + H5_CHECK_OVERFLOW(src->shared->size, size_t, ssize_t); + H5_CHECK_OVERFLOW(dst->shared->size, size_t, ssize_t); + src_delta = (ssize_t)direction * (ssize_t)(buf_stride ? buf_stride : src->shared->size); + dst_delta = (ssize_t)direction * (ssize_t)(buf_stride ? buf_stride : dst->shared->size); + /* Allocate the overlap buffer */ if(NULL == (dbuf = (uint8_t *)H5MM_malloc(dst->shared->size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for string conversion") @@ -4562,12 +4642,12 @@ H5T__conv_s_s(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, #ifndef NDEBUG /* I don't quite trust the overlap calculations yet --rpm */ if (src->shared->size==dst->shared->size || buf_stride) { - assert(s==d); + HDassert(s==d); } else if (d==dbuf) { - assert((dp>=sp && dpshared->size) || + HDassert((dp>=sp && dpshared->size) || (sp>=dp && spshared->size)); } else { - assert((dpshared->size<=sp) || + HDassert((dpshared->size<=sp) || (spshared->size<=dp)); } #endif @@ -4613,6 +4693,7 @@ H5T__conv_s_s(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, case H5T_STR_RESERVED_14: case H5T_STR_RESERVED_15: case H5T_STR_ERROR: + default: HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "source string padding method not supported") } /* end switch */ @@ -4648,6 +4729,7 @@ H5T__conv_s_s(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, case H5T_STR_RESERVED_14: case H5T_STR_RESERVED_15: case H5T_STR_ERROR: + default: HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "destination string padding method not supported") } /* end switch */ @@ -4655,15 +4737,12 @@ H5T__conv_s_s(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * If we used a temporary buffer for the destination then we * should copy the value to the true destination buffer. */ - if (d==dbuf) + if(d == dbuf) HDmemcpy(dp, d, dst->shared->size); - if (buf_stride) { - sp += direction * buf_stride; - dp += direction * buf_stride; - } else { - sp += direction * src->shared->size; - dp += direction * dst->shared->size; - } + + /* Advance source & destination pointers by delta amounts */ + sp += src_delta; + dp += dst_delta; } /* end for */ break; @@ -8865,10 +8944,10 @@ H5T__conv_f_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, #ifndef NDEBUG /* I don't quite trust the overlap calculations yet --rpm */ if (d==dbuf) { - assert ((dp>=sp && dpshared->size) || + HDassert((dp>=sp && dpshared->size) || (sp>=dp && spshared->size)); } else { - assert ((dpshared->size<=sp) || + HDassert((dpshared->size<=sp) || (spshared->size<=dp)); } #endif @@ -8886,7 +8965,7 @@ H5T__conv_f_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, } } else if (H5T_ORDER_VAX==src.order) { tsize = src_p->shared->size; - assert(0 == tsize % 2); + HDassert(0 == tsize % 2); for (i = 0; i < tsize; i += 4) { tmp1 = s[i]; @@ -9044,8 +9123,7 @@ H5T__conv_f_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, } else if (H5T_NORM_IMPLIED==src.u.f.norm) { expo -= src.u.f.ebias; } else { - assert("normalization method not implemented yet" && 0); - HDabort(); + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "normalization method not implemented yet") } /* @@ -9247,11 +9325,11 @@ H5T__conv_f_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * Set padding areas in destination. */ if (dst.offset>0) { - assert (H5T_PAD_ZERO==dst.lsb_pad || H5T_PAD_ONE==dst.lsb_pad); + HDassert(H5T_PAD_ZERO==dst.lsb_pad || H5T_PAD_ONE==dst.lsb_pad); H5T__bit_set(d, (size_t)0, dst.offset, (hbool_t)(H5T_PAD_ONE==dst.lsb_pad)); } if (dst.offset+dst.prec!=8*dst_p->shared->size) { - assert (H5T_PAD_ZERO==dst.msb_pad || H5T_PAD_ONE==dst.msb_pad); + HDassert(H5T_PAD_ZERO==dst.msb_pad || H5T_PAD_ONE==dst.msb_pad); H5T__bit_set(d, dst.offset+dst.prec, 8*dst_p->shared->size - (dst.offset+ dst.prec), (hbool_t)(H5T_PAD_ONE==dst.msb_pad)); @@ -9459,10 +9537,10 @@ H5T__conv_i_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, #ifndef NDEBUG /* I don't quite trust the overlap calculations yet --rpm */ if (d==dbuf) { - assert ((dp>=sp && dpshared->size) || + HDassert((dp>=sp && dpshared->size) || (sp>=dp && spshared->size)); } else { - assert ((dpshared->size<=sp) || + HDassert((dpshared->size<=sp) || (spshared->size<=dp)); } #endif @@ -9548,8 +9626,7 @@ H5T__conv_i_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, if (H5T_NORM_NONE==dst.u.f.norm || H5T_NORM_IMPLIED==dst.u.f.norm) { expo = first + dst.u.f.ebias; } else { - assert("normalization method not implemented yet" && 0); - HDabort(); + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "normalization method not implemented yet") } /* Handle mantissa part here */ @@ -9629,7 +9706,7 @@ H5T__conv_i_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, /* Check if the exponent is too big */ - expo_max = (hsize_t)HDpow((double)2.0, (double)dst.u.f.esize) - 1; + expo_max = (hsize_t)HDpow((double)2.0f, (double)dst.u.f.esize) - 1; if(expo > expo_max) { /*overflows*/ if(cb_struct.func) { /*user's exception handler. Reverse back source order*/ @@ -9687,7 +9764,7 @@ H5T__conv_i_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, } } else if (H5T_ORDER_VAX==dst.order && reverse) { tsize = dst_p->shared->size; - assert(0 == tsize % 2); + HDassert(0 == tsize % 2); for (i = 0; i < tsize; i += 4) { tmp1 = d[i]; @@ -9762,8 +9839,8 @@ H5T_reverse_order(uint8_t *rev, uint8_t *s, size_t size, H5T_order_t order) FUNC_ENTER_NOAPI_NOINIT_NOERR - assert(s); - assert(size); + HDassert(s); + HDassert(size); if (H5T_ORDER_VAX == order) { for (i = 0; i < size; i += 2) { diff --git a/src/H5Tenum.c b/src/H5Tenum.c index 8e4e8a2..2b7563b 100644 --- a/src/H5Tenum.c +++ b/src/H5Tenum.c @@ -127,14 +127,14 @@ H5T__enum_create(const H5T_t *parent) FUNC_ENTER_PACKAGE - assert(parent); + HDassert(parent); /* Build new type */ if(NULL == (ret_value = H5T__alloc())) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") ret_value->shared->type = H5T_ENUM; ret_value->shared->parent = H5T_copy(parent, H5T_COPY_ALL); - assert(ret_value->shared->parent); + HDassert(ret_value->shared->parent); ret_value->shared->size = ret_value->shared->parent->shared->size; done: @@ -220,9 +220,9 @@ H5T__enum_insert(const H5T_t *dt, const char *name, const void *value) FUNC_ENTER_PACKAGE - assert(dt); - assert(name && *name); - assert(value); + HDassert(dt); + HDassert(name && *name); + HDassert(value); /* The name and value had better not already exist */ for (i=0; ishared->u.enumer.nmembs; i++) { @@ -322,8 +322,8 @@ H5T__get_member_value(const H5T_t *dt, unsigned membno, void *value/*out*/) { FUNC_ENTER_PACKAGE_NOERR - assert(dt); - assert(value); + HDassert(dt); + HDassert(value); HDmemcpy(value, dt->shared->u.enumer.value + membno*dt->shared->size, dt->shared->size); @@ -563,9 +563,9 @@ H5T_enum_valueof(const H5T_t *dt, const char *name, void *value/*out*/) FUNC_ENTER_NOAPI_NOINIT /* Check args */ - assert(dt && H5T_ENUM==dt->shared->type); - assert(name && *name); - assert(value); + HDassert(dt && H5T_ENUM==dt->shared->type); + HDassert(name && *name); + HDassert(value); /* Sanity check */ if (dt->shared->u.enumer.nmembs == 0) diff --git a/src/H5Tfields.c b/src/H5Tfields.c index 163bab3..0e0d4e7 100644 --- a/src/H5Tfields.c +++ b/src/H5Tfields.c @@ -202,7 +202,7 @@ H5T__get_member_name(H5T_t const *dt, unsigned membno) FUNC_ENTER_PACKAGE - assert(dt); + HDassert(dt); switch (dt->shared->type) { case H5T_COMPOUND: @@ -435,8 +435,8 @@ H5T__sort_name(const H5T_t *dt, int *map) FUNC_ENTER_PACKAGE_NOERR /* Check args */ - assert(dt); - assert(H5T_COMPOUND==dt->shared->type || H5T_ENUM==dt->shared->type); + HDassert(dt); + HDassert(H5T_COMPOUND==dt->shared->type || H5T_ENUM==dt->shared->type); /* Use a bubble sort because we can short circuit */ if (H5T_COMPOUND==dt->shared->type) { @@ -462,7 +462,7 @@ H5T__sort_name(const H5T_t *dt, int *map) #ifndef NDEBUG /* I never trust a sort :-) -RPM */ for (i=0; ishared->u.compnd.memb[i].name, + HDassert(HDstrcmp(dt->shared->u.compnd.memb[i].name, dt->shared->u.compnd.memb[i+1].name)<0); } #endif @@ -472,7 +472,7 @@ H5T__sort_name(const H5T_t *dt, int *map) dt->shared->u.enumer.sorted = H5T_SORT_NAME; nmembs = dt->shared->u.enumer.nmembs; size = dt->shared->size; - assert(size<=sizeof(tbuf)); + HDassert(size<=sizeof(tbuf)); for (i=nmembs-1, swapped=TRUE; i>0 && swapped; --i) { for (j=0, swapped=FALSE; jshared->u.enumer.name[j], @@ -502,7 +502,7 @@ H5T__sort_name(const H5T_t *dt, int *map) #ifndef NDEBUG /* I never trust a sort :-) -RPM */ for (i=0; ishared->u.enumer.name[i], dt->shared->u.enumer.name[i+1])<0); + HDassert(HDstrcmp(dt->shared->u.enumer.name[i], dt->shared->u.enumer.name[i+1])<0); #endif } } diff --git a/src/H5Tfixed.c b/src/H5Tfixed.c index 51737eb..b2401d4 100644 --- a/src/H5Tfixed.c +++ b/src/H5Tfixed.c @@ -113,7 +113,7 @@ H5T_get_sign(H5T_t const *dt) FUNC_ENTER_NOAPI(H5T_SGN_ERROR) - assert(dt); + HDassert(dt); /* Defer to parent */ while(dt->shared->parent) diff --git a/src/H5Tnative.c b/src/H5Tnative.c index b9192f9..e7d1351 100644 --- a/src/H5Tnative.c +++ b/src/H5Tnative.c @@ -172,7 +172,7 @@ H5T_get_native_type(H5T_t *dtype, H5T_direction_t direction, size_t *struct_alig FUNC_ENTER_NOAPI(NULL) - assert(dtype); + HDassert(dtype); if(H5T_NO_CLASS == (h5_class = H5T_get_class(dtype, FALSE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a valid class") @@ -355,6 +355,7 @@ H5T_get_native_type(H5T_t *dtype, H5T_direction_t direction, size_t *struct_alig case H5T_ENUM: { + H5T_path_t *tpath; /* Type conversion info */ hid_t super_type_id, nat_super_type_id; /* Don't need to do anything special for alignment, offset since the ENUM type usually is integer. */ @@ -380,6 +381,10 @@ H5T_get_native_type(H5T_t *dtype, H5T_direction_t direction, size_t *struct_alig if(NULL == (new_type = H5T__enum_create(nat_super_type))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "unable to create enum type") + /* Find the conversion function */ + if(NULL == (tpath = H5T_path_find(super_type, nat_super_type, NULL, NULL, H5P_DEFAULT, FALSE))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to convert between src and dst data types") + /* Retrieve member info and insert members into new enum type */ if((snmemb = H5T_get_nmembers(dtype)) <= 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "enumerate data type doesn't have any member") @@ -391,7 +396,7 @@ H5T_get_native_type(H5T_t *dtype, H5T_direction_t direction, size_t *struct_alig HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot get member value") HDmemcpy(memb_value, tmp_memb_value, H5T_get_size(super_type)); - if(H5Tconvert(super_type_id, nat_super_type_id, (size_t)1, memb_value, NULL, H5P_DEFAULT) < 0) + if(H5T_convert(tpath, super_type_id, nat_super_type_id, (size_t)1, (size_t)0, (size_t)0, memb_value, NULL, H5P_DEFAULT) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot get member value") if(H5T__enum_insert(new_type, memb_name, memb_value) < 0) @@ -402,10 +407,10 @@ H5T_get_native_type(H5T_t *dtype, H5T_direction_t direction, size_t *struct_alig tmp_memb_value = H5MM_xfree(tmp_memb_value); /* Close base type */ - if(H5Tclose(nat_super_type_id) < 0) + if(H5I_dec_app_ref(nat_super_type_id) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot close datatype") - /* Close super type */ - if(H5Tclose(super_type_id) < 0) + /* Close super type */ + if(H5I_dec_app_ref(super_type_id) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot close datatype") ret_value = new_type; @@ -571,19 +576,19 @@ H5T_get_native_integer(size_t prec, H5T_sign_t sign, H5T_direction_t direction, FUNC_ENTER_NOAPI(NULL) if(direction == H5T_DIR_DEFAULT || direction == H5T_DIR_ASCEND) { - if(prec <= H5Tget_precision(H5T_NATIVE_SCHAR)) { + if(prec <= H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_SCHAR_g))) { match = H5T_NATIVE_INT_MATCH_CHAR; native_size = sizeof(char); - } else if(prec<=H5Tget_precision(H5T_NATIVE_SHORT)) { + } else if(prec<=H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_SHORT_g))) { match = H5T_NATIVE_INT_MATCH_SHORT; native_size = sizeof(short); - } else if(prec<=H5Tget_precision(H5T_NATIVE_INT)) { + } else if(prec<=H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_INT_g))) { match = H5T_NATIVE_INT_MATCH_INT; native_size = sizeof(int); - } else if(prec <= H5Tget_precision(H5T_NATIVE_LONG)) { + } else if(prec <= H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_LONG_g))) { match = H5T_NATIVE_INT_MATCH_LONG; native_size = sizeof(long); - } else if(prec <= H5Tget_precision(H5T_NATIVE_LLONG)) { + } else if(prec <= H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_LLONG_g))) { match = H5T_NATIVE_INT_MATCH_LLONG; native_size = sizeof(long long); } else { /* If no native type matches the querried datatype, simply choose the type of biggest size. */ @@ -591,16 +596,16 @@ H5T_get_native_integer(size_t prec, H5T_sign_t sign, H5T_direction_t direction, native_size = sizeof(long long); } } else if(direction == H5T_DIR_DESCEND) { - if(prec > H5Tget_precision(H5T_NATIVE_LONG)) { + if(prec > H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_LONG_g))) { match = H5T_NATIVE_INT_MATCH_LLONG; native_size = sizeof(long long); - } else if(prec > H5Tget_precision(H5T_NATIVE_INT)) { + } else if(prec > H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_INT_g))) { match = H5T_NATIVE_INT_MATCH_LONG; native_size = sizeof(long); - } else if(prec > H5Tget_precision(H5T_NATIVE_SHORT)) { + } else if(prec > H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_SHORT_g))) { match = H5T_NATIVE_INT_MATCH_INT; native_size = sizeof(int); - } else if(prec > H5Tget_precision(H5T_NATIVE_SCHAR)) { + } else if(prec > H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_SCHAR_g))) { match = H5T_NATIVE_INT_MATCH_SHORT; native_size = sizeof(short); } else { @@ -710,7 +715,7 @@ H5T_get_native_float(size_t size, H5T_direction_t direction, size_t *struct_alig FUNC_ENTER_NOAPI(NULL) - assert(size>0); + HDassert(size>0); if(direction == H5T_DIR_DEFAULT || direction == H5T_DIR_ASCEND) { if(size<=sizeof(float)) { @@ -786,7 +791,7 @@ H5T_get_native_float(size_t size, H5T_direction_t direction, size_t *struct_alig } /* end switch */ /* Create new native type */ - assert(tid>=0); + HDassert(tid>=0); if(NULL==(dt=(H5T_t *)H5I_object(tid))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data type") if((ret_value=H5T_copy(dt, H5T_COPY_TRANSIENT))==NULL) @@ -829,19 +834,19 @@ H5T_get_native_bitfield(size_t prec, H5T_direction_t direction, size_t *struct_a FUNC_ENTER_NOAPI(NULL) if(direction == H5T_DIR_DEFAULT || direction == H5T_DIR_ASCEND) { - if(prec<=H5Tget_precision(H5T_NATIVE_B8)) { + if(prec<=H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_B8_g))) { tid = H5T_NATIVE_B8; native_size = 1; align = H5T_NATIVE_UINT8_ALIGN_g; - } else if(prec<=H5Tget_precision(H5T_NATIVE_B16)) { + } else if(prec<=H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_B16_g))) { tid = H5T_NATIVE_B16; native_size = 2; align = H5T_NATIVE_UINT16_ALIGN_g; - } else if(prec<=H5Tget_precision(H5T_NATIVE_B32)) { + } else if(prec<=H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_B32_g))) { tid = H5T_NATIVE_B32; native_size = 4; align = H5T_NATIVE_UINT32_ALIGN_g; - } else if(prec<=H5Tget_precision(H5T_NATIVE_B64)) { + } else if(prec<=H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_B64_g))) { tid = H5T_NATIVE_B64; native_size = 8; align = H5T_NATIVE_UINT64_ALIGN_g; @@ -851,15 +856,15 @@ H5T_get_native_bitfield(size_t prec, H5T_direction_t direction, size_t *struct_a align = H5T_NATIVE_UINT64_ALIGN_g; } } else if(direction == H5T_DIR_DESCEND) { - if(prec>H5Tget_precision(H5T_NATIVE_B32)) { + if(prec>H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_B32_g))) { tid = H5T_NATIVE_B64; native_size = 8; align = H5T_NATIVE_UINT64_ALIGN_g; - } else if(prec>H5Tget_precision(H5T_NATIVE_B16)) { + } else if(prec>H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_B16_g))) { tid = H5T_NATIVE_B32; native_size = 4; align = H5T_NATIVE_UINT32_ALIGN_g; - } else if(prec>H5Tget_precision(H5T_NATIVE_B8)) { + } else if(prec>H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_B8_g))) { tid = H5T_NATIVE_B16; native_size = 2; align = H5T_NATIVE_UINT16_ALIGN_g; @@ -871,7 +876,7 @@ H5T_get_native_bitfield(size_t prec, H5T_direction_t direction, size_t *struct_a } /* Create new native type */ - assert(tid>=0); + HDassert(tid>=0); if(NULL==(dt=(H5T_t *)H5I_object(tid))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data type") diff --git a/src/H5Toffset.c b/src/H5Toffset.c index bea8d2b..ea4b3b5 100644 --- a/src/H5Toffset.c +++ b/src/H5Toffset.c @@ -272,12 +272,12 @@ H5T_set_offset(const H5T_t *dt, size_t offset) FUNC_ENTER_NOAPI(FAIL) /* Check args */ - assert(dt); - assert(H5T_STRING!=dt->shared->type || 0==offset); - assert(H5T_REFERENCE!=dt->shared->type); - assert(H5T_OPAQUE!=dt->shared->type); - assert(H5T_COMPOUND!=dt->shared->type); - assert(!(H5T_ENUM==dt->shared->type && 0==dt->shared->u.enumer.nmembs)); + HDassert(dt); + HDassert(H5T_STRING!=dt->shared->type || 0==offset); + HDassert(H5T_REFERENCE!=dt->shared->type); + HDassert(H5T_OPAQUE!=dt->shared->type); + HDassert(H5T_COMPOUND!=dt->shared->type); + HDassert(!(H5T_ENUM==dt->shared->type && 0==dt->shared->u.enumer.nmembs)); if (dt->shared->parent) { if (H5T_set_offset(dt->shared->parent, offset)<0) diff --git a/src/H5Tprecis.c b/src/H5Tprecis.c index c5ac186..b3975af 100644 --- a/src/H5Tprecis.c +++ b/src/H5Tprecis.c @@ -236,12 +236,12 @@ H5T_set_precision(const H5T_t *dt, size_t prec) FUNC_ENTER_NOAPI(FAIL) /* Check args */ - assert(dt); - assert(prec>0); - assert(H5T_OPAQUE!=dt->shared->type); - assert(H5T_COMPOUND!=dt->shared->type); - assert(H5T_STRING!=dt->shared->type); - assert(!(H5T_ENUM==dt->shared->type && 0==dt->shared->u.enumer.nmembs)); + HDassert(dt); + HDassert(prec>0); + HDassert(H5T_OPAQUE!=dt->shared->type); + HDassert(H5T_COMPOUND!=dt->shared->type); + HDassert(H5T_STRING!=dt->shared->type); + HDassert(!(H5T_ENUM==dt->shared->type && 0==dt->shared->u.enumer.nmembs)); if (dt->shared->parent) { if (H5T_set_precision(dt->shared->parent, prec)<0) diff --git a/src/H5Tvlen.c b/src/H5Tvlen.c index f497d1e..52a2cde 100644 --- a/src/H5Tvlen.c +++ b/src/H5Tvlen.c @@ -882,7 +882,7 @@ H5T_vlen_disk_read(H5F_t *f, hid_t dxpl_id, void *_vl, void *buf, size_t UNUSED /* Get the heap information */ H5F_addr_decode(f,(const uint8_t **)&vl,&(hobjid.addr)); - INT32DECODE(vl,hobjid.idx); + UINT32DECODE(vl,hobjid.idx); /* Check if this sequence actually has any data */ if(hobjid.addr>0) { @@ -935,7 +935,7 @@ H5T_vlen_disk_write(H5F_t *f, hid_t dxpl_id, const H5T_vlen_alloc_info_t UNUSED /* Get heap information */ H5F_addr_decode(f, (const uint8_t **)&bg, &(bg_hobjid.addr)); - INT32DECODE(bg, bg_hobjid.idx); + UINT32DECODE(bg, bg_hobjid.idx); /* Free heap object for old data */ if(bg_hobjid.addr > 0) { @@ -955,7 +955,7 @@ H5T_vlen_disk_write(H5F_t *f, hid_t dxpl_id, const H5T_vlen_alloc_info_t UNUSED /* Encode the heap information */ H5F_addr_encode(f, &vl, hobjid.addr); - INT32ENCODE(vl, hobjid.idx); + UINT32ENCODE(vl, hobjid.idx); done: FUNC_LEAVE_NOAPI(ret_value) @@ -997,7 +997,7 @@ H5T_vlen_disk_setnull(H5F_t *f, hid_t dxpl_id, void *_vl, void *_bg) /* Get heap information */ H5F_addr_decode(f, (const uint8_t **)&bg, &(bg_hobjid.addr)); - INT32DECODE(bg, bg_hobjid.idx); + UINT32DECODE(bg, bg_hobjid.idx); /* Free heap object for old data */ if(bg_hobjid.addr > 0) { @@ -1012,7 +1012,7 @@ H5T_vlen_disk_setnull(H5F_t *f, hid_t dxpl_id, void *_vl, void *_bg) /* Encode the "nil" heap pointer information */ H5F_addr_encode(f, &vl, (haddr_t)0); - INT32ENCODE(vl, 0); + UINT32ENCODE(vl, 0); done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5V.c b/src/H5V.c index e23af01..4039ac2 100644 --- a/src/H5V.c +++ b/src/H5V.c @@ -78,7 +78,7 @@ H5V_stride_optimize1(unsigned *np/*in,out*/, hsize_t *elmt_size/*in,out*/, * This has to be true because if we optimize the dimensionality down to * zero we still must make one reference. */ - assert(1 == H5V_vector_reduce_product(0, NULL)); + HDassert(1 == H5V_vector_reduce_product(0, NULL)); /* * Combine adjacent memory accesses @@ -127,8 +127,8 @@ H5V_stride_optimize2(unsigned *np/*in,out*/, hsize_t *elmt_size/*in,out*/, * This has to be true because if we optimize the dimensionality down to * zero we still must make one reference. */ - assert(1 == H5V_vector_reduce_product(0, NULL)); - assert (*elmt_size>0); + HDassert(1 == H5V_vector_reduce_product(0, NULL)); + HDassert(*elmt_size>0); /* * Combine adjacent memory accesses @@ -267,48 +267,48 @@ H5V_hyper_stride(unsigned n, const hsize_t *size, FUNC_ENTER_NOAPI_NOINIT_NOERR - assert(n <= H5V_HYPER_NDIMS); - assert(size); - assert(total_size); - assert(stride); + HDassert(n <= H5V_HYPER_NDIMS); + HDassert(size); + HDassert(total_size); + HDassert(stride); /* init */ - assert(n>0); + HDassert(n>0); stride[n-1] = 1; skip = offset ? offset[n-1] : 0; switch(n) { case 2: /* 1-D dataset */ - assert (total_size[1]>=size[1]); + HDassert(total_size[1]>=size[1]); stride[0] = total_size[1]-size[1]; /*overflow checked*/ acc = total_size[1]; skip += acc * (offset ? offset[0] : 0); break; case 3: /* 2-D dataset */ - assert (total_size[2]>=size[2]); + HDassert(total_size[2]>=size[2]); stride[1] = total_size[2]-size[2]; /*overflow checked*/ acc = total_size[2]; skip += acc * (offset ? (hsize_t)offset[1] : 0); - assert (total_size[1]>=size[1]); + HDassert(total_size[1]>=size[1]); stride[0] = acc * (total_size[1] - size[1]); /*overflow checked*/ acc *= total_size[1]; skip += acc * (offset ? (hsize_t)offset[0] : 0); break; case 4: /* 3-D dataset */ - assert (total_size[3]>=size[3]); + HDassert(total_size[3]>=size[3]); stride[2] = total_size[3]-size[3]; /*overflow checked*/ acc = total_size[3]; skip += acc * (offset ? (hsize_t)offset[2] : 0); - assert (total_size[2]>=size[2]); + HDassert(total_size[2]>=size[2]); stride[1] = acc * (total_size[2] - size[2]); /*overflow checked*/ acc *= total_size[2]; skip += acc * (offset ? (hsize_t)offset[1] : 0); - assert (total_size[1]>=size[1]); + HDassert(total_size[1]>=size[1]); stride[0] = acc * (total_size[1] - size[1]); /*overflow checked*/ acc *= total_size[1]; skip += acc * (offset ? (hsize_t)offset[0] : 0); @@ -317,7 +317,7 @@ H5V_hyper_stride(unsigned n, const hsize_t *size, default: /* others */ for (i=(int)(n-2), acc=1; i>=0; --i) { - assert (total_size[i+1]>=size[i+1]); + HDassert(total_size[i+1]>=size[i+1]); stride[i] = acc * (total_size[i+1] - size[i+1]); /*overflow checked*/ acc *= total_size[i+1]; skip += acc * (offset ? (hsize_t)offset[i] : 0); @@ -474,14 +474,14 @@ H5V_hyper_fill(unsigned n, const hsize_t *_size, FUNC_ENTER_NOAPI_NOINIT_NOERR /* check args */ - assert(n > 0 && n <= H5V_HYPER_NDIMS); - assert(_size); - assert(total_size); - assert(dst); + HDassert(n > 0 && n <= H5V_HYPER_NDIMS); + HDassert(_size); + HDassert(total_size); + HDassert(dst); #ifndef NDEBUG for (u = 0; u < n; u++) { - assert(_size[u] > 0); - assert(total_size[u] > 0); + HDassert(_size[u] > 0); + HDassert(total_size[u] > 0); } #endif @@ -560,17 +560,17 @@ H5V_hyper_copy(unsigned n, const hsize_t *_size, FUNC_ENTER_NOAPI_NOINIT_NOERR /* check args */ - assert(n > 0 && n <= H5V_HYPER_NDIMS); - assert(_size); - assert(dst_size); - assert(src_size); - assert(dst); - assert(src); + HDassert(n > 0 && n <= H5V_HYPER_NDIMS); + HDassert(_size); + HDassert(dst_size); + HDassert(src_size); + HDassert(dst); + HDassert(src); #ifndef NDEBUG for (u = 0; u < n; u++) { - assert(_size[u] > 0); - assert(dst_size[u] > 0); - assert(src_size[u] > 0); + HDassert(_size[u] > 0); + HDassert(dst_size[u] > 0); + HDassert(src_size[u] > 0); } #endif @@ -589,7 +589,7 @@ H5V_hyper_copy(unsigned n, const hsize_t *_size, int ii; /*counter */ /* init */ - assert(n>0); + HDassert(n>0); dst_stride[n-1] = 1; src_stride[n-1] = 1; dst_start = dst_offset ? dst_offset[n-1] : 0; @@ -598,8 +598,8 @@ H5V_hyper_copy(unsigned n, const hsize_t *_size, /* Unroll loop for common cases */ switch(n) { case 2: - assert (dst_size[1]>=size[1]); - assert (src_size[1]>=size[1]); + HDassert(dst_size[1]>=size[1]); + HDassert(src_size[1]>=size[1]); dst_stride[0] = dst_size[1] - size[1]; /*overflow checked*/ src_stride[0] = src_size[1] - size[1]; /*overflow checked*/ dst_acc = dst_size[1]; @@ -609,8 +609,8 @@ H5V_hyper_copy(unsigned n, const hsize_t *_size, break; case 3: - assert (dst_size[2]>=size[2]); - assert (src_size[2]>=size[2]); + HDassert(dst_size[2]>=size[2]); + HDassert(src_size[2]>=size[2]); dst_stride[1] = dst_size[2] - size[2]; /*overflow checked*/ src_stride[1] = src_size[2] - size[2]; /*overflow checked*/ dst_acc = dst_size[2]; @@ -618,8 +618,8 @@ H5V_hyper_copy(unsigned n, const hsize_t *_size, dst_start += dst_acc * (dst_offset ? dst_offset[1] : 0); src_start += src_acc * (src_offset ? src_offset[1] : 0); - assert (dst_size[1]>=size[1]); - assert (src_size[1]>=size[1]); + HDassert(dst_size[1]>=size[1]); + HDassert(src_size[1]>=size[1]); dst_stride[0] = dst_acc * (dst_size[1] - size[1]); /*overflow checked*/ src_stride[0] = src_acc * (src_size[1] - size[1]); /*overflow checked*/ dst_acc *= dst_size[1]; @@ -629,8 +629,8 @@ H5V_hyper_copy(unsigned n, const hsize_t *_size, break; case 4: - assert (dst_size[3]>=size[3]); - assert (src_size[3]>=size[3]); + HDassert(dst_size[3]>=size[3]); + HDassert(src_size[3]>=size[3]); dst_stride[2] = dst_size[3] - size[3]; /*overflow checked*/ src_stride[2] = src_size[3] - size[3]; /*overflow checked*/ dst_acc = dst_size[3]; @@ -638,8 +638,8 @@ H5V_hyper_copy(unsigned n, const hsize_t *_size, dst_start += dst_acc * (dst_offset ? dst_offset[2] : 0); src_start += src_acc * (src_offset ? src_offset[2] : 0); - assert (dst_size[2]>=size[2]); - assert (src_size[2]>=size[2]); + HDassert(dst_size[2]>=size[2]); + HDassert(src_size[2]>=size[2]); dst_stride[1] = dst_acc * (dst_size[2] - size[2]); /*overflow checked*/ src_stride[1] = src_acc * (src_size[2] - size[2]); /*overflow checked*/ dst_acc *= dst_size[2]; @@ -647,8 +647,8 @@ H5V_hyper_copy(unsigned n, const hsize_t *_size, dst_start += dst_acc * (dst_offset ? dst_offset[1] : 0); src_start += src_acc * (src_offset ? src_offset[1] : 0); - assert (dst_size[1]>=size[1]); - assert (src_size[1]>=size[1]); + HDassert(dst_size[1]>=size[1]); + HDassert(src_size[1]>=size[1]); dst_stride[0] = dst_acc * (dst_size[1] - size[1]); /*overflow checked*/ src_stride[0] = src_acc * (src_size[1] - size[1]); /*overflow checked*/ dst_acc *= dst_size[1]; @@ -660,8 +660,8 @@ H5V_hyper_copy(unsigned n, const hsize_t *_size, default: /* others */ for (ii=(int)(n-2), dst_acc=1, src_acc=1; ii>=0; --ii) { - assert (dst_size[ii+1]>=size[ii+1]); - assert (src_size[ii+1]>=size[ii+1]); + HDassert(dst_size[ii+1]>=size[ii+1]); + HDassert(src_size[ii+1]>=size[ii+1]); dst_stride[ii] = dst_acc * (dst_size[ii+1] - size[ii+1]); /*overflow checked*/ src_stride[ii] = src_acc * (src_size[ii+1] - size[ii+1]); /*overflow checked*/ dst_acc *= dst_size[ii+1]; @@ -713,7 +713,7 @@ H5V_stride_fill(unsigned n, hsize_t elmt_size, const hsize_t *size, FUNC_ENTER_NOAPI_NOINIT_NOERR - assert (elmt_size < SIZET_MAX); + HDassert(elmt_size < SIZET_MAX); H5V_vector_cpy(n, idx, size); nelmts = H5V_vector_reduce_product(n, size); @@ -729,7 +729,7 @@ H5V_stride_fill(unsigned n, hsize_t elmt_size, const hsize_t *size, if (--idx[j]) carry = FALSE; else { - assert(size); + HDassert(size); idx[j] = size[j]; } /* end else */ } @@ -775,7 +775,7 @@ H5V_stride_copy(unsigned n, hsize_t elmt_size, const hsize_t *size, FUNC_ENTER_NOAPI_NOINIT_NOERR - assert (elmt_size0); - assert(src_n>0); + HDassert(elmt_size < SIZET_MAX); + HDassert(dst_n>0); + HDassert(src_n>0); H5V_vector_cpy(dst_n, dst_idx, dst_size); H5V_vector_cpy(src_n, src_idx, src_size); @@ -937,7 +937,7 @@ H5V_stride_copy2(hsize_t nelmts, hsize_t elmt_size, if (--dst_idx[j]) carry = FALSE; else { - assert(dst_size); + HDassert(dst_size); dst_idx[j] = dst_size[j]; } /* end else */ } @@ -946,7 +946,7 @@ H5V_stride_copy2(hsize_t nelmts, hsize_t elmt_size, if (--src_idx[j]) carry = FALSE; else { - assert(src_size); + HDassert(src_size); src_idx[j] = src_size[j]; } /* end else */ } @@ -983,10 +983,10 @@ H5V_array_fill(void *_dst, const void *src, size_t size, size_t count) FUNC_ENTER_NOAPI_NOINIT_NOERR - assert (dst); - assert (src); - assert (size < SIZET_MAX && size > 0); - assert (count < SIZET_MAX && count > 0); + HDassert(dst); + HDassert(src); + HDassert(size < SIZET_MAX && size > 0); + HDassert(count < SIZET_MAX && count > 0); HDmemcpy(dst, src, size); /* copy first item */ @@ -1038,9 +1038,9 @@ H5V_array_down(unsigned n, const hsize_t *total_size, hsize_t *down) FUNC_ENTER_NOAPI_NOINIT_NOERR - assert(n <= H5V_HYPER_NDIMS); - assert(total_size); - assert(down); + HDassert(n <= H5V_HYPER_NDIMS); + HDassert(total_size); + HDassert(down); /* Build the sizes of each dimension in the array */ /* (From fastest to slowest) */ @@ -1084,9 +1084,9 @@ H5V_array_offset_pre(unsigned n, const hsize_t *acc, const hsize_t *offset) FUNC_ENTER_NOAPI_NOINIT_NOERR - assert(n <= H5V_HYPER_NDIMS); - assert(acc); - assert(offset); + HDassert(n <= H5V_HYPER_NDIMS); + HDassert(acc); + HDassert(offset); /* Compute offset in array */ for (i=(int)(n-1), ret_value=0; i>=0; --i) @@ -1124,9 +1124,9 @@ H5V_array_offset(unsigned n, const hsize_t *total_size, const hsize_t *offset) FUNC_ENTER_NOAPI((HDabort(), 0)) /*lint !e527 Don't worry about unreachable statement */ - assert(n <= H5V_HYPER_NDIMS); - assert(total_size); - assert(offset); + HDassert(n <= H5V_HYPER_NDIMS); + HDassert(total_size); + HDassert(offset); /* Build the sizes of each dimension in the array */ if(H5V_array_down(n,total_size,acc_arr)<0) @@ -1278,10 +1278,10 @@ H5V_chunk_index(unsigned ndims, const hsize_t *coord, const uint32_t *chunk, FUNC_ENTER_NOAPI_NOINIT_NOERR /* Sanity check */ - assert(ndims <= H5V_HYPER_NDIMS); - assert(coord); - assert(chunk); - assert(chunk_idx); + HDassert(ndims <= H5V_HYPER_NDIMS); + HDassert(coord); + HDassert(chunk); + HDassert(chunk_idx); /* Compute the scaled coordinates for actual coordinates */ for(u=0; uH5Z_FILTER_MAX) - HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid filter identification number") - if (id H5Z_FILTER_MAX) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid filter identification number") + if(id < H5Z_FILTER_RESERVED) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to modify predefined filters") /* Do it */ - if (H5Z_unregister (id)<0) - HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, FAIL, "unable to unregister filter") + if(H5Z_unregister(id) < 0) + HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to unregister filter") done: FUNC_LEAVE_API(ret_value) @@ -402,29 +405,18 @@ done: * Programmer: Quincey Koziol * Thursday, November 14, 2002 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t -H5Z_unregister (H5Z_filter_t filter_id) +H5Z_unregister(H5Z_filter_t filter_id) { - hid_t *file_list = NULL; - hid_t *obj_id_list = NULL; - size_t num_obj_id = 0; - size_t num_file_id = 0; - H5F_t *f = NULL; /* File to query */ - H5I_type_t id_type; - hid_t ocpl_id; - H5P_genplist_t *plist; /* Property list */ - size_t filter_index; /* Local index variable for filter */ - int i; - htri_t filter_in_pline = FALSE; - herr_t ret_value=SUCCEED; /* Return value */ + size_t filter_index; /* Local index variable for filter */ + H5Z_object_t object; + herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - assert (filter_id>=0 && filter_id<=H5Z_FILTER_MAX); + HDassert(filter_id>=0 && filter_id<=H5Z_FILTER_MAX); /* Is the filter already registered? */ for (filter_index=0; filter_index=H5Z_table_used_g) HGOTO_ERROR(H5E_PLINE, H5E_NOTFOUND, FAIL, "filter is not registered") - /* Count the number of opened datasets and groups among all opened files */ - if(H5F_get_obj_count(NULL, H5F_OBJ_DATASET | H5F_OBJ_GROUP, FALSE, &num_obj_id) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get object number") + /* Initialize the structure object for iteration */ + object.filter_id = filter_id; + object.found = FALSE; - if(num_obj_id) { - if(NULL == (obj_id_list = (hid_t *)H5MM_malloc(num_obj_id*sizeof(hid_t)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "failed to allocate space") + /* Iterate through all opened datasets, returns a failure if any of them uses the filter */ + if(H5I_iterate(H5I_DATASET, H5Z__check_unregister_dset_cb, &object, FALSE) < 0) + HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "iteration failed") - /* Find all opened objects that may use the filter (datasets and groups). Passing NULL as a pointer to - * file structure indicates searching among all opened files */ - if(H5F_get_obj_ids(NULL, H5F_OBJ_DATASET | H5F_OBJ_GROUP, num_obj_id, obj_id_list, FALSE, &num_obj_id) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get object IDs") - } + if(object.found) + HGOTO_ERROR(H5E_PLINE, H5E_CANTRELEASE, FAIL, "can't unregister filter because a dataset is still using it") - /* Check if any opened object (dataset or group) uses the filter. If so, fail with a message */ - for(i=0; ifilter_id)) < 0) + HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "can't check filter in pipeline") - /* Remove filter from table */ - /* Don't worry about shrinking table size (for now) */ - HDmemmove(&H5Z_table_g[filter_index],&H5Z_table_g[filter_index+1],sizeof(H5Z_class2_t)*((H5Z_table_used_g-1)-filter_index)); -#ifdef H5Z_DEBUG - HDmemmove(&H5Z_stat_table_g[filter_index],&H5Z_stat_table_g[filter_index+1],sizeof(H5Z_stats_t)*((H5Z_table_used_g-1)-filter_index)); -#endif /* H5Z_DEBUG */ - H5Z_table_used_g--; + /* H5I_iterate expects TRUE to stop the loop over objects. Stop the loop and + * let H5Z_unregister return failure. + */ + if(filter_in_pline) { + object->found = TRUE; + ret_value = TRUE; + } /* end if */ done: - if(file_list) H5MM_free(file_list); - if(obj_id_list) H5MM_free(obj_id_list); + if(ocpl_id > 0) + if(H5I_dec_app_ref(ocpl_id) < 0) + HDONE_ERROR(H5E_PLINE, H5E_CANTDEC, FAIL, "can't release plist") FUNC_LEAVE_NOAPI(ret_value) -} /* end H5Z_unregister() */ +} /* end H5Z__check_unregister_group_cb() */ + + +/*------------------------------------------------------------------------- + * Function: H5Z__check_unregister_dset_cb + * + * Purpose: The callback function for H5Z_unregister. It iterates + * through all opened objects. If the object is a dataset + * or a group and it uses the filter to be unregistered, the + * function returns TRUE. + * + * Return: TRUE if the object uses the filter. + * FALSE otherwise. + * + * Programmer: Raymond Lu + * 6 May 2013 + * + *------------------------------------------------------------------------- + */ +static int +H5Z__check_unregister_dset_cb(void *obj_ptr, hid_t UNUSED obj_id, void *key) +{ + hid_t ocpl_id = -1; + H5Z_object_t *object = (H5Z_object_t *)key; + htri_t filter_in_pline = FALSE; + int ret_value = FALSE; /* Return value */ + + FUNC_ENTER_STATIC + + HDassert(obj_ptr); + + /* Get the dataset creation property */ + if((ocpl_id = H5D_get_create_plist((H5D_t *)obj_ptr)) < 0) + HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "can't get dataset creation property list") + + /* Check if the filter is in the dataset creation property list */ + if((filter_in_pline = H5Z__check_unregister(ocpl_id, object->filter_id)) < 0) + HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "can't check filter in pipeline") + + /* H5I_iterate expects TRUE to stop the loop over objects. Stop the loop and + * let H5Z_unregister return failure. + */ + if(filter_in_pline) { + object->found = TRUE; + ret_value = TRUE; + } /* end if */ + +done: + if(ocpl_id > 0) + if(H5I_dec_app_ref(ocpl_id) < 0) + HDONE_ERROR(H5E_PLINE, H5E_CANTDEC, FAIL, "can't release plist") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5Z__check_unregister_dset_cb() */ + + +/*------------------------------------------------------------------------- + * Function: H5Z__flush_file_cb + * + * Purpose: The callback function for H5Z_unregister. It iterates + * through all opened files and flush them. + * + * Return: FALSE if finishes flushing and moves on + * FAIL if there is an error + * + * Programmer: Raymond Lu + * 6 May 2013 + * + *------------------------------------------------------------------------- + */ +static int +H5Z__flush_file_cb(void *obj_ptr, hid_t UNUSED obj_id, void UNUSED *key) +{ + int ret_value = FALSE; /* Return value */ + + FUNC_ENTER_STATIC + + HDassert(obj_ptr); + + /* Call the flush routine for mounted file hierarchies. Do a global flush + * if the file is opened for write */ + if(H5F_ACC_RDWR & H5F_INTENT((H5F_t *)obj_ptr)) { + if(H5F_flush_mounts((H5F_t *)obj_ptr, H5AC_dxpl_id) < 0) + HGOTO_ERROR(H5E_PLINE, H5E_CANTFLUSH, FAIL, "unable to flush file hierarchy") + } /* end if */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5Z__flush_file_cb() */ /*------------------------------------------------------------------------- @@ -1203,12 +1302,12 @@ H5Z_pipeline(const H5O_pline_t *pline, unsigned flags, FUNC_ENTER_NOAPI(FAIL) - assert(0==(flags & ~((unsigned)H5Z_FLAG_INVMASK))); - assert(filter_mask); - assert(nbytes && *nbytes>0); - assert(buf_size && *buf_size>0); - assert(buf && *buf); - assert(!pline || pline->nused0); + HDassert(buf_size && *buf_size>0); + HDassert(buf && *buf); + HDassert(!pline || pline->nusednused; i>0; --i) { @@ -1358,8 +1457,8 @@ H5Z_filter_info(const H5O_pline_t *pline, H5Z_filter_t filter) FUNC_ENTER_NOAPI(NULL) - assert(pline); - assert(filter>=0 && filter<=H5Z_FILTER_MAX); + HDassert(pline); + HDassert(filter>=0 && filter<=H5Z_FILTER_MAX); /* Locate the filter in the pipeline */ for(idx=0; idxnused; idx++) @@ -1403,8 +1502,8 @@ H5Z_filter_in_pline(const H5O_pline_t *pline, H5Z_filter_t filter) FUNC_ENTER_NOAPI(FAIL) - assert(pline); - assert(filter>=0 && filter<=H5Z_FILTER_MAX); + HDassert(pline); + HDassert(filter>=0 && filter<=H5Z_FILTER_MAX); /* Locate the filter in the pipeline */ for(idx=0; idxnused; idx++) @@ -1445,7 +1544,7 @@ H5Z_all_filters_avail(const H5O_pline_t *pline) FUNC_ENTER_NOAPI(FAIL) /* Check args */ - assert(pline); + HDassert(pline); /* Iterate through all the filters in pipeline */ for(i=0; inused; i++) { @@ -1567,15 +1666,44 @@ done: herr_t H5Zget_filter_info(H5Z_filter_t filter, unsigned int *filter_config_flags) { - H5Z_class2_t *fclass; herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) H5TRACE2("e", "Zf*Iu", filter, filter_config_flags); + /* Get the filter info */ + if(H5Z_get_filter_info(filter, filter_config_flags) < 0) + HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "Filter info not retrieved") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Zget_filter_info() */ + + +/*------------------------------------------------------------------------- + * Function: H5Z_get_filter_info + * + * Purpose: Gets information about a pipeline data filter and stores it + * in filter_config_flags. + * + * Return: zero on success / negative on failure + * + * Programmer: Quincey Koziol + * Saturday, May 11, 2013 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Z_get_filter_info(H5Z_filter_t filter, unsigned int *filter_config_flags) +{ + H5Z_class2_t *fclass; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + /* Look up the filter class info */ if(NULL == (fclass = H5Z_find(filter))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Filter not defined") + HGOTO_ERROR(H5E_PLINE, H5E_BADVALUE, FAIL, "Filter not defined") /* Set the filter config flags for the application */ if(filter_config_flags != NULL) { @@ -1588,6 +1716,6 @@ H5Zget_filter_info(H5Z_filter_t filter, unsigned int *filter_config_flags) } /* end if */ done: - FUNC_LEAVE_API(ret_value) -} /* end H5Zget_filter_info() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5Z_get_filter_info() */ diff --git a/src/H5Zfletcher32.c b/src/H5Zfletcher32.c index d2ad965..8d2643d 100644 --- a/src/H5Zfletcher32.c +++ b/src/H5Zfletcher32.c @@ -87,7 +87,7 @@ H5Z_filter_fletcher32 (unsigned flags, size_t UNUSED cd_nelmts, const unsigned U FUNC_ENTER_NOAPI(0) - assert(sizeof(uint32_t)>=4); + HDassert(sizeof(uint32_t)>=4); if (flags & H5Z_FLAG_REVERSE) { /* Read */ /* Do checksum if it's enabled for read; otherwise skip it diff --git a/src/H5Zprivate.h b/src/H5Zprivate.h index 6c0a46f..bd5bef0 100644 --- a/src/H5Zprivate.h +++ b/src/H5Zprivate.h @@ -74,7 +74,6 @@ struct H5O_pline_t; /*forward decl*/ /* Internal API routines */ H5_DLL herr_t H5Z_init(void); H5_DLL herr_t H5Z_register(const H5Z_class2_t *cls); -H5_DLL herr_t H5Z_unregister(H5Z_filter_t id); H5_DLL herr_t H5Z_append(struct H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags, size_t cd_nelmts, const unsigned int cd_values[]); H5_DLL herr_t H5Z_modify(const struct H5O_pline_t *pline, H5Z_filter_t filter, @@ -93,8 +92,10 @@ H5_DLL H5Z_filter_info_t *H5Z_filter_info(const struct H5O_pline_t *pline, H5Z_filter_t filter); H5_DLL htri_t H5Z_filter_in_pline(const struct H5O_pline_t *pline, H5Z_filter_t filter); H5_DLL htri_t H5Z_all_filters_avail(const struct H5O_pline_t *pline); +H5_DLL herr_t H5Z_unregister(H5Z_filter_t filter_id); H5_DLL htri_t H5Z_filter_avail(H5Z_filter_t id); H5_DLL herr_t H5Z_delete(struct H5O_pline_t *pline, H5Z_filter_t filter); +H5_DLL herr_t H5Z_get_filter_info(H5Z_filter_t filter, unsigned int *filter_config_flags); /* Data Transform Functions */ typedef struct H5Z_data_xform_t H5Z_data_xform_t; /* Defined in H5Ztrans.c */ diff --git a/src/H5Zscaleoffset.c b/src/H5Zscaleoffset.c index 1538765..0aaff11 100644 --- a/src/H5Zscaleoffset.c +++ b/src/H5Zscaleoffset.c @@ -1164,7 +1164,7 @@ H5Z_filter_scaleoffset(unsigned flags, size_t cd_nelmts, const unsigned cd_value minval |= minval_mask; } - assert(minbits <= p.size * 8); + HDassert(minbits <= p.size * 8); p.minbits = minbits; /* calculate size of output buffer after decompression */ @@ -1241,7 +1241,7 @@ H5Z_filter_scaleoffset(unsigned flags, size_t cd_nelmts, const unsigned cd_value HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, 0, "pre-compression failed") } - assert(minbits <= p.size * 8); + HDassert(minbits <= p.size * 8); /* calculate buffer size after compression * minbits and minval are stored in the front of the compressed buffer diff --git a/src/H5Zszip.c b/src/H5Zszip.c index fd3d90c..4544ec3 100644 --- a/src/H5Zszip.c +++ b/src/H5Zszip.c @@ -198,7 +198,7 @@ H5Z_set_local_szip(hid_t dcpl_id, hid_t type_id, hid_t space_id) /* Set "local" parameter for this dataset's "pixels-per-scanline" */ /* (Use the chunk's fastest changing dimension size) */ - assert(ndims > 0); + HDassert(ndims > 0); scanline = dims[ndims - 1]; /* Adjust scanline if it is smaller than number of pixels per block or @@ -288,13 +288,13 @@ H5Z_filter_szip (unsigned flags, size_t cd_nelmts, const unsigned cd_values[], /* Sanity check to make certain that we haven't drifted out of date with * the mask options from the szlib.h header */ - assert(H5_SZIP_ALLOW_K13_OPTION_MASK==SZ_ALLOW_K13_OPTION_MASK); - assert(H5_SZIP_CHIP_OPTION_MASK==SZ_CHIP_OPTION_MASK); - assert(H5_SZIP_EC_OPTION_MASK==SZ_EC_OPTION_MASK); - assert(H5_SZIP_LSB_OPTION_MASK==SZ_LSB_OPTION_MASK); - assert(H5_SZIP_MSB_OPTION_MASK==SZ_MSB_OPTION_MASK); - assert(H5_SZIP_NN_OPTION_MASK==SZ_NN_OPTION_MASK); - assert(H5_SZIP_RAW_OPTION_MASK==SZ_RAW_OPTION_MASK); + HDassert(H5_SZIP_ALLOW_K13_OPTION_MASK==SZ_ALLOW_K13_OPTION_MASK); + HDassert(H5_SZIP_CHIP_OPTION_MASK==SZ_CHIP_OPTION_MASK); + HDassert(H5_SZIP_EC_OPTION_MASK==SZ_EC_OPTION_MASK); + HDassert(H5_SZIP_LSB_OPTION_MASK==SZ_LSB_OPTION_MASK); + HDassert(H5_SZIP_MSB_OPTION_MASK==SZ_MSB_OPTION_MASK); + HDassert(H5_SZIP_NN_OPTION_MASK==SZ_NN_OPTION_MASK); + HDassert(H5_SZIP_RAW_OPTION_MASK==SZ_RAW_OPTION_MASK); /* Check arguments */ if (cd_nelmts!=4) @@ -324,7 +324,7 @@ H5Z_filter_szip (unsigned flags, size_t cd_nelmts, const unsigned cd_values[], size_out=nalloc; if(SZ_BufftoBuffDecompress(outbuf, &size_out, newbuf, nbytes-4, &sz_param) != SZ_OK) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "szip_filter: decompression failed") - assert(size_out==nalloc); + HDassert(size_out==nalloc); /* Free the input buffer */ H5MM_xfree(*buf); @@ -351,7 +351,7 @@ H5Z_filter_szip (unsigned flags, size_t cd_nelmts, const unsigned cd_values[], size_out = nbytes; if(SZ_OK!= SZ_BufftoBuffCompress(dst, &size_out, *buf, nbytes, &sz_param)) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, 0, "overflow") - assert(size_out<=nbytes); + HDassert(size_out<=nbytes); /* Free the input buffer */ H5MM_xfree(*buf); diff --git a/src/H5Ztrans.c b/src/H5Ztrans.c index 498db03..f9e7186 100644 --- a/src/H5Ztrans.c +++ b/src/H5Ztrans.c @@ -378,7 +378,7 @@ H5Z_unget_token(H5Z_token *current) FUNC_ENTER_NOAPI_NOINIT_NOERR /* check args */ - assert(current); + HDassert(current); current->tok_type = current->tok_last_type; current->tok_begin = current->tok_last_begin; @@ -414,7 +414,7 @@ H5Z_get_token(H5Z_token *current) FUNC_ENTER_NOAPI_NOINIT /* check args */ - assert(current); + HDassert(current); /* Save the last position for possible ungets */ current->tok_last_type = current->tok_type; @@ -424,9 +424,9 @@ H5Z_get_token(H5Z_token *current) current->tok_begin = current->tok_end; while (current->tok_begin[0] != '\0') { - if (isspace(current->tok_begin[0])) { + if (HDisspace(current->tok_begin[0])) { /* ignore whitespace */ - } else if (isdigit(current->tok_begin[0]) || + } else if (HDisdigit(current->tok_begin[0]) || current->tok_begin[0] == '.') { current->tok_end = current->tok_begin; @@ -439,7 +439,7 @@ H5Z_get_token(H5Z_token *current) /* is number */ current->tok_type = H5Z_XFORM_INTEGER; - while (isdigit(current->tok_end[0])) + while (HDisdigit(current->tok_end[0])) ++current->tok_end; } @@ -458,7 +458,7 @@ H5Z_get_token(H5Z_token *current) if (current->tok_end[0] == '.') do { ++current->tok_end; - } while (isdigit(current->tok_end[0])); + } while (HDisdigit(current->tok_end[0])); if (current->tok_end[0] == 'e' || current->tok_end[0] == 'E') { @@ -468,29 +468,29 @@ H5Z_get_token(H5Z_token *current) current->tok_end[0] == '+') ++current->tok_end; - if (!isdigit(current->tok_end[0])) { + if (!HDisdigit(current->tok_end[0])) { current->tok_type = H5Z_XFORM_ERROR; HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, current, "Invalidly formatted floating point number") } - while (isdigit(current->tok_end[0])) + while (HDisdigit(current->tok_end[0])) ++current->tok_end; } /* Check that this is a properly formatted numerical value */ - if (isalpha(current->tok_end[0]) || current->tok_end[0] == '.') { + if (HDisalpha(current->tok_end[0]) || current->tok_end[0] == '.') { current->tok_type = H5Z_XFORM_ERROR; HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, current, "Invalidly formatted floating point number") } } break; - } else if (isalpha(current->tok_begin[0])) { + } else if (HDisalpha(current->tok_begin[0])) { /* is symbol */ current->tok_type = H5Z_XFORM_SYMBOL; current->tok_end = current->tok_begin; - while (isalnum(current->tok_end[0])) + while (HDisalnum(current->tok_end[0])) ++current->tok_end; break; @@ -995,7 +995,7 @@ H5Z_xform_eval(H5Z_data_xform_t *data_xform_prop, void* array, size_t array_size 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) + else if(array_type == H5T_NATIVE_INT) H5Z_XFORM_DO_OP5(int, array_size) else if(array_type == H5T_NATIVE_UINT) H5Z_XFORM_DO_OP5(unsigned int, array_size) @@ -1026,10 +1026,10 @@ H5Z_xform_eval(H5Z_data_xform_t *data_xform_prop, void* array, size_t array_size /* If it's a quadratic transform, we have no choice but to store multiple copies of the data */ else { for(i = 0; i < data_xform_prop->dat_val_pointers->num_ptrs; i++) { - if(NULL == (data_xform_prop->dat_val_pointers->ptr_dat_val[i] = (void*)H5MM_malloc(array_size * H5Tget_size(array_type)))) + if(NULL == (data_xform_prop->dat_val_pointers->ptr_dat_val[i] = (void*)H5MM_malloc(array_size * H5T_get_size((H5T_t *)H5I_object(array_type))))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "Ran out of memory trying to allocate space for data in data transform") - HDmemcpy(data_xform_prop->dat_val_pointers->ptr_dat_val[i], array, array_size * H5Tget_size(array_type)); + HDmemcpy(data_xform_prop->dat_val_pointers->ptr_dat_val[i], array, array_size * H5T_get_size((H5T_t *)H5I_object(array_type))); } /* end for */ } /* end else */ @@ -1037,7 +1037,7 @@ H5Z_xform_eval(H5Z_data_xform_t *data_xform_prop, void* array, size_t array_size HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "error while performing data transform") if(data_xform_prop->dat_val_pointers->num_ptrs > 1) - HDmemcpy(array, res.value.dat_val, array_size * H5Tget_size(array_type)); + HDmemcpy(array, res.value.dat_val, array_size * H5T_get_size((H5T_t *)H5I_object(array_type))); /* Free the temporary arrays we used */ if(data_xform_prop->dat_val_pointers->num_ptrs > 1) @@ -1175,60 +1175,60 @@ H5Z_xform_find_type(const H5T_t* type) HDassert(type); /* Check for SHORT type */ - if((tmp = (H5T_t *)H5I_object_verify(H5T_NATIVE_SHORT, H5I_DATATYPE)) + if((tmp = (H5T_t *)H5I_object(H5T_NATIVE_SHORT)) && 0 == H5T_cmp(type, tmp, FALSE)) HGOTO_DONE(H5T_NATIVE_SHORT) /* Check for INT type */ - else if((tmp = (H5T_t *)H5I_object_verify(H5T_NATIVE_INT, H5I_DATATYPE)) + else if((tmp = (H5T_t *)H5I_object(H5T_NATIVE_INT)) && 0 == H5T_cmp(type, tmp, FALSE)) HGOTO_DONE(H5T_NATIVE_INT) /* Check for LONG type */ - else if((tmp = (H5T_t *)H5I_object_verify(H5T_NATIVE_LONG, H5I_DATATYPE)) + else if((tmp = (H5T_t *)H5I_object(H5T_NATIVE_LONG)) && 0 == H5T_cmp(type, tmp, FALSE)) HGOTO_DONE(H5T_NATIVE_LONG) /* Check for LONGLONG type */ - else if((tmp = (H5T_t *)H5I_object_verify(H5T_NATIVE_LLONG, H5I_DATATYPE)) + else if((tmp = (H5T_t *)H5I_object(H5T_NATIVE_LLONG)) && 0 == H5T_cmp(type, tmp, FALSE)) HGOTO_DONE(H5T_NATIVE_LLONG) /* Check for UCHAR type */ - else if((tmp = (H5T_t *)H5I_object_verify(H5T_NATIVE_UCHAR, H5I_DATATYPE)) + else if((tmp = (H5T_t *)H5I_object(H5T_NATIVE_UCHAR)) && 0 == H5T_cmp(type, tmp, FALSE)) HGOTO_DONE(H5T_NATIVE_UCHAR) /* Check for CHAR type */ - else if((tmp = (H5T_t *)H5I_object_verify(H5T_NATIVE_CHAR, H5I_DATATYPE)) + else if((tmp = (H5T_t *)H5I_object(H5T_NATIVE_CHAR)) && 0 == H5T_cmp(type, tmp, FALSE)) HGOTO_DONE(H5T_NATIVE_CHAR) /* Check for SCHAR type */ - else if((tmp = (H5T_t *)H5I_object_verify(H5T_NATIVE_SCHAR, H5I_DATATYPE)) + else if((tmp = (H5T_t *)H5I_object(H5T_NATIVE_SCHAR)) && 0 == H5T_cmp(type, tmp, FALSE)) HGOTO_DONE(H5T_NATIVE_SCHAR) /* Check for USHORT type */ - else if((tmp = (H5T_t *)H5I_object_verify(H5T_NATIVE_USHORT, H5I_DATATYPE)) + else if((tmp = (H5T_t *)H5I_object(H5T_NATIVE_USHORT)) && 0 == H5T_cmp(type, tmp, FALSE)) HGOTO_DONE(H5T_NATIVE_USHORT) /* Check for UINT type */ - else if((tmp = (H5T_t *)H5I_object_verify(H5T_NATIVE_UINT, H5I_DATATYPE)) + else if((tmp = (H5T_t *)H5I_object(H5T_NATIVE_UINT)) && 0 == H5T_cmp(type, tmp, FALSE)) HGOTO_DONE(H5T_NATIVE_UINT) /* Check for ULONG type */ - else if((tmp = (H5T_t *)H5I_object_verify(H5T_NATIVE_ULONG, H5I_DATATYPE)) + else if((tmp = (H5T_t *)H5I_object(H5T_NATIVE_ULONG)) && 0 == H5T_cmp(type, tmp, FALSE)) HGOTO_DONE(H5T_NATIVE_ULONG) /* Check for ULONGLONG type */ - else if((tmp = (H5T_t *)H5I_object_verify(H5T_NATIVE_ULLONG, H5I_DATATYPE)) + else if((tmp = (H5T_t *)H5I_object(H5T_NATIVE_ULLONG)) && 0 == H5T_cmp(type, tmp, FALSE)) HGOTO_DONE(H5T_NATIVE_ULLONG) /* Check for FLOAT type */ - else if((tmp = (H5T_t *)H5I_object_verify(H5T_NATIVE_FLOAT, H5I_DATATYPE)) + else if((tmp = (H5T_t *)H5I_object(H5T_NATIVE_FLOAT)) && 0 == H5T_cmp(type, tmp, FALSE)) HGOTO_DONE(H5T_NATIVE_FLOAT) /* Check for DOUBLE type */ - else if((tmp = (H5T_t *)H5I_object_verify(H5T_NATIVE_DOUBLE, H5I_DATATYPE)) + else if((tmp = (H5T_t *)H5I_object(H5T_NATIVE_DOUBLE)) && 0 == H5T_cmp(type, tmp, FALSE)) HGOTO_DONE(H5T_NATIVE_DOUBLE) #if H5_SIZEOF_LONG_DOUBLE !=0 /* Check for LONGDOUBLE type */ - else if((tmp = (H5T_t *)H5I_object_verify(H5T_NATIVE_LDOUBLE, H5I_DATATYPE)) + else if((tmp = (H5T_t *)H5I_object(H5T_NATIVE_LDOUBLE)) && 0 == H5T_cmp(type, tmp, FALSE)) HGOTO_DONE(H5T_NATIVE_LDOUBLE) #endif @@ -1258,7 +1258,7 @@ H5Z_xform_copy_tree(H5Z_node* tree, H5Z_datval_ptrs* dat_val_pointers, H5Z_datva FUNC_ENTER_NOAPI(NULL) - assert(tree); + HDassert(tree); if(tree->type == H5Z_XFORM_INTEGER) { @@ -1335,7 +1335,7 @@ H5Z_op_is_numbs(H5Z_node* _tree) FUNC_ENTER_NOAPI_NOINIT_NOERR - assert(_tree); + HDassert(_tree); if(((_tree->lchild->type == H5Z_XFORM_INTEGER) || (_tree->lchild->type == H5Z_XFORM_FLOAT)) && ((_tree->rchild->type == H5Z_XFORM_INTEGER) || (_tree->rchild->type == H5Z_XFORM_FLOAT))) ret_value = TRUE; @@ -1364,7 +1364,7 @@ H5Z_op_is_numbs2(H5Z_node* _tree) FUNC_ENTER_NOAPI_NOINIT_NOERR - assert(_tree); + HDassert(_tree); if((!_tree->lchild && ((_tree->rchild->type == H5Z_XFORM_INTEGER) || (_tree->rchild->type == H5Z_XFORM_FLOAT))) || ((_tree->lchild && ((_tree->lchild->type == H5Z_XFORM_INTEGER) || (_tree->lchild->type == H5Z_XFORM_FLOAT))) && (_tree->rchild && ((_tree->rchild->type == H5Z_XFORM_INTEGER) || (_tree->rchild->type == H5Z_XFORM_FLOAT))))) @@ -1494,7 +1494,7 @@ H5Z_xform_create(const char *expr) FUNC_ENTER_NOAPI(NULL) - assert(expr); + HDassert(expr); /* Allocate space for the data transform information */ if(NULL == (data_xform_prop = (H5Z_data_xform_t *)H5MM_calloc(sizeof(H5Z_data_xform_t)))) @@ -1740,7 +1740,7 @@ H5Z_xform_extract_xform_str(const H5Z_data_xform_t *data_xform_prop) /* There should be no way that this can be NULL since the function * that calls this one checks to make sure it isn't before * pasing them */ - assert(data_xform_prop); + HDassert(data_xform_prop); FUNC_LEAVE_NOAPI(data_xform_prop->xform_exp) } /* H5Z_xform_extract_xform_str() */ diff --git a/src/H5detect.c b/src/H5detect.c index d6f6a3b..2bf0d2d 100644 --- a/src/H5detect.c +++ b/src/H5detect.c @@ -246,7 +246,7 @@ precision (detected_t *d) _v = (_v << 8) + _i; \ for(_i = 0, _x = (unsigned char *)&_v; _i < (signed)sizeof(TYPE); _i++) { \ _j = (*_x++) - 1; \ - assert(_j < (signed)sizeof(TYPE)); \ + HDassert(_j < (signed)sizeof(TYPE)); \ INFO.perm[_i] = _j; \ } /* end for */ \ } else { /*Not able to detect order if type size is 1 byte. Use native int \ @@ -255,7 +255,7 @@ precision (detected_t *d) _int_v = (_int_v << 8) + _i; \ for(_i = 0, _x = (unsigned char *)&_int_v; _i < (signed)sizeof(int); _i++) { \ _j = (*_x++)-1; \ - assert(_j < (signed)sizeof(int)); \ + HDassert(_j < (signed)sizeof(int)); \ INFO.perm[_i] = _j; \ } /* end for */ \ } /* end else */ \ @@ -296,23 +296,23 @@ precision (detected_t *d) int _i, _j, _last = (-1); \ char *_mesg; \ \ - memset(&INFO, 0, sizeof(INFO)); \ + HDmemset(&INFO, 0, sizeof(INFO)); \ INFO.varname = #VAR; \ INFO.size = sizeof(TYPE); \ \ /* Completely initialize temporary variables, in case the bits used in */ \ /* the type take less space than the number of bits used to store the type */ \ - memset(&_v3, 0, sizeof(TYPE)); \ - memset(&_v2, 0, sizeof(TYPE)); \ - memset(&_v1, 0, sizeof(TYPE)); \ + HDmemset(&_v3, 0, sizeof(TYPE)); \ + HDmemset(&_v2, 0, sizeof(TYPE)); \ + HDmemset(&_v1, 0, sizeof(TYPE)); \ \ /* Byte Order */ \ for(_i = 0, _v1 = 0.0, _v2 = 1.0; _i < (int)sizeof(TYPE); _i++) { \ _v3 = _v1; \ _v1 += _v2; \ _v2 /= 256.0; \ - memcpy(_buf1, (const void *)&_v1, sizeof(TYPE)); \ - memcpy(_buf3, (const void *)&_v3, sizeof(TYPE)); \ + HDmemcpy(_buf1, (const void *)&_v1, sizeof(TYPE)); \ + HDmemcpy(_buf3, (const void *)&_v3, sizeof(TYPE)); \ _j = byte_cmp(sizeof(TYPE), &_buf3, &_buf1); \ if(_j >= 0) { \ INFO.perm[_i] = _j; \ @@ -321,7 +321,7 @@ precision (detected_t *d) } \ fix_order(sizeof(TYPE), _last, INFO.perm, (const char**)&_mesg); \ \ - if(!strcmp(_mesg, "VAX")) \ + if(!HDstrcmp(_mesg, "VAX")) \ INFO.is_vax = TRUE; \ \ /* Implicit mantissa bit */ \ @@ -351,8 +351,8 @@ precision (detected_t *d) INFO.bias = find_bias (INFO.epos, INFO.esize, INFO.perm, &_v1); \ precision (&(INFO)); \ ALIGNMENT(TYPE, INFO); \ - if(!strcmp(INFO.varname, "FLOAT") || !strcmp(INFO.varname, "DOUBLE") || \ - !strcmp(INFO.varname, "LDOUBLE")) { \ + if(!HDstrcmp(INFO.varname, "FLOAT") || !HDstrcmp(INFO.varname, "DOUBLE") || \ + !HDstrcmp(INFO.varname, "LDOUBLE")) { \ COMP_ALIGNMENT(TYPE,INFO.comp_align); \ } \ } @@ -399,7 +399,7 @@ precision (detected_t *d) void (*_handler)(int) = HDsignal(SIGBUS, sigbus_handler); \ void (*_handler2)(int) = HDsignal(SIGSEGV, sigsegv_handler);\ \ - _buf = (char*)malloc(sizeof(TYPE) + align_g[NELMTS(align_g) - 1]); \ + _buf = (char*)HDmalloc(sizeof(TYPE) + align_g[NELMTS(align_g) - 1]); \ if(H5SETJMP(jbuf_g)) _ano++; \ if(_ano < NELMTS(align_g)) { \ *((TYPE*)(_buf+align_g[_ano])) = _val; /*possible SIGBUS or SEGSEGV*/ \ @@ -409,12 +409,12 @@ precision (detected_t *d) /* pointer values when pointing to non-word aligned */ \ /* locations with pointers that are supposed to be */ \ /* word aligned. -QAK */ \ - memset(_buf, 0xff, sizeof(TYPE)+align_g[NELMTS(align_g)-1]); \ + HDmemset(_buf, 0xff, sizeof(TYPE)+align_g[NELMTS(align_g)-1]); \ /*How to handle VAX types?*/ \ if(INFO.perm[0]) /* Big-Endian */ \ - memcpy(_buf+align_g[_ano]+(INFO.size-((INFO.offset+INFO.precision)/8)),((char *)&_val)+(INFO.size-((INFO.offset+INFO.precision)/8)),(size_t)(INFO.precision/8)); \ + HDmemcpy(_buf+align_g[_ano]+(INFO.size-((INFO.offset+INFO.precision)/8)),((char *)&_val)+(INFO.size-((INFO.offset+INFO.precision)/8)),(size_t)(INFO.precision/8)); \ else /* Little-Endian */ \ - memcpy(_buf+align_g[_ano]+(INFO.offset/8),((char *)&_val)+(INFO.offset/8),(size_t)(INFO.precision/8)); \ + HDmemcpy(_buf+align_g[_ano]+(INFO.offset/8),((char *)&_val)+(INFO.offset/8),(size_t)(INFO.precision/8)); \ _val2 = *((TYPE*)(_buf+align_g[_ano])); \ if(_val!=_val2) \ H5LONGJMP(jbuf_g, 1); \ @@ -424,7 +424,7 @@ precision (detected_t *d) (INFO.align)=0; \ fprintf(stderr, "unable to calculate alignment for %s\n", #TYPE); \ } \ - free(_buf); \ + HDfree(_buf); \ HDsignal(SIGBUS, _handler); /*restore original handler*/ \ HDsignal(SIGSEGV, _handler2); /*restore original handler*/ \ } @@ -669,7 +669,7 @@ H5TN_init_interface(void)\n\ dt->shared->u.atomic.msb_pad = H5T_PAD_ZERO;\n", d[i].offset, /*offset */ d[i].precision); /*precision */ - /*assert((d[i].perm[0]>0)==(byte_order>0));*/ /* Double-check that byte-order doesn't change */ + /*HDassert((d[i].perm[0]>0)==(byte_order>0));*/ /* Double-check that byte-order doesn't change */ if (0 == d[i].msize) { /* The part unique to fixed point types */ @@ -705,10 +705,10 @@ H5TN_init_interface(void)\n\ d[i].varname, (unsigned long)(d[i].align)); /* Variables for alignment of compound datatype */ - if(!strcmp(d[i].varname, "SCHAR") || !strcmp(d[i].varname, "SHORT") || - !strcmp(d[i].varname, "INT") || !strcmp(d[i].varname, "LONG") || - !strcmp(d[i].varname, "LLONG") || !strcmp(d[i].varname, "FLOAT") || - !strcmp(d[i].varname, "DOUBLE") || !strcmp(d[i].varname, "LDOUBLE")) { + if(!HDstrcmp(d[i].varname, "SCHAR") || !HDstrcmp(d[i].varname, "SHORT") || + !HDstrcmp(d[i].varname, "INT") || !HDstrcmp(d[i].varname, "LONG") || + !HDstrcmp(d[i].varname, "LLONG") || !HDstrcmp(d[i].varname, "FLOAT") || + !HDstrcmp(d[i].varname, "DOUBLE") || !HDstrcmp(d[i].varname, "LDOUBLE")) { printf(" H5T_NATIVE_%s_COMP_ALIGN_g = %lu;\n", d[i].varname, (unsigned long)(d[i].comp_align)); } @@ -823,7 +823,7 @@ iprint(detected_t *d) printf(" * "); for (i=MIN(pass*4+3,d->size-1); i>=pass*4; --i) { printf ("%4d", d->perm[i]); - if (i>pass*4) fputs (" ", stdout); + if (i>pass*4) HDfputs (" ", stdout); } /* @@ -835,23 +835,23 @@ iprint(detected_t *d) i>=pass*4; --i) { for (j=7; j>=0; --j) { if (k==d->sign && d->msize) { - putchar('S'); + HDputchar('S'); } else if (k>=d->epos && kepos+d->esize) { - putchar('E'); + HDputchar('E'); } else if (k>=d->mpos && kmpos+d->msize) { - putchar('M'); + HDputchar('M'); } else if (d->msize) { - putchar('?'); /*unknown floating point bit */ + HDputchar('?'); /*unknown floating point bit */ } else if (d->sign) { - putchar('I'); + HDputchar('I'); } else { - putchar('U'); + HDputchar('U'); } --k; } - if (i>pass*4) putchar(' '); + if (i>pass*4) HDputchar(' '); } - putchar('\n'); + HDputchar('\n'); } /* @@ -934,13 +934,13 @@ bit_cmp(int nbytes, int *perm, volatile void *_a, volatile void *_b) unsigned char aa, bb; for (i = 0; i < nbytes; i++) { - assert(perm[i] < nbytes); + HDassert(perm[i] < nbytes); if ((aa = a[perm[i]]) != (bb = b[perm[i]])) { for (j = 0; j < 8; j++, aa >>= 1, bb >>= 1) { if ((aa & 1) != (bb & 1)) return i * 8 + j; } - assert("INTERNAL ERROR" && 0); - abort(); + HDassert("INTERNAL ERROR" && 0); + HDabort(); } } return -1; @@ -998,7 +998,7 @@ fix_order(int n, int last, int *perm, const char **mesg) * It could have some other endianess and fall into this * case - JKM & QAK) */ - assert(0 == n % 2); + HDassert(0 == n % 2); if (mesg) *mesg = "VAX"; for (i = 0; i < n; i += 2) { perm[i] = (n - 2) - i; @@ -1008,7 +1008,7 @@ fix_order(int n, int last, int *perm, const char **mesg) } else { fprintf(stderr, "Failed to detect byte order of %d-byte floating point.\n", n); - exit(1); + HDexit(1); } } @@ -1062,7 +1062,7 @@ imp_bit(int n, int *perm, volatile void *_a, volatile void *_b) * A and B. This is the least significant bit of the exponent. */ changed = bit_cmp(n, perm, a, b); - assert(changed >= 0); + HDassert(changed >= 0); /* * The bit to the right (less significant) of the changed bit should @@ -1139,8 +1139,8 @@ static void print_header(void) { - time_t now = time(NULL); - struct tm *tm = localtime(&now); + time_t now = HDtime(NULL); + struct tm *tm = HDlocaltime(&now); char real_name[30]; char host_name[256]; int i; @@ -1199,13 +1199,13 @@ bit.\n"; { size_t n; char *comma; - if ((pwd = getpwuid(getuid()))) { - if ((comma = strchr(pwd->pw_gecos, ','))) { + if ((pwd = HDgetpwuid(HDgetuid()))) { + if ((comma = HDstrchr(pwd->pw_gecos, ','))) { n = MIN(sizeof(real_name)-1, (unsigned)(comma-pwd->pw_gecos)); - strncpy(real_name, pwd->pw_gecos, n); + HDstrncpy(real_name, pwd->pw_gecos, n); real_name[n] = '\0'; } else { - strncpy(real_name, pwd->pw_gecos, sizeof(real_name)); + HDstrncpy(real_name, pwd->pw_gecos, sizeof(real_name)); real_name[sizeof(real_name) - 1] = '\0'; } } else { @@ -1220,7 +1220,7 @@ bit.\n"; * The FQDM of this host or the empty string. */ #ifdef H5_HAVE_GETHOSTNAME - if (gethostname(host_name, sizeof(host_name)) < 0) { + if (HDgethostname(host_name, sizeof(host_name)) < 0) { host_name[0] = '\0'; } #else @@ -1231,7 +1231,7 @@ bit.\n"; * The file header: warning, copyright notice, build information. */ printf("/* Generated automatically by H5detect -- do not edit */\n\n\n"); - puts(FileHeader); /*the copyright notice--see top of this file */ + HDputs(FileHeader); /*the copyright notice--see top of this file */ printf(" *\n * Created:\t\t%s %2d, %4d\n", month_name[tm->tm_mon], tm->tm_mday, 1900 + tm->tm_year); @@ -1239,15 +1239,15 @@ bit.\n"; printf(" *\t\t\t"); if (real_name[0]) printf("%s <", real_name); #ifdef H5_HAVE_GETPWUID - if (pwd) fputs(pwd->pw_name, stdout); + if (pwd) HDfputs(pwd->pw_name, stdout); #endif if (host_name[0]) printf("@%s", host_name); if (real_name[0]) printf(">"); - putchar('\n'); + HDputchar('\n'); } printf(" *\n * Purpose:\t\t"); for (s = purpose; *s; s++) { - putchar(*s); + HDputchar(*s); if ('\n' == *s && s[1]) printf(" *\t\t\t"); } @@ -1256,7 +1256,7 @@ bit.\n"; printf(" *\tIt was generated by code in `H5detect.c'.\n"); printf(" *\n *"); - for (i = 0; i < 73; i++) putchar('-'); + for (i = 0; i < 73; i++) HDputchar('-'); printf("\n */\n\n"); } @@ -1645,7 +1645,7 @@ main(void) nvpairs[1] = UAC_NOPRINT | UAC_SIGBUS; if (setsysinfo(SSI_NVPAIRS, nvpairs, 1, 0, 0)<0) { fprintf(stderr, "H5detect: unable to turn off UAC handling: %s\n", - strerror(errno)); + HDstrerror(errno)); } #endif #endif diff --git a/src/H5make_libsettings.c b/src/H5make_libsettings.c index d903592..fa00c64 100644 --- a/src/H5make_libsettings.c +++ b/src/H5make_libsettings.c @@ -94,7 +94,7 @@ insert_libhdf5_settings(FILE *flibinfo) else HDputc(inchar, flibinfo); } /* end while */ - if(feof(fsettings)) { + if(HDfeof(fsettings)) { /* wrap up */ if(!bol) /* EOF found without a new line */ @@ -182,7 +182,7 @@ information about the library build configuration\n"; size_t n; char *comma; - if((pwd = HDgetpwuid(getuid()))) { + if((pwd = HDgetpwuid(HDgetuid()))) { if((comma = HDstrchr(pwd->pw_gecos, ','))) { n = MIN(sizeof(real_name) - 1, (unsigned)(comma - pwd->pw_gecos)); HDstrncpy(real_name, pwd->pw_gecos, n); @@ -204,7 +204,7 @@ information about the library build configuration\n"; * The FQDM of this host or the empty string. */ #ifdef H5_HAVE_GETHOSTNAME - if(gethostname(host_name, sizeof(host_name)) < 0) + if(HDgethostname(host_name, sizeof(host_name)) < 0) host_name[0] = '\0'; #else host_name[0] = '\0'; diff --git a/src/H5private.h b/src/H5private.h index c2ef54a..74b918f 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -844,6 +844,9 @@ H5_DLL int HDfprintf (FILE *stream, const char *fmt, ...); #ifndef HDgetgroups #define HDgetgroups(Z,G) getgroups(Z,G) #endif /* HDgetgroups */ +#ifndef HDgethostname + #define HDgethostname(N,L) gethostname(N,L) +#endif /* HDgetlogin */ #ifndef HDgetlogin #define HDgetlogin() getlogin() #endif /* HDgetlogin */ @@ -2369,7 +2372,11 @@ func_init_failed: \ #define H5_GLUE4(w,x,y,z) w##x##y##z /* Compile-time "assert" macro */ -#define HDcompile_assert(e) do { enum { compile_assert__ = 1 / (e) }; } while(0) +#define HDcompile_assert(e) ((void)sizeof(char[ !!(e) ? 1 : -1])) +/* Variants that are correct, but generate compile-time warnings in some circumstances: + #define HDcompile_assert(e) do { enum { compile_assert__ = 1 / (e) }; } while(0) + #define HDcompile_assert(e) do { typedef struct { unsigned int b: (e); } x; } while(0) +*/ /* Private functions, not part of the publicly documented API */ H5_DLL herr_t H5_init_library(void); diff --git a/src/H5public.h b/src/H5public.h index 391b705..345e3ff 100644 --- a/src/H5public.h +++ b/src/H5public.h @@ -75,10 +75,10 @@ extern "C" { /* Version numbers */ #define H5_VERS_MAJOR 1 /* For major interface/format changes */ #define H5_VERS_MINOR 9 /* For minor interface/format changes */ -#define H5_VERS_RELEASE 151 /* For tweaks, bug-fixes, or development */ +#define H5_VERS_RELEASE 152 /* For tweaks, bug-fixes, or development */ #define H5_VERS_SUBRELEASE "FA_a5" /* For pre-releases like snap0 */ /* Empty string for real releases. */ -#define H5_VERS_INFO "HDF5 library version: 1.9.151-FA_a5" /* Full version string */ +#define H5_VERS_INFO "HDF5 library version: 1.9.152-FA_a5" /* Full version string */ #define H5check() H5check_version(H5_VERS_MAJOR,H5_VERS_MINOR, \ H5_VERS_RELEASE) diff --git a/src/H5system.c b/src/H5system.c index 3ffe411..a93a128 100644 --- a/src/H5system.c +++ b/src/H5system.c @@ -117,8 +117,8 @@ HDfprintf(FILE *stream, const char *fmt, ...) const char *s; va_list ap; - assert (stream); - assert (fmt); + HDassert(stream); + HDassert(fmt); va_start (ap, fmt); while (*fmt) { diff --git a/src/H5timer.c b/src/H5timer.c index 7bdee8a..301d98b 100644 --- a/src/H5timer.c +++ b/src/H5timer.c @@ -97,8 +97,8 @@ void H5_timer_reset (H5_timer_t *timer) { - assert (timer); - HDmemset (timer, 0, sizeof *timer); + HDassert(timer); + HDmemset(timer, 0, sizeof *timer); } /* end H5_timer_reset() */ @@ -126,7 +126,7 @@ H5_timer_begin (H5_timer_t *timer) struct timeval etime; #endif - assert (timer); + HDassert(timer); #ifdef H5_HAVE_GETRUSAGE HDgetrusage (RUSAGE_SELF, &rusage); @@ -169,7 +169,7 @@ H5_timer_end (H5_timer_t *sum/*in,out*/, H5_timer_t *timer/*in,out*/) { H5_timer_t now; - assert (timer); + HDassert(timer); H5_timer_begin (&now); timer->utime = MAX(0.0, now.utime - timer->utime); @@ -220,7 +220,7 @@ H5_bandwidth(char *buf/*out*/, double nbytes, double nseconds) HDstrcpy(buf, " NaN"); else { bw = nbytes/nseconds; - if(fabs(bw) < 0.0000000001) + if(HDfabs(bw) < 0.0000000001) /* That is == 0.0, but direct comparison between floats is bad */ HDstrcpy(buf, "0.000 B/s"); else if(bw < 1.0) diff --git a/src/H5trace.c b/src/H5trace.c index 92736d4..2babcd4 100644 --- a/src/H5trace.c +++ b/src/H5trace.c @@ -156,7 +156,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) } /* end if */ /* Get tim for event */ - if(fabs(first_time.etime) < 0.0000000001) + if(HDfabs(first_time.etime) < 0.0000000001) /* That is == 0.0, but direct comparison between floats is bad */ H5_timer_begin(&first_time); if(H5_debug_g.ttimes) @@ -179,10 +179,10 @@ H5_trace(const double *returning, const char *func, const char *type, ...) char tmp[128]; sprintf(tmp, "%.6f", event_time.etime-first_time.etime); - fprintf(out, " %*s ", (int)strlen(tmp), ""); + fprintf(out, " %*s ", (int)HDstrlen(tmp), ""); } /* end if */ for(i = 0; i < current_depth; i++) - fputc('+', out); + HDfputc('+', out); fprintf(out, "%*s%s = ", 2*current_depth, "", func); } /* end if */ else { @@ -192,11 +192,11 @@ H5_trace(const double *returning, const char *func, const char *type, ...) } /* end if */ else { if(current_depth>last_call_depth) - fputs(" = \n", out); + HDfputs(" = \n", out); if(H5_debug_g.ttimes) fprintf(out, "@%.6f ", event_time.etime - first_time.etime); for(i = 0; i < current_depth; i++) - fputc('+', out); + HDfputc('+', out); fprintf(out, "%*s%s(", 2*current_depth, "", func); } /* end else */ diff --git a/src/Makefile.in b/src/Makefile.in index 652f4ec..2156c8f 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -525,7 +525,7 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog # Add libtool shared library version numbers to the HDF5 library # See libtool versioning documentation online. LT_VERS_INTERFACE = 6 -LT_VERS_REVISION = 141 +LT_VERS_REVISION = 142 LT_VERS_AGE = 0 H5detect_CFLAGS = -g $(AM_CFLAGS) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 8904fee..766ed7b 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -397,6 +397,8 @@ ADD_TEST ( testmeta.h5 tstint1.h5 tstint2.h5 + unregister_filter_1.h5 + unregister_filter_2.h5 ) SET (H5_TESTS @@ -453,6 +455,7 @@ SET (H5_TESTS file_image enc_dec_plist enc_dec_plist_with_endianess + unregister ) FOREACH (test ${H5_TESTS}) @@ -728,6 +731,7 @@ IF (HDF5_TEST_VFD) tcheck_version testmeta links_env + unregister ) IF (DIRECT_VFD) diff --git a/test/H5srcdir.h b/test/H5srcdir.h index 8bc8780..202d050 100644 --- a/test/H5srcdir.h +++ b/test/H5srcdir.h @@ -50,10 +50,12 @@ static const char *H5_get_srcdir_filename(const char *filename) #ifdef H5_VMS if(filename[0] == '[') { char *tmp = filename; - srcdir_testpath[strlen(srcdir)-1] = '\0'; - strcat(srcdir_testpath, ++tmp); - } else - strcat(srcdir_testpath, filename); + + srcdir_testpath[HDstrlen(srcdir) - 1] = '\0'; + HDstrcat(srcdir_testpath, ++tmp); + } /* end if */ + else + HDstrcat(srcdir_testpath, filename); #else HDstrcat(srcdir_testpath, "/"); HDstrcat(srcdir_testpath, filename); @@ -84,4 +86,3 @@ static const char *H5_get_srcdir(void) } #endif /* _H5SRCDIR_H */ - diff --git a/test/file_image.c b/test/file_image.c index c734db8..d4056a7 100644 --- a/test/file_image.c +++ b/test/file_image.c @@ -1207,6 +1207,9 @@ test_get_file_image_error_rejection(void) err = H5Fclose(file_id); VERIFY(err == SUCCEED, "H5Fclose(2) failed."); + /* tidy up */ + result = h5_cleanup(FILENAME2, fapl_id); + VERIFY(result != 0, "h5_cleanup(2 failed."); /************************** Test #4 **********************************/ /* set up a family file driver test file, and try to get its image diff --git a/test/h5test.c b/test/h5test.c index 91497e3..32d78bd 100644 --- a/test/h5test.c +++ b/test/h5test.c @@ -1124,24 +1124,8 @@ h5_make_local_copy(const char *origfilename, const char *local_copy_name) { int fd_old = (-1), fd_new = (-1); /* File descriptors for copying data */ ssize_t nread; /* Number of bytes read in */ - char buf[READ_BUF_SIZE]; /* Buffer for copying data */ - char filename[FILENAME_BUF_SIZE] = ""; -#ifdef H5_VMS - HDstrcat(filename, origfilename); -#else - const char * srcdir = HDgetenv("srcdir"); /* The source directory */ - - /* Check for using the srcdir from configure time */ - if(NULL == srcdir) - srcdir = config_srcdir; - - if(srcdir && ((HDstrlen(srcdir) + - HDstrlen(origfilename) + 6) < FILENAME_BUF_SIZE)) { - HDstrcpy(filename, srcdir); - HDstrcat(filename, "/"); - } - HDstrcat(filename, origfilename); -#endif + char buf[READ_BUF_SIZE]; /* Buffer for copying data */ + const char *filename = H5_get_srcdir_filename(origfilename);; /* Get the test file name to copy */ /* Copy old file into temporary file */ if((fd_old = HDopen(filename, O_RDONLY, 0666)) < 0) return -1; diff --git a/test/links_env.c b/test/links_env.c index 2da5e64..308d562 100644 --- a/test/links_env.c +++ b/test/links_env.c @@ -21,7 +21,6 @@ #define H5G_TESTING #include "h5test.h" -#include "H5srcdir.h" #include "H5Gpkg.h" /* Groups */ #include "H5Iprivate.h" /* IDs */ #include "H5Lprivate.h" /* Links */ diff --git a/test/unregister.c b/test/unregister.c index 88f4d1b..383958d 100644 --- a/test/unregister.c +++ b/test/unregister.c @@ -145,7 +145,6 @@ test_unregister_filters(hid_t my_fapl) goto error; } /* end if */ - /* Close the group */ if(H5Gclose(gid) < 0) goto error; @@ -176,7 +175,6 @@ test_unregister_filters(hid_t my_fapl) goto error; /* Unregister the filter before closing the dataset. It should fail */ - /*if(H5Zunregister(H5Z_FILTER_DUMMY) < 0) goto error;*/ H5E_BEGIN_TRY { ret = H5Zunregister(H5Z_FILTER_DUMMY); } H5E_END_TRY; @@ -244,14 +242,14 @@ main(void) if(nerrors) goto error; - printf("All dataset tests passed.\n"); + printf("All filter unregistration tests passed.\n"); h5_cleanup(FILENAME, fapl); return 0; error: nerrors = MAX(1, nerrors); - printf("***** %d DATASET TEST%s FAILED! *****\n", + printf("***** %d FILTER UNREGISTRATION TEST%s FAILED! *****\n", nerrors, 1 == nerrors ? "" : "S"); return 1; } diff --git a/tools/h5jam/getub.c b/tools/h5jam/getub.c index f536605..d84f7f2 100644 --- a/tools/h5jam/getub.c +++ b/tools/h5jam/getub.c @@ -153,7 +153,7 @@ main (int argc, const char *argv[]) exit (EXIT_FAILURE); } - buf = malloc ((unsigned)(size + 1)); + buf = (char *)HDmalloc ((unsigned)(size + 1)); if (buf == NULL) { HDclose (fd); diff --git a/tools/h5stat/h5stat.c b/tools/h5stat/h5stat.c index a68760d..dcc2c08 100644 --- a/tools/h5stat/h5stat.c +++ b/tools/h5stat/h5stat.c @@ -136,7 +136,8 @@ static int display_object = FALSE; /* not implemented yet */ /* a structure for handling the order command-line parameters come in */ struct handler_t { - char *obj; + size_t obj_count; + char **obj; }; @@ -552,7 +553,7 @@ dataset_stats(iter_t *iter, const char *name, const H5O_info_t *oi) if(type_found) (iter->dset_type_info[u].count)++; else { - unsigned curr_ntype = iter->dset_ntypes; + unsigned curr_ntype = (unsigned)iter->dset_ntypes; /* Increment # of datatypes seen for datasets */ iter->dset_ntypes++; @@ -670,9 +671,11 @@ obj_stats(const char *path, const H5O_info_t *oi, const char *already_visited, break; case H5O_TYPE_NAMED_DATATYPE: - datatype_stats(iter, oi); + datatype_stats(iter, oi); break; + case H5O_TYPE_UNKNOWN: + case H5O_TYPE_NTYPES: default: /* Gather statistics about this type of object */ iter->uniq_others++; @@ -710,6 +713,9 @@ lnk_stats(const char UNUSED *path, const H5L_info_t *li, void *_iter) iter->uniq_links++; break; + case H5L_TYPE_HARD: + case H5L_TYPE_MAX: + case H5L_TYPE_ERROR: default: /* Gather statistics about this type of object */ iter->uniq_others++; @@ -740,19 +746,19 @@ freespace_stats(hid_t fid, iter_t *iter) /* Query section information */ if((nsects = H5Fget_free_sections(fid, H5FD_MEM_DEFAULT, 0, NULL)) < 0) - return(FAIL); + return(FAIL); else if(nsects) { - if(NULL == (sect_info = (H5F_sect_info_t *)HDcalloc((size_t)nsects, sizeof(H5F_sect_info_t)))) - return(FAIL); - nsects = H5Fget_free_sections(fid, H5FD_MEM_DEFAULT, (size_t)nsects, sect_info); - HDassert(nsects); + if(NULL == (sect_info = (H5F_sect_info_t *)HDcalloc((size_t)nsects, sizeof(H5F_sect_info_t)))) + return(FAIL); + nsects = H5Fget_free_sections(fid, H5FD_MEM_DEFAULT, (size_t)nsects, sect_info); + HDassert(nsects); } /* end else-if */ for(u = 0; u < (size_t)nsects; u++) { unsigned bin; /* "bin" the number of objects falls in */ - if(sect_info[u].size < SIZE_SMALL_SECTS) - (iter->num_small_sects[(size_t)sect_info[u].size])++; + if(sect_info[u].size < SIZE_SMALL_SECTS) + (iter->num_small_sects[(size_t)sect_info[u].size])++; /* Add section size to proper bin */ bin = ceil_log10((unsigned long)sect_info[u].size); @@ -781,6 +787,35 @@ freespace_stats(hid_t fid, iter_t *iter) /*------------------------------------------------------------------------- + * Function: hand_free + * + * Purpose: Free handler structure + * + * Return: Success: 0 + * + * Failure: Never fails + * + *------------------------------------------------------------------------- + */ +static void +hand_free(struct handler_t *hand) +{ + if(hand) { + unsigned u; + + for(u = 0; u < hand->obj_count; u++) + if(hand->obj[u]) { + HDfree(hand->obj[u]); + hand->obj[u] = NULL; + } /* end if */ + hand->obj_count = 0; + HDfree(hand->obj); + HDfree(hand); + } /* end if */ +} /* end hand_free() */ + + +/*------------------------------------------------------------------------- * Function: parse_command_line * * Purpose: Parses command line and sets up global variable to control output @@ -794,50 +829,25 @@ freespace_stats(hid_t fid, iter_t *iter) * *------------------------------------------------------------------------- */ -static struct handler_t * -parse_command_line(int argc, const char *argv[]) +static int +parse_command_line(int argc, const char *argv[], struct handler_t **hand_ret) { - int opt, i; + int opt; + unsigned u; struct handler_t *hand = NULL; - /* Allocate space to hold the command line info */ - if((hand = (struct handler_t *)HDcalloc((size_t)argc, sizeof(struct handler_t)))==NULL) { - error_msg("unable to parse command line arguments \n"); - goto error; - } - /* parse command line options */ - while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) { - switch ((char)opt) { + while((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) { + switch((char)opt) { case 'h': usage(h5tools_getprogname()); h5tools_setstatus(EXIT_SUCCESS); - if (hand) { - for (i = 0; i < argc; i++) - if(hand[i].obj) { - free(hand[i].obj); - hand[i].obj=NULL; - } - - free(hand); - hand = NULL; - } goto done; break; case 'V': print_version(h5tools_getprogname()); h5tools_setstatus(EXIT_SUCCESS); - if (hand) { - for (i = 0; i < argc; i++) - if(hand[i].obj) { - free(hand[i].obj); - hand[i].obj=NULL; - } - - free(hand); - hand = NULL; - } goto done; break; @@ -894,45 +904,52 @@ parse_command_line(int argc, const char *argv[]) case 'O': display_all = FALSE; display_object = TRUE; - for(i = 0; i < argc; i++) - if(!hand[i].obj) { - hand[i].obj = HDstrdup(opt_arg); - break; + + /* Allocate space to hold the command line info */ + if(NULL == (hand = (struct handler_t *)HDcalloc((size_t)1, sizeof(struct handler_t)))) { + error_msg("unable to allocate memory for object struct\n"); + goto error; + } /* end if */ + + /* Allocate space to hold the object strings */ + hand->obj_count = (size_t)argc; + if(NULL == (hand->obj = (char **)HDcalloc((size_t)argc, sizeof(char *)))) { + error_msg("unable to allocate memory for object array\n"); + goto error; + } /* end if */ + + /* Store object names */ + for(u = 0; u < hand->obj_count; u++) + if(NULL == (hand->obj[u] = HDstrdup(opt_arg))) { + error_msg("unable to allocate memory for object name\n"); + goto error; } /* end if */ break; default: usage(h5tools_getprogname()); - h5tools_setstatus(EXIT_FAILURE); goto error; } /* end switch */ } /* end while */ /* check for file name to be processed */ - if (argc <= opt_ind) { + if(argc <= opt_ind) { error_msg("missing file name\n"); usage(h5tools_getprogname()); - h5tools_setstatus(EXIT_FAILURE); goto error; } /* end if */ + /* Set handler structure */ + *hand_ret = hand; + done: - return hand; + return 0; error: - if (hand) { - for (i = 0; i < argc; i++) - if(hand[i].obj) { - free(hand[i].obj); - hand[i].obj=NULL; - } - - free(hand); - hand = NULL; - } + hand_free(hand); h5tools_setstatus(EXIT_FAILURE); - return hand; + return -1; } @@ -947,32 +964,39 @@ error: * *------------------------------------------------------------------------- */ -static herr_t +static void iter_free(iter_t *iter) { /* Clear array of bins for group counts */ - if(iter->group_bins) - free(iter->group_bins); - iter->group_bins = NULL; + if(iter->group_bins) { + HDfree(iter->group_bins); + iter->group_bins = NULL; + } /* end if */ + /* Clear array of bins for attribute counts */ - if(iter->attr_bins) - free(iter->attr_bins); - iter->attr_bins = NULL; + if(iter->attr_bins) { + HDfree(iter->attr_bins); + iter->attr_bins = NULL; + } /* end if */ + /* Clear dataset datatype information found */ - if(iter->dset_type_info) - free(iter->dset_type_info); - iter->dset_type_info = NULL; + if(iter->dset_type_info) { + HDfree(iter->dset_type_info); + iter->dset_type_info = NULL; + } /* end if */ + /* Clear array of bins for dataset dimensions */ - if(iter->dset_dim_bins) - free(iter->dset_dim_bins); - iter->dset_dim_bins = NULL; - /* Clear array of bins for free-space section sizes */ - if(iter->sect_bins) - free(iter->sect_bins); - iter->sect_bins = NULL; + if(iter->dset_dim_bins) { + HDfree(iter->dset_dim_bins); + iter->dset_dim_bins = NULL; + } /* end if */ - return 0; -} + /* Clear array of bins for free-space section sizes */ + if(iter->sect_bins) { + HDfree(iter->sect_bins); + iter->sect_bins = NULL; + } /* end if */ +} /* end iter_free() */ /*------------------------------------------------------------------------- @@ -1428,7 +1452,7 @@ print_storage_summary(const iter_t *iter) { hsize_t total_meta = 0; hsize_t unaccount = 0; - float percent = 0.0; + double percent = 0.0f; HDfprintf(stdout, "File space management strategy: %s\n", FS_STRATEGY_NAME[iter->fs_strategy]); printf("Summary of file space information:\n"); @@ -1451,7 +1475,7 @@ print_storage_summary(const iter_t *iter) HDfprintf(stdout, " File metadata: %Hu bytes\n", total_meta); HDfprintf(stdout, " Raw data: %Hu bytes\n", iter->dset_storage_size); - percent = ((float)iter->free_space / (float)iter->filesize) * 100; + percent = ((double)iter->free_space / (double)iter->filesize) * (double)100.0f; HDfprintf(stdout, " Amount/Percent of tracked free space: %Hu bytes/%3.1f%\n", iter->free_space, percent); @@ -1584,10 +1608,7 @@ main(int argc, const char *argv[]) iter_t iter; const char *fname = NULL; hid_t fid = -1; - hid_t fcpl; struct handler_t *hand = NULL; - H5F_info2_t finfo; - int i; h5tools_setprogname(PROGRAMNAME); h5tools_setstatus(EXIT_SUCCESS); @@ -1598,97 +1619,91 @@ main(int argc, const char *argv[]) /* Initialize h5tools lib */ h5tools_init(); - if((hand = parse_command_line(argc, argv))==NULL) { - goto done; - } - - fname = argv[opt_ind]; - - printf("Filename: %s\n", fname); - HDmemset(&iter, 0, sizeof(iter)); - fid = H5Fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT); - if(fid < 0) { - error_msg("unable to open file \"%s\"\n", fname); - h5tools_setstatus(EXIT_FAILURE); + if(parse_command_line(argc, argv, &hand) < 0) goto done; - } /* end if */ - /* Initialize iter structure */ - iter.fid = fid; - - if(H5Fget_filesize(fid, &iter.filesize) < 0) - warn_msg("Unable to retrieve file size\n"); - HDassert(iter.filesize != 0); - - /* Get storge info for file-level structures */ - if(H5Fget_info2(fid, &finfo) < 0) - warn_msg("Unable to retrieve file info\n"); - else { - iter.super_size = finfo.super.super_size; - iter.super_ext_size = finfo.super.super_ext_size; - iter.SM_hdr_storage_size = finfo.sohm.hdr_size; - iter.SM_index_storage_size = finfo.sohm.msgs_info.index_size; - iter.SM_heap_storage_size = finfo.sohm.msgs_info.heap_size; - iter.free_space = finfo.free.tot_space; - iter.free_hdr = finfo.free.meta_size; - } /* end else */ - - if((fcpl = H5Fget_create_plist(fid)) < 0) - warn_msg("Unable to retrieve file creation property\n"); - - if(H5Pget_userblock(fcpl, &iter.ublk_size) < 0) - warn_msg("Unable to retrieve userblock size\n"); + fname = argv[opt_ind]; - if(H5Pget_file_space(fcpl, &iter.fs_strategy, &iter.fs_threshold) < 0) - warn_msg("Unable to retrieve file space information\n"); - HDassert(iter.fs_strategy != 0 && iter.fs_strategy < H5F_FILE_SPACE_NTYPES); + /* Check for filename given */ + if(fname) { + hid_t fcpl; + H5F_info2_t finfo; - /* get information for free-space sections */ - if(freespace_stats(fid, &iter) < 0) - warn_msg("Unable to retrieve freespace info\n"); + printf("Filename: %s\n", fname); - /* Walk the objects or all file */ - if(display_object) { - unsigned u; + fid = H5Fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT); + if(fid < 0) { + error_msg("unable to open file \"%s\"\n", fname); + h5tools_setstatus(EXIT_FAILURE); + goto done; + } /* end if */ - u = 0; - while(hand[u].obj) { - if (h5trav_visit(fid, hand[u].obj, TRUE, TRUE, obj_stats, lnk_stats, &iter) < 0) - warn_msg("Unable to traverse object \"%s\"\n", hand[u].obj); + /* Initialize iter structure */ + iter.fid = fid; + + if(H5Fget_filesize(fid, &iter.filesize) < 0) + warn_msg("Unable to retrieve file size\n"); + HDassert(iter.filesize != 0); + + /* Get storge info for file-level structures */ + if(H5Fget_info2(fid, &finfo) < 0) + warn_msg("Unable to retrieve file info\n"); + else { + iter.super_size = finfo.super.super_size; + iter.super_ext_size = finfo.super.super_ext_size; + iter.SM_hdr_storage_size = finfo.sohm.hdr_size; + iter.SM_index_storage_size = finfo.sohm.msgs_info.index_size; + iter.SM_heap_storage_size = finfo.sohm.msgs_info.heap_size; + iter.free_space = finfo.free.tot_space; + iter.free_hdr = finfo.free.meta_size; + } /* end else */ + + if((fcpl = H5Fget_create_plist(fid)) < 0) + warn_msg("Unable to retrieve file creation property\n"); + + if(H5Pget_userblock(fcpl, &iter.ublk_size) < 0) + warn_msg("Unable to retrieve userblock size\n"); + + if(H5Pget_file_space(fcpl, &iter.fs_strategy, &iter.fs_threshold) < 0) + warn_msg("Unable to retrieve file space information\n"); + HDassert(iter.fs_strategy != 0 && iter.fs_strategy < H5F_FILE_SPACE_NTYPES); + + /* get information for free-space sections */ + if(freespace_stats(fid, &iter) < 0) + warn_msg("Unable to retrieve freespace info\n"); + + /* Walk the objects or all file */ + if(display_object) { + unsigned u; + + for(u = 0; u < hand->obj_count; u++) { + if(h5trav_visit(fid, hand->obj[u], TRUE, TRUE, obj_stats, lnk_stats, &iter) < 0) + warn_msg("Unable to traverse object \"%s\"\n", hand->obj[u]); + else + print_statistics(hand->obj[u], &iter); + } /* end for */ + } /* end if */ + else { + if(h5trav_visit(fid, "/", TRUE, TRUE, obj_stats, lnk_stats, &iter) < 0) + warn_msg("Unable to traverse objects/links in file \"%s\"\n", fname); else - print_statistics(hand[u].obj, &iter); - u++; - } /* end while */ + print_statistics("/", &iter); + } /* end else */ } /* end if */ - else { - if (h5trav_visit(fid, "/", TRUE, TRUE, obj_stats, lnk_stats, &iter) < 0) - warn_msg("Unable to traverse objects/links in file \"%s\"\n", fname); - else - print_statistics("/", &iter); - } /* end else */ done: - if(hand) { - for (i = 0; i < argc; i++) - if(hand[i].obj) { - free(hand[i].obj); - hand[i].obj=NULL; - } + hand_free(hand); - free(hand); - hand = NULL; + /* Free iter structure */ + iter_free(&iter); - /* Free iter structure */ - iter_free(&iter); - - if(fid >= 0 && H5Fclose(fid) < 0) { - error_msg("unable to close file \"%s\"\n", fname); - h5tools_setstatus(EXIT_FAILURE); - } - } + if(fid >= 0 && H5Fclose(fid) < 0) { + error_msg("unable to close file \"%s\"\n", fname); + h5tools_setstatus(EXIT_FAILURE); + } /* end if */ leave(h5tools_getstatus()); -} +} /* end main() */ diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c index 528fc40..96b508d 100644 --- a/tools/lib/h5diff_array.c +++ b/tools/lib/h5diff_array.c @@ -5783,17 +5783,19 @@ static int ull2float(unsigned long long ull_value, float *f_value) { hid_t dxpl_id; - unsigned char *buf; + unsigned char *buf = NULL; size_t src_size; size_t dst_size; h5difftrace("ull2float start\n"); if((dxpl_id = H5Pcreate(H5P_DATASET_XFER))<0) - return -1; + goto error; src_size = H5Tget_size(H5T_NATIVE_ULLONG); dst_size = H5Tget_size(H5T_NATIVE_FLOAT); buf = (unsigned char*)HDcalloc(1, MAX(src_size, dst_size)); + if(!buf) + goto error; HDmemcpy(buf, &ull_value, src_size); diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c index 5f4227c..3e9c43e 100644 --- a/tools/lib/h5tools.c +++ b/tools/lib/h5tools.c @@ -527,16 +527,18 @@ h5tools_detect_vlen_str(hid_t tid) } } else if(tclass == H5T_COMPOUND) { - int i = 0; - int n = H5Tget_nmembers(tid); + unsigned nmembs; + int snmembs = H5Tget_nmembers(tid); + unsigned u; - if(n < 0) { - n = ret; + if(snmembs < 0) { + ret = FAIL; goto done; } + nmembs = (unsigned)snmembs; - for(i = 0; i < n; i++) { - hid_t mtid = H5Tget_member_type(tid, i); + for(u = 0; u < nmembs; u++) { + hid_t mtid = H5Tget_member_type(tid, u); ret = h5tools_detect_vlen_str(mtid); if((ret == TRUE) || (ret < 0)) { @@ -1150,6 +1152,8 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t s = *(char**) mem; if (s != NULL) size = HDstrlen(s); + else + H5E_THROW(FAIL, H5E_tools_min_id_g, "NULL string"); } else { s = (char *) mem; diff --git a/tools/lib/h5tools_dump.c b/tools/lib/h5tools_dump.c index 4b12560..638b370 100644 --- a/tools/lib/h5tools_dump.c +++ b/tools/lib/h5tools_dump.c @@ -189,7 +189,7 @@ table_t *h5dump_type_table = NULL; /*type table reference for datatype dump */ static int h5tools_print_region_data_blocks(hid_t region_id, FILE *stream, const h5tool_format_t *info, h5tools_context_t *cur_ctx, h5tools_str_t *buffer/*string into which to render */, size_t ncols, - int ndims, hid_t type_id, hssize_t nblocks, hsize_t *ptdata); + unsigned ndims, hid_t type_id, hsize_t nblocks, hsize_t *ptdata); hbool_t h5tools_dump_region_data_points(hid_t region_space, hid_t region_id, FILE *stream, const h5tool_format_t *info, @@ -420,7 +420,7 @@ static int h5tools_print_region_data_blocks(hid_t region_id, FILE *stream, const h5tool_format_t *info, h5tools_context_t *cur_ctx, h5tools_str_t *buffer/*string into which to render */, size_t ncols, - int ndims, hid_t type_id, hssize_t nblocks, hsize_t *ptdata) + unsigned ndims, hid_t type_id, hsize_t nblocks, hsize_t *ptdata) { hbool_t dimension_break = TRUE; hsize_t *dims1 = NULL; @@ -433,9 +433,9 @@ h5tools_print_region_data_blocks(hid_t region_id, unsigned int region_flags; /* buffer extent flags */ hsize_t numelem; hsize_t numindex; - size_t jndx; unsigned indx; - int type_size; + unsigned jndx; + size_t type_size; int ret_value = SUCCEED; hid_t mem_space = -1; hid_t sid1 = -1; @@ -448,6 +448,7 @@ h5tools_print_region_data_blocks(hid_t region_id, HDassert(ptdata); HDmemset(&ctx, 0, sizeof(ctx)); + /* Get the dataspace of the dataset */ if((sid1 = H5Dget_space(region_id)) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_space failed"); @@ -464,7 +465,7 @@ h5tools_print_region_data_blocks(hid_t region_id, } /* 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) @@ -505,7 +506,7 @@ h5tools_print_region_data_blocks(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 < (unsigned)ctx.ndims; indx++) ctx.p_min_idx[indx] = start[indx]; init_acc_pos(&ctx, total_size); @@ -514,11 +515,11 @@ h5tools_print_region_data_blocks(hid_t region_id, if (blkndx == nblocks - 1) region_flags |= END_OF_DATA; - for (indx = 0; indx < (size_t)ctx.ndims; indx++) + for (indx = 0; indx < (unsigned)ctx.ndims; indx++) ctx.p_max_idx[indx] = dims1[indx]; curr_pos = 0; - ctx.sm_pos = blkndx*2*ndims; + ctx.sm_pos = blkndx * 2 * ndims; ctx.size_last_dim = dims1[ndims-1]; h5tools_region_simple_prefix(stream, info, &ctx, curr_pos, ptdata, 0); @@ -541,7 +542,7 @@ h5tools_print_region_data_blocks(hid_t region_id, if(FALSE == dimension_break) elmtno = 0; - } /* end for (jndx = 0; jndx < numelem; jndx++, region_elmtno++, ctx.cur_elmt++) */ + } /* end for (numindex = 0; numindex < numelem; numindex++, elmtno++, ctx.cur_elmt++) */ ctx.indent_level--; } /* end for (blkndx = 0; blkndx < nblocks; blkndx++) */ @@ -594,24 +595,28 @@ h5tools_dump_region_data_blocks(hid_t region_space, hid_t region_id, { HERR_INIT(hbool_t, TRUE) hbool_t dimension_break = TRUE; - hssize_t nblocks; + hssize_t snblocks; + hsize_t nblocks; hsize_t alloc_size; hsize_t *ptdata = NULL; - int ndims; + int sndims; + unsigned ndims; hid_t dtype = -1; hid_t type_id = -1; - int i; + hsize_t u; HDassert(info); HDassert(ctx); HDassert(buffer); - if((nblocks = H5Sget_select_hyper_nblocks(region_space)) <= 0) + if((snblocks = H5Sget_select_hyper_nblocks(region_space)) <= 0) H5E_THROW(dimension_break, H5E_tools_min_id_g, "H5Sget_select_hyper_nblocks failed"); + 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(dimension_break, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed"); + ndims = (unsigned)sndims; /* Render the region { element begin */ h5tools_str_reset(buffer); @@ -636,27 +641,26 @@ h5tools_dump_region_data_blocks(hid_t region_space, hid_t region_id, //HGOTO_ERROR(dimension_break, 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(dimension_break, H5E_tools_min_id_g, "H5Rget_select_hyper_blocklist failed"); - for (i = 0; i < nblocks; i++) { - int j; + for(u = 0; u < nblocks; u++) { + unsigned v; h5tools_str_append(buffer, info->dset_blockformat_pre, - i ? "," OPTIONAL_LINE_BREAK " " : "", (unsigned long) i); + u ? "," OPTIONAL_LINE_BREAK " " : "", (unsigned long)u); /* Start coordinates and opposite corner */ - for (j = 0; j < ndims; j++) - h5tools_str_append(buffer, "%s" HSIZE_T_FORMAT, j ? "," : "(", - ptdata[i * 2 * ndims + j]); + for (v = 0; v < ndims; v++) + h5tools_str_append(buffer, "%s" HSIZE_T_FORMAT, v ? "," : "(", + ptdata[u * 2 * ndims + v]); - for (j = 0; j < ndims; j++) - h5tools_str_append(buffer, "%s" HSIZE_T_FORMAT, j ? "," : ")-(", - ptdata[i * 2 * ndims + j + ndims]); + for (v = 0; v < ndims; v++) + h5tools_str_append(buffer, "%s" HSIZE_T_FORMAT, v ? "," : ")-(", + ptdata[u * 2 * ndims + v + ndims]); h5tools_str_append(buffer, ")"); - } /* end for (i = 0; i < nblocks; i++) */ + } /* end for (u = 0; u < nblocks; u++) */ dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter); /* Render the region datatype info and indices element end */ @@ -2226,12 +2230,16 @@ h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer, const h5tool_format_ /* Change the endianness and see if they're equal. */ order = H5Tget_order(tmp_type); - if (order == H5T_ORDER_LE) - H5Tset_order(str_type, H5T_ORDER_LE); - else if (order == H5T_ORDER_BE) - H5Tset_order(str_type, H5T_ORDER_BE); - - if (H5Tequal(tmp_type, str_type)) { + if(order == H5T_ORDER_LE) { + if(H5Tset_order(str_type, H5T_ORDER_LE) < 0) + HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tset_order failed"); + } /* end if */ + else if(order == H5T_ORDER_BE) { + if(H5Tset_order(str_type, H5T_ORDER_BE) < 0) + HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tset_order failed"); + } /* end if */ + + if(H5Tequal(tmp_type, str_type)) { h5tools_str_append(buffer, "H5T_C_S1;"); goto found_string_type; } @@ -2253,12 +2261,16 @@ h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer, const h5tool_format_ /* Change the endianness and see if they're equal. */ order = H5Tget_order(tmp_type); - if (order == H5T_ORDER_LE) - H5Tset_order(str_type, H5T_ORDER_LE); - else if (order == H5T_ORDER_BE) - H5Tset_order(str_type, H5T_ORDER_BE); - - if (H5Tequal(tmp_type, str_type)) { + if(order == H5T_ORDER_LE) { + if(H5Tset_order(str_type, H5T_ORDER_LE) < 0) + HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tset_order failed"); + } /* end if */ + else if(order == H5T_ORDER_BE) { + if(H5Tset_order(str_type, H5T_ORDER_BE) < 0) + HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tset_order failed"); + } /* end if */ + + if(H5Tequal(tmp_type, str_type)) { h5tools_str_append(buffer, "H5T_FORTRAN_S1;"); goto found_string_type; } diff --git a/vms/src/h5pubconf.h b/vms/src/h5pubconf.h index 6c12d6c..7d36509 100644 --- a/vms/src/h5pubconf.h +++ b/vms/src/h5pubconf.h @@ -99,6 +99,9 @@ /* Define if the direct I/O virtual file driver should be compiled */ /* #undef H5_HAVE_DIRECT */ +/* Define to 1 if you have the header file. */ +#define H5_HAVE_DIRENT_H 1 + /* Define to 1 if you have the header file. */ #define H5_HAVE_DLFCN_H 1 @@ -196,6 +199,9 @@ /* Define to 1 if you have the header file. */ /* #undef H5_HAVE_IO_H */ +/* Define to 1 if you have the `dl' library (-ldl). */ +#define H5_HAVE_LIBDL 1 + /* Define to 1 if you have the `dmalloc' library (-ldmalloc). */ /* #undef H5_HAVE_LIBDMALLOC */ @@ -274,6 +280,9 @@ /* Define to 1 if you have the `rand_r' function. */ /* #define H5_HAVE_RAND_R 1 */ +/* Define to 1 if you have the `setjmp' function. */ +#define H5_HAVE_SETJMP 1 + /* Define to 1 if you have the header file. */ #define H5_HAVE_SETJMP_H 1 @@ -502,7 +511,7 @@ #define H5_PACKAGE_NAME "HDF5" /* Define to the full name and version of this package. */ -#define H5_PACKAGE_STRING "HDF5 1.9.151-FA_a5" +#define H5_PACKAGE_STRING "HDF5 1.9.152-FA_a5" /* Define to the one symbol short name of this package. */ #define H5_PACKAGE_TARNAME "hdf5" @@ -511,7 +520,7 @@ #define H5_PACKAGE_URL "" /* Define to the version of this package. */ -#define H5_PACKAGE_VERSION "1.9.151-FA_a5" +#define H5_PACKAGE_VERSION "1.9.152-FA_a5" /* Width for printf() for type `long long' or `__int64', use `ll' */ #define H5_PRINTF_LL_WIDTH "ll" @@ -674,7 +683,7 @@ /* #undef H5_USING_MEMCHECKER */ /* Version number of package */ -#define H5_VERSION "1.9.151-FA_a5" +#define H5_VERSION "1.9.152-FA_a5" /* Define if vsnprintf() returns the correct value for formatted strings that don't fit into size allowed */ diff --git a/vms/src/make.com b/vms/src/make.com index bd1f55c..cdf0f4a 100644 --- a/vms/src/make.com +++ b/vms/src/make.com @@ -57,7 +57,7 @@ $ cobj1= "H5MFaggr, H5MF, H5MFdbg, H5MFsection, H5MM,"+- "H5O, H5Ocache, H5Ochunk, H5Ocont, H5Ocopy, H5Odbg, H5Odrvinfo, H5Odtype, H5Oefl, H5Ofill, H5Ofsinfo,"+- "H5Oginfo, H5Olayout, H5Olinfo, H5Olink, H5Omessage, H5Omtime, H5Oname, H5Onull, H5Opline,"+- "H5Orefcount, H5Osdspace, H5Oshared, H5Oshmesg, H5Ostab, H5Otest, H5Ounknown,"+- - "H5Pacpl, H5P, H5Pdapl, H5Pdcpl, H5Pdeprec, H5Pdxpl, H5Pfapl, H5Pfcpl, H5Pfmpl, H5Pgcpl, H5Pint,"+- + "H5Pacpl, H5P, H5Pdapl, H5Pdcpl, H5Pdeprec, H5Pdxpl, H5Pencdec, H5Pfapl, H5Pfcpl, H5Pfmpl, H5Pgcpl, H5Pint,"+- "H5Plapl, H5Plcpl, H5Pocpl, H5Pocpypl, H5Pstrcpl, H5Ptest,"+- "H5R, H5RC, H5Rdeprec, H5RS, H5Sall, H5S, H5Sdbg, H5Shyper, H5SL, H5SMbtree2, H5SM, H5SMcache,"+- "H5SMmessage, H5Smpio, H5SMtest, H5Snone, H5Spoint, H5Sselect, H5ST, H5Stest,"+- -- cgit v0.12