summaryrefslogtreecommitdiffstats
path: root/src/H5HFcache.c
diff options
context:
space:
mode:
authorDana Robinson <derobins@hdfgroup.org>2017-11-21 18:38:15 (GMT)
committerDana Robinson <derobins@hdfgroup.org>2017-11-21 18:38:15 (GMT)
commit20bb11b52640befc4a0073520b23d9e49bf3e96c (patch)
treee1f8d0487c48264391c54f7c8f5aadf42f295290 /src/H5HFcache.c
parent4d2e7ea66651e8902c91ea92f0236f327924d138 (diff)
downloadhdf5-20bb11b52640befc4a0073520b23d9e49bf3e96c.zip
hdf5-20bb11b52640befc4a0073520b23d9e49bf3e96c.tar.gz
hdf5-20bb11b52640befc4a0073520b23d9e49bf3e96c.tar.bz2
Fixed an uninitialized filter callback struct in H5Dchunk.c and
unified the naming and initialization of said struct throughout the library. This was causing a crash on VS2015 in debug mode when the debug heap complained. Fixes HDFFV-10330.
Diffstat (limited to 'src/H5HFcache.c')
-rw-r--r--src/H5HFcache.c88
1 files changed, 50 insertions, 38 deletions
diff --git a/src/H5HFcache.c b/src/H5HFcache.c
index f957e2e..069bf17 100644
--- a/src/H5HFcache.c
+++ b/src/H5HFcache.c
@@ -1671,9 +1671,13 @@ H5HF__cache_dblock_verify_chksum(const void *_image, size_t len, void *_udata)
HGOTO_DONE(TRUE);
if(hdr->filter_len > 0) {
- size_t nbytes; /* Number of bytes used in buffer, after applying reverse filters */
- unsigned filter_mask; /* Excluded filters for direct block */
- H5Z_cb_t filter_cb = {NULL, NULL}; /* Filter callback structure */
+ size_t nbytes; /* Number of bytes used in buffer, after applying reverse filters */
+ unsigned filter_mask; /* Excluded filters for direct block */
+ H5Z_cb_t filter_cb; /* Filter callback structure */
+
+ /* Initialize the filter callback struct */
+ filter_cb.op_data = NULL;
+ filter_cb.func = NULL; /* no callback function when failed */
/* Allocate buffer to perform I/O filtering on and copy image into
* it. Must do this as H5Z_pipeline() may re-size the buffer
@@ -1682,17 +1686,17 @@ H5HF__cache_dblock_verify_chksum(const void *_image, size_t len, void *_udata)
if(NULL == (read_buf = H5MM_malloc(len)))
HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, FAIL, "memory allocation failed for pipeline buffer")
- /* Set up parameters for filter pipeline */
- nbytes = len;
- filter_mask = udata->filter_mask;
+ /* Set up parameters for filter pipeline */
+ nbytes = len;
+ filter_mask = udata->filter_mask;
HDmemcpy(read_buf, image, len);
- /* Push direct block data through I/O filter pipeline */
- if(H5Z_pipeline(&(hdr->pline), H5Z_FLAG_REVERSE, &filter_mask, H5Z_ENABLE_EDC, filter_cb, &nbytes, &len, &read_buf) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTFILTER, FAIL, "output pipeline failed")
+ /* Push direct block data through I/O filter pipeline */
+ if(H5Z_pipeline(&(hdr->pline), H5Z_FLAG_REVERSE, &filter_mask, H5Z_ENABLE_EDC, filter_cb, &nbytes, &len, &read_buf) < 0)
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTFILTER, FAIL, "output pipeline failed")
/* Update info about direct block */
- udata->decompressed = TRUE;
+ udata->decompressed = TRUE;
len = nbytes;
} /* end if */
else
@@ -1818,45 +1822,49 @@ H5HF__cache_dblock_deserialize(const void *_image, size_t len, void *_udata,
udata->dblk = NULL;
} /* end if */
else {
- H5Z_cb_t filter_cb = {NULL, NULL}; /* Filter callback structure */
+ H5Z_cb_t filter_cb; /* Filter callback structure */
size_t nbytes; /* Number of bytes used in buffer, after applying reverse filters */
unsigned filter_mask; /* Excluded filters for direct block */
/* Sanity check */
- HDassert(udata->dblk == NULL);
+ HDassert(udata->dblk == NULL);
- /* Allocate buffer to perform I/O filtering on and copy image into
- * it. Must do this as H5Z_pipeline() may resize the buffer
- * provided to it.
- */
- if(NULL == (read_buf = H5MM_malloc(len)))
- HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, NULL, "memory allocation failed for pipeline buffer")
+ /* Initialize the filter callback struct */
+ filter_cb.op_data = NULL;
+ filter_cb.func = NULL; /* no callback function when failed */
+
+ /* Allocate buffer to perform I/O filtering on and copy image into
+ * it. Must do this as H5Z_pipeline() may resize the buffer
+ * provided to it.
+ */
+ if (NULL == (read_buf = H5MM_malloc(len)))
+ HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, NULL, "memory allocation failed for pipeline buffer")
/* Copy compressed image into buffer */
- HDmemcpy(read_buf, image, len);
+ HDmemcpy(read_buf, image, len);
- /* Push direct block data through I/O filter pipeline */
- nbytes = len;
- filter_mask = udata->filter_mask;
- if(H5Z_pipeline(&(hdr->pline), H5Z_FLAG_REVERSE, &filter_mask, H5Z_ENABLE_EDC, filter_cb, &nbytes, &len, &read_buf) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTFILTER, NULL, "output pipeline failed")
+ /* Push direct block data through I/O filter pipeline */
+ nbytes = len;
+ filter_mask = udata->filter_mask;
+ if (H5Z_pipeline(&(hdr->pline), H5Z_FLAG_REVERSE, &filter_mask, H5Z_ENABLE_EDC, filter_cb, &nbytes, &len, &read_buf) < 0)
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTFILTER, NULL, "output pipeline failed")
- /* Sanity check */
- HDassert(nbytes == dblock->size);
+ /* Sanity check */
+ HDassert(nbytes == dblock->size);
- /* Copy un-filtered data into block's buffer */
- HDmemcpy(dblock->blk, read_buf, dblock->size);
- } /* end if */
+ /* Copy un-filtered data into block's buffer */
+ HDmemcpy(dblock->blk, read_buf, dblock->size);
+ } /* end if */
} /* end if */
else {
/* Sanity checks */
- HDassert(udata->dblk == NULL);
- HDassert(!udata->decompressed);
+ HDassert(udata->dblk == NULL);
+ HDassert(!udata->decompressed);
- /* Allocate block buffer */
-/* XXX: Change to using free-list factories */
- if(NULL == (dblock->blk = H5FL_BLK_MALLOC(direct_block, (size_t)dblock->size)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
+ /* Allocate block buffer */
+ /* XXX: Change to using free-list factories */
+ if (NULL == (dblock->blk = H5FL_BLK_MALLOC(direct_block, (size_t)dblock->size)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
/* Copy image to dblock->blk */
HDassert(dblock->size == len);
@@ -1895,9 +1903,9 @@ H5HF__cache_dblock_deserialize(const void *_image, size_t len, void *_udata,
/* Decode checksum on direct block, if requested */
if(hdr->checksum_dblocks) {
- uint32_t stored_chksum; /* Metadata checksum value */
+ uint32_t stored_chksum; /* Metadata checksum value */
- /* checksum verification already done in verify_chksum cb */
+ /* checksum verification already done in verify_chksum cb */
/* Metadata checksum */
UINT32DECODE(image, stored_chksum);
@@ -2188,10 +2196,14 @@ H5HF__cache_dblock_pre_serialize(H5F_t *f, hid_t dxpl_id, void *_thing,
/* Check for I/O filters on this heap */
if(hdr->filter_len > 0) {
- H5Z_cb_t filter_cb = {NULL, NULL}; /* Filter callback structure */
+ H5Z_cb_t filter_cb; /* Filter callback structure */
size_t nbytes; /* Number of bytes used */
unsigned filter_mask = 0; /* Filter mask for block */
+ /* Initialize the filter callback struct */
+ filter_cb.op_data = NULL;
+ filter_cb.func = NULL; /* no callback function when failed */
+
/* Allocate buffer to perform I/O filtering on */
write_size = dblock->size;
if(NULL == (write_buf = H5MM_malloc(write_size)))