diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2010-01-15 03:58:09 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2010-01-15 03:58:09 (GMT) |
commit | bee73cf0aa33d94114d69cf6d4a94aa9c424ae8e (patch) | |
tree | 710d93ccf15a48dd1ff9108e07ad06808ff8f89f | |
parent | ccd0afac9b00aa2683ff72893c9c0d026f74f5c9 (diff) | |
parent | 8984d662ed849e86fa3384bd35ccc13ac34e7495 (diff) | |
download | hdf5-bee73cf0aa33d94114d69cf6d4a94aa9c424ae8e.zip hdf5-bee73cf0aa33d94114d69cf6d4a94aa9c424ae8e.tar.gz hdf5-bee73cf0aa33d94114d69cf6d4a94aa9c424ae8e.tar.bz2 |
[svn-r18110] Description:
Bring r18109 from trunk to 1.8 branch:
Bring r18076-18096 from hdf5_1_8_coverity branch to trunk:
r18076:
Correct Coverity issue #1 by removing dead code
r18077:
Fix coverity item 142. When an error occurred while copying a linked list in
H5S_point_copy, the library would not free the partially allocated list. Added
code to free the list in this case.
r18078:
Correct Coverity issue #2 by removing impossible to reach code.
r18079:
Correct #3 by removing impossible to reach code.
r18080:
Correct Coverity issue #4 by removing impossible to reach code.
r18081:
fix coverity 26 , check (dblik->parent) before calls H5HF_man_iblock_detach().
r18082:
Fixed coverity issues 321 and 316.
321: freed sm_buf in error handling to remove resource leak.
Also set sm_buf to NULL after other instances in which
it is freed to prevent double free.
316: initialized nmembs to 0.
r18083:
Correct Coverity issue #6 by removing debugging knob from error reporting code.
r18084:
Fix coverity item 269 + others. When a error occurred in a function using the
h5tools error framework, the "past_catch" variable would not be set to true
because that statement was before the label that goto jumped to. This could
cause a failure in the cleanup section to go back to the start of the section,
freeing variables twice, etc.
Moved the label infront of past_catch=TRUE.
r18085:
fixed coverity #27, check if (heap) before use heap->obj....
r18086:
fixed coverity #28, check curr_span not null before use it at if(curr_span &&
(io_bytes_left==0 || curr_seq>=maxseq))
r18087:
Correct Coverity issue #7 by cleaning up correctly on error
r18088:
Correct Coverity #8 by removing unchanged variable checking code.
r18089:
Correct Coverity issue #9 - remove impossible to reach code.
r18090:
Correct Coverity issue #11 by removing impossible to reach code. Also clean
up some minor style issues.
r18091:
Fix coverity items 314 and 318. Changed the improper assertion of the return
value of a library function to a check, and a return(void) on failure.
r18092:
Fix coverity item 70. Changed the improper assertion of the return value of a
library function to a check, and a return(void) on failure.
r18093:
Correct Coverity issue #12 by removing dead code.
r18094:
Correct Coverity issue #16 by removing debugging code.
r18095:
Fixed coverity issue # 271.
Removed redundant checking and freeing of sm_buf1 and sm_buf2.
r18096:
Correct Coverity issue #17 by refactoring test to remove dead code.
Also, removed previous "coverity" statements in comments, we'll review
those issues again and see if we can figure them out, now that we have more
experience with Coverity.
Tested on:
Mac OS X/32 10.6.2 (amazon) debug & prod
-rw-r--r-- | src/H5Dchunk.c | 1 | ||||
-rw-r--r-- | src/H5FDfamily.c | 1 | ||||
-rw-r--r-- | src/H5HFdblock.c | 10 | ||||
-rw-r--r-- | src/H5HFhdr.c | 4 | ||||
-rw-r--r-- | src/H5HFsection.c | 18 | ||||
-rw-r--r-- | src/H5HG.c | 91 | ||||
-rw-r--r-- | src/H5Oainfo.c | 8 | ||||
-rw-r--r-- | src/H5Oattr.c | 2 | ||||
-rw-r--r-- | src/H5Olayout.c | 2 | ||||
-rw-r--r-- | src/H5Olink.c | 10 | ||||
-rw-r--r-- | src/H5Omessage.c | 9 | ||||
-rw-r--r-- | src/H5Shyper.c | 1 | ||||
-rw-r--r-- | src/H5Spoint.c | 194 | ||||
-rw-r--r-- | src/H5Znbit.c | 71 | ||||
-rw-r--r-- | test/cache.c | 48 | ||||
-rw-r--r-- | test/cache_api.c | 115 | ||||
-rw-r--r-- | test/cache_common.c | 43 | ||||
-rw-r--r-- | test/dt_arith.c | 229 | ||||
-rw-r--r-- | tools/h5dump/h5dump.c | 18 | ||||
-rw-r--r-- | tools/lib/h5diff_dset.c | 5 | ||||
-rw-r--r-- | tools/lib/h5tools.c | 11 | ||||
-rw-r--r-- | tools/lib/h5tools_error.h | 2 |
22 files changed, 340 insertions, 553 deletions
diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index 67c6b2f..6616ce7 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -2431,7 +2431,6 @@ H5D_chunk_flush_entry(const H5D_t *dset, hid_t dxpl_id, const H5D_dxpl_cache_t * done: /* Free the temp buffer only if it's different than the entry chunk */ if(buf != ent->chunk) - /* coverity["double_free"] */ H5MM_xfree(buf); /* diff --git a/src/H5FDfamily.c b/src/H5FDfamily.c index 87e5e84..3c25426 100644 --- a/src/H5FDfamily.c +++ b/src/H5FDfamily.c @@ -821,7 +821,6 @@ H5FD_family_open(const char *name, unsigned flags, hid_t fapl_id, H5FD_t **x; HDassert(n > 0); - /* coverity["freed_arg"] */ if(NULL == (x = (H5FD_t **)H5MM_realloc(file->memb, n * sizeof(H5FD_t *)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to reallocate members") file->amembs = n; diff --git a/src/H5HFdblock.c b/src/H5HFdblock.c index 8c4c5c8..2716554 100644 --- a/src/H5HFdblock.c +++ b/src/H5HFdblock.c @@ -299,10 +299,12 @@ H5HF_man_dblock_destroy(H5HF_hdr_t *hdr, hid_t dxpl_id, H5HF_direct_t *dblock, #endif /* 0 */ /* Detach from parent indirect block */ - if(H5HF_man_iblock_detach(dblock->parent, dxpl_id, dblock->par_entry) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTATTACH, FAIL, "can't detach from parent indirect block") - dblock->parent = NULL; - dblock->par_entry = 0; + if(dblock->parent) { + if(H5HF_man_iblock_detach(dblock->parent, dxpl_id, dblock->par_entry) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTATTACH, FAIL, "can't detach from parent indirect block"); + dblock->parent = NULL; + dblock->par_entry = 0; + } /* end if */ } /* end else */ /* Indicate that the indirect block should be deleted & file space freed */ diff --git a/src/H5HFhdr.c b/src/H5HFhdr.c index db0093e..0b4936d 100644 --- a/src/H5HFhdr.c +++ b/src/H5HFhdr.c @@ -132,10 +132,6 @@ H5HF_hdr_alloc(H5F_t *f) ret_value = hdr; done: - if(!ret_value && hdr) - if(H5HF_hdr_free(hdr) < 0) - HDONE_ERROR(H5E_HEAP, H5E_CANTRELEASE, NULL, "unable to release fractal heap header") - FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_hdr_alloc() */ diff --git a/src/H5HFsection.c b/src/H5HFsection.c index 152f15a..102dc7c 100644 --- a/src/H5HFsection.c +++ b/src/H5HFsection.c @@ -490,7 +490,6 @@ H5HF_sect_single_new(hsize_t sect_off, size_t sect_size, H5HF_indirect_t *parent, unsigned par_entry) { H5HF_free_section_t *sect = NULL; /* 'Single' free space section to add */ - hbool_t par_incr = FALSE; /* Indicate that parent iblock has been incremented */ H5HF_free_section_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5HF_sect_single_new) @@ -509,7 +508,6 @@ H5HF_sect_single_new(hsize_t sect_off, size_t sect_size, if(sect->u.single.parent) { if(H5HF_iblock_incr(sect->u.single.parent) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, NULL, "can't increment reference count on shared indirect block") - par_incr = TRUE; } /* end if */ sect->u.single.par_entry = par_entry; @@ -518,13 +516,6 @@ H5HF_sect_single_new(hsize_t sect_off, size_t sect_size, done: if(!ret_value && sect) { - /* Check if we should decrement parent ref. count */ - if(par_incr) { - HDassert(sect->u.single.parent); - if(H5HF_iblock_decr(sect->u.single.parent) < 0) - HDONE_ERROR(H5E_HEAP, H5E_CANTDEC, NULL, "can't decrement reference count on parent indirect block") - } /* end if */ - /* Release the section */ (void)H5FL_FREE(H5HF_free_section_t, sect); } /* end if */ @@ -2291,7 +2282,6 @@ H5HF_sect_indirect_new(H5HF_hdr_t *hdr, haddr_t sect_off, hsize_t sect_size, unsigned nentries) { H5HF_free_section_t *sect = NULL; /* 'Indirect' free space section to add */ - hbool_t iblock_incr = FALSE; /* Indicate that parent iblock has been incremented */ H5HF_free_section_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5HF_sect_indirect_new) @@ -2314,7 +2304,6 @@ H5HF_sect_indirect_new(H5HF_hdr_t *hdr, haddr_t sect_off, hsize_t sect_size, sect->u.indirect.u.iblock->max_rows; if(H5HF_iblock_incr(sect->u.indirect.u.iblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, NULL, "can't increment reference count on shared indirect block") - iblock_incr = TRUE; } /* end if */ else { sect->u.indirect.u.iblock_off = iblock_off; @@ -2338,13 +2327,8 @@ H5HF_sect_indirect_new(H5HF_hdr_t *hdr, haddr_t sect_off, hsize_t sect_size, done: if(!ret_value && sect) { - /* Check if we should decrement parent ref. count */ - if(iblock_incr) - if(H5HF_iblock_decr(sect->u.indirect.u.iblock) < 0) - HDONE_ERROR(H5E_HEAP, H5E_CANTDEC, NULL, "can't decrement reference count on shared indirect block") - /* Release the section */ - (void)H5FL_FREE(H5HF_free_section_t, sect); + sect = H5FL_FREE(H5HF_free_section_t, sect); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) @@ -140,31 +140,28 @@ H5FL_BLK_DEFINE(gheap_chunk); *------------------------------------------------------------------------- */ static haddr_t -H5HG_create (H5F_t *f, hid_t dxpl_id, size_t size) +H5HG_create(H5F_t *f, hid_t dxpl_id, size_t size) { H5HG_heap_t *heap = NULL; uint8_t *p = NULL; haddr_t addr; size_t n; - haddr_t ret_value; /* Return value */ + haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5HG_create) /* Check args */ - assert (f); - if (size<H5HG_MINSIZE) + HDassert(f); + if(size < H5HG_MINSIZE) size = H5HG_MINSIZE; size = H5HG_ALIGN(size); /* Create it */ - H5_CHECK_OVERFLOW(size,size_t,hsize_t); - if ( HADDR_UNDEF== - (addr=H5MF_alloc(f, H5FD_MEM_GHEAP, dxpl_id, (hsize_t)size))) - HGOTO_ERROR (H5E_HEAP, H5E_CANTINIT, HADDR_UNDEF, \ - "unable to allocate file space for global heap"); - if (NULL==(heap = H5FL_MALLOC (H5HG_heap_t))) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, HADDR_UNDEF, \ - "memory allocation failed"); + H5_CHECK_OVERFLOW(size, size_t, hsize_t); + if(HADDR_UNDEF == (addr = H5MF_alloc(f, H5FD_MEM_GHEAP, dxpl_id, (hsize_t)size))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, HADDR_UNDEF, "unable to allocate file space for global heap") + if(NULL == (heap = H5FL_MALLOC(H5HG_heap_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, HADDR_UNDEF, "memory allocation failed") heap->addr = addr; heap->size = size; @@ -185,14 +182,14 @@ HDmemset(heap->chunk, 0, size); *p++ = 0; /*reserved*/ *p++ = 0; /*reserved*/ *p++ = 0; /*reserved*/ - H5F_ENCODE_LENGTH (f, p, size); + H5F_ENCODE_LENGTH(f, p, size); /* * Padding so free space object is aligned. If malloc returned memory * which was always at least H5HG_ALIGNMENT aligned then we could just * align the pointer, but this might not be the case. */ - n = H5HG_ALIGN(p-heap->chunk) - (p-heap->chunk); + n = H5HG_ALIGN(p - heap->chunk) - (p - heap->chunk); #ifdef OLD_WAY /* Don't bother zeroing out the rest of the info in the heap -QAK */ HDmemset(p, 0, n); @@ -207,7 +204,7 @@ HDmemset(heap->chunk, 0, size); UINT16ENCODE(p, 0); /*object ID*/ UINT16ENCODE(p, 0); /*reference count*/ UINT32ENCODE(p, 0); /*reserved*/ - H5F_ENCODE_LENGTH (f, p, heap->obj[0].size); + H5F_ENCODE_LENGTH(f, p, heap->obj[0].size); #ifdef OLD_WAY /* Don't bother zeroing out the rest of the info in the heap -QAK */ HDmemset (p, 0, (size_t)((heap->chunk+heap->size) - p)); @@ -226,7 +223,7 @@ HDmemset(heap->chunk, 0, size); MIN(f->shared->ncwfs, H5HG_NCWFS - 1) * sizeof(H5HG_heap_t *)); f->shared->cwfs[0] = heap; f->shared->ncwfs = MIN(H5HG_NCWFS, f->shared->ncwfs+1); - } + } /* end else */ /* Add the heap to the cache */ if (H5AC_set (f, dxpl_id, H5AC_GHEAP, addr, heap, H5AC__NO_FLAGS_SET)<0) @@ -236,9 +233,20 @@ HDmemset(heap->chunk, 0, size); ret_value = addr; done: - if(!(H5F_addr_defined(addr)) && heap) - if(H5HG_dest(f, heap) < 0) - HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, HADDR_UNDEF, "unable to destroy global heap collection") + /* Cleanup on error */ + if(!H5F_addr_defined(ret_value)) { + if(H5F_addr_defined(addr)) { + /* Release the space on disk */ + if(H5MF_xfree(f, H5FD_MEM_GHEAP, dxpl_id, addr, (hsize_t)size) < 0) + HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, HADDR_UNDEF, "unable to free global heap") + + /* Check if the heap object was allocated */ + if(heap) + /* Destroy the heap object */ + if(H5HG_dest(f, heap) < 0) + HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, HADDR_UNDEF, "unable to destroy global heap collection") + } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(ret_value); } /* H5HG_create() */ @@ -705,54 +713,47 @@ done: * Programmer: Robb Matzke * Monday, March 30, 1998 * - * Modifications: - * - * John Mainzer - 6/8/05 - * Modified function to use the dirtied parameter of - * H5AC_unprotect() instead of modifying the is_dirty - * field of the cache info. - * *------------------------------------------------------------------------- */ int -H5HG_link (H5F_t *f, hid_t dxpl_id, const H5HG_t *hobj, int adjust) +H5HG_link(H5F_t *f, hid_t dxpl_id, const H5HG_t *hobj, int adjust) { H5HG_heap_t *heap = NULL; unsigned heap_flags = H5AC__NO_FLAGS_SET; int ret_value; /* Return value */ - FUNC_ENTER_NOAPI(H5HG_link, FAIL); + FUNC_ENTER_NOAPI(H5HG_link, FAIL) /* Check args */ - assert (f); - assert (hobj); - if (0==(f->intent & H5F_ACC_RDWR)) + HDassert(f); + HDassert(hobj); + if(0 == (f->intent & H5F_ACC_RDWR)) HGOTO_ERROR(H5E_HEAP, H5E_WRITEERROR, FAIL, "no write intent on file") - if(adjust!=0) { - /* Load the heap */ - if (NULL == (heap = (H5HG_heap_t *)H5AC_protect(f, dxpl_id, H5AC_GHEAP, hobj->addr, NULL, NULL, H5AC_WRITE))) - HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load heap") - - assert (hobj->idx<heap->nused); - assert (heap->obj[hobj->idx].begin); - if (heap->obj[hobj->idx].nrefs+adjust<0) - HGOTO_ERROR (H5E_HEAP, H5E_BADRANGE, FAIL, "new link count would be out of range") - if (heap->obj[hobj->idx].nrefs+adjust>H5HG_MAXLINK) - HGOTO_ERROR (H5E_HEAP, H5E_BADVALUE, FAIL, "new link count would be out of range") + /* Load the heap */ + if(NULL == (heap = (H5HG_heap_t *)H5AC_protect(f, dxpl_id, H5AC_GHEAP, hobj->addr, NULL, NULL, H5AC_WRITE))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load heap") + + if(adjust != 0) { + HDassert(hobj->idx < heap->nused); + HDassert(heap->obj[hobj->idx].begin); + if((heap->obj[hobj->idx].nrefs + adjust) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, FAIL, "new link count would be out of range") + if((heap->obj[hobj->idx].nrefs + adjust) > H5HG_MAXLINK) + HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, FAIL, "new link count would be out of range") heap->obj[hobj->idx].nrefs += adjust; heap_flags |= H5AC__DIRTIED_FLAG; } /* end if */ /* Set return value */ - ret_value=heap->obj[hobj->idx].nrefs; + ret_value = heap->obj[hobj->idx].nrefs; done: if(heap && H5AC_unprotect(f, dxpl_id, H5AC_GHEAP, hobj->addr, heap, heap_flags) < 0) HDONE_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release object header") - FUNC_LEAVE_NOAPI(ret_value); -} + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HG_link() */ /*------------------------------------------------------------------------- diff --git a/src/H5Oainfo.c b/src/H5Oainfo.c index e61d899..0984cd4 100644 --- a/src/H5Oainfo.c +++ b/src/H5Oainfo.c @@ -431,17 +431,17 @@ H5O_ainfo_copy_file(H5F_t *file_src, void *mesg_src, H5F_t *file_dst, if(H5A_dense_create(file_dst, dxpl_id, ainfo_dst) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to create dense storage for attributes") - if ( (H5A_dense_copy_file_all(file_src, ainfo_src, file_dst, ainfo_dst, recompute_size, cpy_info, dxpl_id)) <0) + if((H5A_dense_copy_file_all(file_src, ainfo_src, file_dst, ainfo_dst, recompute_size, cpy_info, dxpl_id)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to create dense storage for attributes") - } + } /* end if */ /* Set return value */ ret_value = ainfo_dst; done: /* Release destination attribute information on failure */ - if(ret_value == NULL && ainfo_dst != NULL) - (void)H5FL_FREE(H5O_ainfo_t, ainfo_dst); + if(!ret_value && ainfo_dst) + ainfo_dst = H5FL_FREE(H5O_ainfo_t, ainfo_dst); FUNC_LEAVE_NOAPI(ret_value) } /* H5O_ainfo_copy_file() */ diff --git a/src/H5Oattr.c b/src/H5Oattr.c index ad068ad..4d8b17a 100644 --- a/src/H5Oattr.c +++ b/src/H5Oattr.c @@ -668,7 +668,7 @@ H5O_attr_copy_file(H5F_t *file_src, const H5O_msg_class_t UNUSED *mesg_type, if(H5T_set_loc(((H5A_t *)native_src)->shared->dt, file_src, H5T_LOC_DISK) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, NULL, "invalid datatype location") - if ( NULL == (ret_value=H5A_attr_copy_file((H5A_t *)native_src, file_dst, recompute_size, cpy_info, dxpl_id))) + if(NULL == (ret_value = H5A_attr_copy_file((H5A_t *)native_src, file_dst, recompute_size, cpy_info, dxpl_id))) HGOTO_ERROR(H5E_ATTR, H5E_CANTCOPY, NULL, "can't copy attribute") done: diff --git a/src/H5Olayout.c b/src/H5Olayout.c index ebae1fb..6d20ca9 100644 --- a/src/H5Olayout.c +++ b/src/H5Olayout.c @@ -646,7 +646,7 @@ H5O_layout_copy_file(H5F_t *file_src, void *mesg_src, H5F_t *file_dst, done: if(!ret_value) if(layout_dst) - (void)H5FL_FREE(H5O_layout_t, layout_dst); + layout_dst = H5FL_FREE(H5O_layout_t, layout_dst); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_layout_copy_file() */ diff --git a/src/H5Olink.c b/src/H5Olink.c index ffe80e7..4ddfbf6 100644 --- a/src/H5Olink.c +++ b/src/H5Olink.c @@ -705,7 +705,6 @@ H5O_link_copy_file(H5F_t UNUSED *file_src, void *native_src, H5F_t UNUSED *file_ hid_t UNUSED dxpl_id) { H5O_link_t *link_src = (H5O_link_t *)native_src; - H5O_link_t *link_dst = NULL; void *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5O_link_copy_file) @@ -721,17 +720,10 @@ H5O_link_copy_file(H5F_t UNUSED *file_src, void *native_src, H5F_t UNUSED *file_ /* Allocate "blank" link for destination */ /* (values will be filled in during 'post copy' operation) */ - if(NULL == (link_dst = H5FL_CALLOC(H5O_link_t))) + if(NULL == (ret_value = H5FL_CALLOC(H5O_link_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - /* Set return value */ - ret_value = link_dst; - done: - if(!ret_value) - if(link_dst) - H5O_link_free(link_dst); - FUNC_LEAVE_NOAPI(ret_value) } /* H5O_link_copy_file() */ diff --git a/src/H5Omessage.c b/src/H5Omessage.c index 4baa262..28be283 100644 --- a/src/H5Omessage.c +++ b/src/H5Omessage.c @@ -1859,7 +1859,6 @@ H5O_msg_copy_file(const H5O_msg_class_t *type, H5F_t *file_src, void *native_src, H5F_t *file_dst, hbool_t *recompute_size, H5O_copy_t *cpy_info, void *udata, hid_t dxpl_id) { - void *native_mesg = NULL; void *ret_value; FUNC_ENTER_NOAPI_NOINIT(H5O_msg_copy_file) @@ -1876,16 +1875,10 @@ H5O_msg_copy_file(const H5O_msg_class_t *type, H5F_t *file_src, /* The copy_file callback will return an H5O_shared_t only if the message * to be copied is a committed datatype. */ - if(NULL == (native_mesg = (type->copy_file)(file_src, native_src, file_dst, recompute_size, cpy_info, udata, dxpl_id))) + if(NULL == (ret_value = (type->copy_file)(file_src, native_src, file_dst, recompute_size, cpy_info, udata, dxpl_id))) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, NULL, "unable to copy object header message to file") - /* Set return value */ - ret_value = native_mesg; - done: - if(NULL == ret_value && native_mesg) - H5O_msg_free(type->id, native_mesg); - FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_msg_copy_file() */ diff --git a/src/H5Shyper.c b/src/H5Shyper.c index f55135f..f86a743 100644 --- a/src/H5Shyper.c +++ b/src/H5Shyper.c @@ -7546,6 +7546,7 @@ partial_done: /* Yes, goto's are evil, so sue me... :-) */ /* Check if we are done */ if(io_bytes_left==0 || curr_seq>=maxseq) { + HDassert(curr_span); abs_arr[fast_dim]=curr_span->low+(span_size/elem_size); /* Check if we are still within the span */ diff --git a/src/H5Spoint.c b/src/H5Spoint.c index 84b427e..5f4c74d 100644 --- a/src/H5Spoint.c +++ b/src/H5Spoint.c @@ -119,11 +119,11 @@ H5FL_DEFINE_STATIC(H5S_pnt_list_t); herr_t H5S_point_iter_init(H5S_sel_iter_t *iter, const H5S_t *space) { - FUNC_ENTER_NOAPI_NOFUNC(H5S_point_iter_init); + FUNC_ENTER_NOAPI_NOFUNC(H5S_point_iter_init) /* Check args */ - assert (space && H5S_SEL_POINTS==H5S_GET_SELECT_TYPE(space)); - assert (iter); + HDassert(space && H5S_SEL_POINTS==H5S_GET_SELECT_TYPE(space)); + HDassert(iter); /* Initialize the number of points to iterate over */ iter->elmt_left=space->select.num_elem; @@ -134,7 +134,7 @@ H5S_point_iter_init(H5S_sel_iter_t *iter, const H5S_t *space) /* Initialize type of selection iterator */ iter->type=H5S_sel_iter_point; - FUNC_LEAVE_NOAPI(SUCCEED); + FUNC_LEAVE_NOAPI(SUCCEED) } /* H5S_point_iter_init() */ @@ -156,16 +156,16 @@ H5S_point_iter_init(H5S_sel_iter_t *iter, const H5S_t *space) static herr_t H5S_point_iter_coords (const H5S_sel_iter_t *iter, hsize_t *coords) { - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_point_iter_coords); + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_point_iter_coords) /* Check args */ - assert (iter); - assert (coords); + HDassert(iter); + HDassert(coords); /* Copy the offset of the current point */ HDmemcpy(coords,iter->u.pnt.curr->pnt,sizeof(hsize_t)*iter->rank); - FUNC_LEAVE_NOAPI(SUCCEED); + FUNC_LEAVE_NOAPI(SUCCEED) } /* H5S_point_iter_coords() */ @@ -187,18 +187,18 @@ H5S_point_iter_coords (const H5S_sel_iter_t *iter, hsize_t *coords) static herr_t H5S_point_iter_block (const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end) { - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_point_iter_block); + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_point_iter_block) /* Check args */ - assert (iter); - assert (start); - assert (end); + HDassert(iter); + HDassert(start); + HDassert(end); /* Copy the current point as a block */ HDmemcpy(start,iter->u.pnt.curr->pnt,sizeof(hsize_t)*iter->rank); HDmemcpy(end,iter->u.pnt.curr->pnt,sizeof(hsize_t)*iter->rank); - FUNC_LEAVE_NOAPI(SUCCEED); + FUNC_LEAVE_NOAPI(SUCCEED) } /* H5S_point_iter_block() */ @@ -219,12 +219,12 @@ H5S_point_iter_block (const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end) static hsize_t H5S_point_iter_nelmts (const H5S_sel_iter_t *iter) { - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_point_iter_nelmts); + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_point_iter_nelmts) /* Check args */ - assert (iter); + HDassert(iter); - FUNC_LEAVE_NOAPI(iter->elmt_left); + FUNC_LEAVE_NOAPI(iter->elmt_left) } /* H5S_point_iter_nelmts() */ @@ -250,17 +250,17 @@ H5S_point_iter_has_next_block(const H5S_sel_iter_t *iter) { htri_t ret_value=TRUE; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_point_iter_has_next_block); + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_point_iter_has_next_block) /* Check args */ - assert (iter); + HDassert(iter); /* Check if there is another point in the list */ if(iter->u.pnt.curr->next==NULL) HGOTO_DONE(FALSE); done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* H5S_point_iter_has_next_block() */ @@ -285,11 +285,11 @@ done: static herr_t H5S_point_iter_next(H5S_sel_iter_t *iter, size_t nelem) { - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_point_iter_next); + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_point_iter_next) /* Check args */ - assert (iter); - assert (nelem>0); + HDassert(iter); + HDassert(nelem>0); /* Increment the iterator */ while(nelem>0) { @@ -297,7 +297,7 @@ H5S_point_iter_next(H5S_sel_iter_t *iter, size_t nelem) nelem--; } /* end while */ - FUNC_LEAVE_NOAPI(SUCCEED); + FUNC_LEAVE_NOAPI(SUCCEED) } /* H5S_point_iter_next() */ @@ -321,15 +321,15 @@ H5S_point_iter_next(H5S_sel_iter_t *iter, size_t nelem) static herr_t H5S_point_iter_next_block(H5S_sel_iter_t *iter) { - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_point_iter_next_block); + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_point_iter_next_block) /* Check args */ - assert (iter); + HDassert(iter); /* Increment the iterator */ iter->u.pnt.curr=iter->u.pnt.curr->next; - FUNC_LEAVE_NOAPI(SUCCEED); + FUNC_LEAVE_NOAPI(SUCCEED) } /* H5S_point_iter_next_block() */ @@ -353,12 +353,12 @@ H5S_point_iter_next_block(H5S_sel_iter_t *iter) static herr_t H5S_point_iter_release (H5S_sel_iter_t UNUSED * iter) { - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_point_iter_release); + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_point_iter_release) /* Check args */ - assert (iter); + HDassert(iter); - FUNC_LEAVE_NOAPI(SUCCEED); + FUNC_LEAVE_NOAPI(SUCCEED) } /* H5S_point_iter_release() */ @@ -471,10 +471,10 @@ H5S_point_release (H5S_t *space) { H5S_pnt_node_t *curr, *next; /* Point selection nodes */ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_point_release); + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_point_release) /* Check args */ - assert (space); + HDassert(space); /* Delete all the nodes from the list */ curr=space->select.sel_info.pnt_lst->head; @@ -492,7 +492,7 @@ H5S_point_release (H5S_t *space) /* Reset the number of elements in the selection */ space->select.num_elem=0; - FUNC_LEAVE_NOAPI(SUCCEED); + FUNC_LEAVE_NOAPI(SUCCEED) } /* H5S_point_release() */ @@ -584,42 +584,60 @@ done: static herr_t H5S_point_copy(H5S_t *dst, const H5S_t *src, hbool_t UNUSED share_selection) { - H5S_pnt_node_t *curr, *new_node, *new_head; /* Point information nodes */ - herr_t ret_value=SUCCEED; /* return value */ + H5S_pnt_node_t *curr, *new_node, *new_tail; /* Point information nodes */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT(H5S_point_copy); + FUNC_ENTER_NOAPI_NOINIT(H5S_point_copy) - assert(src); - assert(dst); + HDassert(src); + HDassert(dst); /* Allocate room for the head of the point list */ - if((dst->select.sel_info.pnt_lst=H5FL_MALLOC(H5S_pnt_list_t))==NULL) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate point node"); + if(NULL == (dst->select.sel_info.pnt_lst = H5FL_MALLOC(H5S_pnt_list_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate point node") - curr=src->select.sel_info.pnt_lst->head; - new_head=NULL; - while(curr!=NULL) { - /* Create each point */ + curr = src->select.sel_info.pnt_lst->head; + new_tail = NULL; + while(curr) { + /* Create new point */ if(NULL == (new_node = H5FL_MALLOC(H5S_pnt_node_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate point node"); - if((new_node->pnt = (hsize_t *)H5MM_malloc(src->extent.rank*sizeof(hsize_t)))==NULL) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate coordinate information"); - HDmemcpy(new_node->pnt, curr->pnt, (src->extent.rank * sizeof(hsize_t))); + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate point node") new_node->next = NULL; + if(NULL == (new_node->pnt = (hsize_t *)H5MM_malloc(src->extent.rank*sizeof(hsize_t)))) { + new_node = H5FL_FREE(H5S_pnt_node_t, new_node); + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate coordinate information") + } /* end if */ + + /* Copy over the point's coordinates */ + HDmemcpy(new_node->pnt, curr->pnt, (src->extent.rank * sizeof(hsize_t))); /* Keep the order the same when copying */ - if(new_head==NULL) - new_head=dst->select.sel_info.pnt_lst->head=new_node; + if(NULL == new_tail) + new_tail = dst->select.sel_info.pnt_lst->head = new_node; else { - new_head->next=new_node; - new_head=new_node; + new_tail->next = new_node; + new_tail = new_node; } /* end else */ - curr=curr->next; + curr = curr->next; } /* end while */ done: - FUNC_LEAVE_NOAPI(ret_value); + if(ret_value < 0) { + /* Traverse the (incomplete?) dst list, freeing all memory */ + curr = dst->select.sel_info.pnt_lst->head; + while(curr) { + H5S_pnt_node_t *tmp_node = curr; + + curr->pnt = H5MM_xfree(curr->pnt); + curr = curr->next; + tmp_node = H5FL_FREE(H5S_pnt_node_t, tmp_node); + } /* end while */ + + dst->select.sel_info.pnt_lst = H5FL_FREE(H5S_pnt_list_t, dst->select.sel_info.pnt_lst); + } /* end if */ + + FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_point_copy() */ @@ -650,9 +668,9 @@ H5S_point_is_valid (const H5S_t *space) unsigned u; /* Counter */ htri_t ret_value=TRUE; /* return value */ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_point_is_valid); + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_point_is_valid) - assert(space); + HDassert(space); /* Check each point to determine whether selection+offset is within extent */ curr = space->select.sel_info.pnt_lst->head; @@ -670,7 +688,7 @@ H5S_point_is_valid (const H5S_t *space) } /* end while */ done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_point_is_valid() */ @@ -738,9 +756,9 @@ H5S_point_serial_size (const H5S_t *space) H5S_pnt_node_t *curr; /* Point information nodes */ hssize_t ret_value; /* return value */ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_point_serial_size); + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_point_serial_size) - assert(space); + HDassert(space); /* Basic number of bytes required to serialize point selection: * <type (4 bytes)> + <version (4 bytes)> + <padding (4 bytes)> + @@ -756,7 +774,7 @@ H5S_point_serial_size (const H5S_t *space) curr=curr->next; } /* end while */ - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_point_serial_size() */ @@ -787,9 +805,9 @@ H5S_point_serialize (const H5S_t *space, uint8_t *buf) uint32_t len=0; /* number of bytes used */ unsigned u; /* local counting variable */ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_point_serialize); + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_point_serialize) - assert(space); + HDassert(space); /* Store the preamble information */ UINT32ENCODE(buf, (uint32_t)H5S_GET_SELECT_TYPE(space)); /* Store the type of selection */ @@ -822,7 +840,7 @@ H5S_point_serialize (const H5S_t *space, uint8_t *buf) /* Encode length */ UINT32ENCODE(lenp, (uint32_t)len); /* Store the length of the extra information */ - FUNC_LEAVE_NOAPI(SUCCEED); + FUNC_LEAVE_NOAPI(SUCCEED) } /* H5S_point_serialize() */ @@ -1168,9 +1186,9 @@ H5S_point_is_contiguous(const H5S_t *space) { htri_t ret_value; /* return value */ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_point_is_contiguous); + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_point_is_contiguous) - assert(space); + HDassert(space); /* One point is definitely contiguous */ if(space->select.num_elem==1) @@ -1178,7 +1196,7 @@ H5S_point_is_contiguous(const H5S_t *space) else /* More than one point might be contiguous, but it's complex to check and we don't need it right now */ ret_value=FALSE; - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* H5S_point_is_contiguous() */ @@ -1205,9 +1223,9 @@ H5S_point_is_single(const H5S_t *space) { htri_t ret_value; /* return value */ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_point_is_single); + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_point_is_single) - assert(space); + HDassert(space); /* One point is definitely 'single' :-) */ if(space->select.num_elem==1) @@ -1215,7 +1233,7 @@ H5S_point_is_single(const H5S_t *space) else ret_value=FALSE; - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* H5S_point_is_single() */ @@ -1245,10 +1263,10 @@ H5S_point_is_regular(const H5S_t *space) { htri_t ret_value; /* return value */ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_point_is_regular); + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_point_is_regular) /* Check args */ - assert(space); + HDassert(space); /* Only simple check for regular points for now... */ if(space->select.num_elem==1) @@ -1256,7 +1274,7 @@ H5S_point_is_regular(const H5S_t *space) else ret_value=FALSE; - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* H5S_point_is_regular() */ @@ -1420,31 +1438,31 @@ H5S_point_get_seq_list(const H5S_t *space, unsigned flags, H5S_sel_iter_t *iter, int i; /* Local index variable */ herr_t ret_value=SUCCEED; /* return value */ - FUNC_ENTER_NOAPI_NOINIT(H5S_point_get_seq_list); + FUNC_ENTER_NOAPI_NOINIT(H5S_point_get_seq_list) /* 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); /* Choose the minimum number of bytes to sequence through */ - H5_CHECK_OVERFLOW(iter->elmt_left,hsize_t,size_t); - start_io_left=io_left=(size_t)MIN(iter->elmt_left,maxelem); + H5_CHECK_OVERFLOW(iter->elmt_left, hsize_t, size_t); + start_io_left = io_left = (size_t)MIN(iter->elmt_left, maxelem); /* Get the dataspace dimensions */ - if ((ndims=H5S_get_simple_extent_dims (space, dims, NULL))<0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to retrieve data space dimensions"); + if((ndims = H5S_get_simple_extent_dims (space, dims, NULL)) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to retrieve data space dimensions") /* Walk through the points in the selection, starting at the current */ /* location in the iterator */ - node=iter->u.pnt.curr; - curr_seq=0; - while(node!=NULL) { + node = iter->u.pnt.curr; + curr_seq = 0; + while(NULL != node) { /* Compute the offset of each selected point in the buffer */ for(i = ndims - 1, acc = iter->elmt_size, loc = 0; i >= 0; i--) { loc += (node->pnt[i] + space->select.offset[i]) * acc; @@ -1507,6 +1525,6 @@ H5S_point_get_seq_list(const H5S_t *space, unsigned flags, H5S_sel_iter_t *iter, *nelem=start_io_left-io_left; done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_point_get_seq_list() */ diff --git a/src/H5Znbit.c b/src/H5Znbit.c index c534a80..8f785a2 100644 --- a/src/H5Znbit.c +++ b/src/H5Znbit.c @@ -138,7 +138,7 @@ H5Z_can_apply_nbit(hid_t UNUSED dcpl_id, hid_t type_id, hid_t UNUSED space_id) FUNC_ENTER_NOAPI(H5Z_can_apply_nbit, FAIL) /* Get datatype */ - if(NULL == (type = H5I_object_verify(type_id, H5I_DATATYPE))) + if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* Get datatype's class, for checking the "datatype class" */ @@ -742,7 +742,7 @@ H5Z_set_local_nbit(hid_t dcpl_id, hid_t type_id, hid_t space_id) FUNC_ENTER_NOAPI(H5Z_set_local_nbit, FAIL) /* Get datatype */ - if(NULL == (type = H5I_object_verify(type_id, H5I_DATATYPE))) + if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* Get datatype's class */ @@ -781,7 +781,7 @@ H5Z_set_local_nbit(hid_t dcpl_id, hid_t type_id, hid_t space_id) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "datatype needs too many nbit parameters") /* Allocate memory space for cd_values[] */ - if(NULL == (cd_values = H5MM_malloc(cd_values_actual_nparms * sizeof(unsigned)))) + if(NULL == (cd_values = (unsigned *)H5MM_malloc(cd_values_actual_nparms * sizeof(unsigned)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for cd_values[]") /* Get the plist structure */ @@ -862,77 +862,70 @@ done: * Programmer: Xiaowen Wu * Friday, January 21, 2005 * - * Modifications: - * *------------------------------------------------------------------------- */ static size_t H5Z_filter_nbit(unsigned flags, size_t cd_nelmts, const unsigned cd_values[], size_t nbytes, size_t *buf_size, void **buf) { - size_t ret_value = 0; /* return value */ - size_t size_out = 0; /* size of output buffer */ - unsigned d_nelmts = 0; /* number of elements in the chunk */ - unsigned char *outbuf = NULL; /* pointer to new output buffer */ + unsigned char *outbuf; /* pointer to new output buffer */ + size_t size_out = 0; /* size of output buffer */ + unsigned d_nelmts = 0; /* number of elements in the chunk */ + size_t ret_value = 0; /* return value */ FUNC_ENTER_NOAPI(H5Z_filter_nbit, 0) /* check arguments * cd_values[0] stores actual number of parameters in cd_values[] */ - if (cd_nelmts!=cd_values[0]) + if(cd_nelmts != cd_values[0]) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, 0, "invalid nbit aggression level") /* check if need to do nbit compress or decompress * cd_values[1] stores the flag if true indicating no need to compress */ - if (cd_values[1]) { - ret_value = *buf_size; - goto done; - } + if(cd_values[1]) + HGOTO_DONE(*buf_size) /* copy a filter parameter to d_nelmts */ d_nelmts = cd_values[2]; /* input; decompress */ - if (flags & H5Z_FLAG_REVERSE) { + if(flags & H5Z_FLAG_REVERSE) { size_out = d_nelmts * cd_values[4]; /* cd_values[4] stores datatype size */ /* allocate memory space for decompressed buffer */ - if(NULL==(outbuf = H5MM_malloc(size_out))) + if(NULL == (outbuf = (unsigned char *)H5MM_malloc(size_out))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed for nbit decompression") /* decompress the buffer */ - H5Z_nbit_decompress(outbuf, d_nelmts, *buf, cd_values); - } + H5Z_nbit_decompress(outbuf, d_nelmts, (unsigned char *)*buf, cd_values); + } /* end if */ /* output; compress */ else { - assert(nbytes == d_nelmts * cd_values[4]); + HDassert(nbytes == d_nelmts * cd_values[4]); size_out = nbytes; /* allocate memory space for compressed buffer */ - if(NULL==(outbuf = H5MM_malloc(size_out))) + if(NULL == (outbuf = (unsigned char *)H5MM_malloc(size_out))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed for nbit compression") /* compress the buffer, size_out will be changed */ - H5Z_nbit_compress(*buf, d_nelmts, outbuf, &size_out, cd_values); - } + H5Z_nbit_compress((unsigned char *)*buf, d_nelmts, outbuf, &size_out, cd_values); + } /* end else */ /* free the input buffer */ H5MM_xfree(*buf); /* set return values */ *buf = outbuf; - outbuf = NULL; *buf_size = size_out; ret_value = size_out; done: - if(outbuf) - H5MM_xfree(outbuf); FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5Z_filter_nbit() */ /* ======== Nbit Algorithm =============================================== * assume one byte has 8 bit @@ -942,14 +935,17 @@ done: * atomic datatype is treated on byte basis */ -static void H5Z_nbit_next_byte(size_t *j, int *buf_len) +static void +H5Z_nbit_next_byte(size_t *j, int *buf_len) { ++(*j); *buf_len = 8 * sizeof(unsigned char); } -static void H5Z_nbit_decompress_one_byte(unsigned char *data, size_t data_offset, int k, int begin_i, -int end_i, unsigned char *buffer, size_t *j, int *buf_len, parms_atomic p, int datatype_len) +static void +H5Z_nbit_decompress_one_byte(unsigned char *data, size_t data_offset, int k, + int begin_i, int end_i, unsigned char *buffer, size_t *j, int *buf_len, + parms_atomic p, int datatype_len) { int dat_len; /* dat_len is the number of bits to be copied in each data byte */ int uchar_offset; @@ -991,7 +987,8 @@ int end_i, unsigned char *buffer, size_t *j, int *buf_len, parms_atomic p, int d } } -static void H5Z_nbit_decompress_one_nooptype(unsigned char *data, size_t data_offset, +static void +H5Z_nbit_decompress_one_nooptype(unsigned char *data, size_t data_offset, unsigned char *buffer, size_t *j, int *buf_len, unsigned size) { unsigned i; /* index */ @@ -1014,7 +1011,8 @@ static void H5Z_nbit_decompress_one_nooptype(unsigned char *data, size_t data_of } } -static void H5Z_nbit_decompress_one_atomic(unsigned char *data, size_t data_offset, +static void +H5Z_nbit_decompress_one_atomic(unsigned char *data, size_t data_offset, unsigned char *buffer, size_t *j, int *buf_len, parms_atomic p) { /* begin_i: the index of byte having first significant bit @@ -1050,7 +1048,8 @@ static void H5Z_nbit_decompress_one_atomic(unsigned char *data, size_t data_offs } } -static void H5Z_nbit_decompress_one_array(unsigned char *data, size_t data_offset, +static void +H5Z_nbit_decompress_one_array(unsigned char *data, size_t data_offset, unsigned char *buffer, size_t *j, int *buf_len, const unsigned parms[]) { unsigned i, total_size, base_class, base_size, n, begin_index; @@ -1097,7 +1096,8 @@ static void H5Z_nbit_decompress_one_array(unsigned char *data, size_t data_offse } /* end switch */ } -static void H5Z_nbit_decompress_one_compound(unsigned char *data, size_t data_offset, +static void +H5Z_nbit_decompress_one_compound(unsigned char *data, size_t data_offset, unsigned char *buffer, size_t *j, int *buf_len, const unsigned parms[]) { unsigned i, nmembers, member_offset, member_class, size; @@ -1135,7 +1135,8 @@ static void H5Z_nbit_decompress_one_compound(unsigned char *data, size_t data_of } } -static void H5Z_nbit_decompress(unsigned char *data, unsigned d_nelmts, unsigned char *buffer, +static void +H5Z_nbit_decompress(unsigned char *data, unsigned d_nelmts, unsigned char *buffer, const unsigned parms[]) { /* i: index of data, j: index of buffer, @@ -1406,7 +1407,5 @@ static void H5Z_nbit_compress(unsigned char *data, unsigned d_nelmts, unsigned c } break; } /* end switch */ - - *buffer_size = j + 1; /* sometimes is catually j, but to be safe */ } #endif /* H5_HAVE_FILTER_NBIT */ diff --git a/test/cache.c b/test/cache.c index 5e587df..7e204d3 100644 --- a/test/cache.c +++ b/test/cache.c @@ -9227,7 +9227,6 @@ check_flush_cache__flush_op_test(H5C_t * cache_ptr, hbool_t show_progress = FALSE; hbool_t verbose = FALSE; herr_t result; - int target_test = -1; int i; int j; test_entry_t * base_addr; @@ -9238,11 +9237,6 @@ check_flush_cache__flush_op_test(H5C_t * cache_ptr, test_num); #endif - if ( ( target_test > 0 ) && ( test_num != target_test ) ) { - - show_progress = FALSE; - } - if ( show_progress ) { HDfprintf(stdout, "%s:%d:%d: running sanity checks on entry(1).\n", @@ -28667,9 +28661,6 @@ check_auto_cache_resize_aux_fcns(void) if ( pass ) { max_size = 0; - min_clean_size = 0; - cur_size = 0; - cur_num_entries = 0; result = H5C_get_cache_size(cache_ptr, &max_size, NULL, NULL, NULL); @@ -28684,22 +28675,12 @@ check_auto_cache_resize_aux_fcns(void) failure_mssg = "H5C_get_cache_size reports unexpected max_size 3.\n"; - } else if ( ( min_clean_size != 0 ) || - ( cur_size != 0 ) || - ( cur_num_entries != 0 ) ) { - - pass = FALSE; - failure_mssg = "Phantom returns from H5C_get_cache_size?\n"; - } } if ( pass ) { - max_size = 0; min_clean_size = 0; - cur_size = 0; - cur_num_entries = 0; result = H5C_get_cache_size(cache_ptr, NULL, &min_clean_size, NULL, NULL); @@ -28715,22 +28696,12 @@ check_auto_cache_resize_aux_fcns(void) failure_mssg = "H5C_get_cache_size reports unexpected min_clean_size 4.\n"; - } else if ( ( max_size != 0 ) || - ( cur_size != 0 ) || - ( cur_num_entries != 0 ) ) { - - pass = FALSE; - failure_mssg = "Phantom returns from H5C_get_cache_size?\n"; - } } if ( pass ) { - max_size = 0; - min_clean_size = 0; cur_size = 0; - cur_num_entries = 0; result = H5C_get_cache_size(cache_ptr, NULL, NULL, &cur_size, NULL); @@ -28746,21 +28717,11 @@ check_auto_cache_resize_aux_fcns(void) failure_mssg = "H5C_get_cache_size reports unexpected cur_size 5.\n"; - } else if ( ( max_size != 0 ) || - ( min_clean_size != 0 ) || - ( cur_num_entries != 0 ) ) { - - pass = FALSE; - failure_mssg = "Phantom returns from H5C_get_cache_size?\n"; - - } + } } if ( pass ) { - max_size = 0; - min_clean_size = 0; - cur_size = 0; cur_num_entries = 0; result = H5C_get_cache_size(cache_ptr, NULL, NULL, NULL, @@ -28777,13 +28738,6 @@ check_auto_cache_resize_aux_fcns(void) failure_mssg = "H5C_get_cache_size reports unexpected cur_num_entries 2.\n"; - } else if ( ( max_size != 0 ) || - ( min_clean_size != 0 ) || - ( cur_size != 0 ) ) { - - pass = FALSE; - failure_mssg = "Phantom returns from H5C_get_cache_size?\n"; - } } diff --git a/test/cache_api.c b/test/cache_api.c index ad5c823..ee17037 100644 --- a/test/cache_api.c +++ b/test/cache_api.c @@ -1381,7 +1381,6 @@ mdc_api_call_smoke_check(int express_test) const char * fcn_name = "mdc_api_call_smoke_check()"; char filename[512]; hbool_t valid_chunk; - hbool_t report_progress = FALSE; hbool_t dump_hit_rate = FALSE; int64_t min_accesses = 1000; double min_hit_rate = 0.90; @@ -1524,13 +1523,6 @@ mdc_api_call_smoke_check(int express_test) */ /* setup the file name */ - - if ( ( pass ) && ( report_progress ) ) { - - HDfprintf(stdout,"\nSetting up file ... "); - HDfflush(stdout); - } - if ( pass ) { if ( h5_fixname(FILENAME[0], H5P_DEFAULT, filename, sizeof(filename)) @@ -1569,21 +1561,7 @@ mdc_api_call_smoke_check(int express_test) /* verify that the cache is now set to the alternate config */ validate_mdc_config(file_id, &mod_config_1, TRUE, 2); - if ( ( pass ) && ( report_progress ) ) { - - HDfprintf(stdout,"Done.\n"); /* setting up file */ - HDfflush(stdout); - } - - /* create the datasets */ - - if ( ( pass ) && ( report_progress ) ) { - - HDfprintf(stdout,"Creating datasets ... "); - HDfflush(stdout); - } - if ( pass ) { i = 0; @@ -1688,22 +1666,10 @@ mdc_api_call_smoke_check(int express_test) } } - if ( ( pass ) && ( report_progress ) ) { - - HDfprintf(stdout,"Done.\n"); - HDfflush(stdout); - } - /* initialize all datasets on a round robin basis */ i = 0; progress_counter = 0; - if ( ( pass ) && ( report_progress ) ) { - - HDfprintf(stdout, "Initializing datasets "); - HDfflush(stdout); - } - while ( ( pass ) && ( i < DSET_SIZE ) ) { j = 0; @@ -1770,23 +1736,6 @@ mdc_api_call_smoke_check(int express_test) i += CHUNK_SIZE; - if ( ( pass ) && ( report_progress ) ) { - - progress_counter += CHUNK_SIZE; - - if ( progress_counter >= DSET_SIZE / 20 ) { - - progress_counter = 0; - HDfprintf(stdout, "."); - HDfflush(stdout); - } - } - } - - if ( ( pass ) && ( report_progress ) ) { - - HDfprintf(stdout," Done.\n"); /* initializing data sets */ - HDfflush(stdout); } /* set alternate config 2 */ @@ -1803,13 +1752,6 @@ mdc_api_call_smoke_check(int express_test) validate_mdc_config(file_id, &mod_config_2, TRUE, 3); /* do random reads on all datasets */ - - if ( ( pass ) && ( report_progress ) ) { - - HDfprintf(stdout, "Doing random reads on all datasets "); - HDfflush(stdout); - } - n = 0; progress_counter = 0; while ( ( pass ) && ( n < NUM_RANDOM_ACCESSES ) ) @@ -1895,26 +1837,8 @@ mdc_api_call_smoke_check(int express_test) n++; - if ( ( pass ) && ( report_progress ) ) { - - progress_counter++; - - if ( progress_counter >= NUM_RANDOM_ACCESSES / 20 ) { - - progress_counter = 0; - HDfprintf(stdout, "."); - HDfflush(stdout); - } - } - } - - if ( ( pass ) && ( report_progress ) ) { - - HDfprintf(stdout, " Done.\n"); /* random reads on all data sets */ - HDfflush(stdout); } - /* close the file spaces we are done with */ i = 1; while ( ( pass ) && ( i < NUM_DSETS ) ) @@ -1954,13 +1878,6 @@ mdc_api_call_smoke_check(int express_test) validate_mdc_config(file_id, &mod_config_3, TRUE, 4); /* do random reads on data set 0 only */ - - if ( ( pass ) && ( report_progress ) ) { - - HDfprintf(stdout, "Doing random reads on dataset 0 "); - HDfflush(stdout); - } - m = 0; n = 0; progress_counter = 0; @@ -2042,33 +1959,8 @@ mdc_api_call_smoke_check(int express_test) n++; - if ( ( pass ) && ( report_progress ) ) { - - progress_counter++; - - if ( progress_counter >= NUM_RANDOM_ACCESSES / 20 ) { - - progress_counter = 0; - HDfprintf(stdout, "."); - HDfflush(stdout); - } - } - } - - if ( ( pass ) && ( report_progress ) ) { - - HDfprintf(stdout, " Done.\n"); /* random reads data set 0 */ - HDfflush(stdout); - } - - - if ( ( pass ) && ( report_progress ) ) { - - HDfprintf(stdout,"Shutting down ... "); - HDfflush(stdout); } - /* close file space 0 */ if ( pass ) { @@ -2125,13 +2017,6 @@ mdc_api_call_smoke_check(int express_test) } } - if ( ( pass ) && ( report_progress ) ) { - - HDfprintf(stdout,"Done.\n"); /* shutting down */ - HDfflush(stdout); - } - - if ( pass ) { PASSED(); } else { H5_FAILED(); } if ( ! pass ) diff --git a/test/cache_common.c b/test/cache_common.c index 4595d7c..568050a 100644 --- a/test/cache_common.c +++ b/test/cache_common.c @@ -3257,7 +3257,6 @@ unprotect_entry_with_size_change(H5C_t * cache_ptr, hbool_t pin_flag_set; hbool_t unpin_flag_set; hbool_t size_changed_flag_set; - hbool_t verbose = FALSE; test_entry_t * base_addr; test_entry_t * entry_ptr; @@ -3308,39 +3307,25 @@ unprotect_entry_with_size_change(H5C_t * cache_ptr, ( entry_ptr->size != entry_ptr->header.size ) || ( entry_ptr->addr != entry_ptr->header.addr ) ) { - if ( verbose ) { + if ( result < 0 ) + HDfprintf(stdout, "%s: H5C_unprotect() failed.\n", fcn_name); - if ( result < 0 ) { - HDfprintf(stdout, "%s: H5C_unprotect() failed.\n", fcn_name); - } + if ( entry_ptr->header.is_protected ) + HDfprintf(stdout, "%s: entry still protected?!?.\n", fcn_name); - if ( entry_ptr->header.is_protected ) { - HDfprintf(stdout, "%s: entry still protected?!?.\n", - fcn_name); - } + if ( entry_ptr->header.type != &(types[type]) ) + HDfprintf(stdout, "%s: entry has bad type after unprotect.\n", fcn_name); - if ( entry_ptr->header.type != &(types[type]) ) { - HDfprintf(stdout, - "%s: entry has bad type after unprotect.\n", - fcn_name); - } + if ( entry_ptr->size != entry_ptr->header.size ) + HDfprintf(stdout, "%s: bad entry size after unprotect. e/a = %d/%d\n", fcn_name, + (int)(entry_ptr->size), + (int)(entry_ptr->header.size)); - if ( entry_ptr->size != entry_ptr->header.size ) { - HDfprintf(stdout, - "%s: bad entry size after unprotect. e/a = %d/%d\n", - fcn_name, - (int)(entry_ptr->size), - (int)(entry_ptr->header.size)); - } + if ( entry_ptr->addr != entry_ptr->header.addr ) + HDfprintf(stdout, "%s: bad entry addr after unprotect. e/a = 0x%llx/0x%llx\n", fcn_name, + (long long)(entry_ptr->addr), + (long long)(entry_ptr->header.addr)); - if ( entry_ptr->addr != entry_ptr->header.addr ) { - HDfprintf(stdout, - "%s: bad entry addr after unprotect. e/a = 0x%llx/0x%llx\n", - fcn_name, - (long long)(entry_ptr->addr), - (long long)(entry_ptr->header.addr)); - } - } pass = FALSE; failure_mssg = "error in H5C_unprotect()."; diff --git a/test/dt_arith.c b/test/dt_arith.c index 420570a..13cf5ba 100644 --- a/test/dt_arith.c +++ b/test/dt_arith.c @@ -5001,192 +5001,177 @@ run_int_fp_conv(const char *name) static int run_fp_int_conv(const char *name) { +#ifdef H5_FP_TO_INTEGER_OVERFLOW_WORKS int nerrors = 0; int test_values; - int i; - int run_test = TRUE; -#ifndef H5_FP_TO_INTEGER_OVERFLOW_WORKS - /* For Cray X1, the compiler generates floating exception when the - * conversion overflows. So disable all of the conversions from - * floating-point numbers to integers. - */ - run_test = FALSE; -#endif - -#ifdef H5_VMS - run_test = TRUE; -#endif - - if(run_test) { #ifdef H5_VMS - test_values = TEST_NORMAL; - { + test_values = TEST_NORMAL; #else - for(i=0; i<3; i++) { - if(i==0) - test_values = TEST_NORMAL; - else if(i==1) - test_values = TEST_DENORM; - else - test_values = TEST_SPECIAL; + for(test_values = TEST_NORMAL; test_values <= TEST_SPECIAL; test_values++) { #endif /*H5_VMS*/ - nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT, H5T_NATIVE_SCHAR); - nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_DOUBLE, H5T_NATIVE_SCHAR); + nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT, H5T_NATIVE_SCHAR); + nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_DOUBLE, H5T_NATIVE_SCHAR); - nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT, H5T_NATIVE_UCHAR); - nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_DOUBLE, H5T_NATIVE_UCHAR); + nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT, H5T_NATIVE_UCHAR); + nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_DOUBLE, H5T_NATIVE_UCHAR); - nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT, H5T_NATIVE_SHORT); - nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_DOUBLE, H5T_NATIVE_SHORT); + nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT, H5T_NATIVE_SHORT); + nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_DOUBLE, H5T_NATIVE_SHORT); - nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT, H5T_NATIVE_USHORT); - nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_DOUBLE, H5T_NATIVE_USHORT); + nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT, H5T_NATIVE_USHORT); + nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_DOUBLE, H5T_NATIVE_USHORT); - nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT, H5T_NATIVE_INT); - nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_DOUBLE, H5T_NATIVE_INT); + nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT, H5T_NATIVE_INT); + nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_DOUBLE, H5T_NATIVE_INT); - nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT, H5T_NATIVE_UINT); - nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_DOUBLE, H5T_NATIVE_UINT); + nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT, H5T_NATIVE_UINT); + nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_DOUBLE, H5T_NATIVE_UINT); #if H5_SIZEOF_LONG!=H5_SIZEOF_INT - nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT, H5T_NATIVE_LONG); - nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_DOUBLE, H5T_NATIVE_LONG); + nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT, H5T_NATIVE_LONG); + nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_DOUBLE, H5T_NATIVE_LONG); - nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT, H5T_NATIVE_ULONG); - nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_DOUBLE, H5T_NATIVE_ULONG); + nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT, H5T_NATIVE_ULONG); + nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_DOUBLE, H5T_NATIVE_ULONG); #endif #if H5_SIZEOF_LONG_LONG!=H5_SIZEOF_LONG - if(!strcmp(name, "hw")) { /* Hardware conversion */ - /* Windows .NET 2003 doesn't work for hardware conversion of this case. - * .NET should define this macro H5_HW_FP_TO_LLONG_NOT_WORKS. */ + if(!strcmp(name, "hw")) { /* Hardware conversion */ + /* Windows .NET 2003 doesn't work for hardware conversion of this case. + * .NET should define this macro H5_HW_FP_TO_LLONG_NOT_WORKS. */ #ifndef H5_HW_FP_TO_LLONG_NOT_WORKS - nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT, H5T_NATIVE_LLONG); - nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_DOUBLE, H5T_NATIVE_LLONG); + nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT, H5T_NATIVE_LLONG); + nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_DOUBLE, H5T_NATIVE_LLONG); #endif /*H5_HW_FP_TO_LLONG_NOT_WORKS*/ - } else { /* Software conversion */ - nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT, H5T_NATIVE_LLONG); - nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_DOUBLE, H5T_NATIVE_LLONG); - } + } else { /* Software conversion */ + nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT, H5T_NATIVE_LLONG); + nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_DOUBLE, H5T_NATIVE_LLONG); + } #ifdef H5_FP_TO_ULLONG_RIGHT_MAXIMUM - nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT, H5T_NATIVE_ULLONG); - nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_DOUBLE, H5T_NATIVE_ULLONG); + nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT, H5T_NATIVE_ULLONG); + nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_DOUBLE, H5T_NATIVE_ULLONG); #else /*H5_FP_TO_ULLONG_RIGHT_MAXIMUM*/ - { - char str[256]; /*hello string */ - - sprintf(str, "Testing %s %s -> %s conversions", - name, "float", "unsigned long long"); - printf("%-70s", str); - SKIPPED(); - HDputs(" Test skipped due to hardware conversion error."); - - sprintf(str, "Testing %s %s -> %s conversions", - name, "double", "unsigned long long"); - printf("%-70s", str); - SKIPPED(); - HDputs(" Test skipped due to hardware conversion error."); - } + { + char str[256]; /*hello string */ + + sprintf(str, "Testing %s %s -> %s conversions", + name, "float", "unsigned long long"); + printf("%-70s", str); + SKIPPED(); + HDputs(" Test skipped due to hardware conversion error."); + + sprintf(str, "Testing %s %s -> %s conversions", + name, "double", "unsigned long long"); + printf("%-70s", str); + SKIPPED(); + HDputs(" Test skipped due to hardware conversion error."); + } #endif /*H5_FP_TO_ULLONG_RIGHT_MAXIMUM*/ #endif #if H5_LDOUBLE_TO_INTEGER_WORKS && H5_LDOUBLE_TO_INTEGER_ACCURATE #if H5_SIZEOF_LONG_DOUBLE!=H5_SIZEOF_DOUBLE - nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_SCHAR); - nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_UCHAR); - nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_SHORT); - nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_USHORT); - nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_INT); + nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_SCHAR); + nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_UCHAR); + nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_SHORT); + nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_USHORT); + nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_INT); #if H5_LDOUBLE_TO_UINT_ACCURATE - nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_UINT); + nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_UINT); #else /*H5_LDOUBLE_TO_UINT_ACCURATE*/ - { - char str[256]; /*string */ + { + char str[256]; /*string */ - sprintf(str, "Testing %s %s -> %s conversions", - name, "long double", "unsigned int"); - printf("%-70s", str); - SKIPPED(); + sprintf(str, "Testing %s %s -> %s conversions", + name, "long double", "unsigned int"); + printf("%-70s", str); + SKIPPED(); #if H5_SIZEOF_LONG_DOUBLE!=0 - HDputs(" Test skipped due to hardware conversion error."); + HDputs(" Test skipped due to hardware conversion error."); #else - HDputs(" Test skipped due to disabled long double."); + HDputs(" Test skipped due to disabled long double."); #endif - } + } #endif /*H5_LDOUBLE_TO_UINT_ACCURATE*/ #if H5_SIZEOF_LONG!=H5_SIZEOF_INT && H5_SIZEOF_LONG_DOUBLE!=0 - nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_LONG); - nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_ULONG); + nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_LONG); + nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_ULONG); #endif #if H5_SIZEOF_LONG_LONG!=H5_SIZEOF_LONG && H5_SIZEOF_LONG_DOUBLE!=0 #ifdef H5_LDOUBLE_TO_LLONG_ACCURATE - nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_LLONG); + nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_LLONG); #else /*H5_LDOUBLE_TO_LLONG_ACCURATE*/ - { - char str[256]; /*string */ + { + char str[256]; /*string */ - sprintf(str, "Testing %s %s -> %s conversions", - name, "long double", "long long"); - printf("%-70s", str); - SKIPPED(); + sprintf(str, "Testing %s %s -> %s conversions", + name, "long double", "long long"); + printf("%-70s", str); + SKIPPED(); #if H5_SIZEOF_LONG_DOUBLE!=0 - HDputs(" Test skipped due to hardware conversion error."); + HDputs(" Test skipped due to hardware conversion error."); #else - HDputs(" Test skipped due to disabled long double."); + HDputs(" Test skipped due to disabled long double."); #endif - } + } #endif /*H5_LDOUBLE_TO_LLONG_ACCURATE*/ #if defined(H5_FP_TO_ULLONG_RIGHT_MAXIMUM) && defined(H5_LDOUBLE_TO_LLONG_ACCURATE) - nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_ULLONG); + nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_ULLONG); #else /*H5_FP_TO_ULLONG_RIGHT_MAXIMUM && H5_LDOUBLE_TO_LLONG_ACCURATE*/ - { - char str[256]; /*string */ + { + char str[256]; /*string */ - sprintf(str, "Testing %s %s -> %s conversions", - name, "long double", "unsigned long long"); - printf("%-70s", str); - SKIPPED(); + sprintf(str, "Testing %s %s -> %s conversions", + name, "long double", "unsigned long long"); + printf("%-70s", str); + SKIPPED(); #if H5_SIZEOF_LONG_DOUBLE!=0 - HDputs(" Test skipped due to hardware conversion error."); + HDputs(" Test skipped due to hardware conversion error."); #else - HDputs(" Test skipped due to disabled long double."); + HDputs(" Test skipped due to disabled long double."); #endif - } + } #endif /*H5_FP_TO_ULLONG_RIGHT_MAXIMUM && H5_LDOUBLE_TO_LLONG_ACCURATE*/ #endif #endif #else /*H5_LDOUBLE_TO_INTEGER_WORKS && H5_LDOUBLE_TO_INTEGER_ACCURATE*/ - { - char str[256]; /*hello string */ + { + char str[256]; /*hello string */ - sprintf(str, "Testing %s %s -> %s conversions", - name, "long double", "all integers"); - printf("%-70s", str); - SKIPPED(); + sprintf(str, "Testing %s %s -> %s conversions", + name, "long double", "all integers"); + printf("%-70s", str); + SKIPPED(); #if H5_SIZEOF_LONG_DOUBLE!=0 - HDputs(" Test skipped due to hardware conversion error."); + HDputs(" Test skipped due to hardware conversion error."); #else - HDputs(" Test skipped due to disabled long double."); + HDputs(" Test skipped due to disabled long double."); #endif - } -#endif /*H5_LDOUBLE_TO_INTEGER_WORKS && H5_LDOUBLE_TO_INTEGER_ACCURATE*/ } - } else { - char str[256]; /*string */ +#endif /*H5_LDOUBLE_TO_INTEGER_WORKS && H5_LDOUBLE_TO_INTEGER_ACCURATE*/ +#ifndef H5_VMS + } /* end for */ +#endif /* H5_VMS */ +#else /* H5_FP_TO_INTEGER_OVERFLOW_WORKS */ +/* For Cray X1, the compiler generates floating exception when the + * conversion overflows. So disable all of the conversions from + * floating-point numbers to integers. + */ + char str[256]; /*string */ - sprintf(str, "Testing %s %s -> %s conversions", - name, "all floating-point numbers", "all integers"); - printf("%-70s", str); - SKIPPED(); + sprintf(str, "Testing %s %s -> %s conversions", + name, "all floating-point numbers", "all integers"); + printf("%-70s", str); + SKIPPED(); #if H5_SIZEOF_LONG_DOUBLE!=0 - HDputs(" Test skipped due to hardware conversion error."); + HDputs(" Test skipped due to hardware conversion error."); #else - HDputs(" Test skipped due to disbaled long double."); + HDputs(" Test skipped due to disbaled long double."); #endif - } +#endif /* H5_FP_TO_INTEGER_OVERFLOW_WORKS */ return nerrors; } diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c index a6c1f77..6e661df 100644 --- a/tools/h5dump/h5dump.c +++ b/tools/h5dump/h5dump.c @@ -2707,14 +2707,12 @@ dump_dcpl(hid_t dcpl_id,hid_t type_id, hid_t obj_id) H5D_fill_time_t ft; hsize_t storage_size; haddr_t ioffset; - int i, next; + int i; unsigned j; storage_size = H5Dget_storage_size(obj_id); nfilters = H5Pget_nfilters(dcpl_id); ioffset = H5Dget_offset(obj_id); - next = H5Pget_external_count(dcpl_id); - HDassert(next >= 0); HDstrcpy(f_name,"\0"); /*------------------------------------------------------------------------- @@ -2820,6 +2818,10 @@ dump_dcpl(hid_t dcpl_id,hid_t type_id, hid_t obj_id) printf("%s\n",END); } else if (H5D_CONTIGUOUS == H5Pget_layout(dcpl_id)) { + int next; + + next = H5Pget_external_count(dcpl_id); + /*------------------------------------------------------------------------- * EXTERNAL_FILE *------------------------------------------------------------------------- @@ -4511,16 +4513,13 @@ print_enum(hid_t type) unsigned char *value = NULL; /*value array */ unsigned char *copy = NULL; /*a pointer to value array */ unsigned nmembs; /*number of members */ - int snmembs; int nchars; /*number of output characters */ hid_t super; /*enum base integer type */ hid_t native = -1; /*native integer datatype */ size_t dst_size; /*destination value type size */ unsigned i; - snmembs = H5Tget_nmembers(type); - HDassert(snmembs >= 0); - nmembs = (unsigned)snmembs; + nmembs = (unsigned)H5Tget_nmembers(type); super = H5Tget_super(type); /* @@ -6693,16 +6692,13 @@ xml_print_enum(hid_t type) char **name = NULL; /*member names */ unsigned char *value = NULL; /*value array */ unsigned nmembs; /*number of members */ - int snmembs; hid_t super; /*enum base integer type */ hid_t native = -1; /*native integer datatype */ size_t dst_size; /*destination value type size */ unsigned i; /*miscellaneous counters */ size_t j; - snmembs = H5Tget_nmembers(type); - HDassert(snmembs >= 0); - nmembs = (unsigned)snmembs; + nmembs = (unsigned)H5Tget_nmembers(type); super = H5Tget_super(type); indentation(indent); diff --git a/tools/lib/h5diff_dset.c b/tools/lib/h5diff_dset.c index ad9331d..2cc84ca 100644 --- a/tools/lib/h5diff_dset.c +++ b/tools/lib/h5diff_dset.c @@ -545,11 +545,6 @@ hsize_t diff_datasetid( hid_t did1, } /* elmtno */ H5Sclose(sm_space); - /* free */ - HDfree(sm_buf1); - sm_buf1 = NULL; - HDfree(sm_buf2); - sm_buf2 = NULL; } /* hyperslab read */ }/*can_compare*/ diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c index 4761ab9..f510a5b 100644 --- a/tools/lib/h5tools.c +++ b/tools/lib/h5tools.c @@ -2070,6 +2070,7 @@ h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_c H5E_THROW(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed"); if(sm_buf) HDfree(sm_buf); + sm_buf = NULL; } else H5E_THROW(SUCCEED, H5E_tools_min_id_g, "nothing to print"); @@ -2081,6 +2082,9 @@ h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_c } /* hyperslab_count loop */ CATCH + if(sm_buf) + HDfree(sm_buf); + return ret_value; } @@ -3286,7 +3290,7 @@ h5tools_print_enum(h5tools_str_t *buffer, hid_t type) char **name = NULL; /*member names */ unsigned char *value = NULL; /*value array */ unsigned char *copy = NULL; /*a pointer to value array */ - unsigned nmembs; /*number of members */ + unsigned nmembs = 0; /*number of members */ int nchars; /*number of output characters */ hid_t super = -1; /*enum base integer type */ hid_t native = -1; /*native integer datatype */ @@ -3380,10 +3384,9 @@ h5tools_print_enum(h5tools_str_t *buffer, hid_t type) } CATCH - if(name) { /* Release resources */ - for (i = 0; i < nmembs; i++) + for(i = 0; i < nmembs; i++) if(name[i]) free(name[i]); free(name); @@ -3395,7 +3398,7 @@ CATCH if(super >= 0 && H5Tclose(super) < 0) H5E_THROW(FAIL, H5E_tools_min_id_g, "Could not close datatype's super class"); - if (0 == nmembs) + if(0 == nmembs) h5tools_str_append(buffer, "\n<empty>"); return ret_value; diff --git a/tools/lib/h5tools_error.h b/tools/lib/h5tools_error.h index da8f03c..dc5f87b 100644 --- a/tools/lib/h5tools_error.h +++ b/tools/lib/h5tools_error.h @@ -71,7 +71,7 @@ extern hid_t H5E_tools_min_id_g; /* Macro for "catching" flow of control when an error occurs. Note that the * H5_LEAVE macro won't jump back here once it's past this point. */ -#define CATCH past_catch = TRUE; catch_except:; +#define CATCH catch_except:; past_catch = TRUE; /* * H5_LEAVE macro, used to facilitate control flow between a |