summaryrefslogtreecommitdiffstats
path: root/src/H5Dio.c
diff options
context:
space:
mode:
authorjhendersonHDF <jhenderson@hdfgroup.org>2022-04-26 18:18:18 (GMT)
committerGitHub <noreply@github.com>2022-04-26 18:18:18 (GMT)
commitd7565f316de2516f119e464e6450c4f8c73476b2 (patch)
treefcec98687ef88e0c8f5a1b377d48f5349fdae356 /src/H5Dio.c
parent417ee1393b425d5c7c998562e7fb492e28928643 (diff)
downloadhdf5-d7565f316de2516f119e464e6450c4f8c73476b2.zip
hdf5-d7565f316de2516f119e464e6450c4f8c73476b2.tar.gz
hdf5-d7565f316de2516f119e464e6450c4f8c73476b2.tar.bz2
Address some warnings from casting away of const (#1684)
Diffstat (limited to 'src/H5Dio.c')
-rw-r--r--src/H5Dio.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/H5Dio.c b/src/H5Dio.c
index f8a6978..470b245 100644
--- a/src/H5Dio.c
+++ b/src/H5Dio.c
@@ -174,21 +174,21 @@ H5D__read(H5D_t *dataset, hid_t mem_type_id, H5S_t *mem_space, H5S_t *file_space
*/
if (nelmts > 0 && TRUE == H5S_SELECT_SHAPE_SAME(mem_space, file_space) &&
H5S_GET_EXTENT_NDIMS(mem_space) != H5S_GET_EXTENT_NDIMS(file_space)) {
- const void *adj_buf = NULL; /* Pointer to the location in buf corresponding */
- /* to the beginning of the projected mem space. */
+ ptrdiff_t buf_adj = 0;
/* Attempt to construct projected dataspace for memory dataspace */
if (H5S_select_construct_projection(mem_space, &projected_mem_space,
- (unsigned)H5S_GET_EXTENT_NDIMS(file_space), buf, &adj_buf,
- type_info.dst_type_size) < 0)
+ (unsigned)H5S_GET_EXTENT_NDIMS(file_space),
+ type_info.dst_type_size, &buf_adj) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to construct projected memory dataspace")
HDassert(projected_mem_space);
- HDassert(adj_buf);
+
+ /* Adjust the buffer by the given amount */
+ buf = (void *)(((uint8_t *)buf) + buf_adj);
/* Switch to using projected memory dataspace & adjusted buffer */
mem_space = projected_mem_space;
- buf = (void *)adj_buf; /* Casting away 'const' OK -QAK */
- } /* end if */
+ } /* end if */
/* Retrieve dataset properties */
/* <none needed in the general case> */
@@ -407,20 +407,20 @@ H5D__write(H5D_t *dataset, hid_t mem_type_id, H5S_t *mem_space, H5S_t *file_spac
*/
if (nelmts > 0 && TRUE == H5S_SELECT_SHAPE_SAME(mem_space, file_space) &&
H5S_GET_EXTENT_NDIMS(mem_space) != H5S_GET_EXTENT_NDIMS(file_space)) {
- const void *adj_buf = NULL; /* Pointer to the location in buf corresponding */
- /* to the beginning of the projected mem space. */
+ ptrdiff_t buf_adj = 0;
/* Attempt to construct projected dataspace for memory dataspace */
if (H5S_select_construct_projection(mem_space, &projected_mem_space,
- (unsigned)H5S_GET_EXTENT_NDIMS(file_space), buf, &adj_buf,
- type_info.src_type_size) < 0)
+ (unsigned)H5S_GET_EXTENT_NDIMS(file_space),
+ type_info.src_type_size, &buf_adj) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to construct projected memory dataspace")
HDassert(projected_mem_space);
- HDassert(adj_buf);
+
+ /* Adjust the buffer by the given amount */
+ buf = (const void *)(((const uint8_t *)buf) + buf_adj);
/* Switch to using projected memory dataspace & adjusted buffer */
mem_space = projected_mem_space;
- buf = adj_buf;
} /* end if */
/* Retrieve dataset properties */