summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2010-02-20 02:23:44 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2010-02-20 02:23:44 (GMT)
commit0c39a78927ae1e4b7471f96743a8cf5dd30350b0 (patch)
tree21eb68c066d6ef8a139278439d02c89202ce970f
parent7bac0bb48dd18809fa015e91848dc8756c0fe536 (diff)
downloadhdf5-0c39a78927ae1e4b7471f96743a8cf5dd30350b0.zip
hdf5-0c39a78927ae1e4b7471f96743a8cf5dd30350b0.tar.gz
hdf5-0c39a78927ae1e4b7471f96743a8cf5dd30350b0.tar.bz2
[svn-r18300] Description:
Bring Coverity fixes from branch to trunk: r18282: Fix Coverity issue #428 by wrapping testing calls with if(pass) {} block. r18283: Fix Coverity issue #425 by wrapping test calls in if(pass) {} block r18284: Issue 166: init_error() malloc'd 3 pointers in initialization and never freed inc ase of errors. Init pointers to NULL, check allocation results and free allocations in error block r18285: Fix Coverity issue #410 by wrapping test calls with if(pass) {} block. r18286: Issue 165: custom_print_cb() needed allocations freed in error block. r18287: Fix coverity issue # 409 Added if (pass) checks around calls to flush_cache. Additionally, added a check for file_ptr = NULL after call to setup_cache. r18288: Fix coverity# 107 free fh in H5HF_close() correctly before exit the function even when failure occurs. r18289: Fix Coverity issue #429: correct failure return values to match return type from routine. r18290: Fix Coverity issue #103: release allocated indirect section on error r18294: Issue 153, 152: Check allocations and free allocations in error block. Also cleaned up hid_t identifer that were opened in error block. r18295: Fix coverity# 101 free new_loc in H5HF_man_iter_start_entry() correctly before exit the function even when failure occurs r18296: Fix coverity# 100 free down_loc in H5HF_man_iter_down() before exit the function when failure occurs r18297: Fixed coverity issues 54, 55 and 216. Correctly handle the various ways that allocation of attr_name can fail in test_attr_basic_write. r18298: Fix coverity# 119 free object in H5HG_read() before exit the function when failure occurs r18299: Fix coverity issue #112: Add cleanup during error handling of H5MP_create. Tested on: Mac OS X/32 10.6.2 (amazon) w/debug & production Misc. Linux configurations (on original checkins)
-rw-r--r--src/H5Dchunk.c16
-rw-r--r--src/H5HF.c4
-rw-r--r--src/H5HFiter.c14
-rw-r--r--src/H5HFsection.c8
-rw-r--r--src/H5HG.c13
-rw-r--r--src/H5MP.c34
-rw-r--r--test/cache.c274
-rw-r--r--test/dtransform.c441
-rw-r--r--test/err_compat.c19
-rw-r--r--test/error_test.c29
-rw-r--r--test/tattr.c68
11 files changed, 570 insertions, 350 deletions
diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c
index ba4f795..e77f580 100644
--- a/src/H5Dchunk.c
+++ b/src/H5Dchunk.c
@@ -3421,7 +3421,7 @@ H5D_chunk_prune_fill(const H5D_chunk_rec_t *chunk_rec, H5D_chunk_it_ud1_t *udata
/* Calculate the index of this chunk */
if(H5V_chunk_index(rank, chunk_rec->offset, layout->u.chunk.dim, layout->u.chunk.down_chunks, &io_info->store->chunk.index) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, H5_ITER_ERROR, "can't get chunk index")
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't get chunk index")
/* Lock the chunk into the cache, to get a pointer to the chunk buffer */
/* (Casting away const OK -QAK) */
@@ -3780,7 +3780,7 @@ H5D_chunk_prune_by_extent(H5D_t *dset, hid_t dxpl_id, const hsize_t *old_dims)
if(needs_fill) {
/* Allocate space for the stack node */
if(NULL == (tmp_stack = H5FL_MALLOC(H5D_chunk_prune_stack_t)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, H5_ITER_ERROR, "memory allocation failed for stack node")
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for stack node")
/* Set up chunk record for fill routine */
tmp_stack->rec.nbytes = dset->shared->layout.u.chunk.size;
@@ -3800,7 +3800,7 @@ H5D_chunk_prune_by_extent(H5D_t *dset, hid_t dxpl_id, const hsize_t *old_dims)
while(tmp_stack) {
/* Write the fill value */
if(H5D_chunk_prune_fill(&(tmp_stack->rec), &udata) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, H5_ITER_ERROR, "unable to write fill value")
+ HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to write fill value")
/* Advance the stack pointer */
tmp_stack = tmp_stack->next;
@@ -3821,7 +3821,7 @@ H5D_chunk_prune_by_extent(H5D_t *dset, hid_t dxpl_id, const hsize_t *old_dims)
/* Remove the chunk from disk */
if((layout->storage.u.chunk.ops->remove)(&idx_info, &idx_udata) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTDELETE, H5_ITER_ERROR, "unable to remove chunk entry from index")
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTDELETE, FAIL, "unable to remove chunk entry from index")
/* Advance the stack pointer */
tmp_stack = tmp_stack->next;
@@ -4157,7 +4157,7 @@ H5D_chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata)
else if((H5T_get_class(udata->dt_src, FALSE) == H5T_REFERENCE) && (udata->file_src != udata->idx_info_dst->f))
fix_ref = TRUE;
else
- HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to copy dataset elements")
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, H5_ITER_ERROR, "unable to copy dataset elements")
} /* end if */
/* Check for filtered chunks */
@@ -4241,7 +4241,7 @@ H5D_chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata)
/* Copy the reference elements */
if(H5O_copy_expand_ref(udata->file_src, buf, udata->idx_info_dst->dxpl_id, udata->idx_info_dst->f, bkg, ref_count, H5T_get_ref_type(udata->dt_src), udata->cpy_info) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to copy reference attribute")
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, H5_ITER_ERROR, "unable to copy reference attribute")
} /* end if */
/* After fix ref, copy the new reference elements to the buffer to write out */
@@ -4263,7 +4263,7 @@ H5D_chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata)
#if H5_SIZEOF_SIZE_T > 4
/* Check for the chunk expanding too much to encode in a 32-bit value */
if(nbytes > ((size_t)0xffffffff))
- HGOTO_ERROR(H5E_DATASET, H5E_BADRANGE, FAIL, "chunk too large for 32-bit length")
+ HGOTO_ERROR(H5E_DATASET, H5E_BADRANGE, H5_ITER_ERROR, "chunk too large for 32-bit length")
#endif /* H5_SIZEOF_SIZE_T > 4 */
H5_ASSIGN_OVERFLOW(udata_dst.nbytes, nbytes, size_t, uint32_t);
udata->buf = buf;
@@ -4272,7 +4272,7 @@ H5D_chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata)
/* Insert chunk into the destination index */
if((udata->idx_info_dst->storage->ops->insert)(udata->idx_info_dst, &udata_dst) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "unable to insert chunk into index")
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, H5_ITER_ERROR, "unable to insert chunk into index")
/* Write chunk data to destination file */
HDassert(H5F_addr_defined(udata_dst.addr));
diff --git a/src/H5HF.c b/src/H5HF.c
index 0856d89..18e1cdb 100644
--- a/src/H5HF.c
+++ b/src/H5HF.c
@@ -867,10 +867,10 @@ HDfprintf(stderr, "%s; After iterator reset fh->hdr->rc = %Zu\n", FUNC, fh->hdr-
HGOTO_ERROR(H5E_HEAP, H5E_CANTDELETE, FAIL, "unable to delete fractal heap")
} /* end if */
+done:
/* Release the fractal heap wrapper */
- (void)H5FL_FREE(H5HF_t, fh);
+ fh = H5FL_FREE(H5HF_t, fh);
-done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF_close() */
diff --git a/src/H5HFiter.c b/src/H5HFiter.c
index a3c61d7..f7178a1 100644
--- a/src/H5HFiter.c
+++ b/src/H5HFiter.c
@@ -315,7 +315,7 @@ herr_t
H5HF_man_iter_start_entry(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter,
H5HF_indirect_t *iblock, unsigned start_entry)
{
- H5HF_block_loc_t *new_loc; /* Pointer to new block location */
+ H5HF_block_loc_t *new_loc = NULL; /* Pointer to new block location */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5HF_man_iter_start_entry)
@@ -350,6 +350,9 @@ H5HF_man_iter_start_entry(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter,
biter->ready = TRUE;
done:
+ if(ret_value < 0 && new_loc)
+ new_loc = H5FL_FREE(H5HF_block_loc_t, new_loc);
+
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF_man_iter_start_entry() */
@@ -397,7 +400,7 @@ H5HF_man_iter_reset(H5HF_block_iter_t *biter)
HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared indirect block")
/* Free the current location context */
- (void)H5FL_FREE(H5HF_block_loc_t, curr_loc);
+ curr_loc = H5FL_FREE(H5HF_block_loc_t, curr_loc);
/* Advance to next location */
curr_loc = next_loc;
@@ -489,7 +492,7 @@ H5HF_man_iter_up(H5HF_block_iter_t *biter)
up_loc = biter->curr->up;
/* Release this location */
- (void)H5FL_FREE(H5HF_block_loc_t, biter->curr);
+ biter->curr = H5FL_FREE(H5HF_block_loc_t, biter->curr);
/* Point location to next location up */
biter->curr = up_loc;
@@ -515,7 +518,7 @@ done:
herr_t
H5HF_man_iter_down(H5HF_block_iter_t *biter, H5HF_indirect_t *iblock)
{
- H5HF_block_loc_t *down_loc; /* Pointer to new 'down' block location */
+ H5HF_block_loc_t *down_loc = NULL; /* Pointer to new 'down' block location */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5HF_man_iter_down)
@@ -547,6 +550,9 @@ H5HF_man_iter_down(H5HF_block_iter_t *biter, H5HF_indirect_t *iblock)
biter->curr = down_loc;
done:
+ if(ret_value < 0 && down_loc)
+ down_loc = H5FL_FREE(H5HF_block_loc_t, down_loc);
+
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF_man_iter_down() */
diff --git a/src/H5HFsection.c b/src/H5HFsection.c
index 102dc7c..9b23e5d 100644
--- a/src/H5HFsection.c
+++ b/src/H5HFsection.c
@@ -1372,7 +1372,7 @@ H5HF_sect_row_from_single(H5HF_hdr_t *hdr, H5HF_free_section_t *sect,
/* Release single section's hold on underlying indirect block */
if(H5HF_iblock_decr(dblock->parent) < 0)
- HDONE_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared indirect block")
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared indirect block")
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -3756,7 +3756,7 @@ static herr_t
H5HF_sect_indirect_build_parent(H5HF_hdr_t *hdr, H5HF_free_section_t *sect)
{
H5HF_indirect_t *par_iblock; /* Indirect block for parent section */
- H5HF_free_section_t *par_sect; /* Parent indirect section */
+ H5HF_free_section_t *par_sect = NULL; /* Parent indirect section */
unsigned par_row, par_col; /* Row & column in parent indirect section */
unsigned par_entry; /* Entry within parent indirect section */
herr_t ret_value = SUCCEED; /* Return value */
@@ -3802,6 +3802,10 @@ H5HF_sect_indirect_build_parent(H5HF_hdr_t *hdr, H5HF_free_section_t *sect)
par_sect->u.indirect.rc = 1;
done:
+ if(ret_value < 0)
+ if(par_sect && H5HF_sect_indirect_free(par_sect) < 0)
+ HDONE_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't free indirect section node")
+
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF_sect_indirect_build_parent() */
diff --git a/src/H5HG.c b/src/H5HG.c
index 0e3f0e9..f1edb71 100644
--- a/src/H5HG.c
+++ b/src/H5HG.c
@@ -640,10 +640,11 @@ void *
H5HG_read(H5F_t *f, hid_t dxpl_id, H5HG_t *hobj, void *object/*out*/,
size_t *buf_size)
{
- H5HG_heap_t *heap = NULL;
- size_t size;
- uint8_t *p = NULL;
- void *ret_value;
+ H5HG_heap_t *heap = NULL; /* Pointer to global heap object */
+ size_t size; /* Size of the heap object */
+ uint8_t *p; /* Pointer to object in heap buffer */
+ void *orig_object = object; /* Keep a copy of the original object pointer */
+ void *ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5HG_read, NULL)
@@ -659,6 +660,7 @@ H5HG_read(H5F_t *f, hid_t dxpl_id, H5HG_t *hobj, void *object/*out*/,
HDassert(heap->obj[hobj->idx].begin);
size = heap->obj[hobj->idx].size;
p = heap->obj[hobj->idx].begin + H5HG_SIZEOF_OBJHDR(f);
+
/* Allocate a buffer for the object read in, if the user didn't give one */
if(!object && NULL == (object = H5MM_malloc(size)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
@@ -692,6 +694,9 @@ done:
if(heap && H5AC_unprotect(f, dxpl_id, H5AC_GHEAP, hobj->addr, heap, H5AC__NO_FLAGS_SET)<0)
HDONE_ERROR(H5E_HEAP, H5E_PROTECT, NULL, "unable to release object header")
+ if(NULL == ret_value && NULL == orig_object && object)
+ H5MM_free(object);
+
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HG_read() */
diff --git a/src/H5MP.c b/src/H5MP.c
index 63a65ae..dd54316 100644
--- a/src/H5MP.c
+++ b/src/H5MP.c
@@ -87,16 +87,16 @@ H5FL_DEFINE(H5MP_pool_t);
*-------------------------------------------------------------------------
*/
H5MP_pool_t *
-H5MP_create (size_t page_size, unsigned flags)
+H5MP_create(size_t page_size, unsigned flags)
{
- H5MP_pool_t *mp; /* New memory pool header */
+ H5MP_pool_t *mp = NULL; /* New memory pool header */
H5MP_pool_t *ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5MP_create, NULL)
/* Allocate space for the pool header */
- if (NULL==(mp = H5FL_MALLOC(H5MP_pool_t)))
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for memory pool header")
+ if(NULL == (mp = H5FL_MALLOC(H5MP_pool_t)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for memory pool header")
/* Assign information */
mp->page_size = H5MP_BLOCK_ALIGN(page_size);
@@ -108,13 +108,17 @@ H5MP_create (size_t page_size, unsigned flags)
mp->max_size = mp->page_size - H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t));
/* Create factory for pool pages */
- if((mp->page_fac=H5FL_fac_init(page_size))==NULL)
- HGOTO_ERROR (H5E_RESOURCE, H5E_CANTINIT, NULL, "can't create page factory")
+ if(NULL == (mp->page_fac = H5FL_fac_init(page_size)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, NULL, "can't create page factory")
/* Set return value */
ret_value = mp;
done:
+ if(NULL == ret_value && mp)
+ if(H5MP_close(mp) < 0)
+ HDONE_ERROR(H5E_RESOURCE, H5E_CANTFREE, NULL, "unable to free memory pool header")
+
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5MP_create() */
@@ -271,7 +275,7 @@ HDfprintf(stderr,"%s: request = %Zu, needed = %Zu\n", FUNC, request, needed);
/* Allocate new page */
if(NULL == (alloc_page = H5MP_new_page(mp, page_size)))
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for page")
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for page")
/* Set the block to allocate from */
alloc_free = alloc_page->free_blk;
@@ -343,7 +347,7 @@ done:
*-------------------------------------------------------------------------
*/
void *
-H5MP_free (H5MP_pool_t *mp, void *spc)
+H5MP_free(H5MP_pool_t *mp, void *spc)
{
H5MP_page_blk_t *spc_blk; /* Block for space to free */
H5MP_page_t *spc_page; /* Page containing block to free */
@@ -430,7 +434,7 @@ HDfprintf(stderr,"%s: Freeing from page = %p\n", "H5MP_free", spc_page);
*-------------------------------------------------------------------------
*/
herr_t
-H5MP_close (H5MP_pool_t *mp)
+H5MP_close(H5MP_pool_t *mp)
{
herr_t ret_value = SUCCEED; /* Return value */
@@ -447,9 +451,9 @@ H5MP_close (H5MP_pool_t *mp)
/* Free the page appropriately */
if(page->fac_alloc)
- H5FL_FAC_FREE(mp->page_fac,page);
+ page = H5FL_FAC_FREE(mp->page_fac, page);
else
- H5MM_xfree(page);
+ page = H5MM_xfree(page);
page = next_page;
} /* end while */
@@ -457,13 +461,13 @@ H5MP_close (H5MP_pool_t *mp)
/* Release page factory */
if(mp->page_fac)
- if(H5FL_fac_term(mp->page_fac)<0)
- HGOTO_ERROR (H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't destroy page factory")
+ if(H5FL_fac_term(mp->page_fac) < 0)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't destroy page factory")
+done:
/* Free the memory pool itself */
- (void)H5FL_FREE(H5MP_pool_t, mp);
+ mp = H5FL_FREE(H5MP_pool_t, mp);
-done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5MP_close() */
diff --git a/test/cache.c b/test/cache.c
index a83d60e..e02f14a 100644
--- a/test/cache.c
+++ b/test/cache.c
@@ -13586,9 +13586,13 @@ check_get_entry_status(void)
}
}
- protect_entry(file_ptr, 0, 0);
+ if ( pass ) {
+
+ protect_entry(file_ptr, 0, 0);
+
+ unprotect_entry(file_ptr, 0, 0, FALSE, H5C__NO_FLAGS_SET);
- unprotect_entry(file_ptr, 0, 0, FALSE, H5C__NO_FLAGS_SET);
+ }
if ( pass ) {
@@ -13610,7 +13614,11 @@ check_get_entry_status(void)
}
}
- protect_entry(file_ptr, 0, 0);
+ if ( pass ) {
+
+ protect_entry(file_ptr, 0, 0);
+
+ }
if ( pass ) {
@@ -13632,7 +13640,11 @@ check_get_entry_status(void)
}
}
- unprotect_entry(file_ptr, 0, 0, FALSE, H5C__PIN_ENTRY_FLAG);
+ if ( pass ) {
+
+ unprotect_entry(file_ptr, 0, 0, FALSE, H5C__PIN_ENTRY_FLAG);
+
+ }
if ( pass ) {
@@ -13654,7 +13666,11 @@ check_get_entry_status(void)
}
}
- mark_pinned_entry_dirty(0, 0, FALSE, (size_t)0);
+ if ( pass ) {
+
+ mark_pinned_entry_dirty(0, 0, FALSE, (size_t)0);
+
+ }
if ( pass ) {
@@ -13676,7 +13692,11 @@ check_get_entry_status(void)
}
}
- unpin_entry(0, 0);
+ if ( pass ) {
+
+ unpin_entry(0, 0);
+
+ }
if ( pass ) {
@@ -14913,7 +14933,11 @@ check_resize_entry(void)
}
}
- protect_entry(file_ptr, LARGE_ENTRY_TYPE, 0);
+ if ( pass ) {
+
+ protect_entry(file_ptr, LARGE_ENTRY_TYPE, 0);
+
+ }
if ( pass ) {
@@ -15032,7 +15056,11 @@ check_resize_entry(void)
}
}
- protect_entry(file_ptr, LARGE_ENTRY_TYPE, 0);
+ if ( pass ) {
+
+ protect_entry(file_ptr, LARGE_ENTRY_TYPE, 0);
+
+ }
if ( pass ) {
@@ -15104,9 +15132,13 @@ check_resize_entry(void)
}
}
- protect_entry(file_ptr, LARGE_ENTRY_TYPE, 0);
+ if ( pass ) {
+
+ protect_entry(file_ptr, LARGE_ENTRY_TYPE, 0);
+
+ unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 0, FALSE, H5C__PIN_ENTRY_FLAG);
- unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 0, FALSE, H5C__PIN_ENTRY_FLAG);
+ }
if ( pass ) {
@@ -15230,10 +15262,14 @@ check_resize_entry(void)
}
}
- protect_entry(file_ptr, LARGE_ENTRY_TYPE, 0);
+ if ( pass ) {
+
+ protect_entry(file_ptr, LARGE_ENTRY_TYPE, 0);
+
+ unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 0, FALSE,
+ H5C__UNPIN_ENTRY_FLAG | H5C__DELETED_FLAG);
- unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 0, FALSE,
- H5C__UNPIN_ENTRY_FLAG | H5C__DELETED_FLAG);
+ }
if ( pass ) {
@@ -15300,14 +15336,18 @@ check_resize_entry(void)
entry_size = LARGE_ENTRY_SIZE;
}
- protect_entry(file_ptr, LARGE_ENTRY_TYPE, 0);
- unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 0, FALSE, H5C__NO_FLAGS_SET);
+ if ( pass ) {
- protect_entry(file_ptr, LARGE_ENTRY_TYPE, 1);
- unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 1, TRUE, H5C__NO_FLAGS_SET);
+ protect_entry(file_ptr, LARGE_ENTRY_TYPE, 0);
+ unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 0, FALSE, H5C__NO_FLAGS_SET);
- protect_entry(file_ptr, LARGE_ENTRY_TYPE, 2);
- unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 2, FALSE, H5C__NO_FLAGS_SET);
+ protect_entry(file_ptr, LARGE_ENTRY_TYPE, 1);
+ unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 1, TRUE, H5C__NO_FLAGS_SET);
+
+ protect_entry(file_ptr, LARGE_ENTRY_TYPE, 2);
+ unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 2, FALSE, H5C__NO_FLAGS_SET);
+
+ }
if ( pass ) {
@@ -15324,7 +15364,11 @@ check_resize_entry(void)
}
}
- protect_entry(file_ptr, LARGE_ENTRY_TYPE, 3);
+ if ( pass ) {
+
+ protect_entry(file_ptr, LARGE_ENTRY_TYPE, 3);
+
+ }
if ( pass ) {
@@ -15445,7 +15489,11 @@ check_resize_entry(void)
}
}
- protect_entry(file_ptr, LARGE_ENTRY_TYPE, 3);
+ if ( pass ) {
+
+ protect_entry(file_ptr, LARGE_ENTRY_TYPE, 3);
+
+ }
if ( pass ) {
@@ -15517,9 +15565,13 @@ check_resize_entry(void)
}
}
- protect_entry(file_ptr, LARGE_ENTRY_TYPE, 3);
+ if ( pass ) {
+
+ protect_entry(file_ptr, LARGE_ENTRY_TYPE, 3);
- unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 3, FALSE, H5C__PIN_ENTRY_FLAG);
+ unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 3, FALSE, H5C__PIN_ENTRY_FLAG);
+
+ }
if ( pass ) {
@@ -15645,10 +15697,14 @@ check_resize_entry(void)
}
}
- protect_entry(file_ptr, LARGE_ENTRY_TYPE, 3);
+ if ( pass ) {
- unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 3, FALSE,
- H5C__UNPIN_ENTRY_FLAG | H5C__DELETED_FLAG);
+ protect_entry(file_ptr, LARGE_ENTRY_TYPE, 3);
+
+ unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 3, FALSE,
+ H5C__UNPIN_ENTRY_FLAG | H5C__DELETED_FLAG);
+
+ }
if ( pass ) {
@@ -15695,15 +15751,18 @@ check_resize_entry(void)
}
}
- protect_entry(file_ptr, LARGE_ENTRY_TYPE, 2);
- unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 2, FALSE, H5C__DELETED_FLAG);
+ if ( pass ) {
- protect_entry(file_ptr, LARGE_ENTRY_TYPE, 1);
- unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 1, FALSE, H5C__DELETED_FLAG);
+ protect_entry(file_ptr, LARGE_ENTRY_TYPE, 2);
+ unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 2, FALSE, H5C__DELETED_FLAG);
- protect_entry(file_ptr, LARGE_ENTRY_TYPE, 0);
- unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 0, FALSE, H5C__DELETED_FLAG);
+ protect_entry(file_ptr, LARGE_ENTRY_TYPE, 1);
+ unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 1, FALSE, H5C__DELETED_FLAG);
+ protect_entry(file_ptr, LARGE_ENTRY_TYPE, 0);
+ unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 0, FALSE, H5C__DELETED_FLAG);
+
+ }
if ( pass ) {
@@ -15768,7 +15827,7 @@ check_evictions_enabled(void)
int mile_stone = 1;
H5F_t * file_ptr = NULL;
H5C_t * cache_ptr = NULL;
- test_entry_t * base_addr;
+ test_entry_t * base_addr = NULL;
test_entry_t * entry_ptr;
TESTING("evictions enabled/disabled functionality");
@@ -15821,9 +15880,18 @@ check_evictions_enabled(void)
file_ptr = setup_cache((size_t)(1 * 1024 * 1024),
(size_t)( 512 * 1024));
- cache_ptr = file_ptr->shared->cache;
+ if ( file_ptr == NULL ) {
- base_addr = entries[MONSTER_ENTRY_TYPE];
+ pass = FALSE;
+ failure_mssg = "file_ptr NULL from setup_cache.";
+
+ }
+ else
+ {
+ cache_ptr = file_ptr->shared->cache;
+
+ base_addr = entries[MONSTER_ENTRY_TYPE];
+ }
}
if ( show_progress ) /* 2 */
@@ -15867,12 +15935,16 @@ check_evictions_enabled(void)
HDfprintf(stdout, "%s() - %0d -- pass = %d\n",
fcn_name, mile_stone++, (int)pass);
- /* fill the cache */
- for ( i = 0; i < 16 ; i++ )
- {
- protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i);
- unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, i,
- FALSE, H5C__NO_FLAGS_SET);
+ if ( pass ) {
+
+ /* fill the cache */
+ for ( i = 0; i < 16 ; i++ )
+ {
+ protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i);
+ unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, i,
+ FALSE, H5C__NO_FLAGS_SET);
+ }
+
}
if ( show_progress ) /* 5 */
@@ -15900,10 +15972,14 @@ check_evictions_enabled(void)
HDfprintf(stdout, "%s() - %0d -- pass = %d\n",
fcn_name, mile_stone++, (int)pass);
- /* protect and unprotect another entry */
- protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 16);
- unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 16,
- FALSE, H5C__NO_FLAGS_SET);
+ if ( pass ) {
+
+ /* protect and unprotect another entry */
+ protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 16);
+ unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 16,
+ FALSE, H5C__NO_FLAGS_SET);
+
+ }
if ( show_progress ) /* 7 */
HDfprintf(stdout, "%s() - %0d -- pass = %d\n",
@@ -15966,8 +16042,12 @@ check_evictions_enabled(void)
HDfprintf(stdout, "%s() - %0d -- pass = %d\n",
fcn_name, mile_stone++, (int)pass);
- /* insert an entry */
- insert_entry(file_ptr, MONSTER_ENTRY_TYPE, 17, TRUE, H5C__NO_FLAGS_SET);
+ if ( pass ) {
+
+ /* insert an entry */
+ insert_entry(file_ptr, MONSTER_ENTRY_TYPE, 17, TRUE, H5C__NO_FLAGS_SET);
+
+ }
if ( show_progress ) /* 10 */
HDfprintf(stdout, "%s() - %0d -- pass = %d\n",
@@ -16066,10 +16146,14 @@ check_evictions_enabled(void)
HDfprintf(stdout, "%s() - %0d -- pass = %d\n",
fcn_name, mile_stone++, (int)pass);
- /* protect and unprotect another entry */
- protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 18);
- unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 18,
- FALSE, H5C__NO_FLAGS_SET);
+ if ( pass ) {
+
+ /* protect and unprotect another entry */
+ protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 18);
+ unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 18,
+ FALSE, H5C__NO_FLAGS_SET);
+
+ }
if ( show_progress ) /* 15 */
HDfprintf(stdout, "%s() - %0d -- pass = %d\n",
@@ -16095,8 +16179,12 @@ check_evictions_enabled(void)
HDfprintf(stdout, "%s() - %0d -- pass = %d\n",
fcn_name, mile_stone++, (int)pass);
- /* insert another entry */
- insert_entry(file_ptr, MONSTER_ENTRY_TYPE, 19, TRUE, H5C__NO_FLAGS_SET);
+ if ( pass ) {
+
+ /* insert another entry */
+ insert_entry(file_ptr, MONSTER_ENTRY_TYPE, 19, TRUE, H5C__NO_FLAGS_SET);
+
+ }
if ( show_progress ) /* 17 */
HDfprintf(stdout, "%s() - %0d -- pass = %d\n",
@@ -16139,10 +16227,14 @@ check_evictions_enabled(void)
HDfprintf(stdout, "%s() - %0d -- pass = %d\n",
fcn_name, mile_stone++, (int)pass);
- /* protect and unprotect an entry that is in the cache */
- protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 19);
- unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 19,
- FALSE, H5C__NO_FLAGS_SET);
+ if ( pass ) {
+
+ /* protect and unprotect an entry that is in the cache */
+ protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 19);
+ unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 19,
+ FALSE, H5C__NO_FLAGS_SET);
+
+ }
if ( show_progress ) /* 20 */
HDfprintf(stdout, "%s() - %0d -- pass = %d\n",
@@ -16168,10 +16260,14 @@ check_evictions_enabled(void)
HDfprintf(stdout, "%s() - %0d -- pass = %d\n",
fcn_name, mile_stone++, (int)pass);
- /* protect and unprotect an entry that isn't in the cache */
- protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 20);
- unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 20,
- FALSE, H5C__NO_FLAGS_SET);
+ if ( pass ) {
+
+ /* protect and unprotect an entry that isn't in the cache */
+ protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 20);
+ unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 20,
+ FALSE, H5C__NO_FLAGS_SET);
+
+ }
if ( show_progress ) /* 22 */
HDfprintf(stdout, "%s() - %0d -- pass = %d\n",
@@ -16289,13 +16385,16 @@ check_evictions_enabled(void)
HDfprintf(stdout, "%s() - %0d -- pass = %d\n",
fcn_name, mile_stone++, (int)pass);
- /* protect and unprotect an entry that isn't in the cache, forcing
- * the cache to grow.
- */
- protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 21);
- unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 21,
- FALSE, H5C__NO_FLAGS_SET);
+ if ( pass ) {
+ /* protect and unprotect an entry that isn't in the cache, forcing
+ * the cache to grow.
+ */
+ protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 21);
+ unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 21,
+ FALSE, H5C__NO_FLAGS_SET);
+
+ }
if ( show_progress ) /* 27 */
HDfprintf(stdout, "%s() - %0d -- pass = %d\n",
@@ -16338,8 +16437,12 @@ check_evictions_enabled(void)
HDfprintf(stdout, "%s() - %0d -- pass = %d\n",
fcn_name, mile_stone++, (int)pass);
- /* insert an entry */
- insert_entry(file_ptr, MONSTER_ENTRY_TYPE, 22, TRUE, H5C__NO_FLAGS_SET);
+ if ( pass ) {
+
+ /* insert an entry */
+ insert_entry(file_ptr, MONSTER_ENTRY_TYPE, 22, TRUE, H5C__NO_FLAGS_SET);
+
+ }
if ( show_progress ) /* 30 */
HDfprintf(stdout, "%s() - %0d -- pass = %d\n",
@@ -22475,7 +22578,17 @@ check_auto_cache_resize_disable(void)
file_ptr = setup_cache((size_t)(2 * 1024),
(size_t)(1 * 1024));
- cache_ptr = file_ptr->shared->cache;
+
+ if ( file_ptr == NULL ) {
+
+ pass = FALSE;
+ failure_mssg = "file_ptr NULL from setup_cache.";
+
+ }
+ else {
+
+ cache_ptr = file_ptr->shared->cache;
+ }
}
if ( pass ) {
@@ -23536,8 +23649,11 @@ check_auto_cache_resize_disable(void)
if ( show_progress ) HDfprintf(stderr, "check point %d\n", checkpoint++);
- /* flush the cache and destroy all entries so we start from a known point */
- flush_cache(file_ptr, TRUE, FALSE, FALSE);
+ if ( pass ) {
+
+ /* flush the cache and destroy all entries so we start from a known point */
+ flush_cache(file_ptr, TRUE, FALSE, FALSE);
+ }
if ( show_progress ) HDfprintf(stderr, "check point %d\n", checkpoint++);
@@ -23764,8 +23880,11 @@ check_auto_cache_resize_disable(void)
if ( show_progress ) HDfprintf(stderr, "check point %d\n", checkpoint++);
- /* flush the cache and destroy all entries so we start from a known point */
- flush_cache(file_ptr, TRUE, FALSE, FALSE);
+ if ( pass ) {
+
+ /* flush the cache and destroy all entries so we start from a known point */
+ flush_cache(file_ptr, TRUE, FALSE, FALSE);
+ }
if ( show_progress ) HDfprintf(stderr, "check point %d\n", checkpoint++);
@@ -23999,8 +24118,11 @@ check_auto_cache_resize_disable(void)
if ( show_progress ) HDfprintf(stderr, "check point %d\n", checkpoint++);
- /* flush the cache and destroy all entries so we start from a known point */
- flush_cache(file_ptr, TRUE, FALSE, FALSE);
+ if ( pass ) {
+
+ /* flush the cache and destroy all entries so we start from a known point */
+ flush_cache(file_ptr, TRUE, FALSE, FALSE);
+ }
if ( show_progress ) HDfprintf(stderr, "check point %d\n", checkpoint++);
diff --git a/test/dtransform.c b/test/dtransform.c
index cb58a6c..3b1133a 100644
--- a/test/dtransform.c
+++ b/test/dtransform.c
@@ -27,10 +27,10 @@ static int test_set(void);
static int test_getset(const hid_t dxpl_id_simple);
/* These are needed for multiple tests, so are declared here globally and are init'ed in init_test */
-hid_t dset_id_int;
-hid_t dset_id_float;
-hid_t dset_id_int_chunk;
-hid_t dset_id_float_chunk;
+hid_t dset_id_int = -1;
+hid_t dset_id_float = -1;
+hid_t dset_id_int_chunk = -1;
+hid_t dset_id_float_chunk = -1;
const float windchillFfloat[ROWS][COLS] =
@@ -68,15 +68,15 @@ const int transformData[ROWS][COLS] =
size_t i,j; \
\
for(i=0; i<ROWS; i++) \
- for(j=0; j<COLS; j++) \
- { \
- if(!( (((VAR1)[i][j] >= (TYPE)((VAR2)[i][j])) && ( ((VAR1)[i][j] - TOL) < (TYPE)((VAR2)[i][j]))) || ( ((VAR1)[i][j] <= (TYPE)((VAR2)[i][j])) && ( ((VAR1)[i][j] + TOL) > (TYPE)((VAR2)[i][j]))))) \
- { \
- H5_FAILED(); \
- fprintf(stderr, " ERROR: Conversion failed to match computed data\n"); \
- goto error; \
- } \
- } \
+ for(j=0; j<COLS; j++) \
+ { \
+ if(!( (((VAR1)[i][j] >= (TYPE)((VAR2)[i][j])) && ( ((VAR1)[i][j] - TOL) < (TYPE)((VAR2)[i][j]))) || ( ((VAR1)[i][j] <= (TYPE)((VAR2)[i][j])) && ( ((VAR1)[i][j] + TOL) > (TYPE)((VAR2)[i][j]))))) \
+ { \
+ H5_FAILED(); \
+ fprintf(stderr, " ERROR: Conversion failed to match computed data\n"); \
+ goto error; \
+ } \
+ } \
PASSED(); \
}
@@ -85,15 +85,15 @@ const int transformData[ROWS][COLS] =
size_t i,j; \
\
for(i=0; i<ROWS; i++) \
- for(j=0; j<COLS; j++) \
- { \
- if( !(((VAR1)[i][j] <= ((TYPE)(VAR2)[i][j] + TOL)) && ((VAR1)[i][j] >= ((TYPE)(VAR2)[i][j] - TOL))) ) \
- { \
- H5_FAILED(); \
- fprintf(stderr, " ERROR: Conversion failed to match computed data\n"); \
- goto error; \
- } \
- } \
+ for(j=0; j<COLS; j++) \
+ { \
+ if( !(((VAR1)[i][j] <= ((TYPE)(VAR2)[i][j] + TOL)) && ((VAR1)[i][j] >= ((TYPE)(VAR2)[i][j] - TOL))) ) \
+ { \
+ H5_FAILED(); \
+ fprintf(stderr, " ERROR: Conversion failed to match computed data\n"); \
+ goto error; \
+ } \
+ } \
PASSED(); \
}
@@ -172,17 +172,17 @@ const int transformData[ROWS][COLS] =
\
hid_t dataspace, dxpl_id_f_to_c, dxpl_id_utrans, cparms, memspace, dset_chunk, filespace; \
hsize_t dim[2] = {ROWS, COLS}; \
- hsize_t offset[2] = {0, 0}; \
+ hsize_t offset[2] = {0, 0}; \
\
\
if((dataspace = H5Screate_simple(2, dim, NULL)) < 0) TEST_ERROR; \
\
- cparms = H5Pcreate(H5P_DATASET_CREATE); \
- if(H5Pset_chunk(cparms, 2, dim) < 0) TEST_ERROR; \
+ if((cparms = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR; \
+ if(H5Pset_chunk(cparms, 2, dim) < 0) TEST_ERROR; \
\
if((dset_chunk = H5Dcreate2(file_id, "/transformtest_chunk_"TEST_STR, HDF_TYPE, dataspace, H5P_DEFAULT, cparms, H5P_DEFAULT)) < 0) TEST_ERROR; \
- filespace = H5Dget_space (dset_chunk); \
- memspace = H5Screate_simple(2, dim, NULL); \
+ if((filespace = H5Dget_space(dset_chunk)) < 0) TEST_ERROR \
+ if((memspace = H5Screate_simple(2, dim, NULL)) < 0) TEST_ERROR \
if(H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL, dim, NULL) < 0) TEST_ERROR; \
\
if(SIGNED) \
@@ -190,14 +190,14 @@ const int transformData[ROWS][COLS] =
if((dxpl_id_f_to_c = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR; \
if(H5Pset_data_transform(dxpl_id_f_to_c, f_to_c) < 0) TEST_ERROR; \
if(H5Dwrite(dset_chunk, H5T_NATIVE_FLOAT, dataspace, filespace, dxpl_id_f_to_c, windchillFfloat) < 0) TEST_ERROR; \
- if(H5Pclose(dxpl_id_f_to_c) < 0) TEST_ERROR; \
+ if(H5Pclose(dxpl_id_f_to_c) < 0) TEST_ERROR; \
} \
else \
{ \
if((dxpl_id_utrans = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR; \
if(H5Pset_data_transform(dxpl_id_utrans, utrans) < 0) TEST_ERROR; \
if(H5Dwrite(dset_chunk, H5T_NATIVE_INT, dataspace, filespace, dxpl_id_utrans, transformData) < 0) TEST_ERROR; \
- if(H5Pclose(dxpl_id_utrans) < 0) TEST_ERROR; \
+ if(H5Pclose(dxpl_id_utrans) < 0) TEST_ERROR; \
} \
\
\
@@ -211,17 +211,17 @@ const int transformData[ROWS][COLS] =
\
if(SIGNED) \
{ \
- TESTING("chunked, with type conversion (float->"TEST_STR")") \
+ TESTING("chunked, with type conversion (float->"TEST_STR")") \
\
if(H5Dread(dset_id_float_chunk, HDF_TYPE, memspace, filespace, XFORM, array) < 0) TEST_ERROR; \
- COMPARE(TYPE, array, COMPARE_DATA, 2) \
+ COMPARE(TYPE, array, COMPARE_DATA, 2) \
} \
\
- \
- if(H5Pclose(cparms) < 0) TEST_ERROR; \
+ \
+ if(H5Pclose(cparms) < 0) TEST_ERROR; \
if(H5Dclose(dset_chunk) < 0) TEST_ERROR; \
- if(H5Sclose(dataspace) < 0) TEST_ERROR; \
- if(H5Sclose(memspace) < 0) TEST_ERROR; \
+ if(H5Sclose(dataspace) < 0) TEST_ERROR; \
+ if(H5Sclose(memspace) < 0) TEST_ERROR; \
}
#define INVALID_SET_TEST(TRANSFORM) \
@@ -240,7 +240,7 @@ const int transformData[ROWS][COLS] =
int main(void)
{
- hid_t dxpl_id_c_to_f, dxpl_id_c_to_f_copy, dxpl_id_simple, dxpl_id_polynomial, dxpl_id_polynomial_copy, dxpl_id_utrans_inv, file_id;
+ hid_t dxpl_id_c_to_f = -1, dxpl_id_c_to_f_copy = -1, dxpl_id_simple = -1, dxpl_id_polynomial = -1, dxpl_id_polynomial_copy = -1, dxpl_id_utrans_inv = -1, file_id = -1;
const char* c_to_f = "(9/5.0)*x + 32";
const char* simple = "(4/2) * ( (2 + 4)/(5 - 2.5))"; /* this equals 4.8 */
@@ -344,6 +344,19 @@ int main(void)
return 0;
error:
+ H5E_BEGIN_TRY {
+ H5Dclose(dset_id_int);
+ H5Dclose(dset_id_int_chunk);
+ H5Dclose(dset_id_float);
+ H5Dclose(dset_id_float_chunk);
+ H5Fclose(file_id);
+ H5Pclose(dxpl_id_c_to_f);
+ H5Pclose(dxpl_id_c_to_f_copy);
+ H5Pclose(dxpl_id_polynomial);
+ H5Pclose(dxpl_id_polynomial_copy);
+ H5Pclose(dxpl_id_simple);
+ H5Pclose(dxpl_id_utrans_inv);
+ } H5E_END_TRY
return -1;
}
@@ -354,93 +367,128 @@ init_test(hid_t file_id)
/* utrans is a transform for unsigned types: no negative numbers involved and results are < 255 to fit into uchar */
const char* utrans = "((x+100)/4)*3";
- hid_t dataspace, dxpl_id_f_to_c, dxpl_id_utrans, cparms, filespace;
- hsize_t dim[2] = {ROWS, COLS};
- hsize_t offset[2] = {0, 0};
-
- if((dxpl_id_f_to_c = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR;
- if((dxpl_id_utrans = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR;
+ hid_t dataspace = -1, dxpl_id_f_to_c = -1, dxpl_id_utrans = -1, cparms = -1, filespace = -1;
+ hsize_t dim[2] = { ROWS, COLS };
+ hsize_t offset[2] = { 0, 0 };
- if(H5Pset_data_transform(dxpl_id_f_to_c, f_to_c) < 0) TEST_ERROR;
- if(H5Pset_data_transform(dxpl_id_utrans, utrans) < 0) TEST_ERROR;
+ if((dxpl_id_f_to_c = H5Pcreate(H5P_DATASET_XFER)) < 0)
+ TEST_ERROR
+ if((dxpl_id_utrans = H5Pcreate(H5P_DATASET_XFER)) < 0)
+ TEST_ERROR
+ if(H5Pset_data_transform(dxpl_id_f_to_c, f_to_c) < 0)
+ TEST_ERROR
+ if(H5Pset_data_transform(dxpl_id_utrans, utrans) < 0)
+ TEST_ERROR
cparms = H5Pcreate(H5P_DATASET_CREATE);
- if(H5Pset_chunk(cparms, 2, dim) < 0) TEST_ERROR;
+ if(H5Pset_chunk(cparms, 2, dim) < 0)
+ TEST_ERROR
- if((dataspace = H5Screate_simple(2, dim, NULL)) < 0) TEST_ERROR;
+ if((dataspace = H5Screate_simple(2, dim, NULL)) < 0)
+ TEST_ERROR
TESTING("Intializing test...")
- if((dset_id_int = H5Dcreate2(file_id, "/default_int", H5T_NATIVE_INT, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR;
- if(H5Dwrite(dset_id_int, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, dxpl_id_f_to_c, windchillFfloat) < 0) TEST_ERROR;
-
- if((dset_id_float = H5Dcreate2(file_id, "/default_float", H5T_NATIVE_FLOAT, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR;
- if(H5Dwrite(dset_id_float, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, dxpl_id_f_to_c, windchillFfloat) < 0) TEST_ERROR;
-
- if((dset_id_int_chunk = H5Dcreate2(file_id, "/default_chunk_int", H5T_NATIVE_INT, dataspace, H5P_DEFAULT, cparms, H5P_DEFAULT)) < 0) TEST_ERROR;
-
- filespace = H5Dget_space (dset_id_int_chunk);
- if(H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL, dim, NULL) < 0) TEST_ERROR;
- if(H5Dwrite(dset_id_int_chunk, H5T_NATIVE_FLOAT, dataspace, filespace, dxpl_id_f_to_c, windchillFfloat) < 0) TEST_ERROR;
-
- if((dset_id_float_chunk = H5Dcreate2(file_id, "/default_chunk_float", H5T_NATIVE_FLOAT, dataspace, H5P_DEFAULT, cparms, H5P_DEFAULT)) < 0) TEST_ERROR;
- if(H5Dwrite(dset_id_float_chunk, H5T_NATIVE_FLOAT, dataspace, filespace, dxpl_id_f_to_c, windchillFfloat) < 0) TEST_ERROR;
-
+ if((dset_id_int = H5Dcreate2(file_id, "/default_int", H5T_NATIVE_INT,
+ dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+ if(H5Dwrite(dset_id_int, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL,
+ dxpl_id_f_to_c, windchillFfloat) < 0)
+ TEST_ERROR
+
+ if((dset_id_float = H5Dcreate2(file_id, "/default_float",
+ H5T_NATIVE_FLOAT, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+ if(H5Dwrite(dset_id_float, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL,
+ dxpl_id_f_to_c, windchillFfloat) < 0)
+ TEST_ERROR
+
+ if((dset_id_int_chunk = H5Dcreate2(file_id, "/default_chunk_int",
+ H5T_NATIVE_INT, dataspace, H5P_DEFAULT, cparms, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+
+ if((filespace = H5Dget_space(dset_id_int_chunk)) < 0)
+ TEST_ERROR
+ if(H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL, dim, NULL) < 0)
+ TEST_ERROR
+ if(H5Dwrite(dset_id_int_chunk, H5T_NATIVE_FLOAT, dataspace, filespace,
+ dxpl_id_f_to_c, windchillFfloat) < 0)
+ TEST_ERROR
+
+ if((dset_id_float_chunk = H5Dcreate2(file_id, "/default_chunk_float",
+ H5T_NATIVE_FLOAT, dataspace, H5P_DEFAULT, cparms, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+ if(H5Dwrite(dset_id_float_chunk, H5T_NATIVE_FLOAT, dataspace, filespace,
+ dxpl_id_f_to_c, windchillFfloat) < 0)
+ TEST_ERROR
+
+ if(H5Pclose(cparms) < 0)
+ TEST_ERROR
+ if(H5Pclose(dxpl_id_f_to_c) < 0)
+ TEST_ERROR
+ if(H5Pclose(dxpl_id_utrans) < 0)
+ TEST_ERROR
+ if(H5Sclose(dataspace) < 0)
+ TEST_ERROR
+ if(H5Sclose(filespace) < 0)
+ TEST_ERROR
PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Pclose(cparms);
+ H5Pclose(dxpl_id_f_to_c);
+ H5Pclose(dxpl_id_utrans);
+ H5Sclose(dataspace);
+ H5Sclose(filespace);
+ } H5E_END_TRY
- if(H5Pclose(cparms) < 0) TEST_ERROR;
- if(H5Pclose(dxpl_id_f_to_c) < 0) TEST_ERROR;
- if(H5Pclose(dxpl_id_utrans) < 0) TEST_ERROR;
- if(H5Sclose(dataspace) < 0) TEST_ERROR;
-
- return 0;
-error:
- return -1;
+ return -1;
}
static int
test_poly(const hid_t dxpl_id_polynomial)
{
float polyflres[ROWS][COLS];
- int polyintread[ROWS][COLS];
+ int polyintread[ROWS][COLS];
float polyflread[ROWS][COLS];
int windchillC;
int row, col;
- for(row = 0; row<ROWS; row++)
- {
- for(col = 0; col<COLS; col++)
- {
- windchillC = (int)((5.0/9.0)*(windchillFfloat[row][col] - 32));
- polyflres[row][col] = (float)((2.0+windchillC)*((windchillC-8.0)/2.0));
- }
- }
+ for(row = 0; row < ROWS; row++)
+ for(col = 0; col < COLS; col++) {
+ windchillC = (int) ((5.0 / 9.0) * (windchillFfloat[row][col] - 32));
+ polyflres[row][col] = (float) ((2.0 + windchillC) * ((windchillC - 8.0) / 2.0));
+ }
TESTING("data transform, polynomial transform (int->float)")
- if(H5Dread(dset_id_int, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, dxpl_id_polynomial, polyflread) < 0) TEST_ERROR;
+ if(H5Dread(dset_id_int, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL,
+ dxpl_id_polynomial, polyflread) < 0)
+ TEST_ERROR
+
COMPARE(float, polyflread, polyflres, 2.0)
-
- for(row = 0; row<ROWS; row++)
- {
- for(col = 0; col<COLS; col++)
- {
- windchillC = (int)((5.0/9.0)*(windchillFfloat[row][col] - 32));
- polyflres[row][col] = (float)((2+windchillC)*((windchillC-8)/2));
- }
- }
+ for(row = 0; row < ROWS; row++)
+ for(col = 0; col < COLS; col++) {
+ windchillC = (int) ((5.0 / 9.0) * (windchillFfloat[row][col] - 32));
+ polyflres[row][col] = (float) ((2 + windchillC) * ((windchillC - 8) / 2));
+ }
TESTING("data transform, polynomial transform (float->int)")
- if(H5Dread(dset_id_float, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id_polynomial, polyintread) < 0) TEST_ERROR;
+ if(H5Dread(dset_id_float, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
+ dxpl_id_polynomial, polyintread) < 0)
+ TEST_ERROR
+
COMPARE(int, polyintread, polyflres, 4)
return 0;
-error:
- return -1;
+error:
+ return -1;
}
static int
@@ -452,27 +500,29 @@ test_copy(const hid_t dxpl_id_c_to_f_copy, const hid_t dxpl_id_polynomial_copy)
int windchillFintread[ROWS][COLS];
int row, col;
- for(row = 0; row<ROWS; row++)
- {
- for(col = 0; col<COLS; col++)
- {
- windchillC = (int)((5.0/9.0)*(windchillFfloat[row][col] - 32));
- polyflres[row][col] = (float)((2+windchillC)*((windchillC-8)/2));
- }
- }
-
+ for(row = 0; row < ROWS; row++)
+ for(col = 0; col < COLS; col++) {
+ windchillC = (int) ((5.0 / 9.0) * (windchillFfloat[row][col] - 32));
+ polyflres[row][col] = (float) ((2 + windchillC) * ((windchillC - 8) / 2));
+ }
TESTING("data transform, linear transform w/ copied property")
- if(H5Dread(dset_id_float, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id_c_to_f_copy, windchillFintread) < 0) TEST_ERROR;
+ if(H5Dread(dset_id_float, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
+ dxpl_id_c_to_f_copy, windchillFintread) < 0)
+ TEST_ERROR
+
COMPARE(int, windchillFintread, windchillFfloat, 2)
TESTING("data transform, polynomial transform w/ copied property")
- if(H5Dread(dset_id_float, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id_polynomial_copy, polyintread) < 0) TEST_ERROR;
+ if(H5Dread(dset_id_float, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
+ dxpl_id_polynomial_copy, polyintread) < 0)
+ TEST_ERROR
+
COMPARE(int, polyintread, polyflres, 2)
return 0;
-error:
+error:
return -1;
}
@@ -484,36 +534,28 @@ test_trivial(const hid_t dxpl_id_simple)
int row, col;
TESTING("data transform, trivial transform, without type conversion")
- if(H5Dread(dset_id_float, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, dxpl_id_simple, windchillFfloatread) < 0) TEST_ERROR;
- for(row = 0; row<ROWS; row++)
- {
- for(col = 0; col<COLS; col++)
- {
- if((windchillFfloatread[row][col] - 4.8) > FLOAT_TOL)
- {
- H5_FAILED();
- fprintf(stderr, " ERROR: Conversion failed to match computed data\n");
- goto error;
- }
- }
- }
- PASSED();
+ if(H5Dread(dset_id_float, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL,
+ dxpl_id_simple, windchillFfloatread) < 0)
+ TEST_ERROR
+ for(row = 0; row < ROWS; row++)
+ for(col = 0; col < COLS; col++) {
+ if((windchillFfloatread[row][col] - 4.8) > FLOAT_TOL)
+ FAIL_PUTS_ERROR(" ERROR: Conversion failed to match computed data\n");
+ }
+
+ PASSED()
TESTING("data transform, trivial transform, with type conversion")
- if(H5Dread(dset_id_float, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id_simple, windchillFintread) < 0) TEST_ERROR;
- for(row = 0; row<ROWS; row++)
- {
- for(col = 0; col<COLS; col++)
- {
- if(windchillFintread[row][col] != 4)
- {
- H5_FAILED();
- fprintf(stderr, " ERROR: Conversion failed to match computed data\n");
- goto error;
- }
- }
- }
- PASSED();
+ if(H5Dread(dset_id_float, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
+ dxpl_id_simple, windchillFintread) < 0)
+ TEST_ERROR
+ for(row = 0; row < ROWS; row++)
+ for(col = 0; col < COLS; col++) {
+ if(windchillFintread[row][col] != 4)
+ FAIL_PUTS_ERROR(" ERROR: Conversion failed to match computed data\n")
+ }
+
+ PASSED()
return 0;
error:
@@ -523,92 +565,96 @@ error:
static int
test_getset(const hid_t dxpl_id_c_to_f)
{
- int row, col;
- float windchillFfloatread[ROWS][COLS];
- const char* simple = "(4/2) * ( (2 + 4)/(5 - 2.5))"; /* this equals 4.8 */
- const char* c_to_f = "(9/5.0)*x + 32";
- char* ptrgetTest = (char *) HDmalloc(HDstrlen(simple)+1);
+ int row;
+ int col;
+ float windchillFfloatread[ROWS][COLS];
+ const char *simple = "(4/2) * ( (2 + 4)/(5 - 2.5))"; /* this equals 4.8 */
+ const char *c_to_f = "(9/5.0)*x + 32";
+ char *ptrgetTest = NULL;
TESTING("H5Pget_data_transform")
- H5Pget_data_transform(dxpl_id_c_to_f, ptrgetTest, HDstrlen(c_to_f)+1);
+
+ if(NULL == (ptrgetTest = (char *)HDmalloc(HDstrlen(simple) + 1)))
+ TEST_ERROR
+
+ if(H5Pget_data_transform(dxpl_id_c_to_f, ptrgetTest, HDstrlen(c_to_f) + 1) < 0)
+ TEST_ERROR
if(HDstrcmp(c_to_f, ptrgetTest) != 0)
- {
- H5_FAILED();
- fprintf(stderr, " ERROR: Data transform failed to match what was set\n");
- goto error;
- }
- else
- PASSED();
- free(ptrgetTest);
+ FAIL_PUTS_ERROR(" ERROR: Data transform failed to match what was set\n")
- if(H5Pset_data_transform(dxpl_id_c_to_f, simple) < 0) TEST_ERROR;
+ PASSED()
+
+ HDfree(ptrgetTest);
+ ptrgetTest = NULL;
TESTING("data transform, read after reseting of transform property")
- if(H5Dread(dset_id_float, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, dxpl_id_c_to_f, windchillFfloatread) < 0) TEST_ERROR;
- for(row = 0; row<ROWS; row++)
- {
- for(col = 0; col<COLS; col++)
- {
- if((windchillFfloatread[row][col] - 4.8) > FLOAT_TOL)
- {
- H5_FAILED();
- fprintf(stderr, " ERROR: Conversion failed to match computed data\n");
- goto error;
- }
- }
- }
- PASSED();
+ if(H5Pset_data_transform(dxpl_id_c_to_f, simple) < 0)
+ TEST_ERROR
+
+ if(H5Dread(dset_id_float, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL,
+ dxpl_id_c_to_f, windchillFfloatread) < 0)
+ TEST_ERROR
+
+ for(row = 0; row < ROWS; row++)
+ for(col = 0; col < COLS; col++) {
+ if((windchillFfloatread[row][col] - 4.8) > FLOAT_TOL)
+ FAIL_PUTS_ERROR(" ERROR: Conversion failed to match computed data\n")
+ }
- ptrgetTest = (char *) malloc(strlen(simple)+1);
+ PASSED()
- HDmemset(ptrgetTest, 0, strlen(simple)+1);
TESTING("H5Pget_data_transform, after resetting transform property")
- H5Pget_data_transform(dxpl_id_c_to_f, ptrgetTest, strlen(simple)+1);
- if(strcmp(simple, ptrgetTest) != 0)
- {
- H5_FAILED();
- fprintf(stderr, " ERROR: Data transform failed to match what was set\n");
- goto error;
- }
- else
- PASSED();
-
- free(ptrgetTest);
+
+ if(NULL == (ptrgetTest = (char *)HDcalloc(1, HDstrlen(simple) + 1)))
+ TEST_ERROR
+ if(H5Pget_data_transform(dxpl_id_c_to_f, ptrgetTest, HDstrlen(simple) + 1) < 0)
+ TEST_ERROR
+ if(HDstrcmp(simple, ptrgetTest) != 0)
+ FAIL_PUTS_ERROR(" ERROR: Data transform failed to match what was set\n")
+
+ PASSED()
+
+ HDfree(ptrgetTest);
+ ptrgetTest = NULL;
return 0;
error:
- return -1;
+ if(ptrgetTest)
+ HDfree(ptrgetTest);
+
+ return -1;
}
static int
test_set(void)
{
- hid_t dxpl_id;
+ hid_t dxpl_id = -1;
H5E_auto2_t func;
- const char* str = "(9/5.0)*x + 32";
- char* ptrgetTest = (char *) malloc(strlen(str)+1);
+ const char *str = "(9/5.0)*x + 32";
+ char *ptrgetTest = NULL;
+
+ TESTING("H5Pget_data_transform (get before set)")
+
+ if(NULL == (ptrgetTest = (char *)HDmalloc(HDstrlen(str) + 1)))
+ TEST_ERROR
- if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR;
+ if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0)
+ TEST_ERROR
/* Test get before set */
- H5Eget_auto2(H5E_DEFAULT,&func,NULL);
+ H5Eget_auto2(H5E_DEFAULT, &func, NULL);
H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
- TESTING("H5Pget_data_transform (get before set)")
- if(H5Pget_data_transform(dxpl_id, ptrgetTest, strlen(str)+1) < 0)
- {
- PASSED();
- }
- else
- {
- H5_FAILED();
- fprintf(stderr, " ERROR: Data transform get before set succeeded (it shouldn't have)\n");
- free(ptrgetTest);
- goto error;
- }
- free(ptrgetTest);
+
+ if(H5Pget_data_transform(dxpl_id, ptrgetTest, HDstrlen(str) + 1) < 0)
+ PASSED()
+ else
+ FAIL_PUTS_ERROR(" ERROR: Data transform get before set succeeded (it shouldn't have)\n");
+
+ HDfree(ptrgetTest);
+ ptrgetTest = NULL;
TESTING("H5Pset_data_transform (set with NULL transform)");
INVALID_SET_TEST(NULL);
@@ -639,9 +685,18 @@ test_set(void)
H5Eset_auto2(H5E_DEFAULT, func, NULL);
+ if(H5Pclose(dxpl_id) < 0)
+ TEST_ERROR
+
return 0;
error:
- return -1;
+ if(ptrgetTest)
+ HDfree(ptrgetTest);
+ H5E_BEGIN_TRY {
+ H5Pclose(dxpl_id);
+ } H5E_END_TRY
+ return -1;
}
+
diff --git a/test/err_compat.c b/test/err_compat.c
index 33c172f..be86a2d 100644
--- a/test/err_compat.c
+++ b/test/err_compat.c
@@ -186,10 +186,10 @@ dump_error(void)
herr_t
custom_print_cb(int n, H5E_error1_t *err_desc, void* client_data)
{
- FILE *stream = (FILE *)client_data;
- char *maj;
- char *min;
- const int indent = 4;
+ FILE *stream = (FILE *)client_data;
+ char *maj = NULL;
+ char *min = NULL;
+ const int indent = 4;
if(NULL == (min = H5Eget_minor(err_desc->min_num)))
TEST_ERROR;
@@ -200,14 +200,21 @@ custom_print_cb(int n, H5E_error1_t *err_desc, void* client_data)
fprintf(stream, "%*serror #%03d: %s in %s(): line %u\n",
indent, "", n, err_desc->file_name,
err_desc->func_name, err_desc->line);
- fprintf(stream, "%*smajor: %s\n", indent*2, "", maj);
+
+ fprintf(stream, "%*smajor: %s\n", indent * 2, "", maj);
+ fprintf(stream, "%*sminor: %s\n", indent * 2, "", min);
+
HDfree(maj);
- fprintf (stream, "%*sminor: %s\n", indent*2, "", min);
HDfree(min);
return 0;
error:
+ if(maj)
+ HDfree(maj);
+ if(min)
+ HDfree(min);
+
return -1;
}
diff --git a/test/error_test.c b/test/error_test.c
index 21a3e58..e784eb9 100644
--- a/test/error_test.c
+++ b/test/error_test.c
@@ -186,11 +186,16 @@ test_error(hid_t file)
static herr_t
init_error(void)
{
- ssize_t cls_size = (ssize_t)HDstrlen(ERR_CLS_NAME)+1;
- char *cls_name = (char*)HDmalloc(HDstrlen(ERR_CLS_NAME)+1);
+ ssize_t cls_size = (ssize_t)HDstrlen(ERR_CLS_NAME) + 1;
ssize_t msg_size = (ssize_t)HDstrlen(ERR_MIN_SUBROUTINE_MSG) + 1;
- char *msg = (char*)HDmalloc(HDstrlen(ERR_MIN_SUBROUTINE_MSG)+1);
- H5E_type_t *msg_type= (H5E_type_t *)HDmalloc(sizeof(H5E_type_t));
+ char *cls_name = NULL;
+ char *msg = NULL;
+ H5E_type_t msg_type;
+
+ if(NULL == (cls_name = (char *)HDmalloc(HDstrlen(ERR_CLS_NAME) + 1)))
+ TEST_ERROR
+ if(NULL == (msg = (char *)HDmalloc(HDstrlen(ERR_MIN_SUBROUTINE_MSG) + 1)))
+ TEST_ERROR
if((ERR_CLS = H5Eregister_class(ERR_CLS_NAME, PROG_NAME, PROG_VERS)) < 0)
TEST_ERROR;
@@ -218,24 +223,28 @@ init_error(void)
if((ERR_MIN_GETNUM = H5Ecreate_msg(ERR_CLS, H5E_MINOR, ERR_MIN_GETNUM_MSG)) < 0)
TEST_ERROR;
- if(msg_size != H5Eget_msg(ERR_MIN_SUBROUTINE, msg_type, msg, (size_t)msg_size) + 1)
+ if(msg_size != H5Eget_msg(ERR_MIN_SUBROUTINE, &msg_type, msg, (size_t)msg_size) + 1)
TEST_ERROR;
- if(*msg_type != H5E_MINOR)
+ if(msg_type != H5E_MINOR)
TEST_ERROR;
if(HDstrcmp(msg, ERR_MIN_SUBROUTINE_MSG))
TEST_ERROR;
- HDfree(cls_name);
- HDfree(msg);
- HDfree(msg_type);
-
/* Register another class for later testing. */
if((ERR_CLS2 = H5Eregister_class(ERR_CLS2_NAME, PROG2_NAME, PROG_VERS)) < 0)
TEST_ERROR;
+ HDfree(cls_name);
+ HDfree(msg);
+
return 0;
error:
+ if(cls_name)
+ HDfree(cls_name);
+ if(msg)
+ HDfree(msg);
+
return -1;
} /* end init_error() */
diff --git a/test/tattr.c b/test/tattr.c
index 484d83f..828b8a8 100644
--- a/test/tattr.c
+++ b/test/tattr.c
@@ -274,60 +274,68 @@ test_attr_basic_write(hid_t fapl)
attr_name_size = H5Aget_name(attr, (size_t)0, NULL);
CHECK(attr_name_size, FAIL, "H5Aget_name");
- if(attr_name_size > 0)
+ if(attr_name_size > 0) {
attr_name = (char*)HDcalloc((size_t)(attr_name_size + 1), sizeof(char));
-
- ret = (herr_t)H5Aget_name(attr, (size_t)(attr_name_size + 1), attr_name);
- CHECK(ret, FAIL, "H5Aget_name");
- ret = HDstrcmp(attr_name, ATTR_TMP_NAME);
- VERIFY(ret, 0, "HDstrcmp");
-
- if(attr_name)
- HDfree(attr_name);
+ CHECK(attr_name, NULL, "HDcalloc");
+
+ if(attr_name) {
+ ret = (herr_t)H5Aget_name(attr, (size_t)(attr_name_size + 1), attr_name);
+ CHECK(ret, FAIL, "H5Aget_name");
+ ret = HDstrcmp(attr_name, ATTR_TMP_NAME);
+ VERIFY(ret, 0, "HDstrcmp");
+
+ HDfree(attr_name);
+ attr_name = NULL;
+ } /* end if */
+ } /* end if */
/* Read attribute information immediately, without closing attribute */
ret = H5Aread(attr, H5T_NATIVE_INT, read_data1);
CHECK(ret, FAIL, "H5Aread");
/* Verify values read in */
- for(i=0; i<ATTR1_DIM1; i++)
- if(attr_data1[i]!=read_data1[i])
- TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d, read_data1[%d]=%d\n",__LINE__,i,attr_data1[i],i,read_data1[i]);
+ for(i = 0; i < ATTR1_DIM1; i++)
+ if(attr_data1[i] != read_data1[i])
+ TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d, read_data1[%d]=%d\n", __LINE__, i, attr_data1[i], i, read_data1[i]);
/* Close attribute */
- ret=H5Aclose(attr);
+ ret = H5Aclose(attr);
CHECK(ret, FAIL, "H5Aclose");
/* Open the second attribute again */
- attr2=H5Aopen(dataset, ATTR1A_NAME, H5P_DEFAULT);
+ attr2 = H5Aopen(dataset, ATTR1A_NAME, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Aopen");
/* Verify new attribute name */
attr_name_size = H5Aget_name(attr2, (size_t)0, NULL);
CHECK(attr_name_size, FAIL, "H5Aget_name");
- if(attr_name_size>0)
+ if(attr_name_size > 0) {
attr_name = (char*)HDcalloc((size_t)(attr_name_size+1), sizeof(char));
-
- ret=(herr_t)H5Aget_name(attr2, (size_t)(attr_name_size+1), attr_name);
- CHECK(ret, FAIL, "H5Aget_name");
- ret=HDstrcmp(attr_name, ATTR1A_NAME);
- VERIFY(ret, 0, "HDstrcmp");
-
- if(attr_name)
- HDfree(attr_name);
+ CHECK(attr_name, NULL, "HDcalloc");
+
+ if(attr_name) {
+ ret = (herr_t)H5Aget_name(attr2, (size_t)(attr_name_size + 1), attr_name);
+ CHECK(ret, FAIL, "H5Aget_name");
+ ret = HDstrcmp(attr_name, ATTR1A_NAME);
+ VERIFY(ret, 0, "HDstrcmp");
+
+ HDfree(attr_name);
+ attr_name = NULL;
+ } /* end if */
+ } /* end if */
/* Read attribute information immediately, without closing attribute */
- ret=H5Aread(attr2,H5T_NATIVE_INT,read_data1);
+ ret = H5Aread(attr2, H5T_NATIVE_INT, read_data1);
CHECK(ret, FAIL, "H5Aread");
/* Verify values read in */
- for(i=0; i<ATTR1_DIM1; i++)
- if(attr_data1a[i]!=read_data1[i])
- TestErrPrintf("%d: attribute data different: attr_data1a[%d]=%d, read_data1[%d]=%d\n",__LINE__,i,attr_data1a[i],i,read_data1[i]);
+ for(i = 0; i < ATTR1_DIM1; i++)
+ if(attr_data1a[i] != read_data1[i])
+ TestErrPrintf("%d: attribute data different: attr_data1a[%d]=%d, read_data1[%d]=%d\n", __LINE__, i, attr_data1a[i], i, read_data1[i]);
/* Close attribute */
- ret=H5Aclose(attr2);
+ ret = H5Aclose(attr2);
CHECK(ret, FAIL, "H5Aclose");
ret = H5Sclose(sid1);
@@ -1539,7 +1547,7 @@ test_attr_delete(hid_t fapl)
CHECK(attr, FAIL, "H5Aopen_by_idx");
/* Verify Name */
- name_len = H5Aget_name(attr, (size_t)ATTR_NAME_LEN,attr_name);
+ name_len = H5Aget_name(attr, (size_t)ATTR_NAME_LEN, attr_name);
VERIFY(name_len, HDstrlen(ATTR1_NAME), "H5Aget_name");
if(HDstrcmp(attr_name, ATTR1_NAME))
TestErrPrintf("attribute name different: attr_name=%s, should be %s\n",attr_name,ATTR1_NAME);
@@ -1555,7 +1563,7 @@ test_attr_delete(hid_t fapl)
/* Verify Name */
name_len = H5Aget_name(attr, (size_t)ATTR_NAME_LEN, attr_name);
VERIFY(name_len, HDstrlen(ATTR3_NAME), "H5Aget_name");
- if(HDstrcmp(attr_name,ATTR3_NAME))
+ if(HDstrcmp(attr_name, ATTR3_NAME))
TestErrPrintf("attribute name different: attr_name=%s, should be %s\n",attr_name,ATTR3_NAME);
/* Close attribute */