summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2010-02-15 03:23:19 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2010-02-15 03:23:19 (GMT)
commitc5c0afaa613115284c4d564a574a13b97027c1ab (patch)
tree98561ce374f7bd333ede4dc721c291fc2b597ea4
parent824d691cbf1a04e3207218e86246645b5609079e (diff)
downloadhdf5-c5c0afaa613115284c4d564a574a13b97027c1ab.zip
hdf5-c5c0afaa613115284c4d564a574a13b97027c1ab.tar.gz
hdf5-c5c0afaa613115284c4d564a574a13b97027c1ab.tar.bz2
[svn-r18256] Description:
Bring changes from Coverity fixing branch to trunk: r18235: Fixed coverity 114: if (NULL ==_dest) H5MM_free(dest); r18236: Close Coverity issue #28 (again :-) by working through the logic of the routine more thoroughly to eliminate the goto statements. (LK & QK) r18237: fixed coverity 133: if (NULL==_dest && NULL==ret_value && NULL != dest) H5MM_free(dest); r18238: Fix coverity items 421 and 422. Added assertion that the heap's free list is NULL when entering H5HL_fl_deserialize, guarateeing that the free list will always be linked in even on failure. r18239: Fix coverity item 268. Changed H5MM_xfree(read_buf) to read_buf = H5MM_xfree(read_buf) so that read_buf isn't manipulated after it's been freed. r18241: coverity fix: use correct free functon H5FL_FREE()from the previous fix r18242: Coverity fix 139: Free dst correctly in H5O_sdspace_copy(). r18243: Fix Coverity issue #417 by checking for NULL return value from setup_cache() (LK & QK) r18244: Coverity Fix 132: free dest correctly in H5O_efl_copy() r18245: Issue 121: H5S_hyper_make_spans() cannot deal with counts of 0. However, H5Sselect_hyperslab() API does allow a count of 0. Therefore, simply throw an error if this function encounters a count of 0. r18246: Check file_ptr to address coverity issue # 418 r18247: Fixed coverity 113: if (sequence) H5MM_xfree(sequence); r18248: Coverity issue #414 by checking for NULL return from setup_cache() (LK & QK) r18249: fixed coverity 274: moved H5FL_FREE(H5A_t, attr); to a line above so that if attr is null, it will not free it. r18250: Fix coverity issue #86. Check return of malloc function to ensure non-null before continuing. Tested on: Mac OS X/32 10.6.2 (amazon) w/debug & production) (h5committested in daily tests on branch)
-rw-r--r--src/H5Dchunk.c4
-rw-r--r--src/H5HFhuge.c4
-rw-r--r--src/H5HLcache.c22
-rw-r--r--src/H5Oattr.c7
-rw-r--r--src/H5Odbg.c7
-rw-r--r--src/H5Oefl.c58
-rw-r--r--src/H5Olink.c8
-rw-r--r--src/H5Oname.c6
-rw-r--r--src/H5Osdspace.c24
-rw-r--r--src/H5Shyper.c119
-rw-r--r--test/cache.c48
11 files changed, 194 insertions, 113 deletions
diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c
index 07204a0..ba4f795 100644
--- a/src/H5Dchunk.c
+++ b/src/H5Dchunk.c
@@ -2802,7 +2802,9 @@ H5D_chunk_lock(const H5D_io_info_t *io_info, H5D_chunk_ud_t *udata,
HGOTO_ERROR(H5E_IO, H5E_CANTINIT, NULL, "unable to preempt chunk(s) from cache")
/* Create a new entry */
- ent = H5FL_MALLOC(H5D_rdcc_ent_t);
+ if(NULL == (ent = H5FL_MALLOC(H5D_rdcc_ent_t)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, NULL, "can't allocate raw data chunk entry")
+
ent->locked = 0;
ent->dirty = FALSE;
ent->chunk_addr = chunk_addr;
diff --git a/src/H5HFhuge.c b/src/H5HFhuge.c
index 5490c22..7577583 100644
--- a/src/H5HFhuge.c
+++ b/src/H5HFhuge.c
@@ -710,7 +710,7 @@ H5HF_huge_op_real(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *id,
/* Call the user's 'op' callback */
if(op(read_buf, (size_t)obj_size, op_data) < 0) {
/* Release buffer */
- H5MM_xfree(read_buf);
+ read_buf = H5MM_xfree(read_buf);
/* Indicate error */
HGOTO_ERROR(H5E_HEAP, H5E_CANTOPERATE, FAIL, "application's callback failed")
@@ -720,7 +720,7 @@ H5HF_huge_op_real(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *id,
done:
/* Release the buffer for reading */
if(read_buf && read_buf != op_data)
- H5MM_xfree(read_buf);
+ read_buf = H5MM_xfree(read_buf);
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF_huge_op_real() */
diff --git a/src/H5HLcache.c b/src/H5HLcache.c
index 6e725ac..6064fe5 100644
--- a/src/H5HLcache.c
+++ b/src/H5HLcache.c
@@ -138,13 +138,14 @@ const H5AC_class_t H5AC_LHEAP_DBLK[1] = {{
static herr_t
H5HL_fl_deserialize(H5HL_t *heap, hsize_t free_block)
{
- H5HL_free_t *fl, *tail = NULL; /* Heap free block nodes */
+ H5HL_free_t *fl = NULL, *tail = NULL; /* Heap free block nodes */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5HL_fl_deserialize)
/* check arguments */
HDassert(heap);
+ HDassert(!heap->freelist);
/* Build free list */
while(H5HL_FREE_NULL != free_block) {
@@ -161,13 +162,6 @@ H5HL_fl_deserialize(H5HL_t *heap, hsize_t free_block)
fl->prev = tail;
fl->next = NULL;
- /* Insert node into list */
- if(tail)
- tail->next = fl;
- tail = fl;
- if(!heap->freelist)
- heap->freelist = fl;
-
/* Decode offset of next free block */
p = heap->dblk_image + free_block;
H5F_DECODE_LENGTH_LEN(p, free_block, heap->sizeof_size);
@@ -178,9 +172,21 @@ H5HL_fl_deserialize(H5HL_t *heap, hsize_t free_block)
H5F_DECODE_LENGTH_LEN(p, fl->size, heap->sizeof_size);
if(fl->offset + fl->size > heap->dblk_size)
HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, FAIL, "bad heap free list")
+
+ /* Insert node into list */
+ if(tail)
+ tail->next = fl;
+ tail = fl;
+ if(!heap->freelist)
+ heap->freelist = fl;
+ fl = NULL;
} /* end while */
done:
+ if(ret_value < 0)
+ if(fl)
+ fl = H5FL_FREE(H5HL_free_t, fl);
+
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HL_fl_deserialize() */
diff --git a/src/H5Oattr.c b/src/H5Oattr.c
index c913952..35f02a8 100644
--- a/src/H5Oattr.c
+++ b/src/H5Oattr.c
@@ -234,7 +234,7 @@ H5O_attr_decode(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, unsigned UNUSED mesg_fl
ret_value = attr;
done:
- if(NULL == ret_value) {
+ if(NULL == ret_value)
if(attr) {
if(attr->shared) {
/* Free any dynamicly allocated items */
@@ -244,10 +244,9 @@ done:
/* Destroy shared attribute struct */
attr->shared = H5FL_FREE(H5A_shared_t, attr->shared);
} /* end if */
- } /* end if */
- attr = H5FL_FREE(H5A_t, attr);
- } /* end if */
+ attr = H5FL_FREE(H5A_t, attr);
+ } /* end if */
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_attr_decode() */
diff --git a/src/H5Odbg.c b/src/H5Odbg.c
index b731ce9..9285f4b 100644
--- a/src/H5Odbg.c
+++ b/src/H5Odbg.c
@@ -280,7 +280,7 @@ herr_t
H5O_debug_real(H5F_t *f, hid_t dxpl_id, H5O_t *oh, haddr_t addr, FILE *stream, int indent, int fwidth)
{
size_t mesg_total = 0, chunk_total = 0, gap_total = 0;
- unsigned *sequence;
+ unsigned *sequence = NULL;
unsigned i; /* Local index variable */
herr_t ret_value = SUCCEED;
@@ -508,12 +508,15 @@ H5O_debug_real(H5F_t *f, hid_t dxpl_id, H5O_t *oh, haddr_t addr, FILE *stream, i
else
HDfprintf(stream, "%*s<No info for this message>\n", indent + 6, "");
} /* end for */
- sequence = (unsigned *)H5MM_xfree(sequence);
if((mesg_total + gap_total) != chunk_total)
HDfprintf(stream, "*** TOTAL SIZE DOES NOT MATCH ALLOCATED SIZE!\n");
done:
+ /* Release resources */
+ if(sequence)
+ sequence = H5MM_xfree(sequence);
+
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_debug_real() */
diff --git a/src/H5Oefl.c b/src/H5Oefl.c
index 0eb4ba2..25cac88 100644
--- a/src/H5Oefl.c
+++ b/src/H5Oefl.c
@@ -262,27 +262,58 @@ H5O_efl_copy(const void *_mesg, void *_dest)
/* check args */
HDassert(mesg);
if(!dest) {
- if(NULL == (dest = (H5O_efl_t *)H5MM_calloc(sizeof(H5O_efl_t))) ||
- NULL == (dest->slot = (H5O_efl_entry_t *)H5MM_malloc(mesg->nalloc * sizeof(H5O_efl_entry_t))))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
- } else if(dest->nalloc < mesg->nalloc) {
- H5MM_xfree(dest->slot);
- if(NULL == (dest->slot = (H5O_efl_entry_t *)H5MM_malloc(mesg->nalloc * sizeof(H5O_efl_entry_t))))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
- }
+ if(NULL == (dest = (H5O_efl_t *)H5MM_calloc(sizeof(H5O_efl_t))))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTALLOC, NULL, "can't allocate efl message")
+ if(NULL == (dest->slot = (H5O_efl_entry_t *)H5MM_calloc(mesg->nalloc * sizeof(H5O_efl_entry_t))))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTALLOC, NULL, "can't allocate efl message slots")
+ } /* end if */
+ else if(dest->nalloc < mesg->nalloc) {
+ H5O_efl_entry_t *temp_slot; /* Temporary pointer to new slot information */
+
+ /* Allocate new 'slot' information */
+ if(NULL == (temp_slot = (H5O_efl_entry_t *)H5MM_calloc(mesg->nalloc * sizeof(H5O_efl_entry_t))))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTALLOC, NULL, "can't allocate efl message slots")
+
+ /* Release old 'slot' information */
+ for(u = 0; u < dest->nused; u++)
+ dest->slot[u].name = (char *)H5MM_xfree(dest->slot[u].name);
+ dest->slot = (H5O_efl_entry_t *)H5MM_xfree(dest->slot);
+
+ /* Point to new 'slot' information */
+ dest->slot = temp_slot;
+ } /* end if */
+ else {
+ /* Release old 'slot' information */
+ for(u = 0; u < dest->nused; u++)
+ dest->slot[u].name = (char *)H5MM_xfree(dest->slot[u].name);
+ } /* end else */
dest->heap_addr = mesg->heap_addr;
dest->nalloc = mesg->nalloc;
dest->nused = mesg->nused;
for(u = 0; u < mesg->nused; u++) {
dest->slot[u] = mesg->slot[u];
- dest->slot[u].name = H5MM_xstrdup(mesg->slot[u].name);
+ if(NULL == (dest->slot[u].name = H5MM_xstrdup(mesg->slot[u].name)))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTALLOC, NULL, "can't allocate efl message slot name")
} /* end for */
/* Set return value */
ret_value = dest;
done:
+ if(NULL == ret_value) {
+ if(dest && NULL == _dest) {
+ if(dest->slot) {
+ for(u = 0; u < mesg->nused; u++) {
+ if(dest->slot[u].name != NULL && dest->slot[u].name != mesg->slot[u].name)
+ dest->slot[u].name = (char *)H5MM_xfree(dest->slot[u].name);
+ } /* end for */
+ dest->slot = (H5O_efl_entry_t *)H5MM_xfree(dest->slot);
+ } /* end if */
+ dest = (H5O_efl_t *)H5MM_xfree(dest);
+ } /* end if */
+ } /* end if */
+
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_efl_copy() */
@@ -353,12 +384,13 @@ H5O_efl_reset(void *_mesg)
HDassert(mesg);
/* reset */
- for(u = 0; u < mesg->nused; u++)
- mesg->slot[u].name = (char *)H5MM_xfree(mesg->slot[u].name);
+ if(mesg->slot) {
+ for(u = 0; u < mesg->nused; u++)
+ mesg->slot[u].name = (char *)H5MM_xfree(mesg->slot[u].name);
+ mesg->slot = (H5O_efl_entry_t *)H5MM_xfree(mesg->slot);
+ } /* end if */
mesg->heap_addr = HADDR_UNDEF;
mesg->nused = mesg->nalloc = 0;
- if(mesg->slot)
- mesg->slot = (H5O_efl_entry_t *)H5MM_xfree(mesg->slot);
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5O_efl_reset() */
diff --git a/src/H5Olink.c b/src/H5Olink.c
index 4ddfbf6..7ddb1e9 100644
--- a/src/H5Olink.c
+++ b/src/H5Olink.c
@@ -437,6 +437,14 @@ H5O_link_copy(const void *_mesg, void *_dest)
ret_value = dest;
done:
+ if(NULL == ret_value)
+ if(dest) {
+ if(dest->name && dest->name != lnk->name)
+ dest->name = H5MM_xfree(dest->name);
+ if(NULL == _dest)
+ dest = H5FL_FREE(H5O_link_t ,dest);
+ } /* end if */
+
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_link_copy() */
diff --git a/src/H5Oname.c b/src/H5Oname.c
index 5ffa870..01df68c 100644
--- a/src/H5Oname.c
+++ b/src/H5Oname.c
@@ -185,12 +185,16 @@ H5O_name_copy(const void *_mesg, void *_dest)
/* copy */
*dest = *mesg;
if(NULL == (dest->s = H5MM_xstrdup(mesg->s)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
/* Set return value */
ret_value = dest;
done:
+ if(NULL == ret_value)
+ if(dest && NULL == _dest)
+ dest = H5MM_xfree(dest);
+
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_name_copy() */
diff --git a/src/H5Osdspace.c b/src/H5Osdspace.c
index d7dccbd..231de3b 100644
--- a/src/H5Osdspace.c
+++ b/src/H5Osdspace.c
@@ -287,9 +287,9 @@ H5O_sdspace_encode(H5F_t *f, uint8_t *p, const void *_mesg)
PURPOSE
Copies a message from MESG to DEST, allocating DEST if necessary.
USAGE
- void *H5O_sdspace_copy(mesg, dest)
- const void *mesg; IN: Pointer to the source extent dimensionality struct
- const void *dest; IN: Pointer to the destination extent dimensionality struct
+ void *H5O_sdspace_copy(_mesg, _dest)
+ const void *_mesg; IN: Pointer to the source extent dimensionality struct
+ const void *_dest; IN: Pointer to the destination extent dimensionality struct
RETURNS
Pointer to DEST on success, NULL on failure
DESCRIPTION
@@ -297,27 +297,31 @@ H5O_sdspace_encode(H5F_t *f, uint8_t *p, const void *_mesg)
allocating the destination structure if necessary.
--------------------------------------------------------------------------*/
static void *
-H5O_sdspace_copy(const void *mesg, void *dest)
+H5O_sdspace_copy(const void *_mesg, void *_dest)
{
- const H5S_extent_t *src = (const H5S_extent_t *) mesg;
- H5S_extent_t *dst = (H5S_extent_t *) dest;
+ const H5S_extent_t *mesg = (const H5S_extent_t *)_mesg;
+ H5S_extent_t *dest = (H5S_extent_t *)_dest;
void *ret_value; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5O_sdspace_copy)
/* check args */
- HDassert(src);
- if(!dst && NULL == (dst = H5FL_MALLOC(H5S_extent_t)))
+ HDassert(mesg);
+ if(!dest && NULL == (dest = H5FL_MALLOC(H5S_extent_t)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
/* Copy extent information */
- if(H5S_extent_copy(dst, src, TRUE) < 0)
+ if(H5S_extent_copy(dest, mesg, TRUE) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, NULL, "can't copy extent")
/* Set return value */
- ret_value = dst;
+ ret_value = dest;
done:
+ if(NULL == ret_value)
+ if(dest && NULL != _dest)
+ dest = H5FL_FREE(H5S_extent_t, dest);
+
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_sdspace_copy() */
diff --git a/src/H5Shyper.c b/src/H5Shyper.c
index ea37e40..0565cf3 100644
--- a/src/H5Shyper.c
+++ b/src/H5Shyper.c
@@ -5421,17 +5421,17 @@ H5S_hyper_spans_nelem (H5S_hyper_span_info_t *spans)
REVISION LOG
--------------------------------------------------------------------------*/
static H5S_hyper_span_info_t *
-H5S_hyper_make_spans (unsigned rank, const hsize_t *start, const hsize_t *stride,
+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_t *last_span; /* Current position in hyperslab span list */
- H5S_hyper_span_t *head; /* Head of new hyperslab span list */
- hsize_t stride_iter; /* Iterator over the stride values */
- int i; /* Counters */
- unsigned u; /* Counters */
- H5S_hyper_span_info_t *ret_value = NULL;
+ H5S_hyper_span_info_t *down; /* Pointer to spans in next dimension down */
+ H5S_hyper_span_t *span; /* New hyperslab span */
+ H5S_hyper_span_t *last_span; /* Current position in hyperslab span list */
+ H5S_hyper_span_t *head; /* Head of new hyperslab span list */
+ hsize_t stride_iter; /* Iterator over the stride values */
+ int i; /* Counters */
+ unsigned u; /* Counters */
+ H5S_hyper_span_info_t *ret_value; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5S_hyper_make_spans);
@@ -5446,21 +5446,23 @@ H5S_hyper_make_spans (unsigned rank, const hsize_t *start, const hsize_t *stride
down = NULL;
for(i = (rank - 1); i >= 0; i--) {
+ /* Sanity check */
+ if(0 == count[i])
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, NULL, "count == 0 is invalid")
+
/* Start a new list in this dimension */
head = NULL;
last_span = NULL;
- HDassert(count[i] > 0);
-
/* Generate all the span segments for this dimension */
for(u = 0, stride_iter = 0; u < count[i]; u++, stride_iter += stride[i]) {
/* Allocate a span node */
if(NULL == (span = H5FL_MALLOC(H5S_hyper_span_t)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate hyperslab span")
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, NULL, "can't allocate hyperslab span")
/* Set the span's basic information */
span->low = start[i] + stride_iter;
- span->high = span->low + (block[i]-1);
+ span->high = span->low + (block[i] - 1);
span->nelem = block[i];
span->pstride = stride[i];
span->next = NULL;
@@ -5486,7 +5488,7 @@ H5S_hyper_make_spans (unsigned rank, const hsize_t *start, const hsize_t *stride
/* Allocate a span info node */
if(NULL == (down = H5FL_MALLOC(H5S_hyper_span_info_t)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate hyperslab span");
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, NULL, "can't allocate hyperslab span")
/* Set the reference count */
down->count = 0;
@@ -5515,13 +5517,13 @@ done:
do {
if(down) {
head = down->head;
- (void)H5FL_FREE(H5S_hyper_span_info_t, down);
+ down = H5FL_FREE(H5S_hyper_span_info_t, down);
} /* end if */
down = head->down;
while(head) {
last_span = head->next;
- (void)H5FL_FREE(H5S_hyper_span_t, head);
+ head = H5FL_FREE(H5S_hyper_span_t, head);
head = last_span;
} /* end while */
} while(down);
@@ -7376,74 +7378,70 @@ H5S_hyper_get_seq_list_gen(const H5S_t *space,H5S_sel_iter_t *iter,
/* Advance the hyperslab iterator */
/* Check if we are done */
- if(io_bytes_left>0) {
+ if(io_bytes_left > 0) {
/* Move to next span in fastest changing dimension */
- curr_span=curr_span->next;
+ curr_span = curr_span->next;
- if(curr_span!=NULL) {
+ if(NULL != curr_span) {
/* Move location offset of destination */
- loc_off+=(curr_span->low-abs_arr[fast_dim])*elem_size;
+ loc_off += (curr_span->low - abs_arr[fast_dim]) * elem_size;
/* Move iterator for fastest changing dimension */
- abs_arr[fast_dim]=curr_span->low;
+ abs_arr[fast_dim] = curr_span->low;
} /* end if */
} /* end if */
else {
- abs_arr[fast_dim]+=span_size/elem_size;
+ abs_arr[fast_dim] += span_size / elem_size;
/* Check if we are still within the span */
- if(abs_arr[fast_dim]<=curr_span->high) {
- iter->u.hyp.span[fast_dim]=curr_span;
-
- goto partial_done; /* finished with partial span */
+ if(abs_arr[fast_dim] <= curr_span->high) {
+ iter->u.hyp.span[fast_dim] = curr_span;
} /* end if */
/* If we walked off that span, advance to the next span */
else {
/* Advance span in this dimension */
- curr_span=curr_span->next;
+ curr_span = curr_span->next;
/* Check if we have a valid span in this dimension still */
- if(curr_span!=NULL) {
+ if(NULL != curr_span) {
/* Reset absolute position */
- abs_arr[fast_dim]=curr_span->low;
- iter->u.hyp.span[fast_dim]=curr_span;
-
- goto partial_done; /* finished with partial span */
+ abs_arr[fast_dim] = curr_span->low;
+ iter->u.hyp.span[fast_dim] = curr_span;
} /* end if */
} /* end else */
} /* end else */
/* Adjust iterator pointers */
- if(curr_span==NULL) {
+ if(NULL == curr_span) {
/* Same as code in main loop */
/* Start at the next fastest dim */
- curr_dim=fast_dim-1;
+ curr_dim = 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];
+ curr_span = iter->u.hyp.span[curr_dim];
/* Increment absolute position */
abs_arr[curr_dim]++;
/* Check if we are still within the span */
- if(abs_arr[curr_dim]<=curr_span->high) {
+ if(abs_arr[curr_dim] <= curr_span->high) {
break;
} /* end if */
/* If we walked off that span, advance to the next span */
else {
/* Advance span in this dimension */
- curr_span=curr_span->next;
+ curr_span = curr_span->next;
/* Check if we have a valid span in this dimension still */
- if(curr_span!=NULL) {
+ if(NULL != curr_span) {
/* Reset the span in the current dimension */
- ispan[curr_dim]=curr_span;
+ ispan[curr_dim] = curr_span;
/* Reset absolute position */
- abs_arr[curr_dim]=curr_span->low;
+ abs_arr[curr_dim] = curr_span->low;
break;
} /* end if */
@@ -7454,45 +7452,40 @@ H5S_hyper_get_seq_list_gen(const H5S_t *space,H5S_sel_iter_t *iter,
} /* end else */
} /* end while */
- /* Check if we are finished with the spans in the tree */
- if(curr_dim<0) {
- /* We had better be done with I/O or bad things are going to happen... */
- assert(io_bytes_left==0);
-
- goto partial_done; /* finished with partial span */
- } /* end if */
- else {
+ /* 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) {
- assert(curr_span);
- assert(curr_span->down);
- assert(curr_span->down->head);
+ while(curr_dim < fast_dim) {
+ HDassert(curr_span);
+ HDassert(curr_span->down);
+ HDassert(curr_span->down->head);
/* Increment current dimension */
curr_dim++;
/* Set the new span_info & span for this dimension */
- 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]);
- } /* end else */
+ 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];
+ /* Reset the buffer offset */
+ for(i = 0, loc_off = 0; i < ndims; i++)
+ loc_off += (abs_arr[i] + off_arr[i]) * slab[i];
+ } /* end else */
+ else
+ /* We had better be done with I/O or bad things are going to happen... */
+ HDassert(io_bytes_left == 0);
} /* end if */
} /* end if */
-partial_done: /* Yes, goto's are evil, so sue me... :-) */
-
/* Perform the I/O on the elements, based on the position of the iterator */
while(io_bytes_left > 0 && curr_seq < maxseq) {
/* Sanity check */
diff --git a/test/cache.c b/test/cache.c
index 87b97c2..a83d60e 100644
--- a/test/cache.c
+++ b/test/cache.c
@@ -13534,8 +13534,8 @@ check_get_entry_status(void)
hbool_t is_pinned;
size_t entry_size;
H5F_t * file_ptr = NULL;
- test_entry_t * base_addr;
- test_entry_t * entry_ptr;
+ test_entry_t * base_addr = NULL;
+ test_entry_t * entry_ptr = NULL;
TESTING("H5C_get_entry_status() functionality");
@@ -13548,8 +13548,18 @@ check_get_entry_status(void)
file_ptr = setup_cache((size_t)(2 * 1024 * 1024),
(size_t)(1 * 1024 * 1024));
- base_addr = entries[0];
- entry_ptr = &(base_addr[0]);
+ if ( file_ptr == NULL ) {
+
+ pass = FALSE;
+ failure_mssg = "file_ptr NULL from setup_cache.";
+
+ }
+ else {
+
+ base_addr = entries[0];
+ entry_ptr = &(base_addr[0]);
+
+ }
}
if ( pass ) {
@@ -14736,9 +14746,20 @@ check_pin_protected_entry(void)
file_ptr = setup_cache((size_t)(2 * 1024 * 1024),
(size_t)(1 * 1024 * 1024));
+
+ if ( file_ptr == NULL ) {
+
+ pass = FALSE;
+ failure_mssg = "file_ptr NULL from setup_cache.";
+
+ }
}
- protect_entry(file_ptr, 0, 0);
+ if ( pass ) {
+
+ protect_entry(file_ptr, 0, 0);
+
+ }
if ( pass ) {
@@ -14862,11 +14883,20 @@ check_resize_entry(void)
file_ptr = setup_cache((size_t)(2 * 1024 * 1024),
(size_t)(1 * 1024 * 1024));
- cache_ptr = file_ptr->shared->cache;
+ if ( file_ptr == NULL ) {
- base_addr = entries[LARGE_ENTRY_TYPE];
- entry_ptr = &(base_addr[0]);
- entry_size = LARGE_ENTRY_SIZE;
+ pass = FALSE;
+ failure_mssg = "file_ptr NULL from setup_cache.";
+
+ }
+ else
+ {
+ cache_ptr = file_ptr->shared->cache;
+
+ base_addr = entries[LARGE_ENTRY_TYPE];
+ entry_ptr = &(base_addr[0]);
+ entry_size = LARGE_ENTRY_SIZE;
+ }
}
if ( pass ) {