diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/H5AC.c | 15 | ||||
-rw-r--r-- | src/H5C.c | 5 | ||||
-rw-r--r-- | src/H5Cpkg.h | 6 | ||||
-rw-r--r-- | src/H5Cprivate.h | 2 | ||||
-rw-r--r-- | src/H5Dint.c | 2 | ||||
-rw-r--r-- | src/H5Doh.c | 2 | ||||
-rw-r--r-- | src/H5FD.c | 122 | ||||
-rw-r--r-- | src/H5FL.c | 2 | ||||
-rw-r--r-- | src/H5Ffake.c | 2 | ||||
-rw-r--r-- | src/H5Fsfile.c | 2 | ||||
-rw-r--r-- | src/H5O.c | 16 | ||||
-rw-r--r-- | src/H5Oalloc.c | 51 | ||||
-rw-r--r-- | src/H5Oattribute.c | 15 | ||||
-rw-r--r-- | src/H5Ocache.c | 52 | ||||
-rw-r--r-- | src/H5Ochunk.c | 7 | ||||
-rw-r--r-- | src/H5Opkg.h | 6 | ||||
-rw-r--r-- | src/H5Oprivate.h | 2 |
17 files changed, 169 insertions, 140 deletions
@@ -147,9 +147,8 @@ static herr_t H5AC_check_if_write_permitted(const H5F_t *f, static herr_t H5AC_broadcast_clean_list(H5AC_t * cache_ptr); #endif /* JRM */ -static herr_t H5AC_ext_config_2_int_config( - H5AC_cache_config_t * ext_conf_ptr, - H5C_auto_size_ctl_t * int_conf_ptr); +static herr_t H5AC_ext_config_2_int_config(H5AC_cache_config_t * ext_conf_ptr, + H5C_auto_size_ctl_t * int_conf_ptr); #ifdef H5_HAVE_PARALLEL static herr_t H5AC_log_deleted_entry(H5AC_t * cache_ptr, @@ -2218,6 +2217,9 @@ H5AC_pin_protected_entry(void *thing) FUNC_ENTER_NOAPI(H5AC_pin_protected_entry, FAIL) + /* Sanity check */ + HDassert(thing); + #if H5AC__TRACE_FILE_ENABLED /* For the pin protected entry call, only the addr is really necessary * in the trace file. Also write the result to catch occult errors. @@ -2692,7 +2694,7 @@ H5AC_unprotect(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t addr, } #endif /* H5AC__TRACE_FILE_ENABLED */ - dirtied = ( ( (flags & H5AC__DIRTIED_FLAG) == H5AC__DIRTIED_FLAG ) || + dirtied = (hbool_t)( ( (flags & H5AC__DIRTIED_FLAG) == H5AC__DIRTIED_FLAG ) || ( ((H5AC_info_t *)thing)->dirtied ) ); size_changed = ( (flags & H5AC__SIZE_CHANGED_FLAG) == @@ -2701,9 +2703,8 @@ H5AC_unprotect(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t addr, #ifdef H5_HAVE_PARALLEL if ( ( dirtied ) && ( ((H5AC_info_t *)thing)->is_dirty == FALSE ) && ( NULL != (aux_ptr = f->shared->cache->aux_ptr) ) ) { - - if(H5AC_log_dirtied_entry(thing, addr, size_changed, new_size) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "can't log entry") + if(H5AC_log_dirtied_entry((H5AC_info_t *)thing, addr, size_changed, new_size) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "can't log dirtied entry") } if ( ( (flags & H5C__DELETED_FLAG) != 0 ) && @@ -709,8 +709,7 @@ done: H5SL_close(cache_ptr->slist_ptr); cache_ptr->magic = 0; - H5FL_FREE(H5C_t, cache_ptr); - cache_ptr = NULL; + cache_ptr = H5FL_FREE(H5C_t, cache_ptr); } /* end if */ @@ -1052,7 +1051,7 @@ H5C_dest_empty(H5C_t * cache_ptr) cache_ptr->magic = 0; - H5FL_FREE(H5C_t, cache_ptr); + cache_ptr = H5FL_FREE(H5C_t, cache_ptr); done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Cpkg.h b/src/H5Cpkg.h index 3925fdd..ee0b108 100644 --- a/src/H5Cpkg.h +++ b/src/H5Cpkg.h @@ -4557,9 +4557,9 @@ if ( ( (cache_ptr) == NULL ) || \ if ( (entry_ptr)->is_pinned ) { \ \ H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->pel_head_ptr, \ - (cache_ptr)->pel_tail_ptr, \ - (cache_ptr)->pel_len, \ - (cache_ptr)->pel_size, (fail_val)) \ + (cache_ptr)->pel_tail_ptr, \ + (cache_ptr)->pel_len, \ + (cache_ptr)->pel_size, (fail_val)) \ \ } else if ( (entry_ptr)->last_trans != 0 ) { \ \ diff --git a/src/H5Cprivate.h b/src/H5Cprivate.h index 3033a4f..5510cc0 100644 --- a/src/H5Cprivate.h +++ b/src/H5Cprivate.h @@ -83,7 +83,7 @@ * want them on for testing on occasion, but in general they should be * off. */ -#define H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS 0 /* JRM */ +#define H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS 0 #endif /* H5_HAVE_PARALLEL */ diff --git a/src/H5Dint.c b/src/H5Dint.c index 292748b..49a83a2 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -29,7 +29,7 @@ #include "H5private.h" /* Generic Functions */ #include "H5Dpkg.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free Lists */ +#include "H5FLprivate.h" /* Free Lists */ #include "H5FOprivate.h" /* File objects */ #include "H5HLprivate.h" /* Local heaps */ #include "H5Iprivate.h" /* IDs */ diff --git a/src/H5Doh.c b/src/H5Doh.c index e99f9ee..0972d17 100644 --- a/src/H5Doh.c +++ b/src/H5Doh.c @@ -155,7 +155,7 @@ H5O_dset_free_copy_file_udata(void *_udata) H5O_msg_free(H5O_PLINE_ID, udata->src_pline); /* Release space for 'copy file' user data */ - H5FL_FREE(H5D_copy_file_ud_t, udata); + udata = H5FL_FREE(H5D_copy_file_ud_t, udata); FUNC_LEAVE_NOAPI_VOID } /* end H5O_dset_free_copy_file_udata() */ @@ -1930,72 +1930,67 @@ H5FD_read(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t siz /* Check if this information is in the metadata accumulator */ if((file->feature_flags&H5FD_FEAT_ACCUMULATE_METADATA) && type!=H5FD_MEM_DRAW) { - /* Current read overlaps with metadata accumulator */ - if(H5F_addr_overlap(addr,size,file->accum_loc,file->accum_size)) { - unsigned char *read_buf=(unsigned char *)buf; /* Pointer to the buffer being read in */ - size_t amount_read; /* Amount to read at a time */ -#ifndef NDEBUG - hsize_t tempamount_read; /* Amount to read at a time */ -#endif /* NDEBUG */ - hsize_t read_off; /* Offset to read from */ - - /* Double check that we aren't reading raw data */ - assert(type!=H5FD_MEM_DRAW); + /* Current read adjoins or overlaps with metadata accumulator */ + if(H5F_addr_overlap(addr, size, file->accum_loc, file->accum_size) + || ((addr + size) == file->accum_loc) + || (file->accum_loc + file->accum_size) == addr) { + size_t amount_before; /* Amount to read before current accumulator */ + haddr_t new_addr; /* New address of the accumulator buffer */ + size_t new_size; /* New size of the accumulator buffer */ + + /* Compute new values for accumulator */ + new_addr = MIN(addr, file->accum_loc); + new_size = (size_t)(MAX((addr + size), (file->accum_loc + file->accum_size)) + - new_addr); + + /* Check if we need more buffer space */ + if(new_size > file->accum_buf_size) { + /* Adjust the buffer size, by doubling it */ + file->accum_buf_size = MAX(file->accum_buf_size * 2, new_size); + + /* Reallocate the metadata accumulator buffer */ + if(NULL == (file->meta_accum = H5FL_BLK_REALLOC(meta_accum, file->meta_accum, file->accum_buf_size))) + HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, FAIL, "unable to allocate metadata accumulator buffer") +#ifdef H5_CLEAR_MEMORY +HDmemset(file->meta_accum + file->accum_size, 0, (file->accum_buf_size - file->accum_size)); +#endif /* H5_CLEAR_MEMORY */ + } /* end if */ /* Read the part before the metadata accumulator */ - if(addr<file->accum_loc) { + if(addr < file->accum_loc) { /* Set the amount to read */ - H5_ASSIGN_OVERFLOW(amount_read,file->accum_loc-addr,hsize_t,size_t); + H5_ASSIGN_OVERFLOW(amount_before, (file->accum_loc - addr), hsize_t, size_t); + + /* Make room for the metadata to read in */ + HDmemmove(file->meta_accum + amount_before, file->meta_accum, file->accum_size); /* Dispatch to driver */ - if((file->cls->read)(file, type, dxpl_id, addr, amount_read, read_buf) < 0) + if((file->cls->read)(file, type, dxpl_id, addr, amount_before, file->meta_accum) < 0) HGOTO_ERROR(H5E_VFL, H5E_READERROR, FAIL, "driver read request failed") - - /* Adjust the buffer, address & size */ - read_buf+=amount_read; - addr+=amount_read; - size-=amount_read; - } /* end if */ - - /* Copy the part overlapping the metadata accumulator */ - if(size>0 && (addr>=file->accum_loc && addr<(file->accum_loc+file->accum_size))) { - /* Set the offset to "read" from */ - read_off=addr-file->accum_loc; - - /* Set the amount to "read" */ -#ifndef NDEBUG - tempamount_read = file->accum_size-read_off; - H5_CHECK_OVERFLOW(tempamount_read,hsize_t,size_t); - amount_read = MIN(size, (size_t)tempamount_read); -#else /* NDEBUG */ - amount_read = MIN(size, (size_t)(file->accum_size-read_off)); -#endif /* NDEBUG */ - - /* Copy the data out of the buffer */ - HDmemcpy(read_buf,file->meta_accum+read_off,amount_read); - - /* Adjust the buffer, address & size */ - read_buf+=amount_read; - addr+=amount_read; - size-=amount_read; } /* end if */ + else + amount_before = 0; /* Read the part after the metadata accumulator */ - if(size>0 && addr>=(file->accum_loc+file->accum_size)) { + if((addr + size) > (file->accum_loc + file->accum_size)) { + size_t amount_after; /* Amount to read at a time */ + + /* Set the amount to read */ + H5_ASSIGN_OVERFLOW(amount_after, ((addr + size) - (file->accum_loc + file->accum_size)), hsize_t, size_t); + /* Dispatch to driver */ - if((file->cls->read)(file, type, dxpl_id, addr, size, read_buf) < 0) + if((file->cls->read)(file, type, dxpl_id, (file->accum_loc + file->accum_size), amount_after, (file->meta_accum + file->accum_size + amount_before)) < 0) HGOTO_ERROR(H5E_VFL, H5E_READERROR, FAIL, "driver read request failed") - - /* Adjust the buffer, address & size */ - read_buf+=size; - addr+=size; - size-=size; } /* end if */ - /* Make certain we've read it all */ - assert(size==0); + /* Copy the data out of the buffer */ + HDmemcpy(buf, file->meta_accum + (addr - new_addr), size); + + /* Adjust the accumulator address & size */ + file->accum_loc = new_addr; + file->accum_size = new_size; } /* end if */ - /* Current read doesn't overlap with metadata accumulator, read it into accumulator */ + /* Current read doesn't adjoin or overlap with metadata accumulator, read it into accumulator */ else { /* Only update the metadata accumulator if it is not dirty or if * we are allowed to write the accumulator out during reads (when @@ -2288,8 +2283,29 @@ HDmemset(file->meta_accum + file->accum_size, 0, (file->accum_buf_size - file->a /* Mark it as written to */ file->accum_dirty=TRUE; } /* end if */ + /* New metadata overlaps both ends of the current accumulator */ else { - assert(0 && "New metadata overlapped both beginning and end of existing metadata accumulator!"); + /* Check if we need more buffer space */ + if(size>file->accum_buf_size) { + /* Adjust the buffer size, by doubling it */ + file->accum_buf_size = MAX(file->accum_buf_size * 2, size); + + /* Reallocate the metadata accumulator buffer */ + if(NULL == (file->meta_accum = H5FL_BLK_REALLOC(meta_accum, file->meta_accum, file->accum_buf_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate metadata accumulator buffer") +#ifdef H5_CLEAR_MEMORY +HDmemset(file->meta_accum + size, 0, (file->accum_buf_size - size)); +#endif /* H5_CLEAR_MEMORY */ + } /* end if */ + + /* Copy the new metadata to the buffer */ + HDmemcpy(file->meta_accum, buf, size); + + /* Set the new size & location of the metadata accumulator */ + file->accum_size = size; + + /* Mark it as written to */ + file->accum_dirty = TRUE; } /* end else */ } /* end if */ /* New piece of metadata doesn't adjoin or overlap the existing accumulator */ @@ -2133,7 +2133,7 @@ H5FL_fac_term(H5FL_fac_head_t *factory) H5FL_blk_unlink(&(factory->queue)); /* Free factory info */ - H5FL_FREE(H5FL_fac_head_t,factory); + factory = H5FL_FREE(H5FL_fac_head_t, factory); done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Ffake.c b/src/H5Ffake.c index 42a33e0..950eeec 100644 --- a/src/H5Ffake.c +++ b/src/H5Ffake.c @@ -121,7 +121,7 @@ H5F_fake_free(H5F_t *f) /* Destroy shared file struct */ if(f->shared) f->shared = H5FL_FREE(H5F_file_t, f->shared); - H5FL_FREE(H5F_t, f); + f = H5FL_FREE(H5F_t, f); } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) diff --git a/src/H5Fsfile.c b/src/H5Fsfile.c index 354b307..8144986 100644 --- a/src/H5Fsfile.c +++ b/src/H5Fsfile.c @@ -219,7 +219,7 @@ H5F_sfile_remove(H5F_file_t *shared) /* Release the shared file node struct */ /* (the shared file info itself is freed elsewhere) */ - H5FL_FREE(H5F_sfile_node_t, curr); + curr = H5FL_FREE(H5F_sfile_node_t, curr); done: FUNC_LEAVE_NOAPI(ret_value) @@ -1082,7 +1082,7 @@ H5O_create(H5F_t *f, hid_t dxpl_id, size_t size_hint, hid_t ocpl_id, size_hint = H5O_ALIGN_F(f, MAX(H5O_MIN_SIZE, size_hint)); /* Get the property list */ - if(NULL == (oc_plist = H5I_object(ocpl_id))) + if(NULL == (oc_plist = (H5P_genplist_t *)H5I_object(ocpl_id))) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a property list") /* Get any object header status flags set by properties */ @@ -1138,7 +1138,7 @@ H5O_create(H5F_t *f, hid_t dxpl_id, size_t size_hint, hid_t ocpl_id, oh->flags |= H5O_HDR_ATTR_STORE_PHASE_CHANGE; /* Determine correct value for chunk #0 size bits */ - if(size_hint > 4294967295) + if(size_hint > 4294967295UL) oh->flags |= H5O_HDR_CHUNK0_8; else if(size_hint > 65535) oh->flags |= H5O_HDR_CHUNK0_4; @@ -1152,7 +1152,7 @@ H5O_create(H5F_t *f, hid_t dxpl_id, size_t size_hint, hid_t ocpl_id, /* Compute total size of initial object header */ /* (i.e. object header prefix and first chunk) */ - oh_size = H5O_SIZEOF_HDR(oh) + size_hint; + oh_size = (size_t)H5O_SIZEOF_HDR(oh) + size_hint; /* Allocate disk space for header and first chunk */ if(HADDR_UNDEF == (oh_addr = H5MF_alloc(f, H5FD_MEM_OHDR, dxpl_id, (hsize_t)oh_size))) @@ -1522,7 +1522,7 @@ H5O_link(const H5O_loc_t *loc, int adjust, hid_t dxpl_id) } /* end if */ /* Set return value */ - ret_value = oh->nlink; + ret_value = (int)oh->nlink; done: if(oh && H5O_unpin(oh) < 0) @@ -1637,9 +1637,9 @@ H5O_protect(const H5O_loc_t *loc, hid_t dxpl_id, H5AC_protect_t prot) /* Release any continuation messages built up */ if(cont_msg_info.msgs) - H5FL_SEQ_FREE(H5O_cont_t, cont_msg_info.msgs); + cont_msg_info.msgs = (H5O_cont_t *)H5FL_SEQ_FREE(H5O_cont_t, cont_msg_info.msgs); - /* Pass the back out some of the chunk's user data */ + /* Pass back out some of the chunk's user data */ udata.common.merged_null_msgs = chk_udata.common.merged_null_msgs; udata.common.mesgs_modified = chk_udata.common.mesgs_modified; } /* end if */ @@ -1674,7 +1674,7 @@ H5O_protect(const H5O_loc_t *loc, hid_t dxpl_id, H5AC_protect_t prot) if(H5AC_get_entry_status(loc->file, loc->addr, &oh_status) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, NULL, "unable to check metadata cache status for object header") - /* Make certain that object header is dirty */ + /* Make certain that object header is not dirty */ HDassert(!(oh_status & H5AC_ES__IS_DIRTY)); } /* end else */ #endif /* NDEBUG */ @@ -2901,7 +2901,7 @@ H5O_free_visit_visited(void *item, void UNUSED *key, void UNUSED *operator_data/ { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_free_visit_visited) - H5FL_FREE(H5_obj_t, item); + item = H5FL_FREE(H5_obj_t, item); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O_free_visit_visited() */ diff --git a/src/H5Oalloc.c b/src/H5Oalloc.c index 202c190..45ed422 100644 --- a/src/H5Oalloc.c +++ b/src/H5Oalloc.c @@ -167,7 +167,7 @@ H5O_add_gap(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned chunkno, unsigned idx, /* Check if we need to extend message table to hold the new null message */ if(oh->nmesgs >= oh->alloc_nmesgs) if(H5O_alloc_msgs(oh, (size_t)1) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, UFAIL, "can't allocate more space for messages") + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate more space for messages") /* Increment new gap size */ oh->chunk[chunkno].gap += new_gap_size; @@ -369,7 +369,7 @@ H5O_alloc_null(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned null_idx, /* Add the gap to the chunk */ if(H5O_add_gap(f, dxpl_id, oh, alloc_msg->chunkno, null_idx, alloc_msg->raw + alloc_msg->raw_size, gap_size) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, UFAIL, "can't insert gap in chunk") + HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "can't insert gap in chunk") } /* end if */ else { H5O_chunk_proxy_t *null_chk_proxy; /* Chunk that message is in */ @@ -379,7 +379,7 @@ H5O_alloc_null(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned null_idx, /* Check if we need to extend message table to hold the new null message */ if(oh->nmesgs >= oh->alloc_nmesgs) { if(H5O_alloc_msgs(oh, (size_t)1) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, UFAIL, "can't allocate more space for messages") + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate more space for messages") /* "Retarget" 'alloc_msg' pointer into newly re-allocated array of messages */ alloc_msg = &oh->mesg[null_idx]; @@ -387,7 +387,7 @@ H5O_alloc_null(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned null_idx, /* Protect chunk */ if(NULL == (null_chk_proxy = H5O_chunk_protect(f, dxpl_id, oh, alloc_msg->chunkno))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, UFAIL, "unable to load object header chunk") + HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header chunk") /* Create new null message, with the tail of the previous null message */ null_msg = &(oh->mesg[oh->nmesgs++]); @@ -402,7 +402,7 @@ H5O_alloc_null(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned null_idx, /* Release chunk, marking it dirty */ if(H5O_chunk_unprotect(f, dxpl_id, oh, null_chk_proxy, H5AC__DIRTIED_FLAG) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, UFAIL, "unable to unprotect object header chunk") + HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk") /* Check for gap in new null message's chunk */ if(oh->chunk[null_msg->chunkno].gap > 0) { @@ -412,7 +412,7 @@ H5O_alloc_null(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned null_idx, if(H5O_eliminate_gap(f, dxpl_id, oh, null_msg, ((oh->chunk[null_chunkno].image + oh->chunk[null_chunkno].size) - (H5O_SIZEOF_CHKSUM_OH(oh) + oh->chunk[null_chunkno].gap)), oh->chunk[null_chunkno].gap) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTREMOVE, UFAIL, "can't eliminate gap in chunk") + HGOTO_ERROR(H5E_OHDR, H5E_CANTREMOVE, FAIL, "can't eliminate gap in chunk") } /* end if */ /* Set the size of the new "real" message */ @@ -422,7 +422,7 @@ H5O_alloc_null(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned null_idx, /* Protect chunk */ if(NULL == (chk_proxy = H5O_chunk_protect(f, dxpl_id, oh, alloc_msg->chunkno))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, UFAIL, "unable to load object header chunk") + HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header chunk") /* Initialize the new message */ alloc_msg->type = new_type; @@ -435,7 +435,7 @@ H5O_alloc_null(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned null_idx, done: /* Release chunk */ if(chk_proxy && H5O_chunk_unprotect(f, dxpl_id, oh, chk_proxy, chk_flags) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, UFAIL, "unable to unprotect object header chunk") + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk") FUNC_LEAVE_NOAPI(ret_value) } /* H5O_alloc_null() */ @@ -555,7 +555,7 @@ H5O_alloc_extend_chunk(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned chunkno, == ((oh->chunk[chunkno].image + oh->chunk[chunkno].size) - (oh->chunk[chunkno].gap + H5O_SIZEOF_CHKSUM_OH(oh))))) { - extend_msg = u; + extend_msg = (int)u; break; } /* end if */ } /* end for */ @@ -571,7 +571,10 @@ H5O_alloc_extend_chunk(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned chunkno, /* Check for changing the chunk #0 data size enough to need adjusting the flags */ if(oh->version > H5O_VERSION_1 && chunkno == 0) { - uint64_t chunk0_size = oh->chunk[0].size - H5O_SIZEOF_HDR(oh); /* Size of chunk 0's data */ + uint64_t chunk0_size; /* Size of chunk 0's data */ + + HDassert(oh->chunk[0].size >= (size_t)H5O_SIZEOF_HDR(oh)); + chunk0_size = oh->chunk[0].size - (size_t)H5O_SIZEOF_HDR(oh); /* Check for moving from a 1-byte to a 2-byte size encoding */ if(chunk0_size <= 255 && (chunk0_size + delta) > 255) { @@ -611,7 +614,7 @@ H5O_alloc_extend_chunk(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned chunkno, /* Adjust object header prefix flags */ if(adjust_size_flags) { - oh->flags &= ~H5O_HDR_CHUNK0_SIZE; + oh->flags &= (uint8_t)~H5O_HDR_CHUNK0_SIZE; oh->flags |= new_size_flags; /* Mark object header as dirty in cache */ @@ -632,7 +635,7 @@ H5O_alloc_extend_chunk(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned chunkno, HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate more space for messages") /* Set extension message */ - extend_msg = oh->nmesgs++; + extend_msg = (int)oh->nmesgs++; /* Initialize new null message */ oh->mesg[extend_msg].type = H5O_MSG_NULL; @@ -702,7 +705,7 @@ H5O_alloc_extend_chunk(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned chunkno, chk_flags |= H5AC__SIZE_CHANGED_FLAG; /* Set return value */ - *msg_idx = extend_msg; + *msg_idx = (unsigned)extend_msg; done: /* Release chunk */ @@ -795,12 +798,12 @@ H5O_alloc_new_chunk(H5F_t *f, hid_t dxpl_id, H5O_t *oh, size_t size) for(u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) { if(curr_msg->type->id == H5O_NULL_ID) { if(cont_size == curr_msg->raw_size) { - found_null = u; + found_null = (int)u; break; } /* end if */ else if(curr_msg->raw_size > cont_size && (found_null < 0 || curr_msg->raw_size < oh->mesg[found_null].raw_size)) - found_null = u; + found_null = (int)u; } /* end if */ else if(curr_msg->type->id == H5O_CONT_ID) { /* Don't consider continuation messages (for now) */ @@ -841,7 +844,7 @@ H5O_alloc_new_chunk(H5F_t *f, hid_t dxpl_id, H5O_t *oh, size_t size) if(total_size >= cont_size) { if(curr_msg->type->id == H5O_ATTR_ID) { if(found_attr.msgno < 0 || total_size < found_attr.total_size) { - found_attr.msgno = u; + found_attr.msgno = (int)u; found_attr.gap_size = gap_size; found_attr.null_size = null_size; found_attr.total_size = total_size; @@ -850,7 +853,7 @@ H5O_alloc_new_chunk(H5F_t *f, hid_t dxpl_id, H5O_t *oh, size_t size) } /* end if */ else { if(found_other.msgno < 0 || total_size < found_other.total_size) { - found_other.msgno = u; + found_other.msgno = (int)u; found_other.gap_size = gap_size; found_other.null_size = null_size; found_other.total_size = total_size; @@ -947,7 +950,7 @@ H5O_alloc_new_chunk(H5F_t *f, hid_t dxpl_id, H5O_t *oh, size_t size) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, UFAIL, "unable to load object header chunk") /* Create null message for space that message to copy currently occupies */ - found_null = oh->nmesgs++; + found_null = (int)oh->nmesgs++; null_msg = &(oh->mesg[found_null]); null_msg->type = H5O_MSG_NULL; null_msg->native = NULL; @@ -1013,7 +1016,7 @@ H5O_alloc_new_chunk(H5F_t *f, hid_t dxpl_id, H5O_t *oh, size_t size) oh->mesg[idx].dirty = TRUE; oh->mesg[idx].native = NULL; oh->mesg[idx].raw = p + H5O_SIZEOF_MSGHDR_OH(oh); - oh->mesg[idx].raw_size = size - (H5O_SIZEOF_CHKHDR_OH(oh) + H5O_SIZEOF_MSGHDR_OH(oh)); + oh->mesg[idx].raw_size = size - (size_t)(H5O_SIZEOF_CHKHDR_OH(oh) + H5O_SIZEOF_MSGHDR_OH(oh)); oh->mesg[idx].chunkno = chunkno; /* Insert the new chunk into the cache */ @@ -1456,7 +1459,7 @@ H5O_move_msgs_forward(H5F_t *f, hid_t dxpl_id, H5O_t *oh) } while(packed_msg); /* Set return value */ - ret_value = did_packing; + ret_value = (htri_t)did_packing; done: FUNC_LEAVE_NOAPI(ret_value) @@ -1527,7 +1530,7 @@ H5O_merge_null(H5F_t *f, hid_t dxpl_id, H5O_t *oh) /* Check for second message before first message */ else if((curr_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh)) == (curr_msg2->raw + curr_msg2->raw_size)) { /* Adjust first message address and extend length to cover second message */ - adj_raw = -(H5O_SIZEOF_MSGHDR_OH(oh) + curr_msg2->raw_size); + adj_raw = -((ssize_t)(H5O_SIZEOF_MSGHDR_OH(oh) + curr_msg2->raw_size)); adj_raw_size = H5O_SIZEOF_MSGHDR_OH(oh) + curr_msg2->raw_size; /* Message has been merged */ @@ -1582,7 +1585,7 @@ H5O_merge_null(H5F_t *f, hid_t dxpl_id, H5O_t *oh) } while(merged_msg); /* Set return value */ - ret_value = did_merging; + ret_value = (htri_t)did_merging; done: FUNC_LEAVE_NOAPI(ret_value) @@ -1684,7 +1687,7 @@ H5O_remove_empty_chunks(H5F_t *f, hid_t dxpl_id, H5O_t *oh) */ /* Free memory for chunk image */ - H5FL_BLK_FREE(chunk_image, oh->chunk[null_msg->chunkno].image); + oh->chunk[null_msg->chunkno].image = H5FL_BLK_FREE(chunk_image, oh->chunk[null_msg->chunkno].image); /* Remove chunk from list of chunks */ if(null_msg->chunkno < (oh->nchunks - 1)) { @@ -1773,7 +1776,7 @@ H5O_remove_empty_chunks(H5F_t *f, hid_t dxpl_id, H5O_t *oh) } while(deleted_chunk); /* Set return value */ - ret_value = did_deleting; + ret_value = (htri_t)did_deleting; done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Oattribute.c b/src/H5Oattribute.c index cad15ce..0f1cdc6 100644 --- a/src/H5Oattribute.c +++ b/src/H5Oattribute.c @@ -687,16 +687,14 @@ htri_t H5O_attr_find_opened_attr(const H5O_loc_t *loc, H5A_t **attr, const char* HGOTO_ERROR(H5E_ATTR, H5E_BADVALUE, FAIL, "can't get file serial number") /* Count all opened attributes */ - if((num_open_attr = H5F_get_obj_count(loc->file, H5F_OBJ_ATTR | H5F_OBJ_LOCAL)) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTCOUNT, FAIL, "can't get number of opened attributes") + num_open_attr = H5F_get_obj_count(loc->file, H5F_OBJ_ATTR | H5F_OBJ_LOCAL); /* Find out whether the attribute has been opened */ if(num_open_attr) { - attr_id_list = (hid_t*)H5MM_malloc(num_open_attr*sizeof(hid_t)); + attr_id_list = (hid_t *)H5MM_malloc((size_t)num_open_attr * sizeof(hid_t)); /* Retrieve the IDs of all opened attributes */ - if(H5F_get_obj_ids(loc->file, H5F_OBJ_ATTR | H5F_OBJ_LOCAL, num_open_attr, attr_id_list) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't IDs of opened attributes") + H5F_get_obj_ids(loc->file, H5F_OBJ_ATTR | H5F_OBJ_LOCAL, num_open_attr, attr_id_list); for(i=0; i<num_open_attr; i++) { if(NULL == (*attr = (H5A_t *)H5I_object_verify(attr_id_list[i], H5I_ATTR))) @@ -1070,7 +1068,7 @@ H5O_attr_rename_mod_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, /* Check for shared message */ if(mesg->flags & H5O_MSG_FLAG_SHARED) { /* Update the shared attribute in the SOHM storage */ - if(H5O_attr_update_shared(udata->f, udata->dxpl_id, oh, mesg->native, NULL) < 0) + if(H5O_attr_update_shared(udata->f, udata->dxpl_id, oh, (H5A_t *)mesg->native, NULL) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTUPDATE, H5_ITER_ERROR, "unable to update attribute in shared storage") } /* end if */ else { @@ -1755,7 +1753,8 @@ H5O_attr_count_real(H5F_t *f, hid_t dxpl_id, H5O_t *oh) unsigned u; /* Local index variable */ /* Loop over all messages, counting the attributes */ - for(u = ret_value = 0; u < oh->nmesgs; u++) + ret_value = (hsize_t)0; + for(u = 0; u < oh->nmesgs; u++) if(oh->mesg[u].type == H5O_MSG_ATTR) ret_value++; } /* end else */ @@ -1862,7 +1861,7 @@ H5O_attr_exists(const H5O_loc_t *loc, const char *name, hid_t dxpl_id) HGOTO_ERROR(H5E_ATTR, H5E_BADITER, FAIL, "error checking for existence of attribute") /* Check that we found the attribute */ - ret_value = udata.found; + ret_value = (htri_t)udata.found; } /* end else */ done: diff --git a/src/H5Ocache.c b/src/H5Ocache.c index bfd1403..8843557 100644 --- a/src/H5Ocache.c +++ b/src/H5Ocache.c @@ -120,7 +120,10 @@ const H5AC_class_t H5AC_OHDR_CHK[1] = {{ /* Declare external the free list for H5O_unknown_t's */ H5FL_EXTERN(H5O_unknown_t); -/* Declare external the free list for H5O_cont_t sequences */ +/* Declare extern the free list for H5O_chunk_proxy_t's */ +H5FL_EXTERN(H5O_chunk_proxy_t); + +/* Declare the free list for H5O_cont_t sequences */ H5FL_SEQ_DEFINE(H5O_cont_t); @@ -133,8 +136,6 @@ H5FL_SEQ_DEFINE(H5O_cont_t); /* Local Variables */ /*******************/ -/* Declare extern the free list for H5O_chunk_proxy_t's */ -H5FL_EXTERN(H5O_chunk_proxy_t); /*------------------------------------------------------------------------- @@ -203,10 +204,16 @@ H5O_cache_deserialize(haddr_t addr, size_t len, const void *image, /* Time fields */ if(oh->flags & H5O_HDR_STORE_TIMES) { - UINT32DECODE(p, oh->atime); - UINT32DECODE(p, oh->mtime); - UINT32DECODE(p, oh->ctime); - UINT32DECODE(p, oh->btime); + uint32_t tmp; /* Temporary value */ + + UINT32DECODE(p, tmp); + oh->atime = (time_t)tmp; + UINT32DECODE(p, tmp); + oh->mtime = (time_t)tmp; + UINT32DECODE(p, tmp); + oh->ctime = (time_t)tmp; + UINT32DECODE(p, tmp); + oh->btime = (time_t)tmp; } /* end if */ else oh->atime = oh->mtime = oh->ctime = oh->btime = 0; @@ -216,7 +223,7 @@ H5O_cache_deserialize(haddr_t addr, size_t len, const void *image, UINT16DECODE(p, oh->max_compact); UINT16DECODE(p, oh->min_dense); if(oh->max_compact < oh->min_dense) - HGOTO_ERROR(H5E_OHDR, H5E_VERSION, NULL, "bad object header attribute phase change values") + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "bad object header attribute phase change values") } /* end if */ else { oh->max_compact = H5O_CRT_ATTR_MAX_COMPACT_DEF; @@ -245,7 +252,7 @@ H5O_cache_deserialize(haddr_t addr, size_t len, const void *image, HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "bad size for chunk 0") } /* end switch */ if(oh->chunk0_size > 0 && oh->chunk0_size < H5O_SIZEOF_MSGHDR_OH(oh)) - HGOTO_ERROR(H5E_OHDR, H5E_VERSION, NULL, "bad object header chunk size") + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "bad object header chunk size") } /* end if */ else { /* Version */ @@ -276,7 +283,7 @@ H5O_cache_deserialize(haddr_t addr, size_t len, const void *image, UINT32DECODE(p, oh->chunk0_size); if((udata->v1_pfx_nmesgs > 0 && oh->chunk0_size < H5O_SIZEOF_MSGHDR_OH(oh)) || (udata->v1_pfx_nmesgs == 0 && oh->chunk0_size > 0)) - HGOTO_ERROR(H5E_OHDR, H5E_VERSION, NULL, "bad object header chunk size") + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "bad object header chunk size") /* Reserved, in version 1 (for 8-byte alignment padding) */ p += 4; @@ -386,7 +393,10 @@ H5O_cache_serialize(const H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, * on the entire block of memory needs to be updated if anything is * modified */ if(oh->version > H5O_VERSION_1) { - uint64_t chunk0_size = oh->chunk[0].size - H5O_SIZEOF_HDR(oh); /* Size of chunk 0's data */ + uint64_t chunk0_size; /* Size of chunk 0's data */ + + HDassert(oh->chunk[0].size >= (size_t)H5O_SIZEOF_HDR(oh)); + chunk0_size = oh->chunk[0].size - (size_t)H5O_SIZEOF_HDR(oh); /* Magic number */ HDmemcpy(p, H5O_HDR_MAGIC, (size_t)H5O_SIZEOF_MAGIC); @@ -416,7 +426,7 @@ H5O_cache_serialize(const H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, switch(oh->flags & H5O_HDR_CHUNK0_SIZE) { case 0: /* 1 byte size */ HDassert(chunk0_size < 256); - *p++ = chunk0_size; + *p++ = (uint8_t)chunk0_size; break; case 1: /* 2 byte size */ @@ -457,7 +467,7 @@ H5O_cache_serialize(const H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, UINT32ENCODE(p, oh->nlink); /* First chunk size */ - UINT32ENCODE(p, (oh->chunk[0].size - H5O_SIZEOF_HDR(oh))); + UINT32ENCODE(p, (oh->chunk[0].size - (size_t)H5O_SIZEOF_HDR(oh))); /* Zero to alignment */ HDmemset(p, 0, (size_t)(H5O_SIZEOF_HDR(oh) - 12)); @@ -549,6 +559,7 @@ H5O_cache_chk_deserialize(haddr_t addr, size_t len, const void *image, HGOTO_ERROR(H5E_OHDR, H5E_CANTALLOC, NULL, "memory allocation failed") /* Check if we are still decoding the object header */ + /* (as opposed to bringing a piece of it back from the file) */ if(udata->decoding) { /* Sanity check */ HDassert(udata->common.f); @@ -654,16 +665,19 @@ static herr_t H5O_cache_chk_free_icr(haddr_t UNUSED addr, size_t UNUSED len, void *thing) { H5O_chunk_proxy_t *chk_proxy = (H5O_chunk_proxy_t *)thing; /* Object header chunk proxy to destroy */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_cache_chk_free_icr) + FUNC_ENTER_NOAPI_NOINIT(H5O_cache_chk_free_icr) /* Check arguments */ HDassert(chk_proxy); /* Destroy object header chunk proxy */ - H5O_chunk_proxy_dest(chk_proxy); + if(H5O_chunk_proxy_dest(chk_proxy) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "unable to destroy object header chunk proxy") - FUNC_LEAVE_NOAPI(SUCCEED) +done: + FUNC_LEAVE_NOAPI(ret_value) } /* H5O_cache_chk_free_icr() */ @@ -769,7 +783,7 @@ H5O_chunk_deserialize(H5O_t *oh, haddr_t addr, size_t len, const uint8_t *image, if(chunkno == 0) { /* First chunk's 'image' includes room for the object header prefix */ oh->chunk[0].addr = addr; - oh->chunk[0].size = len + H5O_SIZEOF_HDR(oh); + oh->chunk[0].size = len + (size_t)H5O_SIZEOF_HDR(oh); } /* end if */ else { oh->chunk[chunkno].addr = addr; @@ -952,7 +966,7 @@ H5O_chunk_deserialize(H5O_t *oh, haddr_t addr, size_t len, const uint8_t *image, HDassert(nullcnt == 0); /* Set gap information for chunk */ - oh->chunk[chunkno].gap = (eom_ptr - p); + oh->chunk[chunkno].gap = (size_t)(eom_ptr - p); /* Increment location in chunk */ p += oh->chunk[chunkno].gap; @@ -1127,7 +1141,7 @@ H5O_chunk_proxy_dest(H5O_chunk_proxy_t *chk_proxy) HGOTO_ERROR(H5E_OHDR, H5E_CANTDEC, FAIL, "can't decrement reference count on object header") /* Release the chunk proxy object */ - H5FL_FREE(H5O_chunk_proxy_t, chk_proxy); + chk_proxy = H5FL_FREE(H5O_chunk_proxy_t, chk_proxy); done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Ochunk.c b/src/H5Ochunk.c index 0420799..da07d7a 100644 --- a/src/H5Ochunk.c +++ b/src/H5Ochunk.c @@ -154,7 +154,7 @@ H5O_chunk_protect(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned idx) HDassert(oh); HDassert(idx < oh->nchunks); - /* Check for marking first chunk as dirty */ + /* Check for protecting first chunk */ if(0 == idx) { /* Create new "fake" chunk proxy for first chunk */ /* (since the first chunk is already handled by the H5O_t object) */ @@ -233,11 +233,10 @@ H5O_chunk_unprotect(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5O_chunk_proxy_t *chk_p if(H5AC_mark_pinned_or_protected_entry_dirty(oh) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTMARKDIRTY, FAIL, "unable to mark object header as dirty") } /* end else/if */ - else - { + else { /* Sanity check */ HDassert(0 && "Unknown chunk proxy flag(s)?!?"); - } + } /* end else */ /* Free fake chunk proxy */ H5FL_FREE(H5O_chunk_proxy_t, chk_proxy); diff --git a/src/H5Opkg.h b/src/H5Opkg.h index 276601c..13e46e8 100644 --- a/src/H5Opkg.h +++ b/src/H5Opkg.h @@ -25,7 +25,7 @@ /* Other private headers needed by this file */ #include "H5ACprivate.h" /* Metadata cache */ -#include "H5FLprivate.h" /* Free Lists */ +#include "H5FLprivate.h" /* Free Lists */ /* Object header macros */ #define H5O_NMESGS 8 /*initial number of messages */ @@ -247,8 +247,8 @@ typedef struct H5O_chunk_t { } H5O_chunk_t; struct H5O_t { - H5AC_info_t cache_info; /* Information for metadata cache functions, _must_ be */ - /* first field in structure */ + H5AC_info_t cache_info; /* Information for metadata cache functions, _must_ be */ + /* first field in structure */ /* File-specific information (not stored) */ size_t sizeof_size; /* Size of file sizes */ diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h index a960ff8..fb3b1f7 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -63,8 +63,6 @@ typedef struct H5O_t H5O_t; #define H5O_FHEAP_MAX_MAN_SIZE (4 * 1024) #define H5O_FHEAP_ID_LEN 8 -/* #define H5O_ENABLE_BOGUS 1 */ - /* Object header macros */ #define H5O_MESG_MAX_SIZE 65536 /*max obj header message size */ #define H5O_ALL (-1) /* Operate on all messages of type */ |