diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2001-01-09 21:22:30 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2001-01-09 21:22:30 (GMT) |
commit | 35bc545296209684a5c46db0cde11beb9403a4dc (patch) | |
tree | 98b5a037ed928085b98abc1fee71fc62f81073c1 /src/H5S.c | |
parent | 1290c4808d3e9890c765b1445f66b823c9026734 (diff) | |
download | hdf5-35bc545296209684a5c46db0cde11beb9403a4dc.zip hdf5-35bc545296209684a5c46db0cde11beb9403a4dc.tar.gz hdf5-35bc545296209684a5c46db0cde11beb9403a4dc.tar.bz2 |
[svn-r3252] Purpose:
Code cleanup.
Description:
Fixed _lots_ (I mean _tons_) of warnings spit out by the gcc with the
extra warnings. Including a few show-stoppers for compression on IRIX
machines.
Solution:
Changed lots of variables' types to more sensible and consistent types,
more range-checking, more variable typecasts, etc.
Platforms tested:
FreeBSD 4.2 (hawkwind), IRIX64-64 (modi4)
Diffstat (limited to 'src/H5S.c')
-rw-r--r-- | src/H5S.c | 87 |
1 files changed, 45 insertions, 42 deletions
@@ -654,7 +654,7 @@ H5Sextent_copy(hid_t dst_id,hid_t src_id) herr_t H5S_extent_copy(H5S_extent_t *dst, const H5S_extent_t *src) { - int i; + uint u; FUNC_ENTER(H5S_extent_copy, FAIL); @@ -668,15 +668,15 @@ H5S_extent_copy(H5S_extent_t *dst, const H5S_extent_t *src) case H5S_SIMPLE: if (src->u.simple.size) { - dst->u.simple.size = H5FL_ARR_ALLOC(hsize_t,src->u.simple.rank,0); - for (i = 0; i < src->u.simple.rank; i++) { - dst->u.simple.size[i] = src->u.simple.size[i]; + dst->u.simple.size = H5FL_ARR_ALLOC(hsize_t,(hsize_t)src->u.simple.rank,0); + for (u = 0; u < src->u.simple.rank; u++) { + dst->u.simple.size[u] = src->u.simple.size[u]; } } if (src->u.simple.max) { - dst->u.simple.max = H5FL_ARR_ALLOC(hsize_t,src->u.simple.rank,0); - for (i = 0; i < src->u.simple.rank; i++) { - dst->u.simple.max[i] = src->u.simple.max[i]; + dst->u.simple.max = H5FL_ARR_ALLOC(hsize_t,(hsize_t)src->u.simple.rank,0); + for (u = 0; u < src->u.simple.rank; u++) { + dst->u.simple.max[u] = src->u.simple.max[u]; } } break; @@ -754,8 +754,8 @@ H5S_copy(const H5S_t *src) hssize_t H5S_get_simple_extent_npoints(const H5S_t *ds) { - hssize_t ret_value = -1; - intn i; + hssize_t ret_value = -1; + uintn u; FUNC_ENTER(H5S_get_simple_extent_npoints, -1); @@ -768,8 +768,8 @@ H5S_get_simple_extent_npoints(const H5S_t *ds) break; case H5S_SIMPLE: - for (ret_value=1, i=0; i<ds->extent.u.simple.rank; i++) { - ret_value *= ds->extent.u.simple.size[i]; + for (ret_value=1, u=0; u<ds->extent.u.simple.rank; u++) { + ret_value *= ds->extent.u.simple.size[u]; } break; @@ -846,8 +846,8 @@ H5Sget_simple_extent_npoints(hid_t space_id) hsize_t H5S_get_npoints_max(const H5S_t *ds) { - hsize_t ret_value = 0; - intn i; + hsize_t ret_value = 0; + uintn u; FUNC_ENTER(H5S_get_npoints_max, 0); @@ -861,17 +861,17 @@ H5S_get_npoints_max(const H5S_t *ds) case H5S_SIMPLE: if (ds->extent.u.simple.max) { - for (ret_value=1, i=0; i<ds->extent.u.simple.rank; i++) { - if (H5S_UNLIMITED==ds->extent.u.simple.max[i]) { + for (ret_value=1, u=0; u<ds->extent.u.simple.rank; u++) { + if (H5S_UNLIMITED==ds->extent.u.simple.max[u]) { ret_value = HSIZET_MAX; break; } else { - ret_value *= ds->extent.u.simple.max[i]; + ret_value *= ds->extent.u.simple.max[u]; } } } else { - for (ret_value=1, i=0; i<ds->extent.u.simple.rank; i++) { - ret_value *= ds->extent.u.simple.size[i]; + for (ret_value=1, u=0; u<ds->extent.u.simple.rank; u++) { + ret_value *= ds->extent.u.simple.size[u]; } } break; @@ -1164,7 +1164,7 @@ H5S_read(H5G_entry_t *ent) ds->select.type=H5S_SEL_ALL; /* Allocate space for the offset and set it to zeros */ - if (NULL==(ds->select.offset = H5FL_ARR_ALLOC(hssize_t,ds->extent.u.simple.rank,1))) { + if (NULL==(ds->select.offset = H5FL_ARR_ALLOC(hssize_t,(hsize_t)ds->extent.u.simple.rank,1))) { HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); } @@ -1193,7 +1193,7 @@ H5S_read(H5G_entry_t *ent) intn H5S_cmp(const H5S_t *ds1, const H5S_t *ds2) { - intn i; + uintn u; FUNC_ENTER(H5S_cmp, 0); @@ -1214,22 +1214,22 @@ H5S_cmp(const H5S_t *ds1, const H5S_t *ds2) if (ds1->extent.u.simple.rank > ds2->extent.u.simple.rank) HRETURN(1); - for (i = 0; i < ds1->extent.u.simple.rank; i++) { - if (ds1->extent.u.simple.size[i] < ds2->extent.u.simple.size[i]) + for (u = 0; u < ds1->extent.u.simple.rank; u++) { + if (ds1->extent.u.simple.size[u] < ds2->extent.u.simple.size[u]) HRETURN(-1); - if (ds1->extent.u.simple.size[i] > ds2->extent.u.simple.size[i]) + if (ds1->extent.u.simple.size[u] > ds2->extent.u.simple.size[u]) HRETURN(1); } /* don't compare max dimensions */ #ifdef LATER - for (i = 0; i < ds1->extent.u.simple.rank; i++) { - if ((ds1->extent.u.simple.perm ? ds1->extent.u.simple.perm[i] : i) < - (ds2->extent.u.simple.perm ? ds2->extent.u.simple.perm[i] : i)) + for (u = 0; u < ds1->extent.u.simple.rank; u++) { + if ((ds1->extent.u.simple.perm ? ds1->extent.u.simple.perm[u] : u) < + (ds2->extent.u.simple.perm ? ds2->extent.u.simple.perm[u] : i)) HRETURN(-1); - if ((ds1->extent.u.simple.perm ? ds2->extent.u.simple.perm[i] : i) > - (ds2->extent.u.simple.perm ? ds2->extent.u.simple.perm[i] : i)) + if ((ds1->extent.u.simple.perm ? ds2->extent.u.simple.perm[u] : u) > + (ds2->extent.u.simple.perm ? ds2->extent.u.simple.perm[u] : i)) HRETURN(1); } #endif @@ -1415,7 +1415,7 @@ H5S_set_extent_simple (H5S_t *space, int rank, const hsize_t *dims, space->select.offset=H5FL_ARR_FREE(hssize_t,space->select.offset); /* Allocate space for the offset and set it to zeros */ - if (NULL==(space->select.offset = H5FL_ARR_ALLOC(hssize_t,rank,1))) { + if (NULL==(space->select.offset = H5FL_ARR_ALLOC(hssize_t,(hsize_t)rank,1))) { HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); } @@ -1450,12 +1450,12 @@ H5S_set_extent_simple (H5S_t *space, int rank, const hsize_t *dims, /* Set the rank and copy the dims */ space->extent.u.simple.rank = rank; - space->extent.u.simple.size = H5FL_ARR_ALLOC(hsize_t,rank,0); + space->extent.u.simple.size = H5FL_ARR_ALLOC(hsize_t,(hsize_t)rank,0); HDmemcpy(space->extent.u.simple.size, dims, sizeof(hsize_t) * rank); /* Copy the maximum dimensions if specified */ if(max!=NULL) { - space->extent.u.simple.max = H5FL_ARR_ALLOC(hsize_t,rank,0); + space->extent.u.simple.max = H5FL_ARR_ALLOC(hsize_t,(hsize_t)rank,0); HDmemcpy(space->extent.u.simple.max, max, sizeof(hsize_t) * rank); } /* end if */ } @@ -1538,8 +1538,10 @@ H5S_find (const H5S_t *mem_space, const H5S_t *file_space) H5S_conv_g[i]->read = H5S_all_read; H5S_conv_g[i]->write = H5S_all_write; } - else - H5S_conv_g[i]->read = H5S_conv_g[i]->write = NULL; + else { + H5S_conv_g[i]->read = NULL; + H5S_conv_g[i]->write = NULL; + } HRETURN(H5S_conv_g[i]); } @@ -1620,7 +1622,8 @@ H5S_find (const H5S_t *mem_space, const H5S_t *file_space) intn H5S_extend (H5S_t *space, const hsize_t *size) { - intn i, ret_value=0; + intn ret_value=0; + uintn u; FUNC_ENTER (H5S_extend, FAIL); @@ -1628,11 +1631,11 @@ H5S_extend (H5S_t *space, const hsize_t *size) assert (space && H5S_SIMPLE==space->extent.type); assert (size); - for (i=0; i<space->extent.u.simple.rank; i++) { - if (space->extent.u.simple.size[i]<size[i]) { + for (u=0; u<space->extent.u.simple.rank; u++) { + if (space->extent.u.simple.size[u]<size[u]) { if (space->extent.u.simple.max && - H5S_UNLIMITED!=space->extent.u.simple.max[i] && - space->extent.u.simple.max[i]<size[i]) { + H5S_UNLIMITED!=space->extent.u.simple.max[u] && + space->extent.u.simple.max[u]<size[u]) { HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "dimension cannot be increased"); } @@ -1642,9 +1645,9 @@ H5S_extend (H5S_t *space, const hsize_t *size) /* Update */ if (ret_value) { - for (i=0; i<space->extent.u.simple.rank; i++) { - if (space->extent.u.simple.size[i]<size[i]) { - space->extent.u.simple.size[i] = size[i]; + for (u=0; u<space->extent.u.simple.rank; u++) { + if (space->extent.u.simple.size[u]<size[u]) { + space->extent.u.simple.size[u] = size[u]; } } } @@ -1884,7 +1887,7 @@ H5Soffset_simple(hid_t space_id, const hssize_t *offset) /* Allocate space for new offset */ if(space->select.offset==NULL) { - if (NULL==(space->select.offset = H5FL_ARR_ALLOC(hssize_t,space->extent.u.simple.rank,0))) { + if (NULL==(space->select.offset = H5FL_ARR_ALLOC(hssize_t,(hsize_t)space->extent.u.simple.rank,0))) { HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); } |