From 4cb39b5a8bb41af11d0da78cf94f5af49f2e47a5 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Wed, 12 Jun 2002 13:03:33 -0500 Subject: [svn-r5604] Purpose: Code cleanup Description: Clean up some compiler warnings before the code freeze... Platforms tested: FreeBSD 4.5 (sleipnir) --- src/H5B.c | 4 ++-- src/H5FL.c | 6 +++--- src/H5I.c | 2 +- src/H5Oefl.c | 4 ++-- src/H5Sall.c | 4 ++-- src/H5T.c | 24 ++++++++++++++---------- test/h5test.h | 2 +- 7 files changed, 25 insertions(+), 21 deletions(-) diff --git a/src/H5B.c b/src/H5B.c index 2c95919..54ac90c 100644 --- a/src/H5B.c +++ b/src/H5B.c @@ -2088,8 +2088,8 @@ H5B_copy(H5F_t *f, const H5B_t *old_bt) if (NULL==(ret_value->page=H5FL_BLK_ALLOC(page,size,0)) || NULL==(ret_value->native=H5FL_BLK_ALLOC(native_block,total_native_keysize,0)) || - NULL==(ret_value->child=H5FL_ARR_ALLOC(haddr_t,nkeys,0)) || - NULL==(ret_value->key=H5FL_ARR_ALLOC(H5B_key_t,(nkeys+1),0))) { + NULL==(ret_value->child=H5FL_ARR_ALLOC(haddr_t,(hsize_t)nkeys,0)) || + NULL==(ret_value->key=H5FL_ARR_ALLOC(H5B_key_t,(hsize_t)(nkeys+1),0))) { HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for B-tree root node"); } diff --git a/src/H5FL.c b/src/H5FL.c index 10962e4..acb21f2 100644 --- a/src/H5FL.c +++ b/src/H5FL.c @@ -328,7 +328,7 @@ H5FL_reg_alloc(H5FL_reg_head_t *head, unsigned clear) } /* end if */ /* Otherwise allocate a node */ else { - if (NULL==(new_obj = H5FL_malloc(sizeof(H5FL_reg_node_t)+head->size))) + if (NULL==(new_obj = H5FL_malloc((hsize_t)(sizeof(H5FL_reg_node_t)+head->size)))) HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); #ifdef H5FL_DEBUG @@ -599,7 +599,7 @@ H5FL_blk_find_list(H5FL_blk_node_t **head, hsize_t size) *------------------------------------------------------------------------- */ static H5FL_blk_node_t * -H5FL_blk_create_list(H5FL_blk_node_t **head, hsize_t size) +H5FL_blk_create_list(H5FL_blk_node_t **head, size_t size) { H5FL_blk_node_t *temp; /* Temp. pointer to node in the list */ H5FL_blk_node_t *ret_value=NULL; @@ -798,7 +798,7 @@ H5FL_blk_free(H5FL_blk_head_t *head, void *block) temp=(H5FL_blk_list_t *)((unsigned char *)block-sizeof(H5FL_blk_list_t)); /* check if there is a free list for native blocks of this size */ - if((free_list=H5FL_blk_find_list(&(head->head),temp->size))==NULL) { + if((free_list=H5FL_blk_find_list(&(head->head),(hsize_t)temp->size))==NULL) { /* No free list available, create a new list node and insert it to the queue */ free_list=H5FL_blk_create_list(&(head->head),temp->size); } /* end if */ diff --git a/src/H5I.c b/src/H5I.c index a39a791..cc139ea 100644 --- a/src/H5I.c +++ b/src/H5I.c @@ -415,7 +415,7 @@ H5I_clear_group(H5I_type_t grp, hbool_t force) /* Free the object regardless of reference count */ if (grp_ptr->free_func && (grp_ptr->free_func)(cur->obj_ptr)<0) { if (force) { -#if H5I_DEBUG +#ifdef H5I_DEBUG if (H5DEBUG(I)) { fprintf(H5DEBUG(I), "H5I: free grp=%d obj=0x%08lx " "failure ignored\n", (int)grp, diff --git a/src/H5Oefl.c b/src/H5Oefl.c index 34fb951..f3e3beb 100644 --- a/src/H5Oefl.c +++ b/src/H5Oefl.c @@ -422,7 +422,7 @@ H5O_efl_read (H5F_t UNUSED *f, const H5O_efl_t *efl, haddr_t addr, #ifndef NDEBUG hsize_t tempto_read; #endif - hsize_t skip; + hsize_t skip=0; haddr_t cur; ssize_t n; herr_t ret_value = FAIL; @@ -520,7 +520,7 @@ H5O_efl_write (H5F_t UNUSED *f, const H5O_efl_t *efl, haddr_t addr, hsize_t tempto_write; #endif /* NDEBUG */ haddr_t cur; - hsize_t skip; + hsize_t skip=0; herr_t ret_value = FAIL; FUNC_ENTER (H5O_efl_write, FAIL); diff --git a/src/H5Sall.c b/src/H5Sall.c index b088f29..adeda4e 100644 --- a/src/H5Sall.c +++ b/src/H5Sall.c @@ -201,7 +201,7 @@ H5S_all_fgath (H5F_t *f, const struct H5O_layout_t *layout, */ H5_CHECK_OVERFLOW(actual_bytes,hsize_t,size_t); if (H5F_seq_read(f, dxpl_id, layout, pline, fill, efl, file_space, - elmt_size, (size_t)actual_bytes, buf_off, buf/*out*/)<0) { + elmt_size, actual_bytes, buf_off, buf/*out*/)<0) { HRETURN_ERROR(H5E_DATASPACE, H5E_READERROR, 0, "read error"); } @@ -263,7 +263,7 @@ H5S_all_fscat (H5F_t *f, const struct H5O_layout_t *layout, */ H5_CHECK_OVERFLOW(actual_bytes,hsize_t,size_t); if (H5F_seq_write(f, dxpl_id, layout, pline, fill, efl, file_space, - elmt_size, (size_t)actual_bytes, buf_off, buf/*out*/)<0) { + elmt_size, actual_bytes, buf_off, buf/*out*/)<0) { HRETURN_ERROR(H5E_DATASPACE, H5E_WRITEERROR, 0, "write error"); } diff --git a/src/H5T.c b/src/H5T.c index 00c00f5..3f355cc 100644 --- a/src/H5T.c +++ b/src/H5T.c @@ -6348,7 +6348,7 @@ char * H5T_enum_nameof(H5T_t *dt, void *value, char *name/*out*/, size_t size) { int lt, md, rt; /*indices for binary search */ - int cmp; /*comparison result */ + int cmp=0; /*comparison result */ FUNC_ENTER(H5T_enum_nameof, NULL); @@ -6358,14 +6358,16 @@ H5T_enum_nameof(H5T_t *dt, void *value, char *name/*out*/, size_t size) assert(name || 0==size); if (name && size>0) *name = '\0'; + /* Sanity check */ + if (dt->u.enumer.nmembs == 0) { + HRETURN_ERROR(H5E_DATATYPE, H5E_NOTFOUND, NULL, + "datatype has no members"); + } + /* Do a binary search over the values to find the correct one */ H5T_sort_value(dt, NULL); lt = 0; rt = dt->u.enumer.nmembs; - if (rt == 0) { - HRETURN_ERROR(H5E_DATATYPE, H5E_NOTFOUND, NULL, - "datatype has no members"); - } md = -1; while (ltu.enumer.nmembs == 0) { + HRETURN_ERROR(H5E_DATATYPE, H5E_NOTFOUND, FAIL, + "datatype has no members"); + } + /* Do a binary search over the names to find the correct one */ H5T_sort_name(dt, NULL); lt = 0; rt = dt->u.enumer.nmembs; - if (rt == 0) { - HRETURN_ERROR(H5E_DATATYPE, H5E_NOTFOUND, FAIL, - "datatype has no members"); - } md = -1; while (lt