diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2001-11-27 16:29:13 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2001-11-27 16:29:13 (GMT) |
commit | d456c2bb82be98bc2b7c1039927eb52258d1a0eb (patch) | |
tree | a7d8a65aef5d962c89b0965c86eb535917c023ad /test | |
parent | 05264c88788f9bd9b04a58673ded246904210235 (diff) | |
download | hdf5-d456c2bb82be98bc2b7c1039927eb52258d1a0eb.zip hdf5-d456c2bb82be98bc2b7c1039927eb52258d1a0eb.tar.gz hdf5-d456c2bb82be98bc2b7c1039927eb52258d1a0eb.tar.bz2 |
[svn-r4643] Purpose:
Code cleanup
Description:
Windows is generating hundreds of warnings from some of the practices in
the library. Mostly, they are because size_t is 32-bit and hsize_t is
64-bit on Windows and we were carelessly casting the larger values down to
the smaller ones without checking for overflow.
Also, some other small code cleanups,etc.
Solution:
Re-worked some algorithms to eliminate the casts and also added more
overflow checking for assignments and function parameters which needed
casts.
Kent did most of the work, I just went over his changes and fit them into
the the library code a bit better.
Platforms tested:
FreeBSD 4.4 (hawkwind)
Diffstat (limited to 'test')
-rw-r--r-- | test/dsets.c | 2 | ||||
-rw-r--r-- | test/dtypes.c | 4 | ||||
-rw-r--r-- | test/external.c | 2 | ||||
-rw-r--r-- | test/fillval.c | 6 | ||||
-rw-r--r-- | test/h5test.c | 4 | ||||
-rw-r--r-- | test/hyperslab.c | 6 | ||||
-rw-r--r-- | test/tarray.c | 8 | ||||
-rw-r--r-- | test/tattr.c | 2 | ||||
-rw-r--r-- | test/tgenprop.c | 2 | ||||
-rw-r--r-- | test/th5s.c | 4 | ||||
-rw-r--r-- | test/trefer.c | 18 | ||||
-rw-r--r-- | test/tselect.c | 13 | ||||
-rw-r--r-- | test/tvltypes.c | 4 |
13 files changed, 37 insertions, 38 deletions
diff --git a/test/dsets.c b/test/dsets.c index 1c2956a..80ca27d 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -438,7 +438,7 @@ test_compression(hid_t file) for (i=n=0; i<size[0]; i++) { for (j=0; j<size[1]; j++) { - points[i][j] = n++; + points[i][j] = (int)(n++); } } diff --git a/test/dtypes.c b/test/dtypes.c index aa7d5cc..a170027 100644 --- a/test/dtypes.c +++ b/test/dtypes.c @@ -1174,7 +1174,7 @@ test_named (hid_t fapl) /* It should be possible to define an attribute for the named type */ if ((attr1=H5Acreate (type, "attr1", H5T_NATIVE_UCHAR, space, H5P_DEFAULT))<0) goto error; - for (i=0; i<ds_size[0]*ds_size[1]; i++) attr_data[0][i] = i;/*tricky*/ + for (i=0; i<ds_size[0]*ds_size[1]; i++) attr_data[0][i] = (int)i;/*tricky*/ if (H5Awrite(attr1, H5T_NATIVE_UINT, attr_data)<0) goto error; if (H5Aclose (attr1)<0) goto error; @@ -3375,7 +3375,7 @@ test_conv_flt_1 (const char *name, hid_t src, hid_t dst) } else if (FLT_DOUBLE==src_type) { memcpy(aligned, saved+j*sizeof(double), sizeof(double)); if (FLT_FLOAT==dst_type) { - hw_f = *((double*)aligned); + hw_f = (float)(*((double*)aligned)); hw = (unsigned char*)&hw_f; } else if (FLT_DOUBLE==dst_type) { hw_d = *((double*)aligned); diff --git a/test/external.c b/test/external.c index ce1afe0..dfb11b1 100644 --- a/test/external.c +++ b/test/external.c @@ -703,7 +703,7 @@ test_3 (hid_t fapl) hid_t dset=-1; /*dataset */ unsigned i; /*miscellaneous counters */ int fd; /*external file descriptor */ - int part[25], whole[100]; /*raw data buffers */ + int part[25],whole[100]; /*raw data buffers */ hsize_t cur_size=100; /*current data space size */ hsize_t max_size=200; /*maximum data space size */ hssize_t hs_start=100; /*hyperslab starting offset */ diff --git a/test/fillval.c b/test/fillval.c index c794ff9..693bdc6 100644 --- a/test/fillval.c +++ b/test/fillval.c @@ -396,7 +396,7 @@ test_rdwr(hid_t fapl, const char *base_name, H5D_layout_t layout) for (i=0; i<1000; i++) { for (j=0, odd=0; j<5; j++) { hs_offset[j] = rand() % cur_size[j]; - odd += hs_offset[j]%2; + odd += (int)(hs_offset[j]%2); } should_be = odd ? fillval : 9999; if (H5Sselect_hyperslab(fspace, H5S_SELECT_SET, hs_offset, NULL, @@ -594,7 +594,7 @@ test_extend(hid_t fapl, const char *base_name, H5D_layout_t layout) for (i=0; i<1000; i++) { for (j=0, odd=0; j<5; j++) { hs_offset[j] = rand() % cur_size[j]; - odd += hs_offset[j]%2; + odd += (int)(hs_offset[j]%2); } should_be = odd ? fillval : 9999; if (H5Sselect_hyperslab(fspace, H5S_SELECT_SET, hs_offset, NULL, @@ -628,7 +628,7 @@ test_extend(hid_t fapl, const char *base_name, H5D_layout_t layout) if ((hsize_t)hs_offset[j]>=cur_size[j]) { odd = 1; } else { - odd += hs_offset[j]%2; + odd += (int)(hs_offset[j]%2); } } diff --git a/test/h5test.c b/test/h5test.c index 4fae090..05df6c1 100644 --- a/test/h5test.c +++ b/test/h5test.c @@ -434,7 +434,7 @@ h5_fileaccess(void) HDmemset(memb_map, 0, sizeof memb_map); HDmemset(memb_fapl, 0, sizeof memb_fapl); - HDmemset(memb_name, 0, sizeof memb_name); + HDmemset((void*)(&memb_name[0]), 0, sizeof memb_name); HDmemset(memb_addr, 0, sizeof memb_addr); assert(HDstrlen(multi_letters)==H5FD_MEM_NTYPES); @@ -452,7 +452,7 @@ h5_fileaccess(void) } else if (!HDstrcmp(name, "family")) { /* Family of files, each 1MB and using the default driver */ if ((val=HDstrtok(NULL, " \t\n\r"))) { - fam_size = HDstrtod(val, NULL) * 1024*1024; + fam_size = (hsize_t)(HDstrtod(val, NULL) * 1024*1024); } if (H5Pset_fapl_family(fapl, fam_size, H5P_DEFAULT)<0) return -1; } else if (!HDstrcmp(name, "log")) { diff --git a/test/hyperslab.c b/test/hyperslab.c index ea11436..2fd1de5 100644 --- a/test/hyperslab.c +++ b/test/hyperslab.c @@ -212,13 +212,13 @@ test_fill(size_t nx, size_t ny, size_t nz, * original * fill values and add the new ones. */ ref_value = init_full(dst, nx, ny, nz); - for (u=dst_offset[0]; + for (u=(size_t)dst_offset[0]; u<dst_offset[0]+dx; u++) { - for (v = dst_offset[1]; + for (v = (size_t)dst_offset[1]; v < dst_offset[1] + dy; v++) { - for (w = dst_offset[2]; + for (w = (size_t)dst_offset[2]; w < dst_offset[2] + dz; w++) { ref_value -= dst[u*ny*nz+v*nz+w]; diff --git a/test/tarray.c b/test/tarray.c index 4b0943c..6b5e556 100644 --- a/test/tarray.c +++ b/test/tarray.c @@ -507,7 +507,7 @@ test_array_compound_atomic(void) for(i=0; i<SPACE1_DIM1; i++) for(j=0; j<ARRAY1_DIM1; j++) { wdata[i][j].i=i*10+j; - wdata[i][j].f=i*2.5+j; + wdata[i][j].f=(float)(i*2.5+j); } /* end for */ /* Create file */ @@ -724,7 +724,7 @@ test_array_compound_array(void) for(j=0; j<ARRAY1_DIM1; j++) { wdata[i][j].i=i*10+j; for(k=0; k<ARRAY1_DIM1; k++) - wdata[i][j].f[k]=i*10+j*2.5+k; + wdata[i][j].f[k]=(float)(i*10+j*2.5+k); } /* end for */ /* Create file */ @@ -1536,7 +1536,7 @@ test_array_bkg(void) for (j = 0; j < ALEN; j++) { cf[i].a[j] = 100*(i+1) + j; - cf[i].b[j] = 100.*(i+1) + 0.01*j; + cf[i].b[j] = (float)(100.*(i+1) + 0.01*j); cf[i].c[j] = 100.*(i+1) + 0.02*j; } } @@ -1679,7 +1679,7 @@ test_array_bkg(void) /* -------------------------------- */ for (i=0; i< LENGTH; i++) for (j = 0; j < ALEN; j++) - cf[i].b[j]=fld[i].b[j] = 1.313; + cf[i].b[j]=fld[i].b[j] = (float)1.313; status = H5Dwrite (dataset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, fld); CHECK(status, FAIL, "H5Dwrite"); diff --git a/test/tattr.c b/test/tattr.c index c9f2de2..43c87dd 100644 --- a/test/tattr.c +++ b/test/tattr.c @@ -75,7 +75,7 @@ struct attr4_struct { #define ATTR5_NAME "Attr5" #define ATTR5_RANK 0 -float attr_data5=-5.123; /* Test data for 5th attribute */ +float attr_data5=(float)-5.123; /* Test data for 5th attribute */ herr_t attr_op1(hid_t loc_id, const char *name, void *op_data); diff --git a/test/tgenprop.c b/test/tgenprop.c index 9adf1a4..c302e81 100644 --- a/test/tgenprop.c +++ b/test/tgenprop.c @@ -39,7 +39,7 @@ int prop1_def=10; /* Property 1 default value */ #define PROP1_DEF_VALUE (&prop1_def) #define PROP2_NAME "Property 2" -float prop2_def=3.14; /* Property 2 default value */ +float prop2_def=(float)3.14; /* Property 2 default value */ #define PROP2_SIZE sizeof(prop2_def) #define PROP2_DEF_VALUE (&prop2_def) diff --git a/test/th5s.c b/test/th5s.c index 54c45ac..64142ac 100644 --- a/test/th5s.c +++ b/test/th5s.c @@ -70,7 +70,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 */ /**************************************************************** ** @@ -509,7 +509,7 @@ test_h5s_chunk(void) /* Initialize float array */ for(i=0; i<50000; i++) for(j=0; j<3; j++) - chunk_data_flt[i][j]=i*2.5-j*100.3; + chunk_data_flt[i][j]=(float)(i*2.5-j*100.3); status= H5Dwrite(dsetID,H5T_NATIVE_FLOAT,H5S_ALL,H5S_ALL,H5P_DEFAULT,chunk_data_flt); CHECK(status, FAIL, "H5Dwrite"); diff --git a/test/trefer.c b/test/trefer.c index 340ef0c..4d852d9 100644 --- a/test/trefer.c +++ b/test/trefer.c @@ -211,8 +211,8 @@ test_reference_obj(void) /* Check information in referenced dataset */ sid1 = H5Dget_space(dset2); CHECK(sid1, FAIL, "H5Dget_space"); - - ret=H5Sget_simple_extent_npoints(sid1); + + ret=(int)H5Sget_simple_extent_npoints(sid1); VERIFY(ret, 4, "H5Sget_simple_extent_npoints"); /* Read from disk */ @@ -359,7 +359,7 @@ test_reference_region(void) ret = H5Sselect_hyperslab(sid2,H5S_SELECT_SET,start,stride,count,block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); - ret = H5Sget_select_npoints(sid2); + ret = (int)H5Sget_select_npoints(sid2); VERIFY(ret, 36, "H5Sget_select_npoints"); /* Store first dataset region */ @@ -380,7 +380,7 @@ test_reference_region(void) ret = H5Sselect_elements(sid2,H5S_SELECT_SET,POINT1_NPOINTS,(const hssize_t **)coord1); CHECK(ret, FAIL, "H5Sselect_elements"); - ret = H5Sget_select_npoints(sid2); + ret = (int)H5Sget_select_npoints(sid2); VERIFY(ret, 10, "H5Sget_select_npoints"); /* Store second dataset region */ @@ -431,7 +431,7 @@ test_reference_region(void) sid1 = H5Dget_space(dset2); CHECK(sid1, FAIL, "H5Dget_space"); - ret=H5Sget_simple_extent_npoints(sid1); + ret=(int)H5Sget_simple_extent_npoints(sid1); VERIFY(ret, 100, "H5Sget_simple_extent_npoints"); /* Read from disk */ @@ -446,9 +446,9 @@ test_reference_region(void) CHECK(sid2, FAIL, "H5Rget_region"); /* Verify correct hyperslab selected */ - ret = H5Sget_select_npoints(sid2); + ret = (int)H5Sget_select_npoints(sid2); VERIFY(ret, 36, "H5Sget_select_npoints"); - ret = H5Sget_select_hyper_nblocks(sid2); + ret = (int)H5Sget_select_hyper_nblocks(sid2); VERIFY(ret, 1, "H5Sget_select_hyper_nblocks"); coords=HDmalloc(ret*SPACE2_RANK*sizeof(hsize_t)*2); /* allocate space for the hyperslab blocks */ ret = H5Sget_select_hyper_blocklist(sid2,(hsize_t)0,(hsize_t)ret,coords); @@ -474,9 +474,9 @@ test_reference_region(void) CHECK(sid2, FAIL, "H5Rget_region"); /* Verify correct elements selected */ - ret = H5Sget_select_npoints(sid2); + ret = (int)H5Sget_select_npoints(sid2); VERIFY(ret, 10, "H5Sget_select_npoints"); - ret = H5Sget_select_elem_npoints(sid2); + ret = (int)H5Sget_select_elem_npoints(sid2); VERIFY(ret, 10, "H5Sget_select_elem_npoints"); coords=HDmalloc(ret*SPACE2_RANK*sizeof(hsize_t)); /* allocate space for the element points */ ret = H5Sget_select_elem_pointlist(sid2,(hsize_t)0,(hsize_t)ret,coords); diff --git a/test/tselect.c b/test/tselect.c index 32b7226..785d8be 100644 --- a/test/tselect.c +++ b/test/tselect.c @@ -348,7 +348,7 @@ test_select_point(hid_t xfer_plist) VERIFY(temp_coord1[i][2],coord1[i][2],"H5Sget_select_elem_pointlist"); } /* end for */ - ret = H5Sget_select_npoints(sid1); + ret = (int)H5Sget_select_npoints(sid1); VERIFY(ret, 10, "H5Sget_select_npoints"); /* Append another sequence of ten points to disk dataset */ @@ -373,7 +373,7 @@ test_select_point(hid_t xfer_plist) VERIFY(temp_coord1[i][2],coord1[i][2],"H5Sget_select_elem_pointlist"); } /* end for */ - ret = H5Sget_select_npoints(sid1); + ret = (int)H5Sget_select_npoints(sid1); VERIFY(ret, 20, "H5Sget_select_npoints"); /* Select sequence of ten points for memory dataset */ @@ -402,7 +402,7 @@ test_select_point(hid_t xfer_plist) /* the next list of points to the beginning of the point selection list) */ HDmemcpy(((char *)pi.coord)+sizeof(coord2),coord2,sizeof(coord2)); - ret = H5Sget_select_npoints(sid2); + ret = (int)H5Sget_select_npoints(sid2); VERIFY(ret, 10, "H5Sget_select_npoints"); /* Append another sequence of ten points to memory dataset */ @@ -426,7 +426,7 @@ test_select_point(hid_t xfer_plist) VERIFY(temp_coord2[i][1],coord2[i][1],"H5Sget_select_elem_pointlist"); } /* end for */ - ret = H5Sget_select_npoints(sid2); + ret = (int)H5Sget_select_npoints(sid2); VERIFY(ret, 20, "H5Sget_select_npoints"); /* Save points for later iteration */ @@ -468,7 +468,7 @@ test_select_point(hid_t xfer_plist) VERIFY(temp_coord3[i][1],coord3[i][1],"H5Sget_select_elem_pointlist"); } /* end for */ - ret = H5Sget_select_npoints(sid2); + ret = (int)H5Sget_select_npoints(sid2); VERIFY(ret, 10, "H5Sget_select_npoints"); /* Append another sequence of ten points to disk dataset */ @@ -491,8 +491,7 @@ test_select_point(hid_t xfer_plist) VERIFY(temp_coord3[i][0],coord3[i][0],"H5Sget_select_elem_pointlist"); VERIFY(temp_coord3[i][1],coord3[i][1],"H5Sget_select_elem_pointlist"); } /* end for */ - - ret = H5Sget_select_npoints(sid2); + ret = (int)H5Sget_select_npoints(sid2); VERIFY(ret, 20, "H5Sget_select_npoints"); /* Read selection from disk */ diff --git a/test/tvltypes.c b/test/tvltypes.c index 8e59bd2..bfda390 100644 --- a/test/tvltypes.c +++ b/test/tvltypes.c @@ -254,7 +254,7 @@ test_vltypes_vlen_compound(void) wdata[i].len=i+1; for(j=0; j<(i+1); j++) { ((s1 *)wdata[i].p)[j].i=i*10+j; - ((s1 *)wdata[i].p)[j].f=(i*20+j)/3.0; + ((s1 *)wdata[i].p)[j].f=(float)((i*20+j)/3.0); } /* end for */ } /* end for */ @@ -401,7 +401,7 @@ test_vltypes_compound_vlen_atomic(void) /* Allocate and initialize VL data to write */ for(i=0; i<SPACE1_DIM1; i++) { wdata[i].i=i*10; - wdata[i].f=(i*20)/3.0; + wdata[i].f=(float)((i*20)/3.0); wdata[i].v.p=malloc((i+1)*sizeof(unsigned int)); wdata[i].v.len=i+1; for(j=0; j<(i+1); j++) |