From d7565f316de2516f119e464e6450c4f8c73476b2 Mon Sep 17 00:00:00 2001 From: jhendersonHDF Date: Tue, 26 Apr 2022 13:18:18 -0500 Subject: Address some warnings from casting away of const (#1684) --- src/H5Dchunk.c | 67 ++++++++++++++++++++++++++------------------------------ src/H5Dint.c | 10 ++++----- src/H5Dio.c | 26 +++++++++++----------- src/H5Dpkg.h | 8 +++---- src/H5Dprivate.h | 2 +- src/H5Dselect.c | 4 ++-- src/H5Gent.c | 5 ++--- src/H5Gint.c | 2 +- src/H5Gloc.c | 22 +++++++++---------- src/H5Gpkg.h | 4 ++-- src/H5Gprivate.h | 2 +- src/H5Idbg.c | 8 +++---- src/H5Sprivate.h | 4 ++-- src/H5Sselect.c | 50 ++++++++++++++---------------------------- src/H5T.c | 2 +- src/H5Tprivate.h | 2 +- 16 files changed, 97 insertions(+), 121 deletions(-) diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index eac48a9..1d4b215 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -1143,8 +1143,7 @@ done: fm->mem_space = NULL; if (file_space_normalized == TRUE) - if (H5S_hyper_denormalize_offset((H5S_t *)file_space, old_offset) < - 0) /* (Casting away const OK -QAK) */ + if (H5S_hyper_denormalize_offset(file_space, old_offset) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't denormalize selection") FUNC_LEAVE_NOAPI(ret_value) @@ -1371,15 +1370,16 @@ done: *------------------------------------------------------------------------- */ void * -H5D__chunk_mem_alloc(size_t size, const H5O_pline_t *pline) +H5D__chunk_mem_alloc(size_t size, void *pline) { - void *ret_value = NULL; /* Return value */ + H5O_pline_t *_pline = (H5O_pline_t *)pline; + void * ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE_NOERR HDassert(size); - if (pline && pline->nused) + if (_pline && _pline->nused) ret_value = H5MM_malloc(size); else ret_value = H5FL_BLK_MALLOC(chunk, size); @@ -1402,14 +1402,14 @@ H5D__chunk_mem_alloc(size_t size, const H5O_pline_t *pline) *------------------------------------------------------------------------- */ void * -H5D__chunk_mem_xfree(void *chk, const void *_pline) +H5D__chunk_mem_xfree(void *chk, const void *pline) { - const H5O_pline_t *pline = (const H5O_pline_t *)_pline; + const H5O_pline_t *_pline = (const H5O_pline_t *)pline; FUNC_ENTER_PACKAGE_NOERR if (chk) { - if (pline && pline->nused) + if (_pline && _pline->nused) H5MM_xfree(chk); else chk = H5FL_BLK_FREE(chunk, chk); @@ -1426,9 +1426,9 @@ H5D__chunk_mem_xfree(void *chk, const void *_pline) *------------------------------------------------------------------------- */ void -H5D__chunk_mem_free(void *chk, const void *_pline) +H5D__chunk_mem_free(void *chk, void *pline) { - (void)H5D__chunk_mem_xfree(chk, _pline); + (void)H5D__chunk_mem_xfree(chk, pline); } /*------------------------------------------------------------------------- @@ -1580,8 +1580,7 @@ H5D__create_chunk_map_single(H5D_chunk_map_t *fm, const H5D_io_info_t chunk_info->fspace_shared = TRUE; /* Just point at the memory dataspace & selection */ - /* (Casting away const OK -QAK) */ - chunk_info->mspace = (H5S_t *)fm->mem_space; + chunk_info->mspace = fm->mem_space; /* Indicate that the chunk's memory dataspace is shared */ chunk_info->mspace_shared = TRUE; @@ -1856,7 +1855,6 @@ H5D__create_chunk_file_map_hyper(H5D_chunk_map_t *fm, const H5D_io_info_t /* Iterate through each chunk in the dataset */ while (sel_points) { /* Check for intersection of current chunk and file selection */ - /* (Casting away const OK - QAK) */ if (TRUE == H5S_SELECT_INTERSECT_BLOCK(fm->file_space, coords, end)) { H5D_chunk_info_t *new_chunk_info; /* chunk information to insert into skip list */ hsize_t chunk_points; /* Number of elements in chunk selection */ @@ -2015,8 +2013,7 @@ H5D__create_chunk_mem_map_hyper(const H5D_chunk_map_t *fm) HDassert(chunk_info); /* Just point at the memory dataspace & selection */ - /* (Casting away const OK -QAK) */ - chunk_info->mspace = (H5S_t *)fm->mem_space; + chunk_info->mspace = fm->mem_space; /* Indicate that the chunk's memory space is shared */ chunk_info->mspace_shared = TRUE; @@ -2138,8 +2135,7 @@ H5D__create_chunk_mem_map_1d(const H5D_chunk_map_t *fm) HDassert(chunk_info); /* Just point at the memory dataspace & selection */ - /* (Casting away const OK -QAK) */ - chunk_info->mspace = (H5S_t *)fm->mem_space; + chunk_info->mspace = fm->mem_space; /* Indicate that the chunk's memory space is shared */ chunk_info->mspace_shared = TRUE; @@ -4104,11 +4100,11 @@ done: static void * H5D__chunk_lock(const H5D_io_info_t *io_info, H5D_chunk_ud_t *udata, hbool_t relax, hbool_t prev_unfilt_chunk) { - const H5D_t * dset = io_info->dset; /* Local pointer to the dataset info */ - const H5O_pline_t *pline = + const H5D_t *dset = io_info->dset; /* Local pointer to the dataset info */ + H5O_pline_t *pline = &(dset->shared->dcpl_cache .pline); /* I/O pipeline info - always equal to the pline passed to H5D__chunk_mem_alloc */ - const H5O_pline_t * old_pline = pline; /* Old pipeline, i.e. pipeline used to read the chunk */ + H5O_pline_t * old_pline = pline; /* Old pipeline, i.e. pipeline used to read the chunk */ const H5O_layout_t *layout = &(dset->shared->layout); /* Dataset layout */ const H5O_fill_t * fill = &(dset->shared->dcpl_cache.fill); /* Fill value info */ H5D_fill_buf_info_t fb_info; /* Dataset's fill buffer info */ @@ -4688,18 +4684,18 @@ H5D__chunk_allocate(const H5D_io_info_t *io_info, hbool_t full_overwrite, const coordinates) */ hsize_t max_unalloc[H5O_LAYOUT_NDIMS]; /* Last chunk in each dimension that is unallocated (in scaled coordinates) */ - hsize_t scaled[H5O_LAYOUT_NDIMS]; /* Offset of current chunk (in scaled coordinates) */ - size_t orig_chunk_size; /* Original size of chunk in bytes */ - size_t chunk_size; /* Actual size of chunk in bytes, possibly filtered */ - unsigned filter_mask = 0; /* Filter mask for chunks that have them */ - H5O_layout_t * layout = &(dset->shared->layout); /* Dataset layout */ - const H5O_pline_t *pline = &(dset->shared->dcpl_cache.pline); /* I/O pipeline info */ - const H5O_pline_t def_pline = H5O_CRT_PIPELINE_DEF; /* Default pipeline */ - const H5O_fill_t * fill = &(dset->shared->dcpl_cache.fill); /* Fill value info */ - H5D_fill_value_t fill_status; /* The fill value status */ - hbool_t should_fill = FALSE; /* Whether fill values should be written */ - void * unfilt_fill_buf = NULL; /* Unfiltered fill value buffer */ - void ** fill_buf = NULL; /* Pointer to the fill buffer to use for a chunk */ + hsize_t scaled[H5O_LAYOUT_NDIMS]; /* Offset of current chunk (in scaled coordinates) */ + size_t orig_chunk_size; /* Original size of chunk in bytes */ + size_t chunk_size; /* Actual size of chunk in bytes, possibly filtered */ + unsigned filter_mask = 0; /* Filter mask for chunks that have them */ + H5O_layout_t * layout = &(dset->shared->layout); /* Dataset layout */ + H5O_pline_t * pline = &(dset->shared->dcpl_cache.pline); /* I/O pipeline info */ + H5O_pline_t def_pline = H5O_CRT_PIPELINE_DEF; /* Default pipeline */ + const H5O_fill_t *fill = &(dset->shared->dcpl_cache.fill); /* Fill value info */ + H5D_fill_value_t fill_status; /* The fill value status */ + hbool_t should_fill = FALSE; /* Whether fill values should be written */ + void * unfilt_fill_buf = NULL; /* Unfiltered fill value buffer */ + void ** fill_buf = NULL; /* Pointer to the fill buffer to use for a chunk */ #ifdef H5_HAVE_PARALLEL hbool_t blocks_written = FALSE; /* Flag to indicate that chunk was actually written */ hbool_t using_mpi = @@ -4804,10 +4800,9 @@ H5D__chunk_allocate(const H5D_io_info_t *io_info, hbool_t full_overwrite, const if (should_fill) { /* Initialize the fill value buffer */ /* (delay allocating fill buffer for VL datatypes until refilling) */ - /* (casting away const OK - QAK) */ - if (H5D__fill_init(&fb_info, NULL, (H5MM_allocate_t)H5D__chunk_mem_alloc, (void *)pline, - (H5MM_free_t)H5D__chunk_mem_free, (void *)pline, &dset->shared->dcpl_cache.fill, - dset->shared->type, dset->shared->type_id, (size_t)0, orig_chunk_size) < 0) + if (H5D__fill_init(&fb_info, NULL, H5D__chunk_mem_alloc, pline, H5D__chunk_mem_free, pline, + &dset->shared->dcpl_cache.fill, dset->shared->type, dset->shared->type_id, + (size_t)0, orig_chunk_size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't initialize fill buffer info") fb_info_init = TRUE; diff --git a/src/H5Dint.c b/src/H5Dint.c index 3896584..3b6b884 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -75,7 +75,7 @@ typedef struct { /* General stuff */ static H5D_shared_t *H5D__new(hid_t dcpl_id, hid_t dapl_id, hbool_t creating, hbool_t vl_type); -static herr_t H5D__init_type(H5F_t *file, const H5D_t *dset, hid_t type_id, const H5T_t *type); +static herr_t H5D__init_type(H5F_t *file, const H5D_t *dset, hid_t type_id, H5T_t *type); static herr_t H5D__cache_dataspace_info(const H5D_t *dset); static herr_t H5D__init_space(H5F_t *file, const H5D_t *dset, const H5S_t *space); static herr_t H5D__update_oh_info(H5F_t *file, H5D_t *dset, hid_t dapl_id); @@ -488,7 +488,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5D__init_type(H5F_t *file, const H5D_t *dset, hid_t type_id, const H5T_t *type) +H5D__init_type(H5F_t *file, const H5D_t *dset, hid_t type_id, H5T_t *type) { htri_t relocatable; /* Flag whether the type is relocatable */ htri_t immutable; /* Flag whether the type is immutable */ @@ -544,8 +544,8 @@ H5D__init_type(H5F_t *file, const H5D_t *dset, hid_t type_id, const H5T_t *type) /* Use existing datatype */ dset->shared->type_id = type_id; - dset->shared->type = (H5T_t *)type; /* (Cast away const OK - QAK) */ - } /* end else */ + dset->shared->type = type; + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) @@ -2192,7 +2192,7 @@ H5D_oloc(H5D_t *dataset) *------------------------------------------------------------------------- */ H5G_name_t * -H5D_nameof(const H5D_t *dataset) +H5D_nameof(H5D_t *dataset) { /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOERR 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 */ /* */ @@ -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 */ diff --git a/src/H5Dpkg.h b/src/H5Dpkg.h index 0e0eb08..724f3ce 100644 --- a/src/H5Dpkg.h +++ b/src/H5Dpkg.h @@ -594,8 +594,8 @@ H5_DLL herr_t H5D__select_write(const H5D_io_info_t *io_info, const H5D_type_inf hsize_t nelmts, H5S_t *file_space, H5S_t *mem_space); /* Functions that perform direct copying between memory buffers */ -H5_DLL herr_t H5D_select_io_mem(void *dst_buf, const H5S_t *dst_space, const void *src_buf, - const H5S_t *src_space, size_t elmt_size, size_t nelmts); +H5_DLL herr_t H5D_select_io_mem(void *dst_buf, H5S_t *dst_space, const void *src_buf, H5S_t *src_space, + size_t elmt_size, size_t nelmts); /* Functions that perform scatter-gather serial I/O operations */ H5_DLL herr_t H5D__scatter_mem(const void *_tscat_buf, H5S_sel_iter_t *iter, size_t nelmts, void *_buf); @@ -641,8 +641,8 @@ H5_DLL herr_t H5D__chunk_allocate(const H5D_io_info_t *io_info, hbool_t full_ov const hsize_t old_dim[]); H5_DLL herr_t H5D__chunk_file_alloc(const H5D_chk_idx_info_t *idx_info, const H5F_block_t *old_chunk, H5F_block_t *new_chunk, hbool_t *need_insert, const hsize_t *scaled); -H5_DLL void * H5D__chunk_mem_alloc(size_t size, const H5O_pline_t *pline); -H5_DLL void H5D__chunk_mem_free(void *chk, const void *_pline); +H5_DLL void * H5D__chunk_mem_alloc(size_t size, void *pline); +H5_DLL void H5D__chunk_mem_free(void *chk, void *pline); H5_DLL void * H5D__chunk_mem_xfree(void *chk, const void *pline); H5_DLL void * H5D__chunk_mem_realloc(void *chk, size_t size, const H5O_pline_t *pline); H5_DLL herr_t H5D__chunk_update_old_edge_chunks(H5D_t *dset, hsize_t old_dim[]); diff --git a/src/H5Dprivate.h b/src/H5Dprivate.h index ad9794d..515c739 100644 --- a/src/H5Dprivate.h +++ b/src/H5Dprivate.h @@ -164,7 +164,7 @@ H5_DLL herr_t H5D_close(H5D_t *dataset); H5_DLL herr_t H5D_mult_refresh_close(hid_t dset_id); H5_DLL herr_t H5D_mult_refresh_reopen(H5D_t *dataset); H5_DLL H5O_loc_t *H5D_oloc(H5D_t *dataset); -H5_DLL H5G_name_t *H5D_nameof(const H5D_t *dataset); +H5_DLL H5G_name_t *H5D_nameof(H5D_t *dataset); H5_DLL herr_t H5D_flush_all(H5F_t *f); H5_DLL hid_t H5D_get_create_plist(const H5D_t *dset); H5_DLL hid_t H5D_get_access_plist(const H5D_t *dset); diff --git a/src/H5Dselect.c b/src/H5Dselect.c index 1a6292c..ef33ea7 100644 --- a/src/H5Dselect.c +++ b/src/H5Dselect.c @@ -274,8 +274,8 @@ done: *------------------------------------------------------------------------- */ herr_t -H5D_select_io_mem(void *dst_buf, const H5S_t *dst_space, const void *src_buf, const H5S_t *src_space, - size_t elmt_size, size_t nelmts) +H5D_select_io_mem(void *dst_buf, H5S_t *dst_space, const void *src_buf, H5S_t *src_space, size_t elmt_size, + size_t nelmts) { H5S_sel_iter_t *dst_sel_iter = NULL; /* Destination dataspace iteration info */ H5S_sel_iter_t *src_sel_iter = NULL; /* Source dataspace iteration info */ diff --git a/src/H5Gent.c b/src/H5Gent.c index 2f1a2b4..2e06092 100644 --- a/src/H5Gent.c +++ b/src/H5Gent.c @@ -300,7 +300,7 @@ done: *------------------------------------------------------------------------- */ void -H5G__ent_copy(H5G_entry_t *dst, const H5G_entry_t *src, H5_copy_depth_t depth) +H5G__ent_copy(H5G_entry_t *dst, H5G_entry_t *src, H5_copy_depth_t depth) { FUNC_ENTER_PACKAGE_NOERR @@ -318,8 +318,7 @@ H5G__ent_copy(H5G_entry_t *dst, const H5G_entry_t *src, H5_copy_depth_t depth) ; } else if (depth == H5_COPY_SHALLOW) { - /* Discarding 'const' qualifier OK - QAK */ - H5G__ent_reset((H5G_entry_t *)src); + H5G__ent_reset(src); } /* end if */ FUNC_LEAVE_NOAPI_VOID diff --git a/src/H5Gint.c b/src/H5Gint.c index 0c4bee2..34711dd 100644 --- a/src/H5Gint.c +++ b/src/H5Gint.c @@ -689,7 +689,7 @@ H5G_oloc(H5G_t *grp) *------------------------------------------------------------------------- */ H5G_name_t * -H5G_nameof(const H5G_t *grp) +H5G_nameof(H5G_t *grp) { /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOERR diff --git a/src/H5Gloc.c b/src/H5Gloc.c index 346ecdc..fb94685 100644 --- a/src/H5Gloc.c +++ b/src/H5Gloc.c @@ -559,8 +559,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5G__loc_insert(H5G_loc_t *grp_loc, const char *name, H5G_loc_t *obj_loc, H5O_type_t obj_type, - const void *crt_info) +H5G__loc_insert(H5G_loc_t *grp_loc, char *name, H5G_loc_t *obj_loc, H5O_type_t obj_type, const void *crt_info) { H5O_link_t lnk; /* Link for object to insert */ herr_t ret_value = SUCCEED; /* Return value */ @@ -577,9 +576,8 @@ H5G__loc_insert(H5G_loc_t *grp_loc, const char *name, H5G_loc_t *obj_loc, H5O_ty lnk.cset = H5F_DEFAULT_CSET; lnk.corder = 0; /* Will be reset if the group is tracking creation order */ lnk.corder_valid = FALSE; /* Indicate that the creation order isn't valid (yet) */ - /* Casting away const OK -QAK */ - lnk.name = (char *)name; - lnk.u.hard.addr = obj_loc->oloc->addr; + lnk.name = name; + lnk.u.hard.addr = obj_loc->oloc->addr; /* Insert new group into current group's symbol table */ if (H5G_obj_insert(grp_loc->oloc, name, &lnk, TRUE, obj_type, crt_info) < 0) @@ -904,10 +902,10 @@ H5G__loc_set_comment_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc /*in*/, const char H5_ const H5O_link_t H5_ATTR_UNUSED *lnk, H5G_loc_t *obj_loc, void *_udata /*in,out*/, H5G_own_loc_t *own_loc /*out*/) { - H5G_loc_sc_t *udata = (H5G_loc_sc_t *)_udata; /* User data passed in */ - H5O_name_t comment; /* Object header "comment" message */ - htri_t exists; /* Whether a "comment" message already exists */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_loc_sc_t *udata = (H5G_loc_sc_t *)_udata; /* User data passed in */ + H5O_name_t comment = {0}; /* Object header "comment" message */ + htri_t exists; /* Whether a "comment" message already exists */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -927,13 +925,15 @@ H5G__loc_set_comment_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc /*in*/, const char H5_ /* Add the new message */ if (udata->comment && *udata->comment) { - /* Casting away const OK -QAK */ - comment.s = (char *)udata->comment; + if (NULL == (comment.s = HDstrdup(udata->comment))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "can't copy group comment") if (H5O_msg_create(obj_loc->oloc, H5O_NAME_ID, 0, H5O_UPDATE_TIME, &comment) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to set comment object header message") } /* end if */ done: + HDfree(comment.s); + /* Indicate that this callback didn't take ownership of the group * * location for the object */ *own_loc = H5G_OWN_NONE; diff --git a/src/H5Gpkg.h b/src/H5Gpkg.h index d108b03..6939d2f 100644 --- a/src/H5Gpkg.h +++ b/src/H5Gpkg.h @@ -373,7 +373,7 @@ H5_DLL herr_t H5G__stab_valid(H5O_loc_t *grp_oloc, H5O_stab_t *alt_stab); /* * Functions that understand symbol table entries. */ -H5_DLL void H5G__ent_copy(H5G_entry_t *dst, const H5G_entry_t *src, H5_copy_depth_t depth); +H5_DLL void H5G__ent_copy(H5G_entry_t *dst, H5G_entry_t *src, H5_copy_depth_t depth); H5_DLL void H5G__ent_reset(H5G_entry_t *ent); H5_DLL herr_t H5G__ent_decode_vec(const H5F_t *f, const uint8_t **pp, const uint8_t *p_end, H5G_entry_t *ent, unsigned n); @@ -465,7 +465,7 @@ H5_DLL herr_t H5G__name_init(H5G_name_t *name, const char *path); /* * These functions operate on group "locations" */ -H5_DLL herr_t H5G__loc_insert(H5G_loc_t *grp_loc, const char *name, H5G_loc_t *obj_loc, H5O_type_t obj_type, +H5_DLL herr_t H5G__loc_insert(H5G_loc_t *grp_loc, char *name, H5G_loc_t *obj_loc, H5O_type_t obj_type, const void *crt_info); H5_DLL herr_t H5G__loc_addr(const H5G_loc_t *loc, const char *name, haddr_t *addr /*out*/); diff --git a/src/H5Gprivate.h b/src/H5Gprivate.h index d1725f6..d8cd6e8 100644 --- a/src/H5Gprivate.h +++ b/src/H5Gprivate.h @@ -191,7 +191,7 @@ typedef struct H5G_entry_t H5G_entry_t; */ H5_DLL herr_t H5G_init(void); H5_DLL struct H5O_loc_t *H5G_oloc(H5G_t *grp); -H5_DLL H5G_name_t *H5G_nameof(const H5G_t *grp); +H5_DLL H5G_name_t *H5G_nameof(H5G_t *grp); H5_DLL H5F_t *H5G_fileof(H5G_t *grp); H5_DLL H5G_t * H5G_open(const H5G_loc_t *loc); H5_DLL herr_t H5G_close(H5G_t *grp); diff --git a/src/H5Idbg.c b/src/H5Idbg.c index 37232c5..6b4a979 100644 --- a/src/H5Idbg.c +++ b/src/H5Idbg.c @@ -78,7 +78,7 @@ H5I__id_dump_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) H5I_id_info_t * info = (H5I_id_info_t *)_item; /* Pointer to the ID node */ H5I_type_t type = *(H5I_type_t *)_udata; /* User data */ const H5G_name_t *path = NULL; /* Path to file object */ - const void * object = NULL; /* Pointer to VOL connector object */ + void * object = NULL; /* Pointer to VOL connector object */ FUNC_ENTER_PACKAGE_NOERR @@ -94,7 +94,7 @@ H5I__id_dump_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) object = H5VL_object_data(vol_obj); if (H5_VOL_NATIVE == vol_obj->connector->cls->value) - path = H5G_nameof((const H5G_t *)object); + path = H5G_nameof(object); break; } @@ -103,7 +103,7 @@ H5I__id_dump_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) object = H5VL_object_data(vol_obj); if (H5_VOL_NATIVE == vol_obj->connector->cls->value) - path = H5D_nameof((const H5D_t *)object); + path = H5D_nameof(object); break; } @@ -114,7 +114,7 @@ H5I__id_dump_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) object = (void *)H5T_get_actual_type((H5T_t *)dt); /* Casting away const OK - QAK */ H5_GCC_CLANG_DIAG_ON("cast-qual") - path = H5T_nameof((const H5T_t *)object); + path = H5T_nameof(object); break; } diff --git a/src/H5Sprivate.h b/src/H5Sprivate.h index 8a14563..4c997b1 100644 --- a/src/H5Sprivate.h +++ b/src/H5Sprivate.h @@ -246,8 +246,8 @@ H5_DLL herr_t H5S_select_copy(H5S_t *dst, const H5S_t *src, hbool_t share_sele H5_DLL htri_t H5S_select_shape_same(H5S_t *space1, H5S_t *space2); H5_DLL htri_t H5S_select_intersect_block(H5S_t *space, const hsize_t *start, const hsize_t *end); H5_DLL herr_t H5S_select_construct_projection(H5S_t *base_space, H5S_t **new_space_ptr, - unsigned new_space_rank, const void *buf, - void const **adj_buf_ptr, hsize_t element_size); + unsigned new_space_rank, hsize_t element_size, + ptrdiff_t *buf_adj); H5_DLL herr_t H5S_select_release(H5S_t *ds); H5_DLL hssize_t H5S_select_serial_size(H5S_t *space); H5_DLL herr_t H5S_select_serialize(H5S_t *space, uint8_t **p); diff --git a/src/H5Sselect.c b/src/H5Sselect.c index c931304..87ac308 100644 --- a/src/H5Sselect.c +++ b/src/H5Sselect.c @@ -2170,27 +2170,24 @@ done: Note that if m > n, it is possible that the starting point in the buffer associated with the memory dataspace will have to be - adjusted to match the projected dataspace. If the buf parameter - is not NULL, the function must return an adjusted buffer base - address in *adj_buf_ptr. + adjusted to match the projected dataspace. In this case, the amount + of adjustment to be applied to the buffer will be returned via the + buf_adj parameter, if supplied. USAGE htri_t H5S_select_construct_projection(base_space, new_space_ptr, new_space_rank, - buf, - adj_buf_ptr) + element_size, + buf_adj) const H5S_t *base_space; IN: Ptr to Dataspace to project H5S_t ** new_space_ptr; OUT: Ptr to location in which to return the address of the projected space int new_space_rank; IN: Rank of the projected space. - const void * buf; IN: Base address of the buffer - associated with the base space. - May be NULL. - void ** adj_buf_ptr; OUT: If buf != NULL, store the base - address of the section of buf - that is described by *new_space_ptr - in *adj_buf_ptr. + hsize_t element_size; IN: size of each element in the selection + ptrdiff_t buf_adj; OUT: amount of adjustment to be applied + to buffer associated with memory + dataspace RETURNS Non-negative on success/Negative on failure. @@ -2200,9 +2197,6 @@ done: projection of the supplied dataspace and associated selection into the specified rank. Return it in *new_space_ptr. - If buf is supplied, computes the base address of the projected - selection in buf, and stores the base address in *adj_buf_ptr. - GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS The selection in the supplied base_space has thickness 1 in all @@ -2214,7 +2208,7 @@ done: --------------------------------------------------------------------------*/ herr_t H5S_select_construct_projection(H5S_t *base_space, H5S_t **new_space_ptr, unsigned new_space_rank, - const void *buf, void const **adj_buf_ptr, hsize_t element_size) + hsize_t element_size, ptrdiff_t *buf_adj) { H5S_t * new_space = NULL; /* New dataspace constructed */ hsize_t base_space_dims[H5S_MAX_RANK]; /* Current dimensions of base dataspace */ @@ -2233,7 +2227,6 @@ H5S_select_construct_projection(H5S_t *base_space, H5S_t **new_space_ptr, unsign HDassert(new_space_ptr != NULL); HDassert((new_space_rank != 0) || (H5S_GET_SELECT_NPOINTS(base_space) <= 1)); HDassert(new_space_rank <= H5S_MAX_RANK); - HDassert((buf == NULL) || (adj_buf_ptr != NULL)); HDassert(element_size > 0); /* Get the extent info for the base dataspace */ @@ -2396,26 +2389,15 @@ H5S_select_construct_projection(H5S_t *base_space, H5S_t **new_space_ptr, unsign /* load the address of the new space into *new_space_ptr */ *new_space_ptr = new_space; - /* now adjust the buffer if required */ - if (buf != NULL) { + /* return the buffer adjustment amount if required */ + if (buf_adj != NULL) { if (new_space_rank < base_space_rank) { - /* a bit of pointer magic here: - * - * Since we can't do pointer arithmetic on void pointers, we first - * cast buf to a pointer to byte -- i.e. uint8_t. - * - * We then multiply the projected space element offset we - * calculated earlier by the supplied element size, add this - * value to the type cast buf pointer, cast the result back - * to a pointer to void, and assign the result to *adj_buf_ptr. - */ - *adj_buf_ptr = (const void *)(((const uint8_t *)buf) + - ((size_t)(projected_space_element_offset * element_size))); - } /* end if */ + *buf_adj = (ptrdiff_t)(projected_space_element_offset * element_size); + } else /* No adjustment necessary */ - *adj_buf_ptr = buf; - } /* end if */ + *buf_adj = 0; + } done: /* Cleanup on error */ diff --git a/src/H5T.c b/src/H5T.c index 39d7b91..e0dc993 100644 --- a/src/H5T.c +++ b/src/H5T.c @@ -5522,7 +5522,7 @@ done: *------------------------------------------------------------------------- */ H5G_name_t * -H5T_nameof(const H5T_t *dt) +H5T_nameof(H5T_t *dt) { H5G_name_t *ret_value = NULL; diff --git a/src/H5Tprivate.h b/src/H5Tprivate.h index 9731379..aaa7202 100644 --- a/src/H5Tprivate.h +++ b/src/H5Tprivate.h @@ -125,7 +125,7 @@ H5_DLL herr_t H5T_encode(H5T_t *obj, unsigned char *buf, size_t *nalloc); H5_DLL H5T_t * H5T_decode(size_t buf_size, const unsigned char *buf); H5_DLL herr_t H5T_debug(const H5T_t *dt, FILE *stream); H5_DLL struct H5O_loc_t * H5T_oloc(H5T_t *dt); -H5_DLL struct H5G_name_t *H5T_nameof(const H5T_t *dt); +H5_DLL struct H5G_name_t *H5T_nameof(H5T_t *dt); H5_DLL htri_t H5T_is_immutable(const H5T_t *dt); H5_DLL htri_t H5T_is_named(const H5T_t *dt); H5_DLL herr_t H5T_convert_committed_datatype(H5T_t *dt, H5F_t *f); -- cgit v0.12