From 38e0563a6e2bf77c860abb0ec61aa6a9da4204af Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Fri, 6 Sep 2013 14:09:07 -0500 Subject: [svn-r24112] Description: Bring r24101 & 24111 from trunk to 1.8 branch: r24101: ======= Description: Clean up warnings, enable new compiler warning flag(s) and bring back changes from Coverity branch: r20813: Remove the dead code as listed for coverity bug #1722. h5committested. r20814: Issue 69: Check return value and throw error if negative return. Also free datatype id on error r20815: Use HDstrncpy. --gh r20816: Replaced one last HDstrcat call with HDstrncat to resolve coverity issue 832. r20817: Use HDstrncpy and HDstrncat. --gh r20818: Purpose: Fix valgrind issues with h5jam Description: Modified h5jam to free strings strdup'd in parse_command_line before exit. Note that they may still not be freed in case of error, due to the widespread use of exit(). r20819: Issue 80: change loop to use int as loop index. r20820: Maintenance: Fixed the bug found by coverity CID 788 There were two problems with this function: 1) it tried to unnecessary free NULL pointer 2) it tried to allocate c_name buffer that is done by H5Pget_class_name r24111: ======= Description: Restrict GCC diagnostic pragmas to only gcc 4.6+ Tested on: Mac OSX 10.8.4 (amazon) w/gcc 4.8.1, C++ & FORTRAN (too minor to require h5committest) --- config/gnu-flags | 3 +- fortran/src/H5Pf.c | 26 +++++++-------- fortran/test/fortranlib_test_1_8.f90 | 10 ++++++ src/H5FDmpio.c | 14 ++++++-- src/H5FDmpiposix.c | 13 ++++++-- src/H5Fsuper_cache.c | 4 ++- src/H5Pint.c | 26 +++++++-------- src/H5T.c | 13 ++++---- src/H5Tconv.c | 56 +++++++++++++++++++++++++++++++- src/H5Zscaleoffset.c | 52 +++++++++++++++--------------- src/H5private.h | 19 +++++++++++ test/dsets.c | 10 +++--- test/dtypes.c | 62 +++++++++++++++++++----------------- tools/h5dump/h5dump_defines.h | 2 +- tools/h5dump/h5dumpgentest.c | 12 +++---- tools/h5jam/h5jam.c | 17 ++++++---- tools/lib/h5diff_array.c | 17 +++++----- tools/lib/h5tools.c | 28 ++++++++++------ 18 files changed, 246 insertions(+), 138 deletions(-) diff --git a/config/gnu-flags b/config/gnu-flags index eef38ad..57fc23a 100644 --- a/config/gnu-flags +++ b/config/gnu-flags @@ -220,8 +220,7 @@ case "$cc_vendor-$cc_version" in H5_CFLAGS="$H5_CFLAGS -Wformat=2" # The "unreachable code" warning appears to be reliable now... - # (this warning was removed in gcc 4.5+) - #H5_CFLAGS="$H5_CFLAGS -Wunreachable-code" + H5_CFLAGS="$H5_CFLAGS -Wunreachable-code" # Append warning flags from gcc-3.3* case H5_CFLAGS="$H5_CFLAGS -Wendif-labels" diff --git a/fortran/src/H5Pf.c b/fortran/src/H5Pf.c index dba2aa4..262ce55 100644 --- a/fortran/src/H5Pf.c +++ b/fortran/src/H5Pf.c @@ -3370,14 +3370,15 @@ nh5pclose_class_c(hid_t_f *cls) ret_value = 0; return ret_value; } + /****if* H5Pf/h5pget_class_name_c * NAME * h5pget_class_name_c * PURPOSE * Call H5Pget_class_name to get property class name * INPUTS - * cls - identifier of property class - * name - ibuffer to retrieve name in + * cls - identifier of property class + * name - buffer to retrieve name in * name_len - length of the "name" buffer * RETURNS * 0 on success, -1 on failure @@ -3393,30 +3394,25 @@ nh5pget_class_name_c(hid_t_f *cls, _fcd name, int_f *name_len) /******/ { int_f ret_value = -1; - char *c_name = NULL; /* Buffer to hold C string */ - size_t c_size; - c_size = (size_t)*name_len + 1; - - /* - * Allocate buffer to hold name - */ - if(NULL == (c_name = (char *)HDmalloc(c_size))) - goto DONE; + /* Buffer to return name by C function */ + char *c_name; /* - * Call H5Pget_class_name function. + * Call H5Pget_class_name function. c_name is allocated by the library, + * has to be freed by application. */ - c_name = H5Pget_class_name((hid_t)*cls); - if(c_name == NULL) goto DONE; + if(NULL == (c_name = H5Pget_class_name((hid_t)*cls))) + goto DONE; HD5packFstring(c_name, _fcdtocp(name), (size_t)*name_len); ret_value = (int_f)HDstrlen(c_name); + HDfree(c_name); DONE: - HDfree(c_name); return ret_value; } + /****if* H5Pf/h5psetc_c * NAME * h5psetc_c diff --git a/fortran/test/fortranlib_test_1_8.f90 b/fortran/test/fortranlib_test_1_8.f90 index d3ced72..dc45560 100644 --- a/fortran/test/fortranlib_test_1_8.f90 +++ b/fortran/test/fortranlib_test_1_8.f90 @@ -196,6 +196,16 @@ SUBROUTINE test_genprop_basic_class(cleanup, total_error) INTEGER :: size LOGICAL :: flag + !/* Output message about test being performed */ + + !WRITE(*,*) "Testing Basic Generic Property List Class Creation Functionality" + + ! Try some bogus value for class identifier; function should fail gracefully + + cid1 = 456 + CALL H5Pget_class_name_f(cid1, name, size, error) + CALL VERIFY("H5Pget_class_name", error, -1, error) + ! /* Create a new generic class, derived from the root of the class hierarchy */ CALL H5Pcreate_class_f(H5P_ROOT_F, CLASS1_NAME, cid1, error) CALL check("H5Pcreate_class", error, total_error) diff --git a/src/H5FDmpio.c b/src/H5FDmpio.c index 2d73ec0..067d4f4 100644 --- a/src/H5FDmpio.c +++ b/src/H5FDmpio.c @@ -1985,8 +1985,18 @@ H5FD_mpio_truncate(H5FD_t *_file, hid_t UNUSED dxpl_id, hbool_t UNUSED closing) HGOTO_ERROR(H5E_INTERNAL, H5E_BADRANGE, FAIL, "cannot convert from haddr_t to MPI_Offset") /* Extend the file's size */ - if(MPI_SUCCESS != (mpi_code = MPI_File_set_size(file->f, mpi_off))) - HMPI_GOTO_ERROR(FAIL, "MPI_File_set_size failed", mpi_code) + // Suren's modifications to disable truncate + // Original code: commented out the following 2 lines + // if(MPI_SUCCESS != (mpi_code = MPI_File_set_size(file->f, mpi_off))) + // HMPI_GOTO_ERROR(FAIL, "MPI_File_set_size failed", mpi_code) + // Modified code: The following 6 lines + if (getenv("HDF5_TRUNCATE")) { + if(0 == file->mpi_rank) + printf("I: HDF5: MPI-IO VFD: MPI_File_set_size()"); + if(MPI_SUCCESS != (mpi_code = MPI_File_set_size(file->f, mpi_off))) + HMPI_GOTO_ERROR(FAIL, "MPI_File_set_size failed", mpi_code) + } + // End of modified code #else /* H5_MPI_FILE_SET_SIZE_BIG */ /* Wait until all processes are here before reading/writing the byte at * process 0's end of address space. The window for corruption is diff --git a/src/H5FDmpiposix.c b/src/H5FDmpiposix.c index f66b244..4d2a6cf 100644 --- a/src/H5FDmpiposix.c +++ b/src/H5FDmpiposix.c @@ -1378,8 +1378,17 @@ H5FD_mpiposix_truncate(H5FD_t *_file, hid_t UNUSED dxpl_id, hbool_t UNUSED closi if(-1 == HDlseek(file->fd, (HDoff_t)0, SEEK_SET)) HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") #endif /* H5_VMS */ - if(-1 == HDftruncate(file->fd, (HDoff_t)file->eoa)) - HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to extend file properly") + // Suren modification to disable file_truncate + // Original code: two lines commented out + // if(-1 == HDftruncate(file->fd, (HDoff_t)file->eoa)) + // HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to extend file properly") + // Modified code: The following 5 lines + if (getenv("HDF5_TRUNCATE")) { + printf("I: HDF5: MPI-POSIX VFD: ftruncate()\n"); + if(-1 == HDftruncate(file->fd, (HDoff_t)file->eoa)) + HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to extend file properly") + } + // End modified code #endif /* H5_HAVE_WIN32_API */ } /* end if */ diff --git a/src/H5Fsuper_cache.c b/src/H5Fsuper_cache.c index a437451..9839d0f 100644 --- a/src/H5Fsuper_cache.c +++ b/src/H5Fsuper_cache.c @@ -468,7 +468,9 @@ H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, void *_udata) /* (Account for the stored EOA being absolute offset -QAK) */ if((eof + sblock->base_addr) < stored_eoa) - HGOTO_ERROR(H5E_FILE, H5E_TRUNCATED, NULL, "truncated file: eof = %llu, sblock->base_addr = %llu, stored_eoa = %llu", (unsigned long long)eof, (unsigned long long)sblock->base_addr, (unsigned long long)stored_eoa) + if((shared->flags & H5F_ACC_RDWR) || getenv("HDF5_TRUNCATE")) { + HGOTO_ERROR(H5E_FILE, H5E_TRUNCATED, NULL, "truncated file: eof = %llu, sblock->base_addr = %llu, stored_eoa = %llu", (unsigned long long)eof, (unsigned long long)sblock->base_addr, (unsigned long long)stored_eoa) + } /* * Tell the file driver how much address space has already been diff --git a/src/H5Pint.c b/src/H5Pint.c index dcdd78d..b15f039 100644 --- a/src/H5Pint.c +++ b/src/H5Pint.c @@ -4673,9 +4673,6 @@ done: char * H5P_get_class_path(H5P_genclass_t *pclass) { - char *par_path; /* Parent class's full path */ - size_t par_path_len;/* Parent class's full path's length */ - size_t my_path_len; /* This class's name's length */ char *ret_value; /* return value */ FUNC_ENTER_NOAPI_NOINIT @@ -4683,33 +4680,32 @@ H5P_get_class_path(H5P_genclass_t *pclass) HDassert(pclass); /* Recursively build the full path */ - if(pclass->parent!=NULL) { + if(pclass->parent != NULL) { + char *par_path; /* Parent class's full path */ + /* Get the parent class's path */ - par_path=H5P_get_class_path(pclass->parent); - if(par_path!=NULL) { - /* Get the string lengths we need to allocate space */ - par_path_len=HDstrlen(par_path); - my_path_len=HDstrlen(pclass->name); + par_path = H5P_get_class_path(pclass->parent); + if(par_path != NULL) { + size_t ret_str_len; /* Allocate enough space for the parent class's path, plus the '/' * separator, this class's name and the string terminator */ - if(NULL == (ret_value = (char *)H5MM_malloc(par_path_len + 1 + my_path_len + 1))) + ret_str_len = HDstrlen(par_path) + 1 + HDstrlen(pclass->name) + 1; + if(NULL == (ret_value = (char *)H5MM_malloc(ret_str_len))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for class name") /* Build the full path for this class */ - HDstrcpy(ret_value,par_path); - HDstrcat(ret_value,"/"); - HDstrcat(ret_value,pclass->name); + HDsnprintf(ret_value, ret_str_len, "%s/%s", par_path, pclass->name); /* Free the parent class's path */ H5MM_xfree(par_path); } /* end if */ else - ret_value=H5MM_xstrdup(pclass->name); + ret_value = H5MM_xstrdup(pclass->name); } /* end if */ else - ret_value=H5MM_xstrdup(pclass->name); + ret_value = H5MM_xstrdup(pclass->name); done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5T.c b/src/H5T.c index c480a47..d73d270 100644 --- a/src/H5T.c +++ b/src/H5T.c @@ -496,10 +496,10 @@ size_t H5T_NATIVE_UINT_FAST64_ALIGN_g = 0; /* Useful floating-point values for conversion routines */ /* (+/- Inf for all floating-point types) */ -float H5T_NATIVE_FLOAT_POS_INF_g = 0.0; -float H5T_NATIVE_FLOAT_NEG_INF_g = 0.0; -double H5T_NATIVE_DOUBLE_POS_INF_g = 0.0; -double H5T_NATIVE_DOUBLE_NEG_INF_g = 0.0; +float H5T_NATIVE_FLOAT_POS_INF_g = 0.0f; +float H5T_NATIVE_FLOAT_NEG_INF_g = 0.0f; +double H5T_NATIVE_DOUBLE_POS_INF_g = (double)0.0f; +double H5T_NATIVE_DOUBLE_NEG_INF_g = (double)0.0f; /* Declare the free list for H5T_t's and H5T_shared_t's */ H5FL_DEFINE(H5T_t); @@ -2399,7 +2399,7 @@ H5T_register(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst, if(NULL == (new_path = H5FL_CALLOC(H5T_path_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") HDstrncpy(new_path->name, name, (size_t)H5T_NAMELEN); - new_path->name[H5T_NAMELEN-1] = '\0'; + new_path->name[H5T_NAMELEN - 1] = '\0'; if(NULL == (new_path->src = H5T_copy(old_path->src, H5T_COPY_ALL)) || NULL == (new_path->dst=H5T_copy(old_path->dst, H5T_COPY_ALL))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy data types") @@ -4519,7 +4519,8 @@ H5T_path_find(const H5T_t *src, const H5T_t *dst, const char *name, H5E_clear_stack(H5E_DEFAULT); /*ignore the error*/ } /* end if */ else { - HDstrcpy(path->name, H5T_g.soft[i].name); + HDstrncpy(path->name, H5T_g.soft[i].name, (size_t)H5T_NAMELEN); + path->name[H5T_NAMELEN - 1] = '\0'; path->func = H5T_g.soft[i].func; path->is_hard = FALSE; } /* end else */ diff --git a/src/H5Tconv.c b/src/H5Tconv.c index 3a662a3..50e9dc5 100644 --- a/src/H5Tconv.c +++ b/src/H5Tconv.c @@ -8039,7 +8039,9 @@ H5T__conv_float_schar (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { +GCC_DIAG_OFF(float-equal) H5T_CONV_Fx(FLOAT, SCHAR, float, signed char, SCHAR_MIN, SCHAR_MAX); +GCC_DIAG_ON(float-equal) } @@ -8064,7 +8066,9 @@ H5T__conv_float_uchar (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { +GCC_DIAG_OFF(float-equal) H5T_CONV_Fx(FLOAT, UCHAR, float, unsigned char, 0, UCHAR_MAX); +GCC_DIAG_ON(float-equal) } @@ -8089,7 +8093,9 @@ H5T__conv_double_schar (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { +GCC_DIAG_OFF(float-equal) H5T_CONV_Fx(DOUBLE, SCHAR, double, signed char, SCHAR_MIN, SCHAR_MAX); +GCC_DIAG_ON(float-equal) } @@ -8114,7 +8120,9 @@ H5T__conv_double_uchar (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { +GCC_DIAG_OFF(float-equal) H5T_CONV_Fx(DOUBLE, UCHAR, double, unsigned char, 0, UCHAR_MAX); +GCC_DIAG_ON(float-equal) } @@ -8140,7 +8148,9 @@ H5T__conv_ldouble_schar (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { +GCC_DIAG_OFF(float-equal) H5T_CONV_Fx(LDOUBLE, SCHAR, long double, signed char, SCHAR_MIN, SCHAR_MAX); +GCC_DIAG_ON(float-equal) } #endif /* H5T_CONV_INTERNAL_LDOUBLE_INTEGER */ @@ -8167,7 +8177,9 @@ H5T__conv_ldouble_uchar (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { +GCC_DIAG_OFF(float-equal) H5T_CONV_Fx(LDOUBLE, UCHAR, long double, unsigned char, 0, UCHAR_MAX); +GCC_DIAG_ON(float-equal) } #endif /* H5T_CONV_INTERNAL_LDOUBLE_INTEGER */ @@ -8193,7 +8205,9 @@ H5T__conv_float_short (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { +GCC_DIAG_OFF(float-equal) H5T_CONV_Fx(FLOAT, SHORT, float, short, SHRT_MIN, SHRT_MAX); +GCC_DIAG_ON(float-equal) } @@ -8218,7 +8232,9 @@ H5T__conv_float_ushort (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { +GCC_DIAG_OFF(float-equal) H5T_CONV_Fx(FLOAT, USHORT, float, unsigned short, 0, USHRT_MAX); +GCC_DIAG_ON(float-equal) } @@ -8243,7 +8259,9 @@ H5T__conv_double_short (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { +GCC_DIAG_OFF(float-equal) H5T_CONV_Fx(DOUBLE, SHORT, double, short, SHRT_MIN, SHRT_MAX); +GCC_DIAG_ON(float-equal) } @@ -8268,7 +8286,9 @@ H5T__conv_double_ushort (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { +GCC_DIAG_OFF(float-equal) H5T_CONV_Fx(DOUBLE, USHORT, double, unsigned short, 0, USHRT_MAX); +GCC_DIAG_ON(float-equal) } @@ -8294,7 +8314,9 @@ H5T__conv_ldouble_short (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { +GCC_DIAG_OFF(float-equal) H5T_CONV_Fx(LDOUBLE, SHORT, long double, short, SHRT_MIN, SHRT_MAX); +GCC_DIAG_ON(float-equal) } #endif /*H5T_CONV_INTERNAL_LDOUBLE_INTEGER*/ @@ -8321,7 +8343,9 @@ H5T__conv_ldouble_ushort (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { +GCC_DIAG_OFF(float-equal) H5T_CONV_Fx(LDOUBLE, USHORT, long double, unsigned short, 0, USHRT_MAX); +GCC_DIAG_ON(float-equal) } #endif /* H5T_CONV_INTERNAL_LDOUBLE_INTEGER */ @@ -8347,7 +8371,9 @@ H5T__conv_float_int (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { +GCC_DIAG_OFF(float-equal) H5T_CONV_Fx(FLOAT, INT, float, int, INT_MIN, INT_MAX); +GCC_DIAG_ON(float-equal) } @@ -8372,7 +8398,9 @@ H5T__conv_float_uint (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { +GCC_DIAG_OFF(float-equal) H5T_CONV_Fx(FLOAT, UINT, float, unsigned int, 0, UINT_MAX); +GCC_DIAG_ON(float-equal) } @@ -8397,7 +8425,9 @@ H5T__conv_double_int (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { +GCC_DIAG_OFF(float-equal) H5T_CONV_Fx(DOUBLE, INT, double, int, INT_MIN, INT_MAX); +GCC_DIAG_ON(float-equal) } @@ -8422,7 +8452,9 @@ H5T__conv_double_uint (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { +GCC_DIAG_OFF(float-equal) H5T_CONV_Fx(DOUBLE, UINT, double, unsigned int, 0, UINT_MAX); +GCC_DIAG_ON(float-equal) } @@ -8448,7 +8480,9 @@ H5T__conv_ldouble_int (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { +GCC_DIAG_OFF(float-equal) H5T_CONV_Fx(LDOUBLE, INT, long double, int, INT_MIN, INT_MAX); +GCC_DIAG_ON(float-equal) } #endif /* H5T_CONV_INTERNAL_LDOUBLE_INTEGER */ @@ -8475,7 +8509,9 @@ H5T__conv_ldouble_uint (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { +GCC_DIAG_OFF(float-equal) H5T_CONV_Fx(LDOUBLE, UINT, long double, unsigned int, 0, UINT_MAX); +GCC_DIAG_ON(float-equal) } #endif /* H5T_CONV_INTERNAL_LDOUBLE_UINT */ @@ -8501,7 +8537,9 @@ H5T__conv_float_long (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { +GCC_DIAG_OFF(float-equal) H5T_CONV_Fx(FLOAT, LONG, float, long, LONG_MIN, LONG_MAX); +GCC_DIAG_ON(float-equal) } @@ -8526,7 +8564,9 @@ H5T__conv_float_ulong (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { +GCC_DIAG_OFF(float-equal) H5T_CONV_Fx(FLOAT, ULONG, float, unsigned long, 0, ULONG_MAX); +GCC_DIAG_ON(float-equal) } @@ -8551,7 +8591,9 @@ H5T__conv_double_long (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { +GCC_DIAG_OFF(float-equal) H5T_CONV_Fx(DOUBLE, LONG, double, long, LONG_MIN, LONG_MAX); +GCC_DIAG_ON(float-equal) } @@ -8576,7 +8618,9 @@ H5T__conv_double_ulong (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { +GCC_DIAG_OFF(float-equal) H5T_CONV_Fx(DOUBLE, ULONG, double, unsigned long, 0, ULONG_MAX); +GCC_DIAG_ON(float-equal) } @@ -8602,7 +8646,9 @@ H5T__conv_ldouble_long (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { +GCC_DIAG_OFF(float-equal) H5T_CONV_Fx(LDOUBLE, LONG, long double, long, LONG_MIN, LONG_MAX); +GCC_DIAG_ON(float-equal) } #endif /*H5T_CONV_INTERNAL_LDOUBLE_INTEGER*/ @@ -8629,7 +8675,9 @@ H5T__conv_ldouble_ulong (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { +GCC_DIAG_OFF(float-equal) H5T_CONV_Fx(LDOUBLE, ULONG, long double, unsigned long, 0, ULONG_MAX); +GCC_DIAG_ON(float-equal) } #endif /* H5T_CONV_INTERNAL_LDOUBLE_INTEGER */ @@ -8656,7 +8704,9 @@ H5T__conv_float_llong (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { +GCC_DIAG_OFF(float-equal) H5T_CONV_Fx(FLOAT, LLONG, float, long long, LLONG_MIN, LLONG_MAX); +GCC_DIAG_ON(float-equal) } #endif /* H5T_CONV_INTERNAL_FP_LLONG */ @@ -8710,7 +8760,9 @@ H5T__conv_double_llong (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { +GCC_DIAG_OFF(float-equal) H5T_CONV_Fx(DOUBLE, LLONG, double, long long, LLONG_MIN, LLONG_MAX); +GCC_DIAG_ON(float-equal) } #endif /*H5T_CONV_INTERNAL_FP_LLONG*/ @@ -8764,7 +8816,9 @@ H5T__conv_ldouble_llong (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { +GCC_DIAG_OFF(float-equal) H5T_CONV_Fx(LDOUBLE, LLONG, long double, long long, LLONG_MIN, LLONG_MAX); +GCC_DIAG_ON(float-equal) } #endif /*H5T_CONV_INTERNAL_LDOUBLE_LLONG*/ @@ -8909,7 +8963,7 @@ H5T__conv_f_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, /* Allocate enough space for the buffer holding temporary * converted value */ - buf_size = (size_t)HDpow((double)2.0, (double)src.u.f.esize) / 8 + 1; + buf_size = (size_t)HDpow((double)2.0f, (double)src.u.f.esize) / 8 + 1; int_buf = (uint8_t*)H5MM_calloc(buf_size); /* Get the plist structure. Do I need to close it? */ diff --git a/src/H5Zscaleoffset.c b/src/H5Zscaleoffset.c index 0aaff11..83864b9 100644 --- a/src/H5Zscaleoffset.c +++ b/src/H5Zscaleoffset.c @@ -347,10 +347,10 @@ H5Z_class2_t H5Z_SCALEOFFSET[1] = {{ /* Find maximum and minimum values of a buffer with fill value defined for floating-point type */ #define H5Z_scaleoffset_max_min_3(i, d_nelmts, buf, filval, max, min, D_val) \ { \ - i = 0; while(i < d_nelmts && HDfabs(buf[i] - filval) < HDpow(10.0, -D_val)) i++; \ + i = 0; while(i < d_nelmts && HDfabs(buf[i] - filval) < HDpow(10.0f, -D_val)) i++; \ if(i < d_nelmts) min = max = buf[i]; \ for(; i < d_nelmts; i++) { \ - if(HDfabs(buf[i] - filval) < HDpow(10.0, -D_val)) \ + if(HDfabs(buf[i] - filval) < HDpow(10.0f, -D_val)) \ continue; /* ignore fill value */ \ if(buf[i] > max) max = buf[i]; \ if(buf[i] < min) min = buf[i]; \ @@ -394,18 +394,18 @@ H5Z_class2_t H5Z_SCALEOFFSET[1] = {{ #define H5Z_scaleoffset_check_3(i, type, max, min, minbits, D_val) \ { \ if(sizeof(type)==sizeof(int)) { \ - if(H5Z_scaleoffset_rnd(max*HDpow(10.0, D_val) - min*HDpow(10.0, D_val)) \ - > HDpow(2.0, (double)(sizeof(int)*8 - 1))) { \ + if(H5Z_scaleoffset_rnd(max*HDpow(10.0f, D_val) - min*HDpow(10.0f, D_val)) \ + > HDpow(2.0f, (double)(sizeof(int)*8 - 1))) { \ *minbits = sizeof(int)*8; goto done; \ } \ } else if(sizeof(type)==sizeof(long)) { \ - if(H5Z_scaleoffset_rnd(max*HDpow(10.0, D_val) - min*HDpow(10.0, D_val)) \ - > HDpow(2.0, (double)(sizeof(long)*8 - 1))) { \ + if(H5Z_scaleoffset_rnd(max*HDpow(10.0f, D_val) - min*HDpow(10.0f, D_val)) \ + > HDpow(2.0f, (double)(sizeof(long)*8 - 1))) { \ *minbits = sizeof(long)*8; goto done; \ } \ } else if(sizeof(type)==sizeof(long long)) { \ - if(H5Z_scaleoffset_rnd(max*HDpow(10.0, D_val) - min*HDpow(10.0, D_val)) \ - > HDpow(2.0, (double)(sizeof(long long)*8 - 1))) { \ + if(H5Z_scaleoffset_rnd(max*HDpow(10.0f, D_val) - min*HDpow(10.0f, D_val)) \ + > HDpow(2.0f, (double)(sizeof(long long)*8 - 1))) { \ *minbits = sizeof(long long)*8; goto done; \ } \ } else \ @@ -483,27 +483,27 @@ H5Z_class2_t H5Z_SCALEOFFSET[1] = {{ { \ if(sizeof(type)==sizeof(int)) \ for(i = 0; i < d_nelmts; i++) { \ - if(HDfabs(buf[i] - filval) < HDpow(10.0, -D_val)) \ + if(HDfabs(buf[i] - filval) < HDpow(10.0f, -D_val)) \ *(int *)&buf[i] = (int)(((unsigned int)1 << *minbits) - 1); \ else \ *(int *)&buf[i] = H5Z_scaleoffset_rnd( \ - buf[i]*HDpow(10.0, D_val) - min*HDpow(10.0, D_val)); \ + buf[i]*HDpow(10.0f, D_val) - min*HDpow(10.0f, D_val)); \ } \ else if(sizeof(type)==sizeof(long)) \ for(i = 0; i < d_nelmts; i++) { \ - if(HDfabs(buf[i] - filval) < HDpow(10.0, -D_val)) \ + if(HDfabs(buf[i] - filval) < HDpow(10.0f, -D_val)) \ *(long *)&buf[i] = (long)(((unsigned long)1 << *minbits) - 1); \ else \ *(long *)&buf[i] = H5Z_scaleoffset_rnd( \ - buf[i]*HDpow(10.0, D_val) - min*HDpow(10.0, D_val)); \ + buf[i]*HDpow(10.0f, D_val) - min*HDpow(10.0f, D_val)); \ } \ else if(sizeof(type)==sizeof(long long)) \ for(i = 0; i < d_nelmts; i++) { \ - if(HDfabs(buf[i] - filval) < HDpow(10.0, -D_val)) \ + if(HDfabs(buf[i] - filval) < HDpow(10.0f, -D_val)) \ *(long long *)&buf[i] = (long long)(((unsigned long long)1 << *minbits) - 1); \ else \ *(long long *)&buf[i] = H5Z_scaleoffset_rnd( \ - buf[i]*HDpow(10.0, D_val) - min*HDpow(10.0, D_val)); \ + buf[i]*HDpow(10.0f, D_val) - min*HDpow(10.0f, D_val)); \ } \ else \ HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer dataype")\ @@ -515,15 +515,15 @@ H5Z_class2_t H5Z_SCALEOFFSET[1] = {{ if(sizeof(type)==sizeof(int)) \ for(i = 0; i < d_nelmts; i++) \ *(int *)&buf[i] = H5Z_scaleoffset_rnd( \ - buf[i]*HDpow(10.0, D_val) - min*HDpow(10.0, D_val)); \ + buf[i]*HDpow(10.0f, D_val) - min*HDpow(10.0f, D_val)); \ else if(sizeof(type)==sizeof(long)) \ for(i = 0; i < d_nelmts; i++) \ *(long *)&buf[i] = H5Z_scaleoffset_rnd( \ - buf[i]*HDpow(10.0, D_val) - min*HDpow(10.0, D_val)); \ + buf[i]*HDpow(10.0f, D_val) - min*HDpow(10.0f, D_val)); \ else if(sizeof(type)==sizeof(long long)) \ for(i = 0; i < d_nelmts; i++) \ *(long long *)&buf[i] = H5Z_scaleoffset_rnd( \ - buf[i]*HDpow(10.0, D_val) - min*HDpow(10.0, D_val)); \ + buf[i]*HDpow(10.0f, D_val) - min*HDpow(10.0f, D_val)); \ else \ HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer dataype")\ } @@ -560,14 +560,14 @@ H5Z_class2_t H5Z_SCALEOFFSET[1] = {{ H5Z_scaleoffset_get_filval_2(type, cd_values, filval) \ H5Z_scaleoffset_max_min_3(i, d_nelmts, buf, filval, max, min, D_val) \ H5Z_scaleoffset_check_3(i, type, max, min, minbits, D_val) \ - span = H5Z_scaleoffset_rnd(max * HDpow(10.0, D_val) - min * HDpow(10.0, D_val)) + 1; \ + span = H5Z_scaleoffset_rnd(max * HDpow(10.0f, D_val) - min * HDpow(10.0f, D_val)) + 1; \ *minbits = H5Z_scaleoffset_log2((unsigned long long)(span + 1)); \ if(*minbits != sizeof(type) * 8) /* change values if minbits != full precision */ \ H5Z_scaleoffset_modify_1(i, type, buf, d_nelmts, filval, minbits, min, D_val) \ } else { /* fill value undefined */ \ H5Z_scaleoffset_max_min_2(i, d_nelmts, buf, max, min) \ H5Z_scaleoffset_check_3(i, type, max, min, minbits, D_val) \ - span = H5Z_scaleoffset_rnd(max * HDpow(10.0, D_val) - min * HDpow(10.0, D_val)) + 1; \ + span = H5Z_scaleoffset_rnd(max * HDpow(10.0f, D_val) - min * HDpow(10.0f, D_val)) + 1; \ *minbits = H5Z_scaleoffset_log2((unsigned long long)span); \ if(*minbits != sizeof(type) * 8) /* change values if minbits != full precision */ \ H5Z_scaleoffset_modify_2(i, type, buf, d_nelmts, min, D_val) \ @@ -628,15 +628,15 @@ H5Z_class2_t H5Z_SCALEOFFSET[1] = {{ if(sizeof(type)==sizeof(int)) \ for(i = 0; i < d_nelmts; i++) \ buf[i] = (type)((*(int *)&buf[i] == (int)(((unsigned int)1 << minbits) - 1)) ? \ - filval : (double)(*(int *)&buf[i]) / HDpow(10.0, D_val) + min); \ + filval : (double)(*(int *)&buf[i]) / HDpow(10.0f, D_val) + min); \ else if(sizeof(type)==sizeof(long)) \ for(i = 0; i < d_nelmts; i++) \ buf[i] = (type)((*(long *)&buf[i] == (long)(((unsigned long)1 << minbits) - 1)) ? \ - filval : (double)(*(long *)&buf[i]) / HDpow(10.0, D_val) + min); \ + filval : (double)(*(long *)&buf[i]) / HDpow(10.0f, D_val) + min); \ else if(sizeof(type)==sizeof(long long)) \ for(i = 0; i < d_nelmts; i++) \ buf[i] = (type)((*(long long *)&buf[i] == (long long)(((unsigned long long)1 << minbits) - 1)) ? \ - filval : (double)(*(long long *)&buf[i]) / HDpow(10.0, D_val) + min); \ + filval : (double)(*(long long *)&buf[i]) / HDpow(10.0f, D_val) + min); \ else \ HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer dataype") \ } @@ -646,13 +646,13 @@ H5Z_class2_t H5Z_SCALEOFFSET[1] = {{ { \ if(sizeof(type)==sizeof(int)) \ for(i = 0; i < d_nelmts; i++) \ - buf[i] = (type)((double)(*(int *)&buf[i]) / HDpow(10.0, D_val) + min); \ + buf[i] = (type)((double)(*(int *)&buf[i]) / HDpow(10.0f, D_val) + min); \ else if(sizeof(type)==sizeof(long)) \ for(i = 0; i < d_nelmts; i++) \ - buf[i] = (type)((double)(*(long *)&buf[i]) / HDpow(10.0, D_val) + min); \ + buf[i] = (type)((double)(*(long *)&buf[i]) / HDpow(10.0f, D_val) + min); \ else if(sizeof(type)==sizeof(long long)) \ for(i = 0; i < d_nelmts; i++) \ - buf[i] = (type)((double)(*(long long *)&buf[i]) / HDpow(10.0, D_val) + min); \ + buf[i] = (type)((double)(*(long long *)&buf[i]) / HDpow(10.0f, D_val) + min); \ else \ HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer dataype") \ } @@ -1047,7 +1047,7 @@ H5Z_filter_scaleoffset(unsigned flags, size_t cd_nelmts, const unsigned cd_value unsigned filavail; /* flag indicating if fill value is defined or not */ H5Z_SO_scale_type_t scale_type = H5Z_SO_FLOAT_DSCALE;/* scale type */ int scale_factor = 0; /* scale factor */ - double D_val = 0.0; /* decimal scale factor */ + double D_val = 0.0f; /* decimal scale factor */ uint32_t minbits = 0; /* minimum number of bits to store values */ unsigned long long minval= 0; /* minimum value of input buffer */ enum H5Z_scaleoffset_t type; /* memory type corresponding to dataset datatype */ diff --git a/src/H5private.h b/src/H5private.h index f1b03cc..f828a46 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -2058,6 +2058,25 @@ static herr_t H5_INTERFACE_INIT_FUNC(void); #define HDcompile_assert(e) do { typedef struct { unsigned int b: (e); } x; } while(0) */ +/* Macros for enabling/disabling particular GCC warnings */ +/* (see the following web-sites for more info: + * http://www.dbp-consulting.com/tutorials/SuppressingGCCWarnings.html + * http://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Pragmas.html#Diagnostic-Pragmas + */ +/* These pragmas are only implemented usefully in gcc 4.6+ */ +#if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406 + #define GCC_DIAG_STR(s) #s + #define GCC_DIAG_JOINSTR(x,y) GCC_DIAG_STR(x ## y) + #define GCC_DIAG_DO_PRAGMA(x) _Pragma (#x) + #define GCC_DIAG_PRAGMA(x) GCC_DIAG_DO_PRAGMA(GCC diagnostic x) + + #define GCC_DIAG_OFF(x) GCC_DIAG_PRAGMA(push) GCC_DIAG_PRAGMA(ignored GCC_DIAG_JOINSTR(-W,x)) + #define GCC_DIAG_ON(x) GCC_DIAG_PRAGMA(pop) +#else + #define GCC_DIAG_OFF(x) + #define GCC_DIAG_ON(x) +#endif + /* Private functions, not part of the publicly documented API */ H5_DLL herr_t H5_init_library(void); H5_DLL void H5_term_library(void); diff --git a/test/dsets.c b/test/dsets.c index abbbe2c..c4d1fcc 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -1028,10 +1028,10 @@ test_conv_buffer(hid_t fid) cf->a[j][k][l] = 10*(j+1) + l + k; for(j = 0; j < DIM2; j++) - cf->b[j] = (float)(100.*(j+1) + 0.01*j); + cf->b[j] = (float)(100.0f*(j+1) + 0.01f*j); for(j = 0; j < DIM3; j++) - cf->c[j] = 100.*(j+1) + 0.02*j; + cf->c[j] = 100.0f*(j+1) + 0.02f*j; /* Create data space */ @@ -2783,7 +2783,7 @@ test_nbit_int(hid_t file) for(i= 0;i< (size_t)size[0]; i++) for(j = 0; j < (size_t)size[1]; j++) { orig_data[i][j] = (int)(((long long)HDrandom() % - (long long)HDpow(2.0, (double)(precision - 1))) << offset); + (long long)HDpow(2.0f, (double)(precision - 1))) << offset); /* even-numbered values are negtive */ if((i*size[1]+j+1)%2 == 0) @@ -2885,8 +2885,8 @@ test_nbit_float(hid_t file) /* orig_data[] are initialized to be within the range that can be represented by * dataset datatype (no precision loss during datatype conversion) */ - float orig_data[2][5] = {{(float)188384.00, (float)19.103516, (float)-1.0831790e9, (float)-84.242188, - (float)5.2045898}, {(float)-49140.000, (float)2350.2500, (float)-3.2110596e-1, (float)6.4998865e-5, (float)-0.0000000}}; + float orig_data[2][5] = {{(float)188384.00f, (float)19.103516f, (float)-1.0831790e9f, (float)-84.242188f, + (float)5.2045898f}, {(float)-49140.000f, (float)2350.2500f, (float)-3.2110596e-1f, (float)6.4998865e-5f, (float)-0.0000000f}}; float new_data[2][5]; size_t precision, offset; size_t i, j; diff --git a/test/dtypes.c b/test/dtypes.c index dca7eec..700e10c 100644 --- a/test/dtypes.c +++ b/test/dtypes.c @@ -1860,7 +1860,7 @@ test_compound_10(void) hsize_t dim1[1]; void *t1, *t2; char filename[1024]; - int len; + size_t len; int i; TESTING("array datatype of compound type with VL string"); @@ -1868,12 +1868,12 @@ test_compound_10(void) for(i=0; i=0; --i) { char pattern[3]; - pattern[2] = i; + pattern[2] = (char)i; pattern[0] = pattern[1] = 0; H5Tenum_insert(srctype, mname[i], pattern); } @@ -4550,7 +4550,7 @@ test_conv_enum_2(void) /* Source data */ data = (int*)malloc(NTESTELEM*sizeof(int)); for (i=0; i= 0) HDclose (ufid); - if (h5fid >= 0) HDclose (h5fid); - if (ofid >= 0) HDclose (ofid); + if(ufid >= 0) + HDclose (ufid); + if(h5fid >= 0) + HDclose (h5fid); + if(ofid >= 0) + HDclose (ofid); return h5tools_getstatus(); } diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c index bc1ee43..1bad0dd 100644 --- a/tools/lib/h5diff_array.c +++ b/tools/lib/h5diff_array.c @@ -109,7 +109,7 @@ static hbool_t not_comparable; if(0 == (A) && 0 == (B)) \ both_zero = TRUE; \ if(0 != (A)) \ - per = (double)ABS((double)(B - A) / (double)A); \ + per = (double)ABS((double)((B) - (A)) / (double)(A)); \ else \ not_comparable = TRUE; \ } @@ -119,16 +119,16 @@ static hbool_t not_comparable; per = -1; \ not_comparable = FALSE; \ both_zero = FALSE; \ - if(A == 0 && B == 0) \ + if((A) == 0 && (B) == 0) \ both_zero = TRUE; \ - if(A != 0) \ - per = ABS((double)((TYPE)(B - A)) / (double)A) ; \ + if((A) != 0) \ + per = ABS((double)((TYPE)((B) - (A))) / (double)(A)) ; \ else \ not_comparable = TRUE; \ } -# define PDIFF(a,b) ( (b>a) ? (b-a) : (a-b)) +#define PDIFF(a,b) (((b) > (a)) ? ((b) - (a)) : ((a) -(b))) typedef struct mcomp_t { @@ -887,9 +887,8 @@ static hsize_t diff_datum(void *_mem1, /* calculate the number of array elements */ for (u = 0, nelmts = 1; u < (unsigned)ndims; u++) nelmts *= adims[u]; - for (u = 0; u < nelmts; u++) - { - nfound+=diff_datum( + for (u = 0; u < nelmts; u++) { + nfound += diff_datum( mem1 + u * size, mem2 + u * size, /* offset */ memb_type, @@ -904,7 +903,7 @@ static hsize_t diff_datum(void *_mem1, container1_id, container2_id, ph, members); - } + } H5Tclose(memb_type); } break; diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c index c7323c3..4643804 100644 --- a/tools/lib/h5tools.c +++ b/tools/lib/h5tools.c @@ -1443,8 +1443,10 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t offset = H5Tget_member_offset(tid, j); memb = H5Tget_member_type(tid, j); - if (render_bin_output(stream, container, memb, mem + offset, 1) < 0) - return FAIL; + if (render_bin_output(stream, container, memb, mem + offset, 1) < 0) { + H5Tclose(memb); + H5E_THROW(FAIL, H5E_tools_min_id_g, "render_bin_output of compound member failed"); + } H5Tclose(memb); } @@ -1473,8 +1475,10 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t for (block_index = 0; block_index < block_nelmts; block_index++) { mem = ((unsigned char*)_mem) + block_index * size; /* dump the array element */ - if (render_bin_output(stream, container, memb, mem, nelmts) < 0) + if (render_bin_output(stream, container, memb, mem, nelmts) < 0) { + H5Tclose(memb); H5E_THROW(FAIL, H5E_tools_min_id_g, "render_bin_output failed"); + } } H5Tclose(memb); } @@ -1493,8 +1497,10 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t nelmts = ((hvl_t *) mem)->len; /* dump the array element */ - if (render_bin_output(stream, container, memb, ((char *) (((hvl_t *) mem)->p)), nelmts) < 0) + if (render_bin_output(stream, container, memb, ((char *) (((hvl_t *) mem)->p)), nelmts) < 0) { + H5Tclose(memb); H5E_THROW(FAIL, H5E_tools_min_id_g, "render_bin_output failed"); + } } H5Tclose(memb); } @@ -1615,15 +1621,16 @@ render_bin_output_region_data_blocks(hid_t region_id, FILE *stream, } if(H5Sselect_hyperslab(sid1, H5S_SELECT_SET, start, NULL, count, NULL) < 0) - HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sselect_hyperslab failed"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sselect_hyperslab failed"); if(H5Dread(region_id, type_id, mem_space, sid1, H5P_DEFAULT, region_buf) < 0) - HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dread failed"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dread failed"); if(H5Sget_simple_extent_dims(mem_space, total_size, NULL) < 0) - HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed"); - render_bin_output(stream, container, type_id, (char*)region_buf, numelem); + if(render_bin_output(stream, container, type_id, (char*)region_buf, numelem) < 0) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "render_bin_output of data region failed"); /* Render the region data element end */ } /* end for (blkndx = 0; blkndx < nblocks; blkndx++) */ @@ -1753,9 +1760,10 @@ render_bin_output_region_data_points(hid_t region_space, hid_t region_id, if(H5Dread(region_id, type_id, mem_space, region_space, H5P_DEFAULT, region_buf) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dread failed"); if(H5Sget_simple_extent_dims(region_space, dims1, NULL) < 0) - HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed"); - render_bin_output(stream, container, type_id, (char*)region_buf, npoints); + if(render_bin_output(stream, container, type_id, (char*)region_buf, npoints) < 0) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "render_bin_output of data points failed"); done: HDfree(region_buf); -- cgit v0.12