mirror of
https://github.com/HDFGroup/hdf5.git
synced 2025-02-23 16:20:57 +08:00
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.
This commit is contained in:
parent
5c472f5d7b
commit
2b7f23a333
@ -179,6 +179,21 @@ Bug Fixes since HDF5-1.10.1 release
|
||||
|
||||
(ADB - 2017/10/10, HDFFV-10297, HDFFV-10319)
|
||||
|
||||
- An uninitialized struct could cause a memory access error when using
|
||||
variable-length or reference types in a compressed, chunked dataset.
|
||||
|
||||
A struct containing a callback function pointer and a pointer to some
|
||||
associated data was used before initialization. This could cause a
|
||||
memory access error and system crash. This could only occur under
|
||||
unusual conditions when using variable-lenth and reference types in
|
||||
a compressed, chunked dataset.
|
||||
|
||||
On recent versions of Visual Studio, when built in debug mode, the
|
||||
debug heap will complain and cause a crash if the code in question
|
||||
is executed (this will cause the objcopy test to fail).
|
||||
|
||||
(DER - 2017/11/21, HDFFV-10330)
|
||||
|
||||
Configuration
|
||||
-------------
|
||||
- cmake
|
||||
|
@ -5661,7 +5661,7 @@ H5D__chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata)
|
||||
/* needed for commpressed variable length data */
|
||||
hbool_t must_filter = FALSE; /* Whether chunk must be filtered during copy */
|
||||
size_t nbytes; /* Size of chunk in file (in bytes) */
|
||||
H5Z_cb_t cb_struct; /* Filter failure callback struct */
|
||||
H5Z_cb_t filter_cb; /* Filter failure callback struct */
|
||||
int ret_value = H5_ITER_CONT; /* Return value */
|
||||
|
||||
|
||||
@ -5670,6 +5670,10 @@ H5D__chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata)
|
||||
/* Get 'size_t' local value for number of bytes in chunk */
|
||||
H5_CHECKED_ASSIGN(nbytes, size_t, chunk_rec->nbytes, uint32_t);
|
||||
|
||||
/* Initialize the filter callback struct */
|
||||
filter_cb.op_data = NULL;
|
||||
filter_cb.func = NULL; /* no callback function when failed */
|
||||
|
||||
/* Check for filtered chunks */
|
||||
/* Check for an edge chunk that is not filtered */
|
||||
if(pline && pline->nused) {
|
||||
@ -5716,7 +5720,8 @@ H5D__chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata)
|
||||
HDassert(!H5F_addr_defined(chunk_rec->chunk_addr));
|
||||
HDmemcpy(buf, udata->chunk, nbytes);
|
||||
udata->chunk = NULL;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
H5D_rdcc_ent_t *ent = NULL; /* Cache entry */
|
||||
unsigned idx; /* Index of chunk in cache, if present */
|
||||
unsigned u; /* Counter */
|
||||
@ -5748,7 +5753,8 @@ H5D__chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata)
|
||||
|
||||
H5_CHECKED_ASSIGN(nbytes, size_t, shared_fo->layout.u.chunk.size, uint32_t);
|
||||
HDmemcpy(buf, ent->chunk, nbytes);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/* read chunk data from the source file */
|
||||
if(H5F_block_read(udata->file_src, H5FD_MEM_DRAW, chunk_rec->chunk_addr, nbytes, H5AC_rawdata_dxpl_id, buf) < 0)
|
||||
HGOTO_ERROR(H5E_IO, H5E_READERROR, H5_ITER_ERROR, "unable to read raw data chunk")
|
||||
@ -5759,8 +5765,7 @@ H5D__chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata)
|
||||
if(must_filter && (is_vlen || fix_ref) && !udata->chunk_in_cache) {
|
||||
unsigned filter_mask = chunk_rec->filter_mask;
|
||||
|
||||
cb_struct.func = NULL; /* no callback function when failed */
|
||||
if(H5Z_pipeline(pline, H5Z_FLAG_REVERSE, &filter_mask, H5Z_NO_EDC, cb_struct, &nbytes, &buf_size, &buf) < 0)
|
||||
if(H5Z_pipeline(pline, H5Z_FLAG_REVERSE, &filter_mask, H5Z_NO_EDC, filter_cb, &nbytes, &buf_size, &buf) < 0)
|
||||
HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, H5_ITER_ERROR, "data pipeline read failed")
|
||||
} /* end if */
|
||||
|
||||
@ -5822,7 +5827,7 @@ H5D__chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata)
|
||||
|
||||
/* Need to compress variable-length or reference data elements or a chunk found in cache before writing to file */
|
||||
if(must_filter && (is_vlen || fix_ref || udata->chunk_in_cache) ) {
|
||||
if(H5Z_pipeline(pline, 0, &(udata_dst.filter_mask), H5Z_NO_EDC, cb_struct, &nbytes, &buf_size, &buf) < 0)
|
||||
if(H5Z_pipeline(pline, 0, &(udata_dst.filter_mask), H5Z_NO_EDC, filter_cb, &nbytes, &buf_size, &buf) < 0)
|
||||
HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, H5_ITER_ERROR, "output pipeline failed")
|
||||
#if H5_SIZEOF_SIZE_T > 4
|
||||
/* Check for the chunk expanding too much to encode in a 32-bit value */
|
||||
@ -6707,46 +6712,49 @@ H5D__chunk_format_convert_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata)
|
||||
H5_CHECKED_ASSIGN(nbytes, size_t, chunk_rec->nbytes, uint32_t);
|
||||
chunk_addr = chunk_rec->chunk_addr;
|
||||
|
||||
if(new_idx_info->pline->nused &&
|
||||
if (new_idx_info->pline->nused &&
|
||||
(new_idx_info->layout->flags & H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS) &&
|
||||
(H5D__chunk_is_partial_edge_chunk(udata->dset_ndims, new_idx_info->layout->dim, chunk_rec->scaled, udata->dset_dims))) {
|
||||
/* This is a partial non-filtered edge chunk */
|
||||
/* Convert the chunk to a filtered edge chunk for v1 B-tree chunk index */
|
||||
|
||||
unsigned filter_mask = chunk_rec->filter_mask;
|
||||
H5Z_cb_t cb_struct; /* Filter failure callback struct */
|
||||
size_t read_size = nbytes; /* Bytes to read */
|
||||
/* This is a partial non-filtered edge chunk */
|
||||
/* Convert the chunk to a filtered edge chunk for v1 B-tree chunk index */
|
||||
|
||||
HDassert(read_size == new_idx_info->layout->size);
|
||||
unsigned filter_mask = chunk_rec->filter_mask;
|
||||
H5Z_cb_t filter_cb; /* Filter failure callback struct */
|
||||
size_t read_size = nbytes; /* Bytes to read */
|
||||
|
||||
cb_struct.func = NULL; /* no callback function when failed */
|
||||
HDassert(read_size == new_idx_info->layout->size);
|
||||
|
||||
/* Allocate buffer for chunk data */
|
||||
if(NULL == (buf = H5MM_malloc(read_size)))
|
||||
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, H5_ITER_ERROR, "memory allocation failed for raw data chunk")
|
||||
/* Initialize the filter callback struct */
|
||||
filter_cb.op_data = NULL;
|
||||
filter_cb.func = NULL; /* no callback function when failed */
|
||||
|
||||
/* Read the non-filtered edge chunk */
|
||||
if(H5F_block_read(new_idx_info->f, H5FD_MEM_DRAW, chunk_addr, read_size, H5AC_rawdata_dxpl_id, buf) < 0)
|
||||
HGOTO_ERROR(H5E_IO, H5E_READERROR, H5_ITER_ERROR, "unable to read raw data chunk")
|
||||
/* Allocate buffer for chunk data */
|
||||
if (NULL == (buf = H5MM_malloc(read_size)))
|
||||
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, H5_ITER_ERROR, "memory allocation failed for raw data chunk")
|
||||
|
||||
/* Pass the chunk through the pipeline */
|
||||
if(H5Z_pipeline(new_idx_info->pline, 0, &filter_mask, H5Z_NO_EDC, cb_struct, &nbytes, &read_size, &buf) < 0)
|
||||
HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, H5_ITER_ERROR, "output pipeline failed")
|
||||
/* Read the non-filtered edge chunk */
|
||||
if (H5F_block_read(new_idx_info->f, H5FD_MEM_DRAW, chunk_addr, read_size, H5AC_rawdata_dxpl_id, buf) < 0)
|
||||
HGOTO_ERROR(H5E_IO, H5E_READERROR, H5_ITER_ERROR, "unable to read raw data chunk")
|
||||
|
||||
/* Pass the chunk through the pipeline */
|
||||
if (H5Z_pipeline(new_idx_info->pline, 0, &filter_mask, H5Z_NO_EDC, filter_cb, &nbytes, &read_size, &buf) < 0)
|
||||
HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, H5_ITER_ERROR, "output pipeline failed")
|
||||
|
||||
#if H5_SIZEOF_SIZE_T > 4
|
||||
/* Check for the chunk expanding too much to encode in a 32-bit value */
|
||||
if(nbytes > ((size_t)0xffffffff))
|
||||
HGOTO_ERROR(H5E_DATASET, H5E_BADRANGE, H5_ITER_ERROR, "chunk too large for 32-bit length")
|
||||
if (nbytes > ((size_t)0xffffffff))
|
||||
HGOTO_ERROR(H5E_DATASET, H5E_BADRANGE, H5_ITER_ERROR, "chunk too large for 32-bit length")
|
||||
#endif /* H5_SIZEOF_SIZE_T > 4 */
|
||||
|
||||
/* Allocate space for the filtered chunk */
|
||||
if((chunk_addr = H5MF_alloc(new_idx_info->f, H5FD_MEM_DRAW, new_idx_info->dxpl_id, (hsize_t)nbytes)) == HADDR_UNDEF)
|
||||
HGOTO_ERROR(H5E_DATASET, H5E_NOSPACE, H5_ITER_ERROR, "file allocation failed for filtered chunk")
|
||||
HDassert(H5F_addr_defined(chunk_addr));
|
||||
/* Allocate space for the filtered chunk */
|
||||
if ((chunk_addr = H5MF_alloc(new_idx_info->f, H5FD_MEM_DRAW, new_idx_info->dxpl_id, (hsize_t)nbytes)) == HADDR_UNDEF)
|
||||
HGOTO_ERROR(H5E_DATASET, H5E_NOSPACE, H5_ITER_ERROR, "file allocation failed for filtered chunk")
|
||||
HDassert(H5F_addr_defined(chunk_addr));
|
||||
|
||||
/* Write the filtered chunk to disk */
|
||||
if(H5F_block_write(new_idx_info->f, H5FD_MEM_DRAW, chunk_addr, nbytes, H5AC_rawdata_dxpl_id, buf) < 0)
|
||||
HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, H5_ITER_ERROR, "unable to write raw data to file")
|
||||
/* Write the filtered chunk to disk */
|
||||
if (H5F_block_write(new_idx_info->f, H5FD_MEM_DRAW, chunk_addr, nbytes, H5AC_rawdata_dxpl_id, buf) < 0)
|
||||
HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, H5_ITER_ERROR, "unable to write raw data to file")
|
||||
} /* end if */
|
||||
|
||||
/* Set up chunk information for insertion to chunk index */
|
||||
@ -6758,11 +6766,11 @@ H5D__chunk_format_convert_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata)
|
||||
insert_udata.common.storage = new_idx_info->storage;
|
||||
|
||||
/* Insert chunk into the v1 B-tree chunk index */
|
||||
if((new_idx_info->storage->ops->insert)(new_idx_info, &insert_udata, NULL) < 0)
|
||||
if ((new_idx_info->storage->ops->insert)(new_idx_info, &insert_udata, NULL) < 0)
|
||||
HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, H5_ITER_ERROR, "unable to insert chunk addr into index")
|
||||
|
||||
done:
|
||||
if(buf)
|
||||
if (buf)
|
||||
H5MM_xfree(buf);
|
||||
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
|
@ -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)))
|
||||
|
@ -345,9 +345,13 @@ HDfprintf(stderr, "%s: obj_size = %Zu\n", FUNC, obj_size);
|
||||
|
||||
/* Check for I/O pipeline filter on 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 */
|
||||
|
||||
/* 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 = obj_size;
|
||||
if(NULL == (write_buf = H5MM_malloc(write_size)))
|
||||
@ -773,10 +777,14 @@ H5HF_huge_op_real(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *id,
|
||||
|
||||
/* Check for I/O pipeline filter on 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 read_size; /* Object's size in the file */
|
||||
size_t nbytes; /* Number of bytes used */
|
||||
|
||||
/* Initialize the filter callback struct */
|
||||
filter_cb.op_data = NULL;
|
||||
filter_cb.func = NULL; /* no callback function when failed */
|
||||
|
||||
/* De-filter the object */
|
||||
read_size = nbytes = obj_size;
|
||||
if(H5Z_pipeline(&(hdr->pline), H5Z_FLAG_REVERSE, &filter_mask, H5Z_NO_EDC, filter_cb, &nbytes, &read_size, &read_buf) < 0)
|
||||
|
62
src/H5Z.c
62
src/H5Z.c
@ -275,7 +275,7 @@ done:
|
||||
* Function: H5Z_register
|
||||
*
|
||||
* Purpose: Same as the public version except this one allows filters
|
||||
* to be set for predefined method numbers <H5Z_FILTER_RESERVED
|
||||
* to be set for predefined method numbers < H5Z_FILTER_RESERVED
|
||||
*
|
||||
* Return: Non-negative on success
|
||||
* Negative on failure
|
||||
@ -532,7 +532,7 @@ H5Z__check_unregister_dset_cb(void *obj_ptr, hid_t H5_ATTR_UNUSED obj_id, void *
|
||||
|
||||
FUNC_ENTER_STATIC
|
||||
|
||||
HDassert (obj_ptr);
|
||||
HDassert(obj_ptr);
|
||||
|
||||
/* Get the dataset creation property */
|
||||
if ((ocpl_id = H5D_get_create_plist((H5D_t *)obj_ptr)) < 0)
|
||||
@ -576,7 +576,7 @@ H5Z__flush_file_cb(void *obj_ptr, hid_t H5_ATTR_UNUSED obj_id, void H5_ATTR_UNUS
|
||||
|
||||
FUNC_ENTER_STATIC
|
||||
|
||||
HDassert (obj_ptr);
|
||||
HDassert(obj_ptr);
|
||||
|
||||
/* Call the flush routine for mounted file hierarchies. Do a global flush
|
||||
* if the file is opened for write */
|
||||
@ -724,7 +724,7 @@ H5Z_prelude_callback(const H5O_pline_t *pline, hid_t dcpl_id, hid_t type_id,
|
||||
break;
|
||||
|
||||
default:
|
||||
HDassert ("invalid prelude type" && 0);
|
||||
HDassert("invalid prelude type" && 0);
|
||||
} /* end switch */
|
||||
} /* end else */
|
||||
} /* end for */
|
||||
@ -893,7 +893,7 @@ H5Z_can_apply_direct(const H5O_pline_t *pline)
|
||||
|
||||
FUNC_ENTER_NOAPI(FAIL)
|
||||
|
||||
HDassert (pline->nused > 0);
|
||||
HDassert(pline->nused > 0);
|
||||
|
||||
/* Make "can apply" callbacks for filters in pipeline */
|
||||
if (H5Z_prelude_callback(pline, (hid_t)-1, (hid_t)-1, (hid_t)-1, H5Z_PRELUDE_CAN_APPLY) < 0)
|
||||
@ -926,7 +926,7 @@ H5Z_set_local_direct(const H5O_pline_t *pline)
|
||||
|
||||
FUNC_ENTER_NOAPI(FAIL)
|
||||
|
||||
HDassert (pline->nused > 0);
|
||||
HDassert(pline->nused > 0);
|
||||
|
||||
/* Make "set local" callbacks for filters in pipeline */
|
||||
if (H5Z_prelude_callback(pline, (hid_t)-1, (hid_t)-1, (hid_t)-1, H5Z_PRELUDE_SET_LOCAL) < 0)
|
||||
@ -1200,12 +1200,12 @@ H5Z_pipeline(const H5O_pline_t *pline, unsigned flags,
|
||||
|
||||
FUNC_ENTER_NOAPI(FAIL)
|
||||
|
||||
HDassert (0 == (flags & ~((unsigned)H5Z_FLAG_INVMASK)));
|
||||
HDassert (filter_mask);
|
||||
HDassert (nbytes && *nbytes>0);
|
||||
HDassert (buf_size && *buf_size>0);
|
||||
HDassert (buf && *buf);
|
||||
HDassert (!pline || pline->nused<H5Z_MAX_NFILTERS);
|
||||
HDassert(0 == (flags & ~((unsigned)H5Z_FLAG_INVMASK)));
|
||||
HDassert(filter_mask);
|
||||
HDassert(nbytes && *nbytes>0);
|
||||
HDassert(buf_size && *buf_size>0);
|
||||
HDassert(buf && *buf);
|
||||
HDassert(!pline || pline->nused < H5Z_MAX_NFILTERS);
|
||||
|
||||
if (pline && (flags & H5Z_FLAG_REVERSE)) { /* Read */
|
||||
for (i = pline->nused; i > 0; --i) {
|
||||
@ -1235,7 +1235,7 @@ H5Z_pipeline(const H5O_pline_t *pline, unsigned flags,
|
||||
/* Search in the table of registered filters again to find the dynamic filter just loaded and registered */
|
||||
if ((fclass_idx = H5Z_find_idx(pline->filter[idx].id)) < 0)
|
||||
issue_error = TRUE;
|
||||
} /* end if */
|
||||
}
|
||||
else
|
||||
issue_error = TRUE;
|
||||
|
||||
@ -1247,7 +1247,7 @@ H5Z_pipeline(const H5O_pline_t *pline, unsigned flags,
|
||||
HGOTO_ERROR(H5E_PLINE, H5E_READERROR, FAIL, "required filter '%s' is not registered", pline->filter[idx].name)
|
||||
else
|
||||
HGOTO_ERROR(H5E_PLINE, H5E_READERROR, FAIL, "required filter (name unavailable) is not registered")
|
||||
} /* end if */
|
||||
}
|
||||
} /* end if */
|
||||
|
||||
fclass = &H5Z_table_g[fclass_idx];
|
||||
@ -1263,11 +1263,12 @@ H5Z_pipeline(const H5O_pline_t *pline, unsigned flags,
|
||||
#ifdef H5Z_DEBUG
|
||||
H5_timer_end (&(fstats->stats[1].timer), &timer);
|
||||
fstats->stats[1].total += MAX(*nbytes, new_nbytes);
|
||||
if (0 == new_nbytes) fstats->stats[1].errors += *nbytes;
|
||||
if (0 == new_nbytes)
|
||||
fstats->stats[1].errors += *nbytes;
|
||||
#endif
|
||||
|
||||
if (0 == new_nbytes) {
|
||||
if ((cb_struct.func && (H5Z_CB_FAIL == cb_struct.func (pline->filter[idx].id, *buf, *buf_size, cb_struct.op_data))) || !cb_struct.func)
|
||||
if ((cb_struct.func && (H5Z_CB_FAIL == cb_struct.func(pline->filter[idx].id, *buf, *buf_size, cb_struct.op_data))) || !cb_struct.func)
|
||||
HGOTO_ERROR(H5E_PLINE, H5E_READERROR, FAIL, "filter returned failure during read")
|
||||
|
||||
*nbytes = *buf_size;
|
||||
@ -1303,7 +1304,8 @@ H5Z_pipeline(const H5O_pline_t *pline, unsigned flags,
|
||||
#ifdef H5Z_DEBUG
|
||||
H5_timer_end (&(fstats->stats[0].timer), &timer);
|
||||
fstats->stats[0].total += MAX(*nbytes, new_nbytes);
|
||||
if (0 == new_nbytes) fstats->stats[0].errors += *nbytes;
|
||||
if (0 == new_nbytes)
|
||||
fstats->stats[0].errors += *nbytes;
|
||||
#endif
|
||||
if (0 == new_nbytes) {
|
||||
if (0 == (pline->filter[idx].flags & H5Z_FLAG_OPTIONAL)) {
|
||||
@ -1345,8 +1347,8 @@ H5Z_filter_info(const H5O_pline_t *pline, H5Z_filter_t filter)
|
||||
|
||||
FUNC_ENTER_NOAPI(NULL)
|
||||
|
||||
HDassert (pline);
|
||||
HDassert (filter >= 0 && filter <= H5Z_FILTER_MAX);
|
||||
HDassert(pline);
|
||||
HDassert(filter >= 0 && filter <= H5Z_FILTER_MAX);
|
||||
|
||||
/* Locate the filter in the pipeline */
|
||||
for (idx = 0; idx < pline->nused; idx++)
|
||||
@ -1384,8 +1386,8 @@ H5Z_filter_in_pline(const H5O_pline_t *pline, H5Z_filter_t filter)
|
||||
|
||||
FUNC_ENTER_NOAPI(FAIL)
|
||||
|
||||
HDassert (pline);
|
||||
HDassert (filter >= 0 && filter <= H5Z_FILTER_MAX);
|
||||
HDassert(pline);
|
||||
HDassert(filter >= 0 && filter <= H5Z_FILTER_MAX);
|
||||
|
||||
/* Locate the filter in the pipeline */
|
||||
for (idx = 0; idx < pline->nused; idx++)
|
||||
@ -1421,7 +1423,7 @@ H5Z_all_filters_avail(const H5O_pline_t *pline)
|
||||
FUNC_ENTER_NOAPI(FAIL)
|
||||
|
||||
/* Check args */
|
||||
HDassert (pline);
|
||||
HDassert(pline);
|
||||
|
||||
/* Iterate through all the filters in pipeline */
|
||||
for (i = 0; i < pline->nused; i++) {
|
||||
@ -1459,8 +1461,8 @@ H5Z_delete(H5O_pline_t *pline, H5Z_filter_t filter)
|
||||
FUNC_ENTER_NOAPI(FAIL)
|
||||
|
||||
/* Check args */
|
||||
HDassert (pline);
|
||||
HDassert (filter >= 0 && filter <= H5Z_FILTER_MAX);
|
||||
HDassert(pline);
|
||||
HDassert(filter >= 0 && filter <= H5Z_FILTER_MAX);
|
||||
|
||||
/* if the pipeline has no filters, just return */
|
||||
if (pline->nused == 0)
|
||||
@ -1470,7 +1472,7 @@ H5Z_delete(H5O_pline_t *pline, H5Z_filter_t filter)
|
||||
if (H5Z_FILTER_ALL == filter) {
|
||||
if (H5O_msg_reset(H5O_PLINE_ID, pline) < 0)
|
||||
HGOTO_ERROR(H5E_PLINE, H5E_CANTFREE, FAIL, "can't release pipeline info")
|
||||
} /* end if */
|
||||
}
|
||||
/* Delete filter */
|
||||
else {
|
||||
size_t idx; /* Index of filter in pipeline */
|
||||
@ -1481,7 +1483,7 @@ H5Z_delete(H5O_pline_t *pline, H5Z_filter_t filter)
|
||||
if (pline->filter[idx].id == filter) {
|
||||
found = TRUE;
|
||||
break;
|
||||
} /* end if */
|
||||
}
|
||||
|
||||
/* filter was not found in the pipeline */
|
||||
if (!found)
|
||||
@ -1489,11 +1491,11 @@ H5Z_delete(H5O_pline_t *pline, H5Z_filter_t filter)
|
||||
|
||||
/* Free information for deleted filter */
|
||||
if (pline->filter[idx].name && pline->filter[idx].name != pline->filter[idx]._name)
|
||||
HDassert ((HDstrlen(pline->filter[idx].name) + 1) > H5Z_COMMON_NAME_LEN);
|
||||
HDassert((HDstrlen(pline->filter[idx].name) + 1) > H5Z_COMMON_NAME_LEN);
|
||||
if (pline->filter[idx].name != pline->filter[idx]._name)
|
||||
pline->filter[idx].name = (char *)H5MM_xfree(pline->filter[idx].name);
|
||||
if (pline->filter[idx].cd_values && pline->filter[idx].cd_values != pline->filter[idx]._cd_values)
|
||||
HDassert (pline->filter[idx].cd_nelmts > H5Z_COMMON_CD_VALUES);
|
||||
HDassert(pline->filter[idx].cd_nelmts > H5Z_COMMON_CD_VALUES);
|
||||
if (pline->filter[idx].cd_values != pline->filter[idx]._cd_values)
|
||||
pline->filter[idx].cd_values = (unsigned *)H5MM_xfree(pline->filter[idx].cd_values);
|
||||
|
||||
@ -1506,8 +1508,8 @@ H5Z_delete(H5O_pline_t *pline, H5Z_filter_t filter)
|
||||
pline->filter[idx].name = pline->filter[idx]._name;
|
||||
if (pline->filter[idx].cd_nelmts <= H5Z_COMMON_CD_VALUES)
|
||||
pline->filter[idx].cd_values = pline->filter[idx]._cd_values;
|
||||
} /* end for */
|
||||
} /* end if */
|
||||
}
|
||||
}
|
||||
|
||||
/* Decrement number of used filters */
|
||||
pline->nused--;
|
||||
|
@ -129,8 +129,8 @@ typedef H5Z_cb_return_t (*H5Z_filter_func_t)(H5Z_filter_t filter, void* buf,
|
||||
|
||||
/* Structure for filter callback property */
|
||||
typedef struct H5Z_cb_t {
|
||||
H5Z_filter_func_t func;
|
||||
void* op_data;
|
||||
H5Z_filter_func_t func;
|
||||
void *op_data;
|
||||
} H5Z_cb_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
@ -206,14 +206,14 @@ typedef size_t (*H5Z_func_t)(unsigned int flags, size_t cd_nelmts,
|
||||
* contain a pointers to the filter function and timing statistics.
|
||||
*/
|
||||
typedef struct H5Z_class2_t {
|
||||
int version; /* Version number of the H5Z_class_t struct */
|
||||
H5Z_filter_t id; /* Filter ID number */
|
||||
unsigned encoder_present; /* Does this filter have an encoder? */
|
||||
unsigned decoder_present; /* Does this filter have a decoder? */
|
||||
const char *name; /* Comment for debugging */
|
||||
H5Z_can_apply_func_t can_apply; /* The "can apply" callback for a filter */
|
||||
H5Z_set_local_func_t set_local; /* The "set local" callback for a filter */
|
||||
H5Z_func_t filter; /* The actual filter function */
|
||||
int version; /* Version number of the H5Z_class_t struct */
|
||||
H5Z_filter_t id; /* Filter ID number */
|
||||
unsigned encoder_present; /* Does this filter have an encoder? */
|
||||
unsigned decoder_present; /* Does this filter have a decoder? */
|
||||
const char *name; /* Comment for debugging */
|
||||
H5Z_can_apply_func_t can_apply; /* The "can apply" callback for a filter */
|
||||
H5Z_set_local_func_t set_local; /* The "set local" callback for a filter */
|
||||
H5Z_func_t filter; /* The actual filter function */
|
||||
} H5Z_class2_t;
|
||||
|
||||
H5_DLL herr_t H5Zregister(const void *cls);
|
||||
|
Loading…
Reference in New Issue
Block a user