From 450e8db6f2b0930cda72ae943043dc1e80af289b Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Fri, 8 Jan 2010 13:57:09 -0500 Subject: [svn-r18076] Description: Correct Coverity issue #1 by removing dead code Tested on: Mac OS X/32 (amazon) debug --- src/H5Omessage.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/H5Omessage.c b/src/H5Omessage.c index 4a9ecb5..8fa8085 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() */ -- cgit v0.12 From 4b537ff8405630567cafd270a8e41c53c13b0e05 Mon Sep 17 00:00:00 2001 From: Neil Fortner Date: Fri, 8 Jan 2010 13:58:12 -0500 Subject: [svn-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. Tested: Fedora --- src/H5Spoint.c | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/src/H5Spoint.c b/src/H5Spoint.c index 84b427e..cfc31de 100644 --- a/src/H5Spoint.c +++ b/src/H5Spoint.c @@ -584,7 +584,7 @@ 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 */ + 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); @@ -597,28 +597,47 @@ H5S_point_copy(H5S_t *dst, const H5S_t *src, hbool_t UNUSED share_selection) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate point node"); curr=src->select.sel_info.pnt_lst->head; - new_head=NULL; + new_tail=NULL; while(curr!=NULL) { /* Create each 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) + new_node->next = NULL; + if((new_node->pnt = (hsize_t *)H5MM_malloc(src->extent.rank*sizeof(hsize_t)))==NULL) { + (void)H5FL_FREE(H5S_pnt_node_t, new_node); HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate coordinate information"); + } /* end if */ HDmemcpy(new_node->pnt, curr->pnt, (src->extent.rank * sizeof(hsize_t))); - new_node->next = NULL; /* Keep the order the same when copying */ - if(new_head==NULL) - new_head=dst->select.sel_info.pnt_lst->head=new_node; + if(new_tail==NULL) + 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; } /* end while */ done: + if(ret_value < 0) { + H5S_pnt_node_t *tmp_node; + + /* Traverse the (incomplete?) dst list, freeing all memory */ + curr = dst->select.sel_info.pnt_lst->head; + + while(curr) { + (void)H5MM_xfree(curr->pnt); + tmp_node = curr; + curr = curr->next; + (void)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() */ -- cgit v0.12 From 8b5da53df2e15da42e4443c6da8cc45f867b50a8 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Fri, 8 Jan 2010 14:12:02 -0500 Subject: [svn-r18078] Description: Correct Coverity issue #2 by removing impossible to reach code. Tested on: Mac OS X/32 10.6.2 (amazon) w/debug --- src/H5HFsection.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/H5HFsection.c b/src/H5HFsection.c index 91031be..efd0515 100644 --- a/src/H5HFsection.c +++ b/src/H5HFsection.c @@ -2415,7 +2415,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) @@ -2438,7 +2437,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; @@ -2462,13 +2460,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) -- cgit v0.12 From 326fa329675b34d97987268eee981d12924e1ca6 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Fri, 8 Jan 2010 14:13:29 -0500 Subject: [svn-r18079] Description: Correct #3 by removing impossible to reach code. Tested on: Mac OS X/32 10.6.2 (amazon) w/debug --- src/H5HFsection.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/H5HFsection.c b/src/H5HFsection.c index efd0515..472edb8 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 */ -- cgit v0.12 From 3794f9a78a122ed2515541b5507ce3b633884db0 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Fri, 8 Jan 2010 14:17:12 -0500 Subject: [svn-r18080] Description: Correct Coverity issue #4 by removing impossible to reach code. Tested on: Mac OS X/32 10.6.3 (amazon) w/debug --- src/H5HFhdr.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/H5HFhdr.c b/src/H5HFhdr.c index c326a59..3665a09 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() */ -- cgit v0.12 From 11e943f0776878e4e6fa860208aa17b6770c7ba3 Mon Sep 17 00:00:00 2001 From: Peter Cao Date: Fri, 8 Jan 2010 14:17:59 -0500 Subject: [svn-r18081] fix coverity 26 , check (dblik->parent) before calls H5HF_man_iblock_detach(). line, and those below, will be ignored-- M src/H5HFdblock.c --- src/H5HFdblock.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/H5HFdblock.c b/src/H5HFdblock.c index c4b7630..af4713e 100644 --- a/src/H5HFdblock.c +++ b/src/H5HFdblock.c @@ -324,8 +324,11 @@ HDfprintf(stderr, "%s: Reversing iterator\n", FUNC); #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") + + 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 else */ -- cgit v0.12 From 2181d7b0c390ea32d138b7d56fd4b74aedfffe37 Mon Sep 17 00:00:00 2001 From: Mike McGreevy Date: Fri, 8 Jan 2010 14:22:40 -0500 Subject: [svn-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. --- tools/lib/h5tools.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c index 4761ab9..808ec85 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,10 @@ 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 +3291,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 */ -- cgit v0.12 From 23bfde73c21eab60d9c1143230b2c67dc07b4311 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Fri, 8 Jan 2010 14:24:17 -0500 Subject: [svn-r18083] Description: Correct Coverity issue #6 by removing debugging knob from error reporting code. Tested on: Mac OS X/32 10.6.3 (amazon) w/debug --- test/cache_common.c | 43 ++++++++++++++----------------------------- 1 file changed, 14 insertions(+), 29 deletions(-) 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()."; -- cgit v0.12 From 0ec9ee15c8f3cb3f495e767ccbd9ce52ac1c4d26 Mon Sep 17 00:00:00 2001 From: Neil Fortner Date: Fri, 8 Jan 2010 14:24:47 -0500 Subject: [svn-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. Tested: Fedora --- tools/lib/h5tools_error.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 -- cgit v0.12 From 984511ef0ad3d2596ee32cb56594f7d903bbdd90 Mon Sep 17 00:00:00 2001 From: Peter Cao Date: Fri, 8 Jan 2010 14:24:53 -0500 Subject: [svn-r18085] fixed coverity #27, check if (heap) before use heap->obj.... --- src/H5HG.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/H5HG.c b/src/H5HG.c index b4662eb..ace07ce 100644 --- a/src/H5HG.c +++ b/src/H5HG.c @@ -800,7 +800,8 @@ H5HG_link (H5F_t *f, hid_t dxpl_id, const H5HG_t *hobj, int adjust) } /* end if */ /* Set return value */ - ret_value=heap->obj[hobj->idx].nrefs; + if (heap) + ret_value=heap->obj[hobj->idx].nrefs; done: if (heap && H5AC_unprotect(f, dxpl_id, H5AC_GHEAP, hobj->addr, heap, heap_flags)<0) -- cgit v0.12 From 73508da070ec8a922605a964c572c60b9a5fa96b Mon Sep 17 00:00:00 2001 From: Peter Cao Date: Fri, 8 Jan 2010 14:34:19 -0500 Subject: [svn-r18086] fixed coverity #28, check curr_span not null before use it at if(curr_span && (io_bytes_left==0 || curr_seq>=maxseq)) --- src/H5Shyper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/H5Shyper.c b/src/H5Shyper.c index f55135f..9e8bb14 100644 --- a/src/H5Shyper.c +++ b/src/H5Shyper.c @@ -7545,7 +7545,7 @@ partial_done: /* Yes, goto's are evil, so sue me... :-) */ } /* end while */ /* Check if we are done */ - if(io_bytes_left==0 || curr_seq>=maxseq) { + if(curr_span && (io_bytes_left==0 || curr_seq>=maxseq)) { abs_arr[fast_dim]=curr_span->low+(span_size/elem_size); /* Check if we are still within the span */ -- cgit v0.12 From 1b6cd030d3b48c3a23b106a9dc8f6086c1b4d220 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Fri, 8 Jan 2010 14:39:09 -0500 Subject: [svn-r18087] Description: Correct Coverity issue #7 by cleaning up correctly on error Tested on: Mac OS X/32 10.6.3 (amazon) w/debug --- src/H5HG.c | 51 ++++++++++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/src/H5HG.c b/src/H5HG.c index ace07ce..48da6c6 100644 --- a/src/H5HG.c +++ b/src/H5HG.c @@ -161,28 +161,25 @@ static haddr_t H5HG_create (H5F_t *f, hid_t dxpl_id, size_t size) { H5HG_heap_t *heap = NULL; - haddr_t ret_value = HADDR_UNDEF; uint8_t *p = NULL; haddr_t addr; size_t n; + haddr_t ret_value = HADDR_UNDEF; FUNC_ENTER_NOAPI_NOINIT(H5HG_create) /* Check args */ - assert (f); - if (sizeaddr = addr; heap->size = size; @@ -203,14 +200,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); @@ -225,7 +222,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)); @@ -244,21 +241,29 @@ 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) - HGOTO_ERROR (H5E_HEAP, H5E_CANTINIT, HADDR_UNDEF, \ - "unable to cache global heap collection"); + if(H5AC_set(f, dxpl_id, H5AC_GHEAP, addr, heap, H5AC__NO_FLAGS_SET) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, HADDR_UNDEF, "unable to cache global heap collection") 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(HADDR_UNDEF == 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() */ -- cgit v0.12 From 987054a9e52eb55c2c310000e59f34a7c7659014 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Fri, 8 Jan 2010 14:46:53 -0500 Subject: [svn-r18088] Description: Correct Coverity #8 by removing unchanged variable checking code. Tested on: Mac OS X/32 10.6.3 (amazon) w/debug --- test/cache.c | 42 +----------------------------------------- 1 file changed, 1 insertion(+), 41 deletions(-) diff --git a/test/cache.c b/test/cache.c index 5e587df..b7f6a9f 100644 --- a/test/cache.c +++ b/test/cache.c @@ -28667,9 +28667,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 +28681,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 +28702,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 +28723,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 +28744,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"; - } } -- cgit v0.12 From 322b981c37ae88de5f1ca73825abdcde6bcf0d4b Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Fri, 8 Jan 2010 14:50:23 -0500 Subject: [svn-r18089] Description: Correct Coverity issue #9 - remove impossible to read code. Tested on: Mac OS X/32 10.6.3 (amazon) --- test/cache.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/test/cache.c b/test/cache.c index b7f6a9f..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", -- cgit v0.12 From df60e8a5233cf6adbd786b80442f6c35f54a4e15 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Fri, 8 Jan 2010 15:01:16 -0500 Subject: [svn-r18090] Description: Correct Coverity issue #11 by removing impossible to reach code. Also clean up some minor style issues. Tested on: Mac OS X/32 10.6.3 (amazon) w/debug --- src/H5Oainfo.c | 8 ++++---- src/H5Oattr.c | 2 +- src/H5Olayout.c | 2 +- src/H5Olink.c | 10 +--------- 4 files changed, 7 insertions(+), 15 deletions(-) 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() */ -- cgit v0.12 From 0f15b4c999d25ee3460744e6e121c63bb72d8b94 Mon Sep 17 00:00:00 2001 From: Neil Fortner Date: Fri, 8 Jan 2010 15:01:41 -0500 Subject: [svn-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. Tested: Fedora --- tools/h5dump/h5dump.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c index a6c1f77..3ea201b 100644 --- a/tools/h5dump/h5dump.c +++ b/tools/h5dump/h5dump.c @@ -4519,7 +4519,8 @@ print_enum(hid_t type) unsigned i; snmembs = H5Tget_nmembers(type); - HDassert(snmembs >= 0); + if(snmembs < 0) + return; nmembs = (unsigned)snmembs; super = H5Tget_super(type); @@ -6701,7 +6702,8 @@ xml_print_enum(hid_t type) size_t j; snmembs = H5Tget_nmembers(type); - HDassert(snmembs >= 0); + if(snmembs < 0) + return; nmembs = (unsigned)snmembs; super = H5Tget_super(type); -- cgit v0.12 From c3b6d069917365da14924b908fea07346d023005 Mon Sep 17 00:00:00 2001 From: Neil Fortner Date: Fri, 8 Jan 2010 15:07:54 -0500 Subject: [svn-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. Tested: Fedora --- tools/h5dump/h5dump.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c index 3ea201b..ad8b1af 100644 --- a/tools/h5dump/h5dump.c +++ b/tools/h5dump/h5dump.c @@ -2714,7 +2714,8 @@ dump_dcpl(hid_t dcpl_id,hid_t type_id, hid_t obj_id) nfilters = H5Pget_nfilters(dcpl_id); ioffset = H5Dget_offset(obj_id); next = H5Pget_external_count(dcpl_id); - HDassert(next >= 0); + if(next < 0) + return; HDstrcpy(f_name,"\0"); /*------------------------------------------------------------------------- -- cgit v0.12 From 179c3e9c54828cdd97ceb9ea25c74d4e43ca6716 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Fri, 8 Jan 2010 15:13:25 -0500 Subject: [svn-r18093] Description: Correct Coverity issue #12 by removing dead code. Tested on: Mac OS X/32 10.6.3 (amazon) w/debug --- src/H5Znbit.c | 69 ++++++++++++++++++++++++++++++----------------------------- 1 file changed, 35 insertions(+), 34 deletions(-) diff --git a/src/H5Znbit.c b/src/H5Znbit.c index c534a80..3448386 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, -- cgit v0.12 From 41280d6bbe7ceb8aec9e5d4bbb74fc1e3d66ef07 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Fri, 8 Jan 2010 15:19:07 -0500 Subject: [svn-r18094] Description: Correct Coverity issue #16 by removing debugging code. Tested on: Mac OS X/32 10.6.2 (amazon) w/debug --- test/cache_api.c | 115 ------------------------------------------------------- 1 file changed, 115 deletions(-) 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 ) -- cgit v0.12 From b93ed894c6371e426f04403ac1d125f836b82d89 Mon Sep 17 00:00:00 2001 From: Mike McGreevy Date: Fri, 8 Jan 2010 15:22:56 -0500 Subject: [svn-r18095] Fixed coverity issue # 271. Removed redundant checking and freeing of sm_buf1 and sm_buf2. --- tools/lib/h5diff_dset.c | 5 ----- 1 file changed, 5 deletions(-) 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*/ -- cgit v0.12 From 8984d662ed849e86fa3384bd35ccc13ac34e7495 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Fri, 8 Jan 2010 15:32:12 -0500 Subject: [svn-r18096] Description: Correct Coverity issue #17 by refactoring test to remove dead code. Tested on: Mac OS X/32 10.6.2 (amazon) w/debug --- test/dt_arith.c | 229 ++++++++++++++++++++++++++------------------------------ 1 file changed, 107 insertions(+), 122 deletions(-) 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; } -- cgit v0.12