summaryrefslogtreecommitdiffstats
path: root/src/H5Shyper.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2010-07-29 19:07:26 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2010-07-29 19:07:26 (GMT)
commit7fe87a24722f991ffc030782cd42d24df00dbace (patch)
tree7d466f911a952916b99e2c86e83202d0e07cffaa /src/H5Shyper.c
parent178b80b679b874d99287b28898e242533721ea67 (diff)
downloadhdf5-7fe87a24722f991ffc030782cd42d24df00dbace.zip
hdf5-7fe87a24722f991ffc030782cd42d24df00dbace.tar.gz
hdf5-7fe87a24722f991ffc030782cd42d24df00dbace.tar.bz2
[svn-r19153] Description:
Bring changes on Coverity branch back to trunk: r19040: Fixed coverity #440 - NULL check after dereference. We moved the NULL check up into the IF block and changed it to assertion. r19041: Maintenance: Addressed Coverity issues 441 and 449 by initializing proper variables r19042: In function H5O_chunk_protect (H5Ochunk.c): - Initialize H5O_chunk_proxy_t pointers chk_proxy and ret_value. - Free chk_proxy on error. r19043: Addressed coverity issues 442 - 448 by initializing pointers to NULL. Tested on: Mac OS X/32 10.6.4 (amazon) w/debug & production (Too minor to require h5committest)
Diffstat (limited to 'src/H5Shyper.c')
-rw-r--r--src/H5Shyper.c360
1 files changed, 136 insertions, 224 deletions
diff --git a/src/H5Shyper.c b/src/H5Shyper.c
index 937fc26..a4fe5a3 100644
--- a/src/H5Shyper.c
+++ b/src/H5Shyper.c
@@ -2711,43 +2711,43 @@ done:
herr_t
H5S_hyper_bounds(const H5S_t *space, hsize_t *start, hsize_t *end)
{
- int rank; /* Dataspace rank */
- int i; /* index variable */
- herr_t ret_value=SUCCEED; /* Return value */
+ unsigned rank; /* Dataspace rank */
+ unsigned i; /* index variable */
+ herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(H5S_hyper_bounds,FAIL)
+ FUNC_ENTER_NOAPI(H5S_hyper_bounds, FAIL)
- assert(space);
- assert(start);
- assert(end);
+ HDassert(space);
+ HDassert(start);
+ HDassert(end);
/* Set the start and end arrays up */
- rank=space->extent.rank;
- for(i=0; i<rank; i++) {
- start[i]=HSIZET_MAX;
- end[i]=0;
+ rank = space->extent.rank;
+ for(i = 0; i < rank; i++) {
+ start[i] = HSIZET_MAX;
+ end[i] = 0;
} /* end for */
/* Check for a "regular" hyperslab selection */
if(space->select.sel_info.hslab->diminfo_valid) {
- const H5S_hyper_dim_t *diminfo=space->select.sel_info.hslab->opt_diminfo; /* local alias for diminfo */
+ const H5S_hyper_dim_t *diminfo = space->select.sel_info.hslab->opt_diminfo; /* local alias for diminfo */
/* Check each dimension */
- for(i=0; i<rank; i++) {
+ for(i = 0; i < rank; i++) {
/* Check for offset moving selection negative */
- if((space->select.offset[i]+(hssize_t)diminfo[i].start)<0)
+ if((space->select.offset[i] + (hssize_t)diminfo[i].start) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "offset moves selection out of bounds")
/* Compute the smallest location in this dimension */
- start[i]=diminfo[i].start+space->select.offset[i];
+ start[i] = diminfo[i].start + space->select.offset[i];
/* Compute the largest location in this dimension */
- end[i]=diminfo[i].start+diminfo[i].stride*(diminfo[i].count-1)+(diminfo[i].block-1)+space->select.offset[i];
+ end[i] = diminfo[i].start + diminfo[i].stride * (diminfo[i].count - 1) + (diminfo[i].block - 1) + space->select.offset[i];
} /* end for */
} /* end if */
else {
/* Call the recursive routine to get the bounds for the span tree */
- ret_value=H5S_hyper_bounds_helper(space->select.sel_info.hslab->span_lst,space->select.offset,(hsize_t)0,start,end);
+ ret_value = H5S_hyper_bounds_helper(space->select.sel_info.hslab->span_lst, space->select.offset, (hsize_t)0, start, end);
} /* end if */
done:
@@ -2781,7 +2781,7 @@ H5S_hyper_offset(const H5S_t *space, hsize_t *offset)
const hssize_t *sel_offset; /* Pointer to the selection's offset */
const hsize_t *dim_size; /* Pointer to a dataspace's extent */
hsize_t accum; /* Accumulator for dimension sizes */
- int rank; /* Dataspace rank */
+ unsigned rank; /* Dataspace rank */
int i; /* index variable */
herr_t ret_value = SUCCEED; /* Return value */
@@ -2804,7 +2804,7 @@ H5S_hyper_offset(const H5S_t *space, hsize_t *offset)
/* Loop through starting coordinates, calculating the linear offset */
accum = 1;
- for(i = (rank - 1); i >= 0; i--) {
+ for(i = (int)(rank - 1); i >= 0; i--) {
hssize_t hyp_offset = (hssize_t)diminfo[i].start + sel_offset[i]; /* Hyperslab's offset in this dimension */
/* Check for offset moving selection out of the dataspace */
@@ -2824,7 +2824,7 @@ H5S_hyper_offset(const H5S_t *space, hsize_t *offset)
/* Calculate the accumulator for each dimension */
accum = 1;
- for(i = (rank - 1); i >= 0; i--) {
+ for(i = (int)(rank - 1); i >= 0; i--) {
/* Set the accumulator for this dimension */
dim_accum[i] = accum;
@@ -4505,115 +4505,6 @@ done:
/*--------------------------------------------------------------------------
NAME
- H5S_hyper_move_helper
- PURPOSE
- Helper routine to move offset in span trees
- USAGE
- herr_t H5S_hyper_move_helper(spans, offset)
- H5S_hyper_span_info_t *spans; IN: Span tree to operate with
- const hssize_t *offset; IN: Offset to move to
- RETURNS
- Non-negative on success, negative on failure
- DESCRIPTION
- Adjust the location of the spans in a span tree by moving selection to an
- offset.
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
-static herr_t
-H5S_hyper_move_helper (H5S_hyper_span_info_t *spans, const hssize_t *offset)
-{
- H5S_hyper_span_t *span; /* Pointer to current span in span tree */
-
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_hyper_move_helper);
-
- /* Sanity check */
- assert(spans);
- assert(offset);
-
- /* Check if we've already set this down span tree */
- if(spans->scratch!=(H5S_hyper_span_info_t *)~((size_t)NULL)) {
- /* Set the tree's scratch pointer */
- spans->scratch=(H5S_hyper_span_info_t *)~((size_t)NULL);
-
- /* Get the span lists for each span in this tree */
- span=spans->head;
-
- /* Iterate over the spans in tree */
- while(span!=NULL) {
- /* Adjust span location */
- assert(*offset>=0);
- span->high=*offset+(span->high-span->low);
- span->low=*offset;
-
- /* Recursively move spans in next dimension down */
- if(span->down!=NULL)
- H5S_hyper_move_helper(span->down,offset+1);
-
- /* Advance to next span in this dimension */
- span=span->next;
- } /* end while */
- } /* end if */
-
- FUNC_LEAVE_NOAPI(SUCCEED);
-} /* H5S_hyper_move_helper() */
-
-
-/*--------------------------------------------------------------------------
- NAME
- H5S_hyper_move
- PURPOSE
- Move a hyperslab selection by to an offset
- USAGE
- herr_t H5S_hyper_move(space,offset)
- H5S_t *space; IN/OUT: Pointer to dataspace to move
- const hssize_t *offset; IN: Offset to move to
- RETURNS
- Non-negative on success, negative on failure
- DESCRIPTION
- Moves a hyperslab selection to a new offset.
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
-herr_t
-H5S_hyper_move(H5S_t *space, const hssize_t *offset)
-{
- unsigned u; /* Local index variable */
- herr_t ret_value=SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI_NOINIT(H5S_hyper_move);
-
- assert(space);
- assert(offset);
-
- /* Move to the offset with the "regular" coordinates, if they exist */
- if(space->select.sel_info.hslab->diminfo_valid) {
- for(u=0; u<space->extent.rank; u++) {
- assert(offset[u]>=0);
- space->select.sel_info.hslab->opt_diminfo[u].start=offset[u];
- } /* end for */
- } /* end if */
-
- /* Subtract the offset from the span tree coordinates, if they exist */
- if(space->select.sel_info.hslab->span_lst) {
- if(H5S_hyper_move_helper(space->select.sel_info.hslab->span_lst,offset)<0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_BADSELECT, FAIL, "can't perform hyperslab offset movement");
-
- /* Reset the scratch pointers for the next routine which needs them */
- H5S_hyper_span_scratch(space->select.sel_info.hslab->span_lst, NULL);
- } /* end if */
-
-done:
- FUNC_LEAVE_NOAPI(ret_value);
-} /* H5S_hyper_move() */
-
-
-/*--------------------------------------------------------------------------
- NAME
H5S_hyper_normalize_offset
PURPOSE
"Normalize" a hyperslab selection by adjusting it's coordinates by the
@@ -5774,10 +5665,9 @@ static H5S_hyper_span_info_t *
H5S_hyper_make_spans(unsigned rank, const hsize_t *start, const hsize_t *stride,
const hsize_t *count, const hsize_t *block)
{
- H5S_hyper_span_info_t *down; /* Pointer to spans in next dimension down */
- H5S_hyper_span_t *span; /* New hyperslab span */
+ H5S_hyper_span_info_t *down = NULL; /* Pointer to spans in next dimension down */
H5S_hyper_span_t *last_span; /* Current position in hyperslab span list */
- H5S_hyper_span_t *head; /* Head of new hyperslab span list */
+ H5S_hyper_span_t *head = NULL; /* Head of new hyperslab span list */
hsize_t stride_iter; /* Iterator over the stride values */
int i; /* Counters */
unsigned u; /* Counters */
@@ -5793,8 +5683,7 @@ H5S_hyper_make_spans(unsigned rank, const hsize_t *start, const hsize_t *stride,
HDassert(block);
/* Start creating spans in fastest changing dimension */
- down = NULL;
- for(i = (rank - 1); i >= 0; i--) {
+ for(i = (int)(rank - 1); i >= 0; i--) {
/* Sanity check */
if(0 == count[i])
@@ -5806,6 +5695,8 @@ H5S_hyper_make_spans(unsigned rank, const hsize_t *start, const hsize_t *stride,
/* Generate all the span segments for this dimension */
for(u = 0, stride_iter = 0; u < count[i]; u++, stride_iter += stride[i]) {
+ H5S_hyper_span_t *span; /* New hyperslab span */
+
/* Allocate a span node */
if(NULL == (span = H5FL_MALLOC(H5S_hyper_span_t)))
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, NULL, "can't allocate hyperslab span")
@@ -5918,7 +5809,7 @@ H5S_hyper_rebuild_helper(const H5S_hyper_span_t *span, H5S_hyper_dim_t span_slab
hsize_t curr_block, next_block;
hsize_t curr_start;
hsize_t curr_low;
- int outcount;
+ size_t outcount;
unsigned u;
H5S_hyper_dim_t canon_down_span_slab_info[H5S_MAX_RANK];
hbool_t ret_value = TRUE;
@@ -6318,6 +6209,11 @@ H5S_generate_hyperslab (H5S_t *space, H5S_seloper_t op,
} /* end if */
break;
+ case H5S_SELECT_NOOP:
+ case H5S_SELECT_SET:
+ case H5S_SELECT_APPEND:
+ case H5S_SELECT_PREPEND:
+ case H5S_SELECT_INVALID:
default:
HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation");
} /* end switch */
@@ -6444,6 +6340,10 @@ H5S_select_hyperslab (H5S_t *space, H5S_seloper_t op,
case H5S_SELECT_NOTB: /* Binary "A not B" operation for hyperslabs */
HGOTO_DONE(SUCCEED); /* Selection stays same */
+ case H5S_SELECT_NOOP:
+ case H5S_SELECT_APPEND:
+ case H5S_SELECT_PREPEND:
+ case H5S_SELECT_INVALID:
default:
HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation");
} /* end switch */
@@ -6503,6 +6403,10 @@ H5S_select_hyperslab (H5S_t *space, H5S_seloper_t op,
case H5S_SELECT_NOTB: /* Binary "A not B" operation for hyperslabs */
HGOTO_DONE(SUCCEED); /* Selection stays "none" */
+ case H5S_SELECT_NOOP:
+ case H5S_SELECT_APPEND:
+ case H5S_SELECT_PREPEND:
+ case H5S_SELECT_INVALID:
default:
HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation");
} /* end switch */
@@ -6551,6 +6455,10 @@ H5S_select_hyperslab (H5S_t *space, H5S_seloper_t op,
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't convert selection");
HGOTO_DONE(SUCCEED);
+ case H5S_SELECT_NOOP:
+ case H5S_SELECT_APPEND:
+ case H5S_SELECT_PREPEND:
+ case H5S_SELECT_INVALID:
default:
HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation");
} /* end switch */
@@ -6565,6 +6473,8 @@ H5S_select_hyperslab (H5S_t *space, H5S_seloper_t op,
break;
/* Else fall through to error */
+ case H5S_SEL_ERROR:
+ case H5S_SEL_N:
default:
HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation");
} /* end switch */
@@ -7653,52 +7563,53 @@ H5S_hyper_get_seq_list_gen(const H5S_t *space,H5S_sel_iter_t *iter,
size_t io_used; /* Number of elements processed */
size_t curr_seq=0; /* Number of sequence/offsets stored in the arrays */
size_t elem_size; /* Size of each element iterating over */
- int ndims; /* Number of dimensions of dataset */
- int fast_dim; /* Rank of the fastest changing dimension for the dataspace */
+ unsigned ndims; /* Number of dimensions of dataset */
+ unsigned fast_dim; /* Rank of the fastest changing dimension for the dataspace */
int curr_dim; /* Current dimension being operated on */
+ unsigned u; /* Index variable */
int i; /* Index variable */
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_hyper_get_seq_list_gen);
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_hyper_get_seq_list_gen)
/* Check args */
- assert(space);
- assert(iter);
- assert(maxseq>0);
- assert(maxelem>0);
- assert(nseq);
- assert(nelem);
- assert(off);
- assert(len);
+ HDassert(space);
+ HDassert(iter);
+ HDassert(maxseq > 0);
+ HDassert(maxelem > 0);
+ HDassert(nseq);
+ HDassert(nelem);
+ HDassert(off);
+ HDassert(len);
/* Set the rank of the fastest changing dimension */
- ndims=space->extent.rank;
- fast_dim=(ndims-1);
+ ndims = space->extent.rank;
+ fast_dim = (ndims - 1);
/* Get the pointers to the current span info and span nodes */
- curr_span=iter->u.hyp.span[fast_dim];
- abs_arr=iter->u.hyp.off;
- off_arr=space->select.offset;
- ispan=iter->u.hyp.span;
- elem_size=iter->elmt_size;
+ curr_span = iter->u.hyp.span[fast_dim];
+ abs_arr = iter->u.hyp.off;
+ off_arr = space->select.offset;
+ ispan = iter->u.hyp.span;
+ elem_size = iter->elmt_size;
/* Set the amount of elements to perform I/O on, etc. */
- H5_CHECK_OVERFLOW(iter->elmt_left,hsize_t,size_t);
- io_left=MIN(maxelem,(size_t)iter->elmt_left);
- io_bytes_left=io_left*elem_size;
+ H5_CHECK_OVERFLOW(iter->elmt_left, hsize_t, size_t);
+ io_left = MIN(maxelem, (size_t)iter->elmt_left);
+ io_bytes_left = io_left * elem_size;
/* Compute the cumulative size of dataspace dimensions */
- for(i=fast_dim, acc=elem_size; i>=0; i--) {
- slab[i]=acc;
- acc*=space->extent.size[i];
+ for(i = (int)fast_dim, acc = elem_size; i >= 0; i--) {
+ slab[i] = acc;
+ acc *= space->extent.size[i];
} /* end for */
/* Set the offset of the first element iterated on */
- for(i=0, loc_off=0; i<ndims; i++)
+ for(u = 0, loc_off = 0; u < ndims; u++)
/* Compute the sequential element offset */
- loc_off+=(abs_arr[i]+off_arr[i])*slab[i];
+ loc_off += (abs_arr[u] + off_arr[u]) * slab[u];
/* Range check against number of elements left in selection */
- assert(io_bytes_left<=(iter->elmt_left*elem_size));
+ HDassert(io_bytes_left <= (iter->elmt_left * elem_size));
/* Take care of any partial spans leftover from previous I/Os */
if(abs_arr[fast_dim]!=curr_span->low) {
@@ -7765,7 +7676,7 @@ H5S_hyper_get_seq_list_gen(const H5S_t *space,H5S_sel_iter_t *iter,
if(NULL == curr_span) {
/* Same as code in main loop */
/* Start at the next fastest dim */
- curr_dim = fast_dim - 1;
+ curr_dim = (int)(fast_dim - 1);
/* Work back up through the dimensions */
while(curr_dim >= 0) {
@@ -7804,7 +7715,7 @@ H5S_hyper_get_seq_list_gen(const H5S_t *space,H5S_sel_iter_t *iter,
/* Check if we have more spans in the tree */
if(curr_dim >= 0) {
/* Walk back down the iterator positions, reseting them */
- while(curr_dim < fast_dim) {
+ while((unsigned)curr_dim < fast_dim) {
HDassert(curr_span);
HDassert(curr_span->down);
HDassert(curr_span->down->head);
@@ -7826,8 +7737,8 @@ H5S_hyper_get_seq_list_gen(const H5S_t *space,H5S_sel_iter_t *iter,
HDassert(curr_span == iter->u.hyp.span[fast_dim]);
/* Reset the buffer offset */
- for(i = 0, loc_off = 0; i < ndims; i++)
- loc_off += (abs_arr[i] + off_arr[i]) * slab[i];
+ for(u = 0, loc_off = 0; u < ndims; u++)
+ loc_off += (abs_arr[u] + off_arr[u]) * slab[u];
} /* end else */
else
/* We had better be done with I/O or bad things are going to happen... */
@@ -7946,10 +7857,10 @@ H5S_hyper_get_seq_list_gen(const H5S_t *space,H5S_sel_iter_t *iter,
/* Adjust iterator pointers */
/* Start at the next fastest dim */
- curr_dim=fast_dim-1;
+ curr_dim = (int)(fast_dim - 1);
/* Work back up through the dimensions */
- while(curr_dim>=0) {
+ while(curr_dim >= 0) {
/* Reset the current span */
curr_span=iter->u.hyp.span[curr_dim];
@@ -7983,51 +7894,51 @@ H5S_hyper_get_seq_list_gen(const H5S_t *space,H5S_sel_iter_t *iter,
} /* end while */
/* Check if we are finished with the spans in the tree */
- if(curr_dim<0) {
+ if(curr_dim < 0) {
/* We had better be done with I/O or bad things are going to happen... */
- assert(io_bytes_left==0);
+ HDassert(io_bytes_left == 0);
break;
} /* end if */
else {
/* Walk back down the iterator positions, reseting them */
- while(curr_dim<fast_dim) {
- assert(curr_span);
- assert(curr_span->down);
- assert(curr_span->down->head);
+ while((unsigned)curr_dim < fast_dim) {
+ HDassert(curr_span);
+ HDassert(curr_span->down);
+ HDassert(curr_span->down->head);
/* Increment current dimension to the next dimension down */
curr_dim++;
/* Set the new span for the next dimension down */
- iter->u.hyp.span[curr_dim]=curr_span->down->head;
+ iter->u.hyp.span[curr_dim] = curr_span->down->head;
/* Advance span down the tree */
- curr_span=curr_span->down->head;
+ curr_span = curr_span->down->head;
/* Reset the absolute offset for the dim */
- abs_arr[curr_dim]=curr_span->low;
+ abs_arr[curr_dim] = curr_span->low;
} /* end while */
/* Verify that the curr_span points to the fastest dim */
- assert(curr_span==iter->u.hyp.span[fast_dim]);
+ HDassert(curr_span == iter->u.hyp.span[fast_dim]);
} /* end else */
/* Reset the buffer offset */
- for(i=0, loc_off=0; i<ndims; i++)
- loc_off+=(abs_arr[i]+off_arr[i])*slab[i];
+ for(u = 0, loc_off = 0; u < ndims; u++)
+ loc_off += (abs_arr[u] + off_arr[u]) * slab[u];
} /* end while */
/* Decrement number of elements left in iterator */
- io_used=(io_left-(io_bytes_left/elem_size));
- iter->elmt_left-=io_used;
+ io_used = (io_left - (io_bytes_left / elem_size));
+ iter->elmt_left -= io_used;
/* Set the number of sequences generated */
- *nseq=curr_seq;
+ *nseq = curr_seq;
/* Set the number of elements used */
- *nelem=io_used;
+ *nelem = io_used;
- FUNC_LEAVE_NOAPI(SUCCEED);
+ FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5S_hyper_get_seq_list_gen() */
@@ -8085,11 +7996,12 @@ H5S_hyper_get_seq_list_opt(const H5S_t *space,H5S_sel_iter_t *iter,
size_t act_blk_count; /* Actual number of blocks to output */
size_t total_rows; /* Total number of entire rows to output */
size_t curr_rows; /* Current number of entire rows to output */
- int fast_dim; /* Rank of the fastest changing dimension for the dataspace */
+ unsigned fast_dim; /* Rank of the fastest changing dimension for the dataspace */
+ unsigned ndims; /* Number of dimensions of dataset */
int temp_dim; /* Temporary rank holder */
- int ndims; /* Number of dimensions of dataset */
hsize_t acc; /* Accumulator */
hsize_t loc; /* Coordinate offset */
+ unsigned u; /* Local index variable */
int i; /* Local index variable */
size_t curr_seq=0; /* Current sequence being operated on */
size_t actual_elem; /* The actual number of elements to count */
@@ -8115,34 +8027,34 @@ H5S_hyper_get_seq_list_opt(const H5S_t *space,H5S_sel_iter_t *iter,
tdiminfo=iter->u.hyp.diminfo;
/* Check if this is a "flattened" regular hyperslab selection */
- if(iter->u.hyp.iter_rank!=0 && iter->u.hyp.iter_rank<space->extent.rank) {
+ if(iter->u.hyp.iter_rank != 0 && iter->u.hyp.iter_rank < space->extent.rank) {
/* Set the aliases for a few important dimension ranks */
- ndims=iter->u.hyp.iter_rank;
- fast_dim=ndims-1;
+ ndims = iter->u.hyp.iter_rank;
+ fast_dim = ndims - 1;
/* Set the local copy of the selection offset */
- sel_off=iter->u.hyp.sel_off;
+ sel_off = iter->u.hyp.sel_off;
/* Set up the pointer to the size of the memory space */
- mem_size=iter->u.hyp.size;
+ mem_size = iter->u.hyp.size;
} /* end if */
else {
/* Set the aliases for a few important dimension ranks */
- ndims=space->extent.rank;
- fast_dim=ndims-1;
+ ndims = space->extent.rank;
+ fast_dim = ndims - 1;
/* Set the local copy of the selection offset */
- sel_off=space->select.offset;
+ sel_off = space->select.offset;
/* Set up the pointer to the size of the memory space */
- mem_size=space->extent.size;
+ mem_size = space->extent.size;
} /* end else */
/* initialize row sizes for each dimension */
- elem_size=iter->elmt_size;
- for(i=(ndims-1),acc=elem_size; i>=0; i--) {
- slab[i]=acc;
- acc*=mem_size[i];
+ elem_size = iter->elmt_size;
+ for(i = (int)fast_dim, acc = elem_size; i >= 0; i--) {
+ slab[i] = acc;
+ acc *= mem_size[i];
} /* end for */
/* Calculate the number of elements to sequence through */
@@ -8166,8 +8078,8 @@ H5S_hyper_get_seq_list_opt(const H5S_t *space,H5S_sel_iter_t *iter,
actual_elem=MIN(leftover,io_left);
/* Compute the initial buffer offset */
- for(i=0,loc=0; i<ndims; i++)
- loc+=(iter->u.hyp.off[i]+sel_off[i])*slab[i];
+ for(u = 0, loc = 0; u < ndims; u++)
+ loc += (iter->u.hyp.off[u] + sel_off[u]) * slab[u];
/* Add a new sequence */
off[curr_seq]=loc;
@@ -8199,24 +8111,24 @@ H5S_hyper_get_seq_list_opt(const H5S_t *space,H5S_sel_iter_t *iter,
/* Copy the location of the point to get */
/* (Add in the selection offset) */
- for(i=0; i<ndims; i++)
- offset[i] = iter->u.hyp.off[i] + sel_off[i];
+ for(u = 0; u < ndims; u++)
+ offset[u] = iter->u.hyp.off[u] + sel_off[u];
/* Compute the current "counts" for this location */
- for(i=0; i<ndims; i++) {
- if(tdiminfo[i].count==1) {
- tmp_count[i] = 0;
- tmp_block[i] = iter->u.hyp.off[i]-tdiminfo[i].start;
+ for(u = 0; u < ndims; u++) {
+ if(tdiminfo[u].count == 1) {
+ tmp_count[u] = 0;
+ tmp_block[u] = iter->u.hyp.off[u] - tdiminfo[u].start;
} /* end if */
else {
- tmp_count[i] = (iter->u.hyp.off[i]-tdiminfo[i].start)/tdiminfo[i].stride;
- tmp_block[i] = (iter->u.hyp.off[i]-tdiminfo[i].start)%tdiminfo[i].stride;
+ tmp_count[u] = (iter->u.hyp.off[u] - tdiminfo[u].start) / tdiminfo[u].stride;
+ tmp_block[u] = (iter->u.hyp.off[u] - tdiminfo[u].start) % tdiminfo[u].stride;
} /* end else */
} /* end for */
/* Compute the initial buffer offset */
- for(i=0,loc=0; i<ndims; i++)
- loc+=offset[i]*slab[i];
+ for(u = 0, loc = 0; u < ndims; u++)
+ loc += offset[u] * slab[u];
/* Set the number of elements to write each time */
H5_ASSIGN_OVERFLOW(actual_elem,tdiminfo[fast_dim].block,hsize_t,size_t);
@@ -8239,12 +8151,12 @@ H5S_hyper_get_seq_list_opt(const H5S_t *space,H5S_sel_iter_t *iter,
tot_blk_count=MIN(tot_blk_count,(maxseq-curr_seq));
/* Compute the amount to wrap at the end of each row */
- for(i=0; i<ndims; i++)
- wrap[i]=(mem_size[i]-(tdiminfo[i].stride*tdiminfo[i].count))*slab[i];
+ for(u = 0; u < ndims; u++)
+ wrap[u] = (mem_size[u] - (tdiminfo[u].stride * tdiminfo[u].count)) * slab[u];
/* Compute the amount to skip between blocks */
- for(i=0; i<ndims; i++)
- skip[i]=(tdiminfo[i].stride-tdiminfo[i].block)*slab[i];
+ for(u = 0; u < ndims; u++)
+ skip[u] = (tdiminfo[u].stride - tdiminfo[u].block) * slab[u];
/* Check if there is a partial row left (with full blocks) */
if(tmp_count[fast_dim]>0) {
@@ -8292,7 +8204,7 @@ H5S_hyper_get_seq_list_opt(const H5S_t *space,H5S_sel_iter_t *iter,
tmp_count[fast_dim]=0;
/* Increment the offset and count for the other dimensions */
- temp_dim=fast_dim-1;
+ temp_dim = (int)fast_dim - 1;
while(temp_dim>=0) {
/* Move to the next row in the curent dimension */
offset[temp_dim]++;
@@ -8392,7 +8304,7 @@ H5S_hyper_get_seq_list_opt(const H5S_t *space,H5S_sel_iter_t *iter,
loc += wrap[fast_dim];
/* Increment the offset and count for the other dimensions */
- temp_dim=fast_dim-1;
+ temp_dim = (int)fast_dim - 1;
while(temp_dim>=0) {
/* Move to the next row in the curent dimension */
offset[temp_dim]++;
@@ -8491,20 +8403,20 @@ H5S_hyper_get_seq_list_opt(const H5S_t *space,H5S_sel_iter_t *iter,
/* Update the iterator with the location we stopped */
/* (Subtract out the selection offset) */
- for(i=0; i<ndims; i++)
- iter->u.hyp.off[i] = offset[i] - sel_off[i];
+ for(u = 0; u < ndims; u++)
+ iter->u.hyp.off[u] = offset[u] - sel_off[u];
/* Decrement the number of elements left in selection */
- iter->elmt_left-=(nelmts-io_left);
+ iter->elmt_left -= (nelmts - io_left);
} /* end if */
/* Set the number of sequences generated */
- *nseq=curr_seq;
+ *nseq = curr_seq;
/* Set the number of bytes used */
- *nelem=start_io_left-io_left;
+ *nelem = start_io_left - io_left;
- FUNC_LEAVE_NOAPI(SUCCEED);
+ FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5S_hyper_get_seq_list_opt() */