From e5e786f589896da6f6414da51b56ccc119df8adb Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Thu, 1 Jul 2004 15:02:47 -0500 Subject: [svn-r8782] Purpose: Code cleanup Description: Clean up almost all warnings from Windows builds. Platforms tested: FreeBSD 4.10 (sleipnir) w/parallel Too minor to require h5committest --- c++/test/th5s.cpp | 2 +- src/H5Dio.c | 16 +- src/H5Pdcpl.c | 2 +- src/H5Shyper.c | 8 +- src/H5Spoint.c | 2 +- src/H5Sprivate.h | 2 +- src/H5Sselect.c | 2 +- src/H5TB.c | 11 +- src/H5Tconv.c | 2 +- src/H5Ztrans.c | 545 +++++++++++++++++++++----------------------------- test/bittests.c | 12 +- test/dsets.c | 7 +- test/dtransform.c | 68 ++++--- test/dtypes.c | 8 +- test/h5test.c | 2 +- test/ntypes.c | 2 +- test/th5s.c | 4 +- tools/h5dump/h5dump.c | 4 +- tools/h5ls/h5ls.c | 5 +- 19 files changed, 318 insertions(+), 386 deletions(-) diff --git a/c++/test/th5s.cpp b/c++/test/th5s.cpp index 8ea38ad..eac6703 100644 --- a/c++/test/th5s.cpp +++ b/c++/test/th5s.cpp @@ -77,7 +77,7 @@ struct space4_struct { unsigned u; float f; char c2; - } space4_data={'v',987123,-3.14,'g'}; /* Test data for 4th dataspace */ + } space4_data={'v',987123,(float)-3.14,'g'}; /* Test data for 4th dataspace */ /* Null dataspace */ int space5_data = 7; diff --git a/src/H5Dio.c b/src/H5Dio.c index 9585cd8..8996431 100644 --- a/src/H5Dio.c +++ b/src/H5Dio.c @@ -1152,7 +1152,7 @@ H5D_contig_read(hsize_t nelmts, H5D_t *dataset, target_size = max_type_size; /* If the buffer is too large to hold all the elements, make it smaller */ else if(target_size>(nelmts*max_type_size)) - target_size=(nelmts*max_type_size); + target_size=(size_t)(nelmts*max_type_size); } /* end if */ request_nelmts = target_size / max_type_size; @@ -1203,7 +1203,7 @@ H5D_contig_read(hsize_t nelmts, H5D_t *dataset, for (smine_start=0; smine_start(nelmts*max_type_size)) - target_size=(nelmts*max_type_size); + target_size=(size_t)(nelmts*max_type_size); } /* end if */ request_nelmts = target_size / max_type_size; @@ -1452,7 +1452,7 @@ H5D_contig_write(hsize_t nelmts, H5D_t *dataset, for (smine_start=0; smine_start(nelmts*max_type_size)) - target_size=(nelmts*max_type_size); + target_size=(size_t)(nelmts*max_type_size); } /* end if */ request_nelmts = target_size / max_type_size; @@ -1739,7 +1739,7 @@ H5D_chunk_read(hsize_t nelmts, H5D_t *dataset, for (smine_start=0; smine_startchunk_points; smine_start+=smine_nelmts) { /* Go figure out how many elements to read from the file */ assert(H5S_SELECT_ITER_NELMTS(&file_iter)==(chunk_info->chunk_points-smine_start)); - smine_nelmts = MIN(request_nelmts, (chunk_info->chunk_points-smine_start)); + smine_nelmts = (size_t)MIN(request_nelmts, (chunk_info->chunk_points-smine_start)); /* * Gather the data from disk into the data type conversion @@ -2026,7 +2026,7 @@ H5D_chunk_write(hsize_t nelmts, H5D_t *dataset, target_size = max_type_size; /* If the buffer is too large to hold all the elements, make it smaller */ else if(target_size>(nelmts*max_type_size)) - target_size=(nelmts*max_type_size); + target_size=(size_t)(nelmts*max_type_size); } /* end if */ request_nelmts = target_size / max_type_size; @@ -2096,7 +2096,7 @@ H5D_chunk_write(hsize_t nelmts, H5D_t *dataset, for (smine_start=0; smine_startchunk_points; smine_start+=smine_nelmts) { /* Go figure out how many elements to read from the file */ assert(H5S_SELECT_ITER_NELMTS(&file_iter)==(chunk_info->chunk_points-smine_start)); - smine_nelmts = MIN(request_nelmts, (chunk_info->chunk_points-smine_start)); + smine_nelmts = (size_t)MIN(request_nelmts, (chunk_info->chunk_points-smine_start)); /* * Gather the data from disk into the data type conversion diff --git a/src/H5Pdcpl.c b/src/H5Pdcpl.c index 48abd21..99f3e30 100644 --- a/src/H5Pdcpl.c +++ b/src/H5Pdcpl.c @@ -175,7 +175,7 @@ H5Pset_chunk(hid_t plist_id, int ndims, const hsize_t dim[/*ndims*/]) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "all chunk dimensions must be positive"); if (dim[i] != (dim[i]&0xffffffff)) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "all chunk dimensions must be less than 2^32"); - real_dims[i]=dim[i]; /* Store user's chunk dimensions */ + real_dims[i]=(size_t)dim[i]; /* Store user's chunk dimensions */ } /* end for */ layout = H5D_CHUNKED; diff --git a/src/H5Shyper.c b/src/H5Shyper.c index 0425d76..2ee7356 100644 --- a/src/H5Shyper.c +++ b/src/H5Shyper.c @@ -658,13 +658,13 @@ H5S_hyper_iter_next(H5S_sel_iter_t *iter, size_t nelem) while(temp_dim>=0) { if(temp_dim==fast_dim) { size_t actual_elem; /* Actual # of elements advanced on each iteration through loop */ - size_t block_elem; /* Number of elements left in a block */ + hsize_t block_elem; /* Number of elements left in a block */ /* Compute the number of elements left in block */ block_elem=tdiminfo[temp_dim].block-iter_offset[temp_dim]; /* Compute the number of actual elements to advance */ - actual_elem=MIN(nelem,block_elem); + actual_elem=(size_t)MIN(nelem,block_elem); /* Move the iterator over as many elements as possible */ iter_offset[temp_dim]+=actual_elem; @@ -729,13 +729,13 @@ H5S_hyper_iter_next(H5S_sel_iter_t *iter, size_t nelem) /* Increment absolute position */ if(curr_dim==fast_dim) { size_t actual_elem; /* Actual # of elements advanced on each iteration through loop */ - size_t span_elem; /* Number of elements left in a span */ + hsize_t span_elem; /* Number of elements left in a span */ /* Compute the number of elements left in block */ span_elem=(curr_span->high-abs_arr[curr_dim])+1; /* Compute the number of actual elements to advance */ - actual_elem=MIN(nelem,span_elem); + actual_elem=(size_t)MIN(nelem,span_elem); /* Move the iterator over as many elements as possible */ abs_arr[curr_dim]+=actual_elem; diff --git a/src/H5Spoint.c b/src/H5Spoint.c index 11802e5..4970321 100644 --- a/src/H5Spoint.c +++ b/src/H5Spoint.c @@ -1312,7 +1312,7 @@ H5S_point_get_seq_list(const H5S_t *space, unsigned flags, H5S_sel_iter_t *iter, /* Choose the minimum number of bytes to sequence through */ H5_CHECK_OVERFLOW(iter->elmt_left,hsize_t,size_t); - start_io_left=io_left=MIN(iter->elmt_left,maxelem); + start_io_left=io_left=(size_t)MIN(iter->elmt_left,maxelem); /* Get the dataspace dimensions */ if ((ndims=H5S_get_simple_extent_dims (space, dims, NULL))<0) diff --git a/src/H5Sprivate.h b/src/H5Sprivate.h index 89215cd..1c0c4d0 100644 --- a/src/H5Sprivate.h +++ b/src/H5Sprivate.h @@ -267,7 +267,7 @@ H5_DLL herr_t H5S_select_release(H5S_t *ds); H5_DLL herr_t H5S_select_get_seq_list(const H5S_t *space, unsigned flags, H5S_sel_iter_t *iter, size_t maxseq, size_t maxbytes, size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len); -H5_DLL herr_t H5S_select_serial_size(const H5S_t *space); +H5_DLL hssize_t H5S_select_serial_size(const H5S_t *space); H5_DLL herr_t H5S_select_serialize(const H5S_t *space, uint8_t *buf); H5_DLL htri_t H5S_select_is_contiguous(const H5S_t *space); H5_DLL htri_t H5S_select_is_single(const H5S_t *space); diff --git a/src/H5Sselect.c b/src/H5Sselect.c index 61a1f5d..e9fc5a3 100644 --- a/src/H5Sselect.c +++ b/src/H5Sselect.c @@ -225,7 +225,7 @@ H5S_select_get_seq_list(const H5S_t *space, unsigned flags, * *------------------------------------------------------------------------- */ -herr_t +hssize_t H5S_select_serial_size(const H5S_t *space) { hssize_t ret_value; /* Return value */ diff --git a/src/H5TB.c b/src/H5TB.c index 164380f..526acaf 100644 --- a/src/H5TB.c +++ b/src/H5TB.c @@ -215,12 +215,21 @@ H5TB_int_cmp(const void *k1, const void *k2, int UNUSED cmparg) static int H5TB_hsize_cmp(const void *k1, const void *k2, int UNUSED cmparg) { + int ret_value; + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5TB_hsize_cmp); assert(k1); assert(k2); - FUNC_LEAVE_NOAPI(*(const hsize_t *)k1 - *(const hsize_t *)k2); + if(*(const hsize_t *)k1 < *(const hsize_t *)k2) + ret_value=-1; + else if(*(const hsize_t *)k1 > *(const hsize_t *)k2) + ret_value=1; + else + ret_value=0; + + FUNC_LEAVE_NOAPI(ret_value); } /* end H5TB_hsize_cmp() */ diff --git a/src/H5Tconv.c b/src/H5Tconv.c index 389de12..82c7084 100644 --- a/src/H5Tconv.c +++ b/src/H5Tconv.c @@ -9293,7 +9293,7 @@ H5T_conv_i_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * Find the sign bit value of the source. */ if (H5T_SGN_2 == src.u.i.sign) - sign = H5T_bit_get_d(int_buf, src.prec-1, 1); + sign = (size_t)H5T_bit_get_d(int_buf, src.prec-1, 1); /* * What is the bit position(starting from 0 as first one) for the most significant diff --git a/src/H5Ztrans.c b/src/H5Ztrans.c index 3a0931a..c53a758 100644 --- a/src/H5Ztrans.c +++ b/src/H5Ztrans.c @@ -724,7 +724,8 @@ H5Z_new_node(H5Z_token_type type) *------------------------------------------------------------------------- */ -herr_t H5Z_xform_eval(const H5Z_data_xform_t *data_xform_prop, void* array, size_t array_size, const H5T_t *buf_type) +herr_t +H5Z_xform_eval(const H5Z_data_xform_t *data_xform_prop, void* array, size_t array_size, const H5T_t *buf_type) { H5Z_node *tree; hid_t array_type; @@ -736,7 +737,7 @@ herr_t H5Z_xform_eval(const H5Z_data_xform_t *data_xform_prop, void* array, size FUNC_ENTER_NOAPI(H5Z_xform_eval, FAIL) - assert(data_xform_prop); + assert(data_xform_prop); tree=data_xform_prop->parse_root; @@ -776,7 +777,7 @@ herr_t H5Z_xform_eval(const H5Z_data_xform_t *data_xform_prop, void* array, size } else if(array_type == H5T_NATIVE_FLOAT) { - f = tree->value.float_val; + f = (float)tree->value.float_val; for(i=0; itype == H5Z_XFORM_INTEGER) { res.type = H5Z_XFORM_INTEGER; - res.value = tree->value; - HGOTO_DONE(res) + res.value.int_val = tree->value.int_val; } else if (tree->type == H5Z_XFORM_FLOAT) { res.type = H5Z_XFORM_FLOAT; - res.value = tree->value; - HGOTO_DONE(res) + res.value.float_val = tree->value.float_val; } else if (tree->type == H5Z_XFORM_SYMBOL) { res.type = H5Z_XFORM_SYMBOL; - res.value = tree->value; + res.value.sym_val = tree->value.sym_val; res.ar_type = array_type; - HGOTO_DONE(res) } else { resl = H5Z_eval_full(tree->lchild, array, array_size, array_type); resr = H5Z_eval_full(tree->rchild, array, array_size, array_type); - switch (tree->type) - { - case H5Z_XFORM_PLUS: - if( (resl.type == H5Z_XFORM_SYMBOL) && (resr.type==H5Z_XFORM_INTEGER)) - { - res.type = H5Z_XFORM_SYMBOL; + res.type = H5Z_XFORM_SYMBOL; + + /* Check for un-handled datatype */ + if(array_type!= H5T_NATIVE_INT && array_type!= H5T_NATIVE_FLOAT) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, error, "Cannot perform a data transform on this type") + + switch (tree->type) { + case H5Z_XFORM_PLUS: + if( (resl.type == H5Z_XFORM_SYMBOL) && (resr.type==H5Z_XFORM_INTEGER)) + { if(array_type == H5T_NATIVE_INT) { - for(i=0; ia[j][k][l] = 10*(j+1) + l + k; for (j = 0; j < DIM2; j++) - cf->b[j] = 100.*(j+1) + 0.01*j; + cf->b[j] = (float)(100.*(j+1) + 0.01*j); for (j = 0; j < DIM3; j++) cf->c[j] = 100.*(j+1) + 0.02*j; @@ -2964,9 +2964,10 @@ test_set_local(hid_t fapl) h5_fixname(FILENAME[5], fapl, filename, sizeof filename); /* Initialize the integer & floating-point dataset */ - for (i = n = 0; i < DSET_DIM1; i++) + n=0.0; + for (i = 0; i < DSET_DIM1; i++) for (j = 0; j < DSET_DIM2; j++) { - points[i][j] = n++; + points[i][j] = (int)n++; points_dbl[i][j] = (double)1.5*n++; } diff --git a/test/dtransform.c b/test/dtransform.c index 5e67986..9d1665b 100644 --- a/test/dtransform.c +++ b/test/dtransform.c @@ -47,42 +47,52 @@ int main() herr_t err; int row, col; + TESTING("data transform, setting up") + for(row = 0; rowint)") /* Read in the integer data with a data transform. */ - err = H5Dread(dset_id_int, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id_c_to_f, windchillFintread); + if((err = H5Dread(dset_id_int, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id_c_to_f, windchillFintread))<0) TEST_ERROR; if( (compare_int(*windchillFintread, *windchillFint, 2)) == 0) { @@ -93,7 +103,7 @@ int main() PASSED(); TESTING("data transform, no data type conversion (float->float)") - err = H5Dread(dset_id_float, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, dxpl_id_c_to_f, windchillFfloatread); + if((err = H5Dread(dset_id_float, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, dxpl_id_c_to_f, windchillFfloatread))<0) TEST_ERROR; if( (compare_float(*windchillFfloat, *windchillFfloatread, 2.0)) == 0) { fprintf(stderr, "ERROR: Conversion failed to match computed data\n"); @@ -103,7 +113,7 @@ int main() PASSED(); TESTING("data transform, with data type conversion (int->float)") - err = H5Dread(dset_id_int, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, dxpl_id_c_to_f, windchillFfloatread); + if((err = H5Dread(dset_id_int, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, dxpl_id_c_to_f, windchillFfloatread))<0) TEST_ERROR; if( (compare_float(*windchillFfloat, *windchillFfloatread, 2.0)) == 0) { fprintf(stderr, "ERROR: Conversion failed to match computed data\n"); @@ -113,7 +123,7 @@ int main() PASSED(); TESTING("data transform, with data type conversion (float->int)") - err = H5Dread(dset_id_float, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id_c_to_f, windchillFintread); + if((err = H5Dread(dset_id_float, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id_c_to_f, windchillFintread))<0) TEST_ERROR; if( (compare_int(*windchillFint, *windchillFintread, 2)) == 0) { fprintf(stderr, "ERROR: Conversion failed to match computed data\n"); @@ -123,7 +133,7 @@ int main() PASSED(); TESTING("data transform, trivial transform, without type conversion") - err = H5Dread(dset_id_float, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, dxpl_id_simple, windchillFfloatread); + if((err = H5Dread(dset_id_float, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, dxpl_id_simple, windchillFfloatread))<0) TEST_ERROR; for(row = 0; row=0) - return(sb.st_size); + return((off_t)sb.st_size); return(0); } /* end get_file_size() */ diff --git a/test/ntypes.c b/test/ntypes.c index 9772bb6..952c90c 100644 --- a/test/ntypes.c +++ b/test/ntypes.c @@ -1577,7 +1577,7 @@ test_vl_dtype(hid_t file) tmp=malloc(t2->len*sizeof(unsigned int)); memcpy(tmp, t2->p, t2->len*H5Tget_size(nat_super_type)); - if (H5Tconvert(nat_super_type, H5T_NATIVE_UINT, (hsize_t)t2->len, tmp, NULL, H5P_DEFAULT)) + if (H5Tconvert(nat_super_type, H5T_NATIVE_UINT, t2->len, tmp, NULL, H5P_DEFAULT)) TEST_ERROR; for(k=0; klen; k++) { diff --git a/test/th5s.c b/test/th5s.c index deb2dae..f77f0cd 100644 --- a/test/th5s.c +++ b/test/th5s.c @@ -362,7 +362,7 @@ test_h5s_null(void) VERIFY(stype, H5S_NULL, "H5Sget_simple_extent_type"); /* Verify there is zero element in the dataspace */ - ret = H5Sget_simple_extent_npoints(dset_sid2); + ret = (herr_t)H5Sget_simple_extent_npoints(dset_sid2); VERIFY(ret, 0, "H5Sget_simple_extent_npoints"); /* Try reading from the dataset (make certain our buffer is unmodified) */ @@ -390,7 +390,7 @@ test_h5s_null(void) VERIFY(stype, H5S_NULL, "H5Sget_simple_extent_type"); /* Verify there is zero element in the dataspace */ - ret = H5Sget_simple_extent_npoints(attr_sid); + ret = (herr_t)H5Sget_simple_extent_npoints(attr_sid); VERIFY(ret, 0, "H5Sget_simple_extent_npoints"); /* Close the dataspace */ diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c index ed41369..cfc4955 100644 --- a/tools/h5dump/h5dump.c +++ b/tools/h5dump/h5dump.c @@ -3712,7 +3712,7 @@ print_enum(hid_t type) /* Convert values to native data type */ if (native > 0) - H5Tconvert(super, native, (hsize_t)nmembs, value, NULL, H5P_DEFAULT); + H5Tconvert(super, native, nmembs, value, NULL, H5P_DEFAULT); /* * Sort members by increasing value @@ -6156,7 +6156,7 @@ xml_print_enum(hid_t type) /* Convert values to native data type */ if (native > 0) - H5Tconvert(super, native, (hsize_t)nmembs, value, NULL, H5P_DEFAULT); + H5Tconvert(super, native, nmembs, value, NULL, H5P_DEFAULT); /* Sort members by increasing value */ /*not implemented yet */ diff --git a/tools/h5ls/h5ls.c b/tools/h5ls/h5ls.c index ed73af4..7107162 100644 --- a/tools/h5ls/h5ls.c +++ b/tools/h5ls/h5ls.c @@ -801,7 +801,7 @@ display_enum_type(hid_t type, int ind) } /* Convert values to native data type */ - if (native>0) H5Tconvert(super, native, (hsize_t)nmembs, value, NULL, H5P_DEFAULT); + if (native>0) H5Tconvert(super, native, nmembs, value, NULL, H5P_DEFAULT); /* Sort members by increasing value */ /*not implemented yet*/ @@ -2216,7 +2216,7 @@ main (int argc, const char *argv[]) * doesn't exist). */ show_file_name_g = (argc-argno > 1); /*show file names if more than one*/ while (argno