summaryrefslogtreecommitdiffstats
path: root/src/H5HFman.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5HFman.c')
-rw-r--r--src/H5HFman.c33
1 files changed, 29 insertions, 4 deletions
diff --git a/src/H5HFman.c b/src/H5HFman.c
index e92e80c..47478e6 100644
--- a/src/H5HFman.c
+++ b/src/H5HFman.c
@@ -44,6 +44,19 @@
/* Local Macros */
/****************/
+/* Macro to check if we can apply all filters in the pipeline. Use whenever
+ * performing a modification operation */
+ #define H5HF_MAN_WRITE_CHECK_PLINE(HDR) \
+{ \
+ if(!((HDR)->checked_filters)) { \
+ if((HDR)->pline.nused) \
+ if(H5Z_can_apply_direct(&((HDR)->pline)) < 0) \
+ HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "I/O filters can't operate on this heap") \
+ \
+ (HDR)->checked_filters = TRUE; \
+ } /* end if */ \
+}
+
/******************/
/* Local Typedefs */
@@ -113,6 +126,9 @@ H5HF_man_insert(H5HF_hdr_t *hdr, hid_t dxpl_id, size_t obj_size, const void *obj
HDassert(obj);
HDassert(id);
+ /* Check pipeline */
+ H5HF_MAN_WRITE_CHECK_PLINE(hdr)
+
/* Look for free space */
if((node_found = H5HF_space_find(hdr, dxpl_id, (hsize_t)obj_size, &sec_node)) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "can't locate free space in fractal heap")
@@ -151,7 +167,8 @@ H5HF_man_insert(H5HF_hdr_t *hdr, hid_t dxpl_id, size_t obj_size, const void *obj
/* Insert object into block */
/* Get the offset of the object within the block */
- blk_off = sec_node->sect_info.addr - dblock->block_off;
+ H5_CHECK_OVERFLOW((sec_node->sect_info.addr - dblock->block_off), hsize_t, size_t);
+ blk_off = (size_t)(sec_node->sect_info.addr - dblock->block_off);
/* Sanity checks */
HDassert(sec_node->sect_info.size >= obj_size);
@@ -209,7 +226,7 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5HF_man_op_real(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *id,
+H5HF_man_op_real(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *id,
H5HF_operator_t op, void *op_data, unsigned op_flags)
{
H5HF_direct_t *dblock = NULL; /* Pointer to direct block to query */
@@ -234,6 +251,9 @@ H5HF_man_op_real(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *id,
/* Set the access mode for the direct block */
if(op_flags & H5HF_OP_MODIFY) {
+ /* Check pipeline */
+ H5HF_MAN_WRITE_CHECK_PLINE(hdr)
+
dblock_access = H5AC_WRITE;
dblock_cache_flags = H5AC__DIRTIED_FLAG;
} /* end if */
@@ -280,7 +300,8 @@ H5HF_man_op_real(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *id,
/* Set direct block info */
dblock_addr = iblock->ents[entry].addr;
- dblock_size = hdr->man_dtable.row_block_size[entry / hdr->man_dtable.cparam.width];
+ H5_CHECK_OVERFLOW((hdr->man_dtable.row_block_size[entry / hdr->man_dtable.cparam.width]), hsize_t, size_t);
+ dblock_size = (size_t)hdr->man_dtable.row_block_size[entry / hdr->man_dtable.cparam.width];
/* Check for offset of invalid direct block */
if(!H5F_addr_defined(dblock_addr)) {
@@ -480,6 +501,9 @@ H5HF_man_remove(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *id)
HDassert(hdr);
HDassert(id);
+ /* Check pipeline */
+ H5HF_MAN_WRITE_CHECK_PLINE(hdr)
+
/* Skip over the flag byte */
id++;
@@ -514,7 +538,8 @@ H5HF_man_remove(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *id)
HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, FAIL, "fractal heap ID not in allocated direct block")
/* Set direct block info */
- dblock_size = hdr->man_dtable.row_block_size[dblock_entry / hdr->man_dtable.cparam.width];
+ H5_CHECK_OVERFLOW((hdr->man_dtable.row_block_size[dblock_entry / hdr->man_dtable.cparam.width]), hsize_t, size_t);
+ dblock_size = (size_t)(hdr->man_dtable.row_block_size[dblock_entry / hdr->man_dtable.cparam.width]);
/* Compute the direct block's offset in the heap's address space */
/* (based on parent indirect block's block offset) */