summaryrefslogtreecommitdiffstats
path: root/src/H5Zscaleoffset.c
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 /src/H5Zscaleoffset.c
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)
Diffstat (limited to 'src/H5Zscaleoffset.c')
-rw-r--r--src/H5Zscaleoffset.c52
1 files changed, 26 insertions, 26 deletions
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 */