From 68d21ca78b509165fbf530ce34f6f904ad8dbd7c Mon Sep 17 00:00:00 2001 From: MuQun Yang Date: Fri, 3 May 2002 17:31:13 -0500 Subject: [svn-r5350] Purpose: code clean up to erase warnings on windows Description: most warnings are due to casting from data type of large size to that of small size Solution: Using H5_CHECK_OVERFLOW and H5_ASSIGN_OVERFLOW Platforms tested: linux 2.2.18 and windows 2000 --- src/H5.c | 2 +- src/H5Distore.c | 2 +- src/H5FD.c | 3 +-- src/H5FDcore.c | 2 +- src/H5FDstdio.c | 2 +- src/H5FL.c | 16 +++++++++------- src/H5Fistore.c | 2 +- src/H5Oattr.c | 2 +- src/H5S.c | 7 +++++-- src/H5Sall.c | 2 +- src/H5T.c | 2 +- src/H5Tconv.c | 8 +++++--- 12 files changed, 28 insertions(+), 22 deletions(-) diff --git a/src/H5.c b/src/H5.c index 67725e5..03b1cef 100644 --- a/src/H5.c +++ b/src/H5.c @@ -948,7 +948,7 @@ HDfprintf (FILE *stream, const char *fmt, ...) case 'g': case 'G': if (!HDstrcmp (modifier, "h")) { - float x = va_arg (ap, double); + float x = (float)(va_arg (ap, double)); n = fprintf (stream, template, x); } else if (!*modifier || !HDstrcmp (modifier, "l")) { double x = va_arg (ap, double); diff --git a/src/H5Distore.c b/src/H5Distore.c index f78ae86..4483d96 100644 --- a/src/H5Distore.c +++ b/src/H5Distore.c @@ -106,7 +106,7 @@ typedef H5F_rdcc_ent_t *H5F_rdcc_ent_ptr_t; /* For free lists */ static size_t H5F_istore_sizeof_rkey(H5F_t *f, const void *_udata); static herr_t H5F_istore_new_node(H5F_t *f, H5B_ins_t, void *_lt_key, void *_udata, void *_rt_key, - haddr_t*/*out*/); + haddr_t*addr_p/*out*/); static int H5F_istore_cmp2(H5F_t *f, void *_lt_key, void *_udata, void *_rt_key); static int H5F_istore_cmp3(H5F_t *f, void *_lt_key, void *_udata, diff --git a/src/H5FD.c b/src/H5FD.c index 1554f5c..bfcfe3a 100644 --- a/src/H5FD.c +++ b/src/H5FD.c @@ -2356,10 +2356,9 @@ H5FD_write(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t s } /* end if */ /* Calculate the proper offset of the existing metadata */ - old_offset=(addr+size)-file->accum_loc; + H5_ASSIGN_OVERFLOW(old_offset,(addr+size)-file->accum_loc,hsize_t,size_t);/*check for overflow*/ /* Move the existing metadata to the proper location */ - H5_ASSIGN_OVERFLOW(old_offset,(addr+size)-file->accum_loc,hsize_t,size_t);/*check for overflow*/ HDmemmove(file->meta_accum+size,file->meta_accum+old_offset,(size_t)(file->accum_size-old_offset)); /* Copy the new metadata at the front */ diff --git a/src/H5FDcore.c b/src/H5FDcore.c index 15bb866..52e1736 100644 --- a/src/H5FDcore.c +++ b/src/H5FDcore.c @@ -577,7 +577,7 @@ H5FD_core_get_eof(H5FD_t *_file) */ static herr_t H5FD_core_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, haddr_t addr, - hsize_t size, void *buf/*out*/) + hsize_t size, void *buf) { H5FD_core_t *file = (H5FD_core_t*)_file; diff --git a/src/H5FDstdio.c b/src/H5FDstdio.c index cf93505..9569f8f 100644 --- a/src/H5FDstdio.c +++ b/src/H5FDstdio.c @@ -648,7 +648,7 @@ H5FD_stdio_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsi * Read zeros past the logical end of file (physical is handled below) */ if ((size_t) addr + size > file->eof) { - size_t nbytes = (size_t) addr + size - file->eof; + size_t nbytes = (size_t) addr + size - file->eof; memset((unsigned char *)buf + size - nbytes, 0, nbytes); size -= nbytes; } diff --git a/src/H5FL.c b/src/H5FL.c index 31dadfb..b4f765d 100644 --- a/src/H5FL.c +++ b/src/H5FL.c @@ -600,7 +600,7 @@ H5FL_blk_create_list(H5FL_blk_node_t **head, hsize_t size) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for chunk info"); /* Set the correct values for the new free list */ - temp->size=size; + H5_ASSIGN_OVERFLOW(temp->size,size,hsize_t,size_t); temp->list=NULL; /* Attach to head of priority queue */ @@ -713,10 +713,12 @@ H5FL_blk_alloc(H5FL_blk_head_t *head, hsize_t size, unsigned clear) /* Decrement the number of blocks & memory used on free list */ head->onlist--; - head->list_mem-=size; + H5_ASSIGN_OVERFLOW(head->list_mem,head->list_mem-size,hsize_t,size_t); + /*head->list_mem-=size;*/ /* Decrement the amount of global "block" free list memory in use */ - H5FL_blk_gc_head.mem_freed-=size; + H5_ASSIGN_OVERFLOW(H5FL_blk_gc_head.mem_freed,H5FL_blk_gc_head.mem_freed-size,hsize_t,size_t); + /*H5FL_blk_gc_head.mem_freed-=size;*/ } /* end if */ /* No free list available, or there are no nodes on the list, allocate a new node to give to the user */ @@ -729,7 +731,7 @@ H5FL_blk_alloc(H5FL_blk_head_t *head, hsize_t size, unsigned clear) head->allocated++; /* Initialize the block allocated */ - temp->size=size; + H5_ASSIGN_OVERFLOW(temp->size,size,hsize_t,size_t); temp->next=NULL; /* Set the return value to the block itself */ @@ -1156,7 +1158,7 @@ H5FL_arr_free(H5FL_arr_head_t *head, void *obj) head->u.list_arr[temp->nelem]=temp; /* Set the amount of memory being freed */ - mem_size=temp->nelem*head->size; + H5_ASSIGN_OVERFLOW(mem_size,temp->nelem*head->size,hsize_t,size_t); /* Increment the number of blocks & memory used on free list */ head->onlist[temp->nelem]++; @@ -1240,7 +1242,7 @@ H5FL_arr_alloc(H5FL_arr_head_t *head, hsize_t elem, unsigned clear) head->list_mem-=mem_size; /* Decrement the amount of global "array" free list memory in use */ - H5FL_arr_gc_head.mem_freed-=mem_size; + H5_ASSIGN_OVERFLOW(H5FL_arr_gc_head.mem_freed,H5FL_arr_gc_head.mem_freed-mem_size,hsize_t,size_t); } /* end if */ /* Otherwise allocate a node */ @@ -1373,7 +1375,7 @@ H5FL_arr_gc_list(H5FL_arr_head_t *head) for(i=0; imaxelem; i++) { if(head->onlist[i]>0) { /* Calculate the total memory used on this list */ - total_mem=head->onlist[i]*i*head->size; + H5_ASSIGN_OVERFLOW(total_mem,head->onlist[i]*i*head->size,hsize_t,size_t); /* For each free list being garbage collected, walk through the nodes and free them */ arr_free_list=head->u.list_arr[i]; diff --git a/src/H5Fistore.c b/src/H5Fistore.c index f78ae86..4483d96 100644 --- a/src/H5Fistore.c +++ b/src/H5Fistore.c @@ -106,7 +106,7 @@ typedef H5F_rdcc_ent_t *H5F_rdcc_ent_ptr_t; /* For free lists */ static size_t H5F_istore_sizeof_rkey(H5F_t *f, const void *_udata); static herr_t H5F_istore_new_node(H5F_t *f, H5B_ins_t, void *_lt_key, void *_udata, void *_rt_key, - haddr_t*/*out*/); + haddr_t*addr_p/*out*/); static int H5F_istore_cmp2(H5F_t *f, void *_lt_key, void *_udata, void *_rt_key); static int H5F_istore_cmp3(H5F_t *f, void *_lt_key, void *_udata, diff --git a/src/H5Oattr.c b/src/H5Oattr.c index d54ed52..7187dae 100644 --- a/src/H5Oattr.c +++ b/src/H5Oattr.c @@ -155,7 +155,7 @@ H5O_attr_decode(H5F_t *f, const uint8_t *p, H5O_shared_t UNUSED *sh) p += H5O_ALIGN(attr->ds_size); /* Compute the size of the data */ - attr->data_size=H5S_get_simple_extent_npoints(attr->ds)*H5T_get_size(attr->dt); + H5_ASSIGN_OVERFLOW(attr->data_size,H5S_get_simple_extent_npoints(attr->ds)*H5T_get_size(attr->dt),hsize_t,size_t); /* Go get the data */ if (NULL==(attr->data = H5MM_malloc(attr->data_size))) { diff --git a/src/H5S.c b/src/H5S.c index 33f9a9a..f44e085 100644 --- a/src/H5S.c +++ b/src/H5S.c @@ -263,8 +263,11 @@ H5S_term_interface(void) H5I_destroy_group(H5I_DATASPACE); /* Clear/free conversion table */ - HDmemset(H5S_fconv_g, 0, sizeof(H5S_fconv_g)); - HDmemset(H5S_mconv_g, 0, sizeof(H5S_mconv_g)); + HDmemset((void*)&H5S_fconv_g[0], 0, sizeof(H5S_fconv_g)); + HDmemset((void*)&H5S_mconv_g[0], 0, sizeof(H5S_mconv_g)); + + /*HDmemset(H5S_fconv_g, 0, sizeof(H5S_fconv_g)); + HDmemset(H5S_mconv_g, 0, sizeof(H5S_mconv_g));*/ for (i=0; iu.array.nelem=1; iu.array.dim[i],dim[i],hsize_t,size_t); - ret_value->u.array.nelem *= dim[i]; + ret_value->u.array.nelem *=(size_t)dim[i]; } /* end for */ /* Copy the dimension permutations */ diff --git a/src/H5Tconv.c b/src/H5Tconv.c index b3c2e11..6db7550 100644 --- a/src/H5Tconv.c +++ b/src/H5Tconv.c @@ -2345,8 +2345,9 @@ H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts, /* Get length of sequences in bytes */ seq_len=(*(src->u.vlen.getlen))(src->u.vlen.f,s); assert(seq_len>=0); - src_size=seq_len*src_base_size; - dst_size=seq_len*dst_base_size; + H5_CHECK_OVERFLOW(seq_len,hssize_t,size_t); + src_size=(size_t)seq_len*src_base_size; + dst_size=(size_t)seq_len*dst_base_size; /* Check if conversion buffer is large enough, resize if * necessary */ @@ -3203,7 +3204,8 @@ H5T_conv_f_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts, * accomodate that value. The mantissa of course is no * longer normalized. */ - mrsh += 1-expo; + H5_ASSIGN_OVERFLOW(mrsh,(mrsh+1-expo),hssize_t,size_t); + /*mrsh += 1-expo;*/ expo = 0; } else if (expo>=expo_max) { -- cgit v0.12