summaryrefslogtreecommitdiffstats
path: root/src/H5Dcontig.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5Dcontig.c')
-rw-r--r--src/H5Dcontig.c43
1 files changed, 25 insertions, 18 deletions
diff --git a/src/H5Dcontig.c b/src/H5Dcontig.c
index dc09768..898b46d 100644
--- a/src/H5Dcontig.c
+++ b/src/H5Dcontig.c
@@ -259,7 +259,7 @@ H5D__contig_fill(const H5D_t *dset, hid_t dxpl_id)
/* Get the number of elements in the dataset's dataspace */
if((snpoints = H5S_GET_EXTENT_NPOINTS(dset->shared->space)) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "dataset has negative number of elements")
- H5_ASSIGN_OVERFLOW(npoints, snpoints, hssize_t, size_t);
+ H5_CHECKED_ASSIGN(npoints, size_t, snpoints, hssize_t);
/* Initialize the fill value buffer */
if(H5D__fill_init(&fb_info, NULL, NULL, NULL, NULL, NULL,
@@ -396,10 +396,7 @@ H5D__contig_construct(H5F_t *f, H5D_t *dset)
size_t dt_size; /* Size of datatype */
hsize_t tmp_size; /* Temporary holder for raw data size */
size_t tmp_sieve_buf_size; /* Temporary holder for sieve buffer size */
- hsize_t dim[H5O_LAYOUT_NDIMS]; /* Current size of data in elements */
- hsize_t max_dim[H5O_LAYOUT_NDIMS]; /* Maximum size of data in elements */
- int ndims; /* Rank of dataspace */
- int i; /* Local index variable */
+ unsigned u; /* Local index variable */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
@@ -415,11 +412,9 @@ H5D__contig_construct(H5F_t *f, H5D_t *dset)
*/
/* Check for invalid dataset dimensions */
- if((ndims = H5S_get_simple_extent_dims(dset->shared->space, dim, max_dim)) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize contiguous storage")
- for(i = 0; i < ndims; i++)
- if(max_dim[i] > dim[i])
- HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "extendible contiguous non-external dataset")
+ for(u = 0; u < dset->shared->ndims; u++)
+ if(dset->shared->max_dims[u] > dset->shared->curr_dims[u])
+ HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "extendible contiguous non-external dataset not allowed")
/* Retrieve the number of elements in the dataspace */
if((snelmts = H5S_GET_EXTENT_NPOINTS(dset->shared->space)) < 0)
@@ -649,6 +644,7 @@ H5D__contig_readvv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len,
size_t sieve_size = (size_t)-1; /* Size of sieve buffer */
haddr_t rel_eoa; /* Relative end of file address */
hsize_t max_data; /* Actual maximum size of data to cache */
+ hsize_t min; /* temporary minimum value (avoids some ugly macro nesting) */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
@@ -689,7 +685,8 @@ H5D__contig_readvv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len,
max_data = store_contig->dset_size - dst_off;
/* Compute the size of the sieve buffer */
- H5_ASSIGN_OVERFLOW(dset_contig->sieve_size, MIN3(rel_eoa - dset_contig->sieve_loc, max_data, dset_contig->sieve_buf_size), hsize_t, size_t);
+ min = MIN3(rel_eoa - dset_contig->sieve_loc, max_data, dset_contig->sieve_buf_size);
+ H5_CHECKED_ASSIGN(dset_contig->sieve_size, size_t, min, hsize_t);
/* Read the new sieve buffer */
if(H5F_block_read(file, H5FD_MEM_DRAW, dset_contig->sieve_loc, dset_contig->sieve_size, udata->dxpl_id, dset_contig->sieve_buf) < 0)
@@ -762,9 +759,13 @@ H5D__contig_readvv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len,
/* Only need this when resizing sieve buffer */
max_data = store_contig->dset_size - dst_off;
- /* Compute the size of the sieve buffer */
- /* Don't read off the end of the file, don't read past the end of the data element and don't read more than the buffer size */
- H5_ASSIGN_OVERFLOW(dset_contig->sieve_size, MIN3(rel_eoa - dset_contig->sieve_loc, max_data, dset_contig->sieve_buf_size), hsize_t, size_t);
+ /* Compute the size of the sieve buffer.
+ * Don't read off the end of the file, don't read past
+ * the end of the data element, and don't read more than
+ * the buffer size.
+ */
+ min = MIN3(rel_eoa - dset_contig->sieve_loc, max_data, dset_contig->sieve_buf_size);
+ H5_CHECKED_ASSIGN(dset_contig->sieve_size, size_t, min, hsize_t);
/* Update local copies of sieve information */
sieve_start = dset_contig->sieve_loc;
@@ -920,6 +921,7 @@ H5D__contig_writevv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len,
size_t sieve_size = (size_t)-1; /* size of sieve buffer */
haddr_t rel_eoa; /* Relative end of file address */
hsize_t max_data; /* Actual maximum size of data to cache */
+ hsize_t min; /* temporary minimum value (avoids some ugly macro nesting) */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
@@ -965,7 +967,8 @@ if(dset_contig->sieve_size > len)
max_data = store_contig->dset_size - dst_off;
/* Compute the size of the sieve buffer */
- H5_ASSIGN_OVERFLOW(dset_contig->sieve_size, MIN3(rel_eoa - dset_contig->sieve_loc, max_data, dset_contig->sieve_buf_size), hsize_t, size_t);
+ min = MIN3(rel_eoa - dset_contig->sieve_loc, max_data, dset_contig->sieve_buf_size);
+ H5_CHECKED_ASSIGN(dset_contig->sieve_size, size_t, min, hsize_t);
/* Check if there is any point in reading the data from the file */
if(dset_contig->sieve_size > len) {
@@ -1080,9 +1083,13 @@ if(dset_contig->sieve_size > len)
/* Only need this when resizing sieve buffer */
max_data = store_contig->dset_size - dst_off;
- /* Compute the size of the sieve buffer */
- /* Don't read off the end of the file, don't read past the end of the data element and don't read more than the buffer size */
- H5_ASSIGN_OVERFLOW(dset_contig->sieve_size, MIN3(rel_eoa - dset_contig->sieve_loc, max_data, dset_contig->sieve_buf_size), hsize_t, size_t);
+ /* Compute the size of the sieve buffer.
+ * Don't read off the end of the file, don't read past
+ * the end of the data element, and don't read more than
+ * the buffer size.
+ */
+ min = MIN3(rel_eoa - dset_contig->sieve_loc, max_data, dset_contig->sieve_buf_size);
+ H5_CHECKED_ASSIGN(dset_contig->sieve_size, size_t, min, hsize_t);
/* Update local copies of sieve information */
sieve_start = dset_contig->sieve_loc;