summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2013-09-05 20:44:14 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2013-09-05 20:44:14 (GMT)
commit5b876c929f79003c85585570827452f5d8052d01 (patch)
tree89a1fa7bb8221a8679f180868467464e331c18ce
parenta1fe10691cf7ce1737aa420191efb996f7fe5657 (diff)
downloadhdf5-5b876c929f79003c85585570827452f5d8052d01.zip
hdf5-5b876c929f79003c85585570827452f5d8052d01.tar.gz
hdf5-5b876c929f79003c85585570827452f5d8052d01.tar.bz2
[svn-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 Tested on: Mac OSX 10.8.4 (amazon) w/gcc 4.8.1, C++ & FORTRAN (too minor to require h5committest)
-rw-r--r--config/gnu-flags3
-rw-r--r--fortran/src/H5Pf.c26
-rw-r--r--fortran/test/fortranlib_test_1_8.f9010
-rw-r--r--src/H5Pint.c26
-rw-r--r--src/H5T.c13
-rw-r--r--src/H5Tconv.c56
-rw-r--r--src/H5Zscaleoffset.c52
-rw-r--r--src/H5private.h24
-rw-r--r--test/dsets.c10
-rw-r--r--test/dtypes.c62
-rw-r--r--tools/h5dump/h5dump_defines.h2
-rw-r--r--tools/h5dump/h5dumpgentest.c12
-rw-r--r--tools/h5jam/h5jam.c17
-rw-r--r--tools/lib/h5diff_array.c17
-rw-r--r--tools/lib/h5tools.c28
15 files changed, 225 insertions, 133 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/H5Pint.c b/src/H5Pint.c
index 13cc3c1..40d0a9c 100644
--- a/src/H5Pint.c
+++ b/src/H5Pint.c
@@ -4787,9 +4787,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
@@ -4797,33 +4794,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 8f44035..f918ee1 100644
--- a/src/H5T.c
+++ b/src/H5T.c
@@ -494,10 +494,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);
@@ -2395,7 +2395,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")
@@ -4515,7 +4515,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 9ff0f00..bf686b8 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 2701c63..c376789 100644
--- a/src/H5private.h
+++ b/src/H5private.h
@@ -2354,6 +2354,30 @@ func_init_failed: \
#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 in gcc 4.2+ */
+#if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 402
+ #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)
+ /* These pragmas are only implemented in gcc 4.6+ */
+ #if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406
+ #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) GCC_DIAG_PRAGMA(ignored GCC_DIAG_JOINSTR(-W,x))
+ #define GCC_DIAG_ON(x) GCC_DIAG_PRAGMA(warning GCC_DIAG_JOINSTR(-W,x))
+ #endif
+#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 7abe818..cec8f9a 100644
--- a/test/dsets.c
+++ b/test/dsets.c
@@ -1023,10 +1023,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 */
@@ -2770,7 +2770,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)
@@ -2872,8 +2872,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 117a21a..de64713 100644
--- a/test/dtypes.c
+++ b/test/dtypes.c
@@ -1859,7 +1859,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");
@@ -1867,12 +1867,12 @@ test_compound_10(void)
for(i=0; i<ARRAY_DIM; i++) {
wdata[i].i1 = i*10+i;
wdata[i].str = HDstrdup("C string A");
- wdata[i].str[9] += i;
+ wdata[i].str[9] += (char)i;
wdata[i].i2 = i*1000+i*10;
wdata[i].text.p = (void*)HDstrdup("variable-length text A\0");
- len = wdata[i].text.len = strlen((char*)wdata[i].text.p)+1;
- ((char*)(wdata[i].text.p))[len-2] += i;
+ len = wdata[i].text.len = HDstrlen((char*)wdata[i].text.p)+1;
+ ((char*)(wdata[i].text.p))[len-2] += (char)i;
((char*)(wdata[i].text.p))[len-1] = '\0';
}
@@ -2088,11 +2088,11 @@ test_compound_11(void)
/* Initialize buffer */
for(u = 0; u < NTESTELEM; u++) {
- ((big_t *)buf)[u].d1 = (double)u * (double)1.5;
- ((big_t *)buf)[u].d2 = (double)u * (double)2.5;
- ((big_t *)buf)[u].d3 = (double)u * (double)3.5;
- ((big_t *)buf)[u].i1 = u * 3;
- ((big_t *)buf)[u].i2 = u * 5;
+ ((big_t *)buf)[u].d1 = (double)u * (double)1.5f;
+ ((big_t *)buf)[u].d2 = (double)u * (double)2.5f;
+ ((big_t *)buf)[u].d3 = (double)u * (double)3.5f;
+ ((big_t *)buf)[u].i1 = (int)(u * 3);
+ ((big_t *)buf)[u].i2 = (int)(u * 5);
((big_t *)buf)[u].s1 = (char *)HDmalloc((size_t)32);
sprintf(((big_t *)buf)[u].s1, "%u", (unsigned)u);
} /* end for */
@@ -2351,8 +2351,8 @@ test_compound_13(void)
/* Create some phony data. */
HDmemset(&data_out, 0, sizeof(data_out));
for(u = 0; u < COMPOUND13_ARRAY_SIZE + 1; u++)
- data_out.x[u] = u;
- data_out.y = 99.99;
+ data_out.x[u] = (unsigned char)u;
+ data_out.y = 99.99f;
/* Set latest_format in access propertly list to enable the latest
* compound datatype format.
@@ -2966,7 +2966,7 @@ test_compound_16(void)
} cmpd_struct;
cmpd_struct wdata1 = {1254, 5471};
- int obj_count;
+ ssize_t obj_count;
hid_t file;
hid_t cmpd_m_tid, cmpd_f_tid, int_id;
hid_t space_id;
@@ -3003,7 +3003,7 @@ test_compound_16(void)
/* Check behavior of H5Fget_obj_count */
if((obj_count = H5Fget_obj_count(file, H5F_OBJ_DATATYPE)) != 1) {
H5_FAILED(); AT();
- printf(" H5Fget_obj_count returned: %d; expected: 1\n", obj_count);
+ printf(" H5Fget_obj_count returned: %zd; expected: 1\n", obj_count);
goto error;
}
@@ -3737,7 +3737,7 @@ test_named (hid_t fapl)
H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error;
for(i = 0; i < (size_t)ds_size[0]; i++)
for(j = 0; j < (size_t)ds_size[1]; j++)
- attr_data[i][j] = (int)(i * ds_size[1] + j);
+ attr_data[i][j] = (unsigned)(i * ds_size[1] + j);
if(H5Awrite(attr1, H5T_NATIVE_UINT, attr_data) < 0) goto error;
if(H5Aclose(attr1) < 0) goto error;
@@ -4282,9 +4282,9 @@ test_conv_str_2(void)
if((f_type = mkstr((size_t)8, H5T_STR_SPACEPAD)) < 0) goto error;
if(NULL == (buf = (char*)HDcalloc(nelmts, (size_t)8))) goto error;
for(i = 0; i < nelmts; i++) {
- nchars = HDrand() % 8;
+ nchars = (size_t)(HDrand() % 8);
for(j = 0; j < nchars; j++)
- buf[i * 8 + j] = 'a' + HDrand() % 26;
+ buf[i * 8 + j] = (char)('a' + HDrand() % 26);
while(j < nchars)
buf[i * 8 + j++] = '\0';
} /* end for */
@@ -4338,7 +4338,7 @@ test_conv_str_3(void)
const size_t nelmts = NTESTELEM;
size_t i, j, nchars;
int ret_value = 1;
- int size;
+ size_t size;
H5T_pad_t inpad;
H5T_sign_t sign;
char *tag = NULL;
@@ -4353,9 +4353,9 @@ test_conv_str_3(void)
if(NULL == (buf = (char*)HDcalloc(nelmts, (size_t)8)))
FAIL_PUTS_ERROR("Allocation failed.");
for(i = 0; i < nelmts; i++) {
- nchars = HDrand() % 8;
+ nchars = (size_t)(HDrand() % 8);
for(j = 0; j < nchars; j++)
- buf[i * 8 + j] = 'a' + HDrand() % 26;
+ buf[i * 8 + j] = (char)('a' + HDrand() % 26);
while(j < nchars)
buf[i * 8 + j++] = '\0';
} /* end for */
@@ -4461,7 +4461,7 @@ test_conv_enum_1(void)
if((t2 = H5Tenum_create(H5T_NATIVE_INT)) < 0) goto error;
s[1] = '\0';
for(i = 0; i < 26; i++) {
- s[0] = 'A' + i;
+ s[0] = (char)('A' + i);
H5Tenum_insert(t1, s, &i);
H5Tenum_insert(t2, s, (val = i * 1000 + i, &val));
} /* end for */
@@ -4535,7 +4535,7 @@ test_conv_enum_2(void)
srctype = H5Tenum_create(oddsize);
for (i=7; i>=0; --i) {
char pattern[3];
- pattern[2] = i;
+ pattern[2] = (char)i;
pattern[0] = pattern[1] = 0;
H5Tenum_insert(srctype, mname[i], pattern);
}
@@ -4549,7 +4549,7 @@ test_conv_enum_2(void)
/* Source data */
data = (int*)malloc(NTESTELEM*sizeof(int));
for (i=0; i<NTESTELEM; i++) {
- ((char*)data)[i*3+2] = i % 8;
+ ((char*)data)[i*3+2] = (char)(i % 8);
((char*)data)[i*3+0] = 0;
((char*)data)[i*3+1] = 0;
}
@@ -4695,7 +4695,7 @@ static int
test_bitfield_funcs(void)
{
hid_t type=-1, ntype=-1, super=-1;
- int size;
+ size_t size;
char* tag=0;
H5T_pad_t inpad;
H5T_cset_t cset;
@@ -5016,7 +5016,7 @@ static int
opaque_funcs(void)
{
hid_t type = -1, super=-1;
- int size;
+ size_t size;
H5T_pad_t inpad;
H5T_cset_t cset;
H5T_str_t strpad;
@@ -5920,13 +5920,13 @@ static int
test_int_float_except(void)
{
#if H5_SIZEOF_INT==4 && H5_SIZEOF_FLOAT==4
- float buf[CONVERT_SIZE] = {(float)INT_MIN - 172.0, (float)INT_MAX - 32.0,
- (float)INT_MAX - 68.0, (float)4.5};
+ float buf[CONVERT_SIZE] = {(float)INT_MIN - 172.0f, (float)INT_MAX - 32.0f,
+ (float)INT_MAX - 68.0f, (float)4.5f};
int buf_int[CONVERT_SIZE] = {INT_MIN, INT_MAX, INT_MAX-127, 4};
- float buf_float[CONVERT_SIZE] = {INT_MIN, INT_MAX + 1.0, INT_MAX - 127.0, 4};
+ float buf_float[CONVERT_SIZE] = {(float)INT_MIN, (float)INT_MAX + 1.0f, (float)INT_MAX - 127.0f, 4};
int *intp; /* Pointer to buffer, as integers */
int buf2[CONVERT_SIZE] = {INT_MIN, INT_MAX, INT_MAX - 72, 0};
- float buf2_float[CONVERT_SIZE] = {INT_MIN, INT_MAX, INT_MAX - 127.0, (float)0.0};
+ float buf2_float[CONVERT_SIZE] = {(float)INT_MIN, (float)INT_MAX, (float)INT_MAX - 127.0f, (float)0.0f};
int buf2_int[CONVERT_SIZE] = {INT_MIN, INT_MAX, INT_MAX - 127, 0};
float *floatp; /* Pointer to buffer #2, as floats */
hid_t dxpl; /* Dataset transfer property list */
@@ -7048,7 +7048,8 @@ error:
* 10 November 2011
*-------------------------------------------------------------------------
*/
-int test_utf_ascii_conv(void)
+static int
+test_utf_ascii_conv(void)
{
hid_t fid = -1;
hid_t did = -1;
@@ -7265,7 +7266,7 @@ error:
int
main(void)
{
- unsigned long nerrors = 0;
+ long nerrors = 0;
hid_t fapl = -1;
/* Set the random # seed */
@@ -7338,3 +7339,4 @@ main(void)
return 0;
}
+
diff --git a/tools/h5dump/h5dump_defines.h b/tools/h5dump/h5dump_defines.h
index 66d73e3..5f2df43 100644
--- a/tools/h5dump/h5dump_defines.h
+++ b/tools/h5dump/h5dump_defines.h
@@ -25,7 +25,7 @@
/* Macros for displaying objects */
#define begin_obj(obj,name,begin) \
do { \
- if (name) \
+ if ((name)) \
PRINTSTREAM(rawoutstream, "%s \"%s\" %s", (obj), (name), (begin)); \
else \
PRINTSTREAM(rawoutstream, "%s %s", (obj), (begin)); \
diff --git a/tools/h5dump/h5dumpgentest.c b/tools/h5dump/h5dumpgentest.c
index 71b1e65..88035a2 100644
--- a/tools/h5dump/h5dumpgentest.c
+++ b/tools/h5dump/h5dumpgentest.c
@@ -3839,7 +3839,7 @@ static void write_attr_in(hid_t loc_id,
/* create 1D attributes with dimension [2], 2 elements */
hsize_t dims[1]={2};
- char buf1[2][2]= {"ab","de"}; /* string */
+ char buf1[2][3]= {"ab","de"}; /* string */
char buf2[2]= {1,2}; /* bitfield, opaque */
s_t buf3[2]= {{1,2},{3,4}}; /* compound */
hobj_ref_t buf4[2]; /* reference */
@@ -3851,7 +3851,7 @@ static void write_attr_in(hid_t loc_id,
/* create 2D attributes with dimension [3][2], 6 elements */
hsize_t dims2[2]={3,2};
- char buf12[6][2]= {"ab","cd","ef","gh","ij","kl"}; /* string */
+ char buf12[6][3]= {"ab","cd","ef","gh","ij","kl"}; /* string */
char buf22[3][2]= {{1,2},{3,4},{5,6}}; /* bitfield, opaque */
s_t buf32[6]= {{1,2},{3,4},{5,6},{7,8},{9,10},{11,12}}; /* compound */
hobj_ref_t buf42[3][2]; /* reference */
@@ -3862,7 +3862,7 @@ static void write_attr_in(hid_t loc_id,
/* create 3D attributes with dimension [4][3][2], 24 elements */
hsize_t dims3[3]={4,3,2};
- char buf13[24][2]= {"ab","cd","ef","gh","ij","kl","mn","pq",
+ char buf13[24][3]= {"ab","cd","ef","gh","ij","kl","mn","pq",
"rs","tu","vw","xz","AB","CD","EF","GH",
"IJ","KL","MN","PQ","RS","TU","VW","XZ"}; /* string */
char buf23[4][3][2]; /* bitfield, opaque */
@@ -4281,7 +4281,7 @@ static void write_dset_in(hid_t loc_id,
/* create 1D attributes with dimension [2], 2 elements */
hsize_t dims[1]={2};
- char buf1[2][2]= {"ab","de"}; /* string */
+ char buf1[2][3]= {"ab","de"}; /* string */
char buf2[2]= {1,2}; /* bitfield, opaque */
s_t buf3[2]= {{1,2},{3,4}}; /* compound */
hobj_ref_t buf4[2]; /* reference */
@@ -4293,7 +4293,7 @@ static void write_dset_in(hid_t loc_id,
/* create 2D attributes with dimension [3][2], 6 elements */
hsize_t dims2[2]={3,2};
- char buf12[6][2]= {"ab","cd","ef","gh","ij","kl"}; /* string */
+ char buf12[6][3]= {"ab","cd","ef","gh","ij","kl"}; /* string */
char buf22[3][2]= {{1,2},{3,4},{5,6}}; /* bitfield, opaque */
s_t buf32[6]= {{1,2},{3,4},{5,6},{7,8},{9,10},{11,12}}; /* compound */
hobj_ref_t buf42[3][2]; /* reference */
@@ -4304,7 +4304,7 @@ static void write_dset_in(hid_t loc_id,
/* create 3D attributes with dimension [4][3][2], 24 elements */
hsize_t dims3[3]={4,3,2};
- char buf13[24][2]= {"ab","cd","ef","gh","ij","kl","mn","pq",
+ char buf13[24][3]= {"ab","cd","ef","gh","ij","kl","mn","pq",
"rs","tu","vw","xz","AB","CD","EF","GH",
"IJ","KL","MN","PQ","RS","TU","VW","XZ"}; /* string */
char buf23[4][3][2]; /* bitfield, opaque */
diff --git a/tools/h5jam/h5jam.c b/tools/h5jam/h5jam.c
index 52eb0aa..ab38f65 100644
--- a/tools/h5jam/h5jam.c
+++ b/tools/h5jam/h5jam.c
@@ -327,7 +327,7 @@ main (int argc, const char *argv[])
leave (EXIT_FAILURE);
}
- h5fsize = sbuf2.st_size;
+ h5fsize = (hsize_t)sbuf2.st_size;
if (output_file == NULL) {
ofid = HDopen (input_file, O_WRONLY, 0);
@@ -385,16 +385,19 @@ main (int argc, const char *argv[])
/* pad the ub */
where = write_pad (ofid, where);
- if (ub_file)
+ if(ub_file)
HDfree (ub_file);
- if (input_file)
+ if(input_file)
HDfree (input_file);
- if (output_file)
+ if(output_file)
HDfree (output_file);
- if (ufid >= 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 96b508d..7dba0e5 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
{
@@ -890,9 +890,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,
@@ -907,7 +906,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 7b43d2e..d9a1827 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);