summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNeil Fortner <nfortne2@hdfgroup.org>2009-04-20 16:59:01 (GMT)
committerNeil Fortner <nfortne2@hdfgroup.org>2009-04-20 16:59:01 (GMT)
commit90aea941c557b4db38abe02ff63c426fc298c421 (patch)
tree5c113a73c44111d34ed9c2ef2e92b7ece5a79148 /src
parent4446e5da7186aad436db16600bf3aca6cadc7635 (diff)
downloadhdf5-90aea941c557b4db38abe02ff63c426fc298c421.zip
hdf5-90aea941c557b4db38abe02ff63c426fc298c421.tar.gz
hdf5-90aea941c557b4db38abe02ff63c426fc298c421.tar.bz2
[svn-r16804] Purpose: Fix bug 1548
Description: When writing data to a dataset, the data transform was performed after type conversion. This caused an error if the file type was non-native. This has been changed so data transforms are always performed on the memory type. Tested: jam, linew. smirom (h5committest)
Diffstat (limited to 'src')
-rw-r--r--src/H5Dscatgath.c11
-rw-r--r--src/H5Tconv.c54
2 files changed, 33 insertions, 32 deletions
diff --git a/src/H5Dscatgath.c b/src/H5Dscatgath.c
index bb9f46b..ed73f3c 100644
--- a/src/H5Dscatgath.c
+++ b/src/H5Dscatgath.c
@@ -662,6 +662,12 @@ H5D_scatgath_write(const H5D_io_info_t *io_info, const H5D_type_info_t *type_inf
HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file gather failed")
} /* end if */
+ /* Do the data transform before the type conversion (since
+ * transforms must be done in the memory type). */
+ if(!type_info->is_xform_noop)
+ if(H5Z_xform_eval(dxpl_cache->data_xform_prop, type_info->tconv_buf, smine_nelmts, type_info->mem_type) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Error performing data transform")
+
/*
* Perform datatype conversion.
*/
@@ -669,11 +675,6 @@ H5D_scatgath_write(const H5D_io_info_t *io_info, const H5D_type_info_t *type_inf
smine_nelmts, (size_t)0, (size_t)0, type_info->tconv_buf,
type_info->bkg_buf, io_info->dxpl_id) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTCONVERT, FAIL, "datatype conversion failed")
-
- /* Do the data transform after the type conversion (since we're using dataset->shared->type). */
- if(!type_info->is_xform_noop)
- if(H5Z_xform_eval(dxpl_cache->data_xform_prop, type_info->tconv_buf, smine_nelmts, type_info->dset_type) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Error performing data transform")
} /* end else */
/*
diff --git a/src/H5Tconv.c b/src/H5Tconv.c
index 90b7a21..c621bf4 100644
--- a/src/H5Tconv.c
+++ b/src/H5Tconv.c
@@ -194,7 +194,7 @@
src_id, dst_id, S, D, cb_struct.user_data); \
if(except_ret == H5T_CONV_UNHANDLED) \
/* Let compiler convert if case is ignored by user handler*/ \
- *((DT*)D) = (D_MAX); \
+ *((DT*)D) = (DT)(D_MAX); \
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 */ \
@@ -203,7 +203,7 @@
src_id, dst_id, S, D, cb_struct.user_data); \
if(except_ret == H5T_CONV_UNHANDLED) \
/* Let compiler convert if case is ignored by user handler*/ \
- *((DT*)D) = (D_MIN); \
+ *((DT*)D) = (DT)(D_MIN); \
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 */ \
@@ -212,9 +212,9 @@
}
#define H5T_CONV_Xx_NOEX_CORE(S,D,ST,DT,D_MIN,D_MAX) { \
if (*((ST*)S) > (DT)(D_MAX)) { \
- *((DT*)D) = (D_MAX); \
+ *((DT*)D) = (DT)(D_MAX); \
} else if (*((ST*)S) < (DT)(D_MIN)) { \
- *((DT*)D) = (D_MIN); \
+ *((DT*)D) = (DT)(D_MIN); \
} else \
*((DT*)D) = (DT)(*((ST*)S)); \
}
@@ -225,7 +225,7 @@
src_id, dst_id, S, D, cb_struct.user_data); \
if(except_ret == H5T_CONV_UNHANDLED) \
/* Let compiler convert if case is ignored by user handler*/ \
- *((DT*)D) = (D_MAX); \
+ *((DT*)D) = (DT)(D_MAX); \
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 */ \
@@ -234,7 +234,7 @@
}
#define H5T_CONV_Ux_NOEX_CORE(S,D,ST,DT,D_MIN,D_MAX) { \
if (*((ST*)S) > (DT)(D_MAX)) { \
- *((DT*)D) = (D_MAX); \
+ *((DT*)D) = (DT)(D_MAX); \
} else \
*((DT*)D) = (DT)(*((ST*)S)); \
}
@@ -270,12 +270,12 @@
}
#define H5T_CONV_uS_CORE(S,D,ST,DT,D_MIN,D_MAX) { \
- if (sizeof(ST)==sizeof(DT) && *((ST*)S) > (D_MAX)) { \
+ if (sizeof(ST)==sizeof(DT) && *((ST*)S) > (DT)(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) \
/* Let compiler convert if case is ignored by user handler*/ \
- *((DT*)D) = (D_MAX); \
+ *((DT*)D) = (DT)(D_MAX); \
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 */ \
@@ -319,7 +319,7 @@
src_id, dst_id, S, D, cb_struct.user_data); \
if(except_ret == H5T_CONV_UNHANDLED) \
/* Let compiler convert if case is ignored by user handler*/ \
- *((DT*)D) = (D_MAX); \
+ *((DT*)D) = (DT)(D_MAX); \
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 */ \
@@ -330,7 +330,7 @@
if (*((ST*)S) < 0) { \
*((DT*)D) = 0; \
} else if (sizeof(ST)>sizeof(DT) && *((ST*)S) > (DT)(D_MAX)) { \
- *((DT*)D) = (D_MAX); \
+ *((DT*)D) = (DT)(D_MAX); \
} else \
*((DT*)D) = (DT)(*((ST*)S)); \
}
@@ -384,7 +384,7 @@
src_id, dst_id, S, D, cb_struct.user_data); \
if(except_ret == H5T_CONV_UNHANDLED) \
/* Let compiler convert if case is ignored by user handler*/ \
- *((DT*)D) = (D_MAX); \
+ *((DT*)D) = (DT)(D_MAX); \
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 */ \
@@ -394,7 +394,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 (*((ST*)S) > (DT)(D_MAX)) { \
- *((DT*)D) = (D_MAX); \
+ *((DT*)D) = (DT)(D_MAX); \
} else \
*((DT*)D) = (DT)(*((ST*)S)); \
}
@@ -553,7 +553,7 @@
src_id, dst_id, S, D, cb_struct.user_data); \
if(except_ret == H5T_CONV_UNHANDLED) \
/* Let compiler convert if case is ignored by user handler*/ \
- *((DT*)D) = (D_MAX); \
+ *((DT*)D) = (DT)(D_MAX); \
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 */ \
@@ -562,7 +562,7 @@
src_id, dst_id, S, D, cb_struct.user_data); \
if(except_ret == H5T_CONV_UNHANDLED) \
/* Let compiler convert if case is ignored by user handler*/ \
- *((DT*)D) = (D_MIN); \
+ *((DT*)D) = (DT)(D_MIN); \
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 */ \
@@ -581,9 +581,9 @@
}
#define H5T_CONV_Fx_NOEX_CORE(S,D,ST,DT,D_MIN,D_MAX) { \
if (*((ST*)S) > (DT)(D_MAX)) { \
- *((DT*)D) = (D_MAX); \
+ *((DT*)D) = (DT)(D_MAX); \
} else if (*((ST*)S) < (DT)(D_MIN)) { \
- *((DT*)D) = (D_MIN); \
+ *((DT*)D) = (DT)(D_MIN); \
} \
else \
*((DT*)D) = (DT)(*((ST*)S)); \
@@ -621,7 +621,7 @@
case H5T_CONV_INIT: \
/* Sanity check and initialize statistics */ \
cdata->need_bkg = H5T_BKG_NO; \
- if (NULL==(st=H5I_object(src_id)) || NULL==(dt=H5I_object(dst_id))) \
+ 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") \
if (st->shared->size!=sizeof(ST) || dt->shared->size!=sizeof(DT)) \
@@ -669,7 +669,7 @@
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get conversion exception callback"); \
\
/* Get source and destination datatypes */ \
- if (NULL==(st=H5I_object(src_id)) || NULL==(dt=H5I_object(dst_id))) \
+ 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") \
\
@@ -714,7 +714,7 @@
} /* end if */ \
else { \
/* Single forward pass over all data */ \
- src = dst = buf; \
+ src = dst = (uint8_t*)buf; \
safe=nelmts; \
} /* end else */ \
\
@@ -9755,8 +9755,8 @@ H5T_conv_f_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
switch (cdata->command) {
case H5T_CONV_INIT:
- if (NULL==(src_p=H5I_object(src_id)) ||
- NULL==(dst_p=H5I_object(dst_id)))
+ if (NULL==(src_p=(H5T_t*)H5I_object(src_id)) ||
+ NULL==(dst_p=(H5T_t*)H5I_object(dst_id)))
HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype");
src = src_p->shared->u.atomic;
dst = dst_p->shared->u.atomic;
@@ -9774,8 +9774,8 @@ H5T_conv_f_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
case H5T_CONV_CONV:
/* Get the datatypes */
- if (NULL==(src_p=H5I_object(src_id)) ||
- NULL==(dst_p=H5I_object(dst_id)))
+ if (NULL==(src_p=(H5T_t*)H5I_object(src_id)) ||
+ NULL==(dst_p=(H5T_t*)H5I_object(dst_id)))
HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype");
src = src_p->shared->u.atomic;
dst = dst_p->shared->u.atomic;
@@ -10345,8 +10345,8 @@ H5T_conv_i_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
switch (cdata->command) {
case H5T_CONV_INIT:
- if (NULL==(src_p=H5I_object(src_id)) ||
- NULL==(dst_p=H5I_object(dst_id)))
+ if (NULL==(src_p=(H5T_t*)H5I_object(src_id)) ||
+ NULL==(dst_p=(H5T_t*)H5I_object(dst_id)))
HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype");
src = src_p->shared->u.atomic;
dst = dst_p->shared->u.atomic;
@@ -10364,8 +10364,8 @@ H5T_conv_i_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
case H5T_CONV_CONV:
/* Get the datatypes */
- if (NULL==(src_p=H5I_object(src_id)) ||
- NULL==(dst_p=H5I_object(dst_id)))
+ if (NULL==(src_p=(H5T_t*)H5I_object(src_id)) ||
+ NULL==(dst_p=(H5T_t*)H5I_object(dst_id)))
HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype");
src = src_p->shared->u.atomic;
dst = dst_p->shared->u.atomic;