summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2012-10-21 03:44:32 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2012-10-21 03:44:32 (GMT)
commit8430e2d4dea5015e1d71ae518bbd98a1aa06363b (patch)
tree48367b471bbac3ae1bc6c9eff5f8410b391ab014
parent961a24ac3c18614850f998d7391728164090d1d6 (diff)
downloadhdf5-8430e2d4dea5015e1d71ae518bbd98a1aa06363b.zip
hdf5-8430e2d4dea5015e1d71ae518bbd98a1aa06363b.tar.gz
hdf5-8430e2d4dea5015e1d71ae518bbd98a1aa06363b.tar.bz2
[svn-r22935] Description:
Clean up a few warnings and minor code issues during review of enum -> int/float conversion changes. Tested on: Mac OSX/64 10.8.2 (amazon) w/debug (too minor to require h5committest)
-rw-r--r--src/H5Tconv.c25
-rw-r--r--test/enum.c10
2 files changed, 16 insertions, 19 deletions
diff --git a/src/H5Tconv.c b/src/H5Tconv.c
index b0827f8..5ecf864 100644
--- a/src/H5Tconv.c
+++ b/src/H5Tconv.c
@@ -2909,8 +2909,8 @@ H5T__conv_enum_numeric(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t ne
size_t buf_stride, size_t UNUSED bkg_stride, void *_buf,
void UNUSED *bkg, hid_t UNUSED dxpl_id)
{
- H5T_t *src = NULL, *dst = NULL; /*src and dst datatypes */
- H5T_t *src_parent = NULL; /*parent type for src */
+ H5T_t *src, *dst; /*src and dst datatypes */
+ H5T_t *src_parent; /*parent type for src */
hid_t src_parent_id = -1; /*ID for parent of the source */
H5T_path_t *tpath; /* Conversion information */
herr_t ret_value = SUCCEED; /* Return value */
@@ -2941,24 +2941,17 @@ H5T__conv_enum_numeric(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t ne
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype")
src_parent = src->shared->parent;
- if(H5T_INTEGER != src_parent->shared->type)
- HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "the base type of the source enum is not an integer type")
if(NULL == (tpath = H5T_path_find(src_parent, dst, NULL, NULL, dxpl_id, FALSE))) {
HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unable to convert between src and dest datatype")
- } else if (!H5T_path_noop(tpath)) {
+ } else if(!H5T_path_noop(tpath)) {
if((src_parent_id = H5I_register(H5I_DATATYPE, H5T_copy(src_parent, H5T_COPY_ALL), FALSE)) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register types for conversion")
- }
-
- /* Convert the data */
- if(H5T_convert(tpath, src_parent_id, dst_id, nelmts, buf_stride, bkg_stride, _buf, bkg, dxpl_id) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "datatype conversion failed")
-
- /* Release the temporary datatype IDs used */
- if(src_parent_id >= 0)
- H5I_dec_ref(src_parent_id);
+ /* Convert the data */
+ if(H5T_convert(tpath, src_parent_id, dst_id, nelmts, buf_stride, bkg_stride, _buf, bkg, dxpl_id) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "datatype conversion failed")
+ }
break;
default:
@@ -2967,6 +2960,10 @@ H5T__conv_enum_numeric(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t ne
} /* end switch */
done:
+ /* Release the temporary datatype IDs used */
+ if(src_parent_id >= 0)
+ H5I_dec_ref(src_parent_id);
+
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T__conv_enum_numeric() */
diff --git a/test/enum.c b/test/enum.c
index c0526d8..9178a2b 100644
--- a/test/enum.c
+++ b/test/enum.c
@@ -134,7 +134,7 @@ test_conv(hid_t file)
static c_e1 data1[]={E1_RED, E1_GREEN, E1_BLUE, E1_GREEN, E1_WHITE,
E1_WHITE, E1_BLACK, E1_GREEN, E1_BLUE, E1_RED,
E1_RED, E1_BLUE, E1_GREEN, E1_BLACK, E1_WHITE,
- E1_RED, E1_WHITE, 0, -1, -2};
+ E1_RED, E1_WHITE, (c_e1)0, (c_e1)-1, (c_e1)-2};
c_e1 data2[NELMTS(data1)];
short data_short[NELMTS(data1)];
int data_int[NELMTS(data1)];
@@ -178,7 +178,7 @@ test_conv(hid_t file)
if(H5Dread(dset, H5T_NATIVE_SHORT, space, space, H5P_DEFAULT, data_short) < 0) FAIL_STACK_ERROR
for(i = 0; i < (size_t)ds_size[0]; i++)
- if(data1[i] != data_short[i]) {
+ if((short)data1[i] != data_short[i]) {
H5_FAILED();
printf(" 2. data1[%lu]=%d, data_short[%lu]=%d (should be same)\n",
(unsigned long)i, (int)(data1[i]),
@@ -190,7 +190,7 @@ test_conv(hid_t file)
if(H5Dread(dset, H5T_NATIVE_DOUBLE, space, space, H5P_DEFAULT, data_double) < 0) FAIL_STACK_ERROR
for(i = 0; i < (size_t)ds_size[0]; i++)
- if(data1[i] != (int)data_double[i]) {
+ if(data1[i] != (unsigned)data_double[i]) {
H5_FAILED();
printf(" 3. data1[%lu]=%d, data_double[%lu]=%d (should be same)\n",
(unsigned long)i, (int)(data1[i]),
@@ -212,7 +212,7 @@ test_conv(hid_t file)
if(H5Dread(dset, H5T_NATIVE_INT, space, space, H5P_DEFAULT, data_int) < 0) FAIL_STACK_ERROR
for(i = 0; i < (size_t)ds_size[0]; i++)
- if(data1[i] != data_int[i]) {
+ if((int)data1[i] != data_int[i]) {
H5_FAILED();
printf(" 4. data1[%lu]=%d, data_int[%lu]=%d (should be same)\n",
(unsigned long)i, (int)(data1[i]),
@@ -234,7 +234,7 @@ test_conv(hid_t file)
if(H5Dread(dset, H5T_NATIVE_DOUBLE, space, space, H5P_DEFAULT, data_double) < 0) FAIL_STACK_ERROR
for(i = 0; i < (size_t)ds_size[0]; i++)
- if(data1[i] != (int)data_double[i]) {
+ if(data1[i] != (unsigned)data_double[i]) {
H5_FAILED();
printf(" 5. data1[%lu]=%d, data_double[%lu]=%d (should be same)\n",
(unsigned long)i, (int)(data1[i]),