From 2725a29b0e7158b8b0d8dfd7d3ab42126db6f235 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Wed, 3 Jan 2001 20:31:33 -0500 Subject: [svn-r3236] Purpose: Clean up code. Description: Cleaned up various compiler warnings. Platforms tested: FreeBSD 4.2 (hawkwind) --- src/H5.c | 12 ++++++------ src/H5B.c | 25 +++++++++++++++---------- src/H5D.c | 9 ++++----- src/H5Dcontig.c | 18 ++++++++++++------ src/H5F.c | 16 ++++++++-------- src/H5FL.c | 8 ++++---- src/H5FLprivate.h | 8 ++++---- src/H5Fcontig.c | 18 ++++++++++++------ 8 files changed, 65 insertions(+), 49 deletions(-) diff --git a/src/H5.c b/src/H5.c index 9bf0fb2..c92415f 100644 --- a/src/H5.c +++ b/src/H5.c @@ -1295,7 +1295,7 @@ H5_trace (hbool_t returning, const char *func, const char *type, ...) va_list ap; char buf[64], *rest; const char *argname; - intn argno=0, ptr, n, asize_idx; + intn argno=0, ptr, asize_idx; hssize_t asize[16]; hssize_t i; void *vp = NULL; @@ -1341,7 +1341,7 @@ H5_trace (hbool_t returning, const char *func, const char *type, ...) */ argname = va_arg (ap, char*); if (argname) { - n = MAX (0, (int)HDstrlen(argname)-3); + unsigned n = MAX (0, (int)HDstrlen(argname)-3); if (!HDstrcmp (argname+n, "_id")) { HDstrncpy (buf, argname, MIN ((int)sizeof(buf)-1, n)); buf[MIN((int)sizeof(buf)-1, n)] = '\0'; @@ -1517,8 +1517,8 @@ H5_trace (hbool_t returning, const char *func, const char *type, ...) fprintf(out, "NULL"); } } else { - H5E_major_t n = va_arg(ap, H5E_major_t); - fprintf(out, "%d", (int)n); + H5E_major_t emaj = va_arg(ap, H5E_major_t); + fprintf(out, "%d", (int)emaj); } break; @@ -1530,8 +1530,8 @@ H5_trace (hbool_t returning, const char *func, const char *type, ...) fprintf(out, "NULL"); } } else { - H5E_minor_t n = va_arg(ap, H5E_minor_t); - fprintf(out, "%d", (int)n); + H5E_minor_t emin = va_arg(ap, H5E_minor_t); + fprintf(out, "%d", (int)emin); } break; diff --git a/src/H5B.c b/src/H5B.c index d9ee960..4ee4b9d 100644 --- a/src/H5B.c +++ b/src/H5B.c @@ -123,7 +123,7 @@ static herr_t H5B_flush(H5F_t *f, hbool_t destroy, haddr_t addr, H5B_t *b); static H5B_t *H5B_load(H5F_t *f, haddr_t addr, const void *_type, void *udata); static herr_t H5B_decode_key(H5F_t *f, H5B_t *bt, intn idx); static herr_t H5B_decode_keys(H5F_t *f, H5B_t *bt, intn idx); -static size_t H5B_nodesize(H5F_t *f, const H5B_class_t *type, +static hsize_t H5B_nodesize(H5F_t *f, const H5B_class_t *type, size_t *total_nkey_size, size_t sizeof_rkey); static herr_t H5B_split(H5F_t *f, const H5B_class_t *type, H5B_t *old_bt, haddr_t old_addr, intn idx, @@ -190,7 +190,8 @@ H5B_create(H5F_t *f, const H5B_class_t *type, void *udata, haddr_t *addr_p/*out*/) { H5B_t *bt = NULL; - size_t size, sizeof_rkey; + size_t sizeof_rkey; + hsize_t size; size_t total_native_keysize; size_t offset; intn i; @@ -306,7 +307,8 @@ static H5B_t * H5B_load(H5F_t *f, haddr_t addr, const void *_type, void *udata) { const H5B_class_t *type = (const H5B_class_t *) _type; - size_t size, total_nkey_size; + size_t total_nkey_size; + hsize_t size; H5B_t *bt = NULL; intn i; uint8_t *p; @@ -418,7 +420,7 @@ static herr_t H5B_flush(H5F_t *f, hbool_t destroy, haddr_t addr, H5B_t *bt) { intn i; - size_t size = 0; + hsize_t size = 0; uint8_t *p = bt->page; FUNC_ENTER(H5B_flush, FAIL); @@ -882,7 +884,7 @@ H5B_insert(H5F_t *f, const H5B_class_t *type, haddr_t addr, haddr_t child, old_root; intn level; H5B_t *bt; - size_t size; + hsize_t size; H5B_ins_t my_ins = H5B_INS_ERROR; herr_t ret_value = FAIL; @@ -1651,7 +1653,8 @@ H5B_remove_helper(H5F_t *f, haddr_t addr, const H5B_class_t *type, H5B_t *bt = NULL, *sibling = NULL; H5B_ins_t ret_value = H5B_INS_ERROR; intn idx=-1, lt=0, rt, cmp=1, i; - size_t sizeof_rkey, sizeof_node, sizeof_rec; + size_t sizeof_rkey, sizeof_rec; + hsize_t sizeof_node; FUNC_ENTER(H5B_remove_helper, H5B_INS_ERROR); assert(f); @@ -1995,11 +1998,11 @@ H5B_remove(H5F_t *f, const H5B_class_t *type, haddr_t addr, void *udata) * *------------------------------------------------------------------------- */ -static size_t +static hsize_t H5B_nodesize(H5F_t *f, const H5B_class_t *type, size_t *total_nkey_size/*out*/, size_t sizeof_rkey) { - size_t size; + hsize_t size; FUNC_ENTER(H5B_nodesize, (size_t) 0); @@ -2049,7 +2052,8 @@ static H5B_t * H5B_copy(H5F_t *f, const H5B_t *old_bt) { H5B_t *ret_value = NULL; - size_t size, total_native_keysize; + size_t total_native_keysize; + hsize_t size; uintn nkeys; uintn u; @@ -2087,7 +2091,8 @@ H5B_copy(H5F_t *f, const H5B_t *old_bt) } /* Copy the other structures */ - HDmemcpy(ret_value->page,old_bt->page,size); + assert(size==(hsize_t)((size_t)size)); /*check for overflow*/ + HDmemcpy(ret_value->page,old_bt->page,(size_t)size); HDmemcpy(ret_value->native,old_bt->native,total_native_keysize); HDmemcpy(ret_value->child,old_bt->child,sizeof(haddr_t)*nkeys); HDmemcpy(ret_value->key,old_bt->key,sizeof(H5B_key_t)*(nkeys+1)); diff --git a/src/H5D.c b/src/H5D.c index acf1742..28fb717 100644 --- a/src/H5D.c +++ b/src/H5D.c @@ -1826,7 +1826,7 @@ printf("%s: check 2.0, src_type_size=%d, dst_type_size=%d, target_size=%d, min_e #endif /* Start strip mining... */ - assert(nelmts==(hssize_t)(size_t)nelmts); /*check for overflow*/ + assert(nelmts==(hssize_t)((size_t)nelmts)); /*check for overflow*/ for (smine_start=0; smine_start<(size_t)nelmts; smine_start+=smine_nelmts) { @@ -2294,7 +2294,7 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space, #endif /* Start strip mining... */ - assert(nelmts==(hssize_t)(size_t)nelmts); /*check for overflow*/ + assert(nelmts==(hssize_t)((size_t)nelmts)); /*check for overflow*/ for (smine_start=0; smine_start<(size_t)nelmts; smine_start+=smine_nelmts) { @@ -2772,9 +2772,8 @@ H5Dget_storage_size(hid_t dset_id) H5TRACE1("h","i",dset_id); /* Check args */ - if (H5I_DATASET!=H5I_get_type(dset_id) || - NULL==(dset=H5I_object(dset_id))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset"); + if (H5I_DATASET!=H5I_get_type(dset_id) || NULL==(dset=H5I_object(dset_id))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a dataset"); } size = H5D_get_storage_size(dset); diff --git a/src/H5Dcontig.c b/src/H5Dcontig.c index 385eb0b..14fdda7 100644 --- a/src/H5Dcontig.c +++ b/src/H5Dcontig.c @@ -72,7 +72,8 @@ H5F_contig_read(H5F_t *f, H5FD_mem_t type, haddr_t addr, hsize_t size, hid_t dxp /* If entire read is within the sieve buffer, read it from the buffer */ if(addr>=sieve_start && contig_endshared->sieve_buf+(addr-sieve_start),size); + assert(size==(hsize_t)((size_t)size)); /*check for overflow*/ + HDmemcpy(buf,f->shared->sieve_buf+(addr-sieve_start),(size_t)size); } /* end if */ /* Entire request is not within this data sieve buffer */ else { @@ -134,7 +135,8 @@ H5F_contig_read(H5F_t *f, H5FD_mem_t type, haddr_t addr, hsize_t size, hid_t dxp f->shared->sieve_dirty=0; /* Grab the data out of the buffer (must be first piece of data in buffer ) */ - HDmemcpy(buf,f->shared->sieve_buf,size); + assert(size==(hsize_t)((size_t)size)); /*check for overflow*/ + HDmemcpy(buf,f->shared->sieve_buf,(size_t)size); } /* end else */ } /* end else */ } /* end if */ @@ -174,7 +176,8 @@ H5F_contig_read(H5F_t *f, H5FD_mem_t type, haddr_t addr, hsize_t size, hid_t dxp f->shared->sieve_dirty=0; /* Grab the data out of the buffer (must be first piece of data in buffer ) */ - HDmemcpy(buf,f->shared->sieve_buf,size); + assert(size==(hsize_t)((size_t)size)); /*check for overflow*/ + HDmemcpy(buf,f->shared->sieve_buf,(size_t)size); } /* end else */ } /* end else */ } /* end if */ @@ -234,7 +237,8 @@ H5F_contig_write(H5F_t *f, H5FD_mem_t type, haddr_t addr, hsize_t size, /* If entire write is within the sieve buffer, write it to the buffer */ if(addr>=sieve_start && contig_endshared->sieve_buf+(addr-sieve_start),buf,size); + assert(size==(hsize_t)((size_t)size)); /*check for overflow*/ + HDmemcpy(f->shared->sieve_buf+(addr-sieve_start),buf,(size_t)size); /* Set sieve buffer dirty flag */ f->shared->sieve_dirty=1; @@ -301,7 +305,8 @@ H5F_contig_write(H5F_t *f, H5FD_mem_t type, haddr_t addr, hsize_t size, } /* Grab the data out of the buffer (must be first piece of data in buffer) */ - HDmemcpy(f->shared->sieve_buf,buf,size); + assert(size==(hsize_t)((size_t)size)); /*check for overflow*/ + HDmemcpy(f->shared->sieve_buf,buf,(size_t)size); /* Set sieve buffer dirty flag */ f->shared->sieve_dirty=1; @@ -342,7 +347,8 @@ H5F_contig_write(H5F_t *f, H5FD_mem_t type, haddr_t addr, hsize_t size, } /* Grab the data out of the buffer (must be first piece of data in buffer) */ - HDmemcpy(f->shared->sieve_buf,buf,size); + assert(size==(hsize_t)((size_t)size)); /*check for overflow*/ + HDmemcpy(f->shared->sieve_buf,buf,(size_t)size); /* Set sieve buffer dirty flag */ f->shared->sieve_dirty=1; diff --git a/src/H5F.c b/src/H5F.c index 8dc72ab..8767e6b 100644 --- a/src/H5F.c +++ b/src/H5F.c @@ -600,7 +600,7 @@ H5F_locate_signature(H5FD_t *file) HRETURN_ERROR(H5E_IO, H5E_CANTINIT, HADDR_UNDEF, "unable to set EOA value for file signature"); } - if (H5FD_read(file, H5FD_MEM_SUPER, H5P_DEFAULT, addr, H5F_SIGNATURE_LEN, buf)<0) { + if (H5FD_read(file, H5FD_MEM_SUPER, H5P_DEFAULT, addr, (hsize_t)H5F_SIGNATURE_LEN, buf)<0) { HRETURN_ERROR(H5E_IO, H5E_CANTINIT, HADDR_UNDEF, "unable to read file signature"); } @@ -960,9 +960,9 @@ H5F_open(const char *name, uintn flags, hid_t fcpl_id, hid_t fapl_id) H5FD_t *lf=NULL; /*file driver part of `shared' */ uint8_t buf[256]; /*temporary I/O buffer */ const uint8_t *p; /*ptr into temp I/O buffer */ - size_t fixed_size=24; /*fixed sizeof superblock */ - size_t variable_size; /*variable sizeof superblock */ - size_t driver_size; /*size of driver info block */ + hsize_t fixed_size=24; /*fixed sizeof superblock */ + hsize_t variable_size; /*variable sizeof superblock */ + hsize_t driver_size; /*size of driver info block */ H5G_entry_t root_ent; /*root symbol table entry */ haddr_t eof; /*end of file address */ haddr_t stored_eoa; /*relative end-of-addr in file */ @@ -1192,7 +1192,7 @@ H5F_open(const char *name, uintn flags, hid_t fcpl_id, hid_t fapl_id) /* File consistency flags. Not really used yet */ UINT32DECODE(p, shared->consist_flags); - assert((size_t)(p-buf) == fixed_size); + assert((hsize_t)(p-buf) == fixed_size); /* Decode the variable-length part of the superblock... */ variable_size = H5F_SIZEOF_ADDR(file) + /*base addr*/ @@ -1200,7 +1200,7 @@ H5F_open(const char *name, uintn flags, hid_t fcpl_id, hid_t fapl_id) H5F_SIZEOF_ADDR(file) + /*end-of-address*/ H5F_SIZEOF_ADDR(file) + /*reserved address*/ H5G_SIZEOF_ENTRY(file); /*root group ptr*/ - assert(variable_size<=sizeof buf); + assert(variable_size<=sizeof(buf)); if (H5FD_set_eoa(lf, shared->boot_addr+fixed_size+variable_size)<0 || H5FD_read(lf, H5FD_MEM_SUPER, H5P_DEFAULT, shared->boot_addr+fixed_size, variable_size, buf)<0) { @@ -1221,7 +1221,7 @@ H5F_open(const char *name, uintn flags, hid_t fcpl_id, hid_t fapl_id) if (H5F_addr_defined(shared->driver_addr)) { haddr_t drv_addr = shared->base_addr + shared->driver_addr; if (H5FD_set_eoa(lf, drv_addr+16)<0 || - H5FD_read(lf, H5FD_MEM_SUPER, H5P_DEFAULT, drv_addr, 16, buf)<0) { + H5FD_read(lf, H5FD_MEM_SUPER, H5P_DEFAULT, drv_addr, (hsize_t)16, buf)<0) { HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to read driver information block"); } @@ -1714,7 +1714,7 @@ H5F_flush(H5F_t *f, H5F_scope_t scope, hbool_t invalidate, */ if ((driver_size=H5FD_sb_size(f->shared->lf))) { driver_size += 16; /*driver block header */ - assert(driver_size<=sizeof dbuf); + assert(driver_size<=sizeof(dbuf)); p = dbuf; /* Version */ diff --git a/src/H5FL.c b/src/H5FL.c index 8ba125f..cd619ab 100644 --- a/src/H5FL.c +++ b/src/H5FL.c @@ -680,7 +680,7 @@ H5FL_blk_init(H5FL_blk_head_t *head) *------------------------------------------------------------------------- */ void * -H5FL_blk_alloc(H5FL_blk_head_t *head, size_t size, uintn clear) +H5FL_blk_alloc(H5FL_blk_head_t *head, hsize_t size, uintn clear) { H5FL_blk_node_t *free_list; /* The free list of nodes of correct size */ H5FL_blk_list_t *temp; /* Temp. ptr to the new native list allocated */ @@ -839,7 +839,7 @@ printf("%s: head->name=%s, garbage collecting all block lists\n",FUNC,head->name *------------------------------------------------------------------------- */ void * -H5FL_blk_realloc(H5FL_blk_head_t *head, void *block, size_t new_size) +H5FL_blk_realloc(H5FL_blk_head_t *head, void *block, hsize_t new_size) { H5FL_blk_list_t *temp; /* Temp. ptr to the new block node allocated */ void *ret_value=NULL; /* Return value */ @@ -1192,7 +1192,7 @@ H5FL_arr_free(H5FL_arr_head_t *head, void *obj) *------------------------------------------------------------------------- */ void * -H5FL_arr_alloc(H5FL_arr_head_t *head, size_t elem, uintn clear) +H5FL_arr_alloc(H5FL_arr_head_t *head, hsize_t elem, uintn clear) { H5FL_arr_node_t *new_obj; /* Pointer to the new free list node allocated */ void *ret_value; /* Pointer to object to return */ @@ -1280,7 +1280,7 @@ H5FL_arr_alloc(H5FL_arr_head_t *head, size_t elem, uintn clear) *------------------------------------------------------------------------- */ void * -H5FL_arr_realloc(H5FL_arr_head_t *head, void * obj, size_t new_elem) +H5FL_arr_realloc(H5FL_arr_head_t *head, void * obj, hsize_t new_elem) { H5FL_arr_node_t *temp; /* Temp. ptr to the new free list node allocated */ void *ret_value; /* Pointer to object to return */ diff --git a/src/H5FLprivate.h b/src/H5FLprivate.h index af3a98f..472bcca 100644 --- a/src/H5FLprivate.h +++ b/src/H5FLprivate.h @@ -171,14 +171,14 @@ typedef struct H5FL_arr_head_t { /* * Library prototypes. */ -__DLL__ void * H5FL_blk_alloc(H5FL_blk_head_t *head, size_t size, uintn clear); +__DLL__ void * H5FL_blk_alloc(H5FL_blk_head_t *head, hsize_t size, uintn clear); __DLL__ void * H5FL_blk_free(H5FL_blk_head_t *head, void *block); -__DLL__ void * H5FL_blk_realloc(H5FL_blk_head_t *head, void *block, size_t new_size); +__DLL__ void * H5FL_blk_realloc(H5FL_blk_head_t *head, void *block, hsize_t new_size); __DLL__ void * H5FL_reg_alloc(H5FL_reg_head_t *head, uintn clear); __DLL__ void * H5FL_reg_free(H5FL_reg_head_t *head, void *obj); -__DLL__ void * H5FL_arr_alloc(H5FL_arr_head_t *head, size_t elem, uintn clear); +__DLL__ void * H5FL_arr_alloc(H5FL_arr_head_t *head, hsize_t elem, uintn clear); __DLL__ void * H5FL_arr_free(H5FL_arr_head_t *head, void *obj); -__DLL__ void * H5FL_arr_realloc(H5FL_arr_head_t *head, void *obj, size_t new_elem); +__DLL__ void * H5FL_arr_realloc(H5FL_arr_head_t *head, void *obj, hsize_t new_elem); __DLL__ herr_t H5FL_garbage_coll(void); __DLL__ herr_t H5FL_set_free_list_limits(int reg_global_lim, int reg_list_lim, int arr_global_lim, int arr_list_lim, int blk_global_lim, int blk_list_lim); diff --git a/src/H5Fcontig.c b/src/H5Fcontig.c index 385eb0b..14fdda7 100644 --- a/src/H5Fcontig.c +++ b/src/H5Fcontig.c @@ -72,7 +72,8 @@ H5F_contig_read(H5F_t *f, H5FD_mem_t type, haddr_t addr, hsize_t size, hid_t dxp /* If entire read is within the sieve buffer, read it from the buffer */ if(addr>=sieve_start && contig_endshared->sieve_buf+(addr-sieve_start),size); + assert(size==(hsize_t)((size_t)size)); /*check for overflow*/ + HDmemcpy(buf,f->shared->sieve_buf+(addr-sieve_start),(size_t)size); } /* end if */ /* Entire request is not within this data sieve buffer */ else { @@ -134,7 +135,8 @@ H5F_contig_read(H5F_t *f, H5FD_mem_t type, haddr_t addr, hsize_t size, hid_t dxp f->shared->sieve_dirty=0; /* Grab the data out of the buffer (must be first piece of data in buffer ) */ - HDmemcpy(buf,f->shared->sieve_buf,size); + assert(size==(hsize_t)((size_t)size)); /*check for overflow*/ + HDmemcpy(buf,f->shared->sieve_buf,(size_t)size); } /* end else */ } /* end else */ } /* end if */ @@ -174,7 +176,8 @@ H5F_contig_read(H5F_t *f, H5FD_mem_t type, haddr_t addr, hsize_t size, hid_t dxp f->shared->sieve_dirty=0; /* Grab the data out of the buffer (must be first piece of data in buffer ) */ - HDmemcpy(buf,f->shared->sieve_buf,size); + assert(size==(hsize_t)((size_t)size)); /*check for overflow*/ + HDmemcpy(buf,f->shared->sieve_buf,(size_t)size); } /* end else */ } /* end else */ } /* end if */ @@ -234,7 +237,8 @@ H5F_contig_write(H5F_t *f, H5FD_mem_t type, haddr_t addr, hsize_t size, /* If entire write is within the sieve buffer, write it to the buffer */ if(addr>=sieve_start && contig_endshared->sieve_buf+(addr-sieve_start),buf,size); + assert(size==(hsize_t)((size_t)size)); /*check for overflow*/ + HDmemcpy(f->shared->sieve_buf+(addr-sieve_start),buf,(size_t)size); /* Set sieve buffer dirty flag */ f->shared->sieve_dirty=1; @@ -301,7 +305,8 @@ H5F_contig_write(H5F_t *f, H5FD_mem_t type, haddr_t addr, hsize_t size, } /* Grab the data out of the buffer (must be first piece of data in buffer) */ - HDmemcpy(f->shared->sieve_buf,buf,size); + assert(size==(hsize_t)((size_t)size)); /*check for overflow*/ + HDmemcpy(f->shared->sieve_buf,buf,(size_t)size); /* Set sieve buffer dirty flag */ f->shared->sieve_dirty=1; @@ -342,7 +347,8 @@ H5F_contig_write(H5F_t *f, H5FD_mem_t type, haddr_t addr, hsize_t size, } /* Grab the data out of the buffer (must be first piece of data in buffer) */ - HDmemcpy(f->shared->sieve_buf,buf,size); + assert(size==(hsize_t)((size_t)size)); /*check for overflow*/ + HDmemcpy(f->shared->sieve_buf,buf,(size_t)size); /* Set sieve buffer dirty flag */ f->shared->sieve_dirty=1; -- cgit v0.12