diff options
Diffstat (limited to 'src/H5HLcache.c')
-rw-r--r-- | src/H5HLcache.c | 47 |
1 files changed, 25 insertions, 22 deletions
diff --git a/src/H5HLcache.c b/src/H5HLcache.c index a3c43ac..d946815 100644 --- a/src/H5HLcache.c +++ b/src/H5HLcache.c @@ -121,7 +121,7 @@ const H5AC_class_t H5AC_LHEAP_DBLK[1] = {{ /*------------------------------------------------------------------------- - * Function: H5HL_fl_deserialize + * Function: H5HL__fl_deserialize * * Purpose: Deserialize the free list for a heap data block * @@ -134,13 +134,13 @@ const H5AC_class_t H5AC_LHEAP_DBLK[1] = {{ *------------------------------------------------------------------------- */ static herr_t -H5HL_fl_deserialize(H5HL_t *heap) +H5HL__fl_deserialize(H5HL_t *heap) { H5HL_free_t *fl = NULL, *tail = NULL; /* Heap free block nodes */ hsize_t free_block; /* Offset of free block */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* check arguments */ HDassert(heap); @@ -188,11 +188,11 @@ done: fl = H5FL_FREE(H5HL_free_t, fl); FUNC_LEAVE_NOAPI(ret_value) -} /* end H5HL_fl_deserialize() */ +} /* end H5HL__fl_deserialize() */ /*------------------------------------------------------------------------- - * Function: H5HL_fl_serialize + * Function: H5HL__fl_serialize * * Purpose: Serialize the free list for a heap data block * @@ -206,11 +206,11 @@ done: *------------------------------------------------------------------------- */ static void -H5HL_fl_serialize(const H5HL_t *heap) +H5HL__fl_serialize(const H5HL_t *heap) { H5HL_free_t *fl; /* Pointer to heap free list node */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* check arguments */ HDassert(heap); @@ -231,7 +231,7 @@ H5HL_fl_serialize(const H5HL_t *heap) } /* end for */ FUNC_LEAVE_NOAPI_VOID -} /* end H5HL_fl_serialize() */ +} /* end H5HL__fl_serialize() */ /*------------------------------------------------------------------------- @@ -258,6 +258,7 @@ H5HL_prefix_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata) size_t spec_read_size; /* Size of buffer to speculatively read in */ const uint8_t *p; /* Pointer into decoding buffer */ haddr_t eoa; /* Relative end of file address */ + hsize_t min; /* temp min value to avoid macro nesting */ H5HL_prfx_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -276,7 +277,8 @@ H5HL_prefix_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, NULL, "unable to determine file size") /* Compute the size of the speculative local heap prefix buffer */ - H5_ASSIGN_OVERFLOW(spec_read_size, MIN(eoa - addr, H5HL_SPEC_READ_SIZE), /* From: */ hsize_t, /* To: */ size_t); + min = MIN(eoa - addr, H5HL_SPEC_READ_SIZE); + H5_CHECKED_ASSIGN(spec_read_size, size_t, min, hsize_t); HDassert(spec_read_size >= udata->sizeof_prfx); /* Attempt to speculatively read both local heap prefix and heap data */ @@ -298,11 +300,11 @@ H5HL_prefix_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata) /* Allocate space in memory for the heap */ if(NULL == (heap = H5HL_new(udata->sizeof_size, udata->sizeof_addr, udata->sizeof_prfx))) - HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "can't allocate local heap structure") + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "can't allocate local heap structure") /* Allocate the heap prefix */ if(NULL == (prfx = H5HL_prfx_new(heap))) - HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "can't allocate local heap prefix") + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "can't allocate local heap prefix") /* Store the prefix's address & length */ heap->prfx_addr = udata->prfx_addr; @@ -313,8 +315,9 @@ H5HL_prefix_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata) /* Free list head */ H5F_DECODE_LENGTH_LEN(p, heap->free_block, udata->sizeof_size); - if(heap->free_block != H5HL_FREE_NULL && heap->free_block >= heap->dblk_size) - HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, NULL, "bad heap free list") + + if((heap->free_block != H5HL_FREE_NULL) && (heap->free_block >= heap->dblk_size)) + HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, NULL, "bad heap free list") /* Heap data address */ H5F_addr_decode_len(udata->sizeof_addr, &p, &(heap->dblk_addr)); @@ -347,7 +350,7 @@ H5HL_prefix_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata) } /* end else */ /* Build free list */ - if(H5HL_fl_deserialize(heap) < 0) + if(H5HL__fl_deserialize(heap) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, NULL, "can't initialize free list") } /* end if */ else @@ -453,7 +456,7 @@ H5HL_prefix_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, } /* end if */ /* Serialize the free list into the heap data's image */ - H5HL_fl_serialize(heap); + H5HL__fl_serialize(heap); /* Copy the heap data block into the cache image */ HDmemcpy(p, heap->dblk_image, heap->dblk_size); @@ -632,7 +635,7 @@ H5HL_datablock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata) FUNC_ENTER_NOAPI_NOINIT - /* check arguments */ + /* Check arguments */ HDassert(f); HDassert(H5F_addr_defined(addr)); HDassert(udata); @@ -642,7 +645,7 @@ H5HL_datablock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata) /* Allocate space in memory for the heap data block */ if(NULL == (dblk = H5HL_dblk_new(udata->heap))) - HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "memory allocation failed") + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "memory allocation failed") /* Check for heap still retaining image */ if(NULL == udata->heap->dblk_image) { @@ -655,7 +658,7 @@ H5HL_datablock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata) HGOTO_ERROR(H5E_HEAP, H5E_READERROR, NULL, "unable to read local heap data block") /* Build free list */ - if(H5HL_fl_deserialize(udata->heap) < 0) + if(H5HL__fl_deserialize(udata->heap) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, NULL, "can't initialize free list") } /* end if */ @@ -669,7 +672,7 @@ done: /* Release the [possibly partially initialized] local heap on errors */ if(!ret_value && dblk) if(H5HL_dblk_dest(dblk) < 0) - HDONE_ERROR(H5E_HEAP, H5E_CANTRELEASE, NULL, "unable to destroy local heap data block") + HDONE_ERROR(H5E_HEAP, H5E_CANTRELEASE, NULL, "unable to destroy local heap data block") FUNC_LEAVE_NOAPI(ret_value) } /* end H5HL_datablock_load() */ @@ -712,7 +715,7 @@ H5HL_datablock_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, heap->free_block = heap->freelist ? heap->freelist->offset : H5HL_FREE_NULL; /* Serialize the free list into the heap data's image */ - H5HL_fl_serialize(heap); + H5HL__fl_serialize(heap); /* Write the data block to the file */ if(H5F_block_write(f, H5FD_MEM_LHEAP, heap->dblk_addr, heap->dblk_size, dxpl_id, heap->dblk_image) < 0) @@ -752,7 +755,7 @@ H5HL_datablock_dest(H5F_t *f, void *_thing) FUNC_ENTER_NOAPI_NOINIT - /* check arguments */ + /* Check arguments */ HDassert(dblk); HDassert(dblk->heap); HDassert(!dblk->heap->single_cache_obj); @@ -802,7 +805,7 @@ H5HL_datablock_clear(H5F_t *f, void *_thing, hbool_t destroy) FUNC_ENTER_NOAPI_NOINIT - /* check arguments */ + /* Check arguments */ HDassert(dblk); /* Mark local heap data block as clean */ |