Fixed all -Wincompatible-pointer-types-discards-qualifiers warnings (#341)

* Fixed various -Wincompatible-pointer-types-discards-qualifiers warnings by adding const

* Fixed various -Wincompatible-pointer-types-discards-qualifiers warning by removing extraneous consts

There were casts with const, but the function parameter doesn't actaully take const, so just modified the casts.

In the other case, a local variable was const that should not have been, becuase its source wasn't const either.

* Fixed a -Wincompatible-pointer-types-discards-qualifiers warning by strdup-ing a string

Create a duplicate string instead of mutating a supposedly const one.
This commit is contained in:
Sean McBride 2021-02-22 12:37:12 -05:00 committed by GitHub
parent 99669024ff
commit 5ed255a607
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 34 additions and 32 deletions

View File

@ -76,9 +76,9 @@ main(void)
/* Access reference and read dataset data through new API */
assert(H5Rget_type((const H5R_ref_t *)&new_ref_buf[0]) == H5R_OBJECT2);
H5Rget_obj_type3((const H5R_ref_t *)&new_ref_buf[0], H5P_DEFAULT, &obj_type);
H5Rget_obj_type3(&new_ref_buf[0], H5P_DEFAULT, &obj_type);
assert(obj_type == H5O_TYPE_DATASET);
dset1 = H5Ropen_object((const H5R_ref_t *)&new_ref_buf[0], H5P_DEFAULT, H5P_DEFAULT);
dset1 = H5Ropen_object(&new_ref_buf[0], H5P_DEFAULT, H5P_DEFAULT);
H5Dread(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset_buf);
H5Dclose(dset1);
H5Rdestroy(&new_ref_buf[0]);

View File

@ -78,9 +78,9 @@ main(void)
/* Access reference and read dataset data without opening original file */
assert(H5Rget_type((const H5R_ref_t *)&ref_buf[0]) == H5R_OBJECT2);
H5Rget_obj_type3((const H5R_ref_t *)&ref_buf[0], H5P_DEFAULT, &obj_type);
H5Rget_obj_type3(&ref_buf[0], H5P_DEFAULT, &obj_type);
assert(obj_type == H5O_TYPE_DATASET);
dset1 = H5Ropen_object((const H5R_ref_t *)&ref_buf[0], H5P_DEFAULT, H5P_DEFAULT);
dset1 = H5Ropen_object(&ref_buf[0], H5P_DEFAULT, H5P_DEFAULT);
H5Dread(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset_buf);
H5Dclose(dset1);
H5Rdestroy(&ref_buf[0]);

View File

@ -4267,18 +4267,18 @@ H5D__chunk_allocate(const H5D_io_info_t *io_info, hbool_t full_overwrite, hsize_
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 */
const 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 */
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 */
#ifdef H5_HAVE_PARALLEL
hbool_t blocks_written = FALSE; /* Flag to indicate that chunk was actually written */
hbool_t using_mpi =

View File

@ -553,10 +553,10 @@ done:
herr_t
H5G__user_path_test(hid_t obj_id, char *user_path, size_t *user_path_len, unsigned *obj_hidden)
{
void * obj_ptr; /* Pointer to object for ID */
H5G_name_t *obj_path; /* Pointer to group hier. path for obj */
hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
herr_t ret_value = SUCCEED; /* Return value */
void * obj_ptr; /* Pointer to object for ID */
const H5G_name_t *obj_path; /* Pointer to group hier. path for obj */
hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE

View File

@ -76,10 +76,10 @@ static int H5I__id_dump_cb(void *_item, void *_key, void *_udata);
static int
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 */
H5G_name_t * path = NULL; /* Path to file object */
const void * object = NULL; /* Pointer to VOL connector object */
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 */
FUNC_ENTER_STATIC_NOERR

View File

@ -63,7 +63,7 @@ static herr_t H5O__copy_expand_ref_object1(H5O_loc_t *src_oloc, const void *buf_
static herr_t H5O__copy_expand_ref_region1(H5O_loc_t *src_oloc, const void *buf_src, H5O_loc_t *dst_oloc,
H5G_loc_t *dst_root_loc, void *buf_dst, size_t ref_count,
H5O_copy_t *cpy_info);
static herr_t H5O__copy_expand_ref_object2(H5O_loc_t *src_oloc, hid_t tid_src, H5T_t *dt_src,
static herr_t H5O__copy_expand_ref_object2(H5O_loc_t *src_oloc, hid_t tid_src, const H5T_t *dt_src,
const void *buf_src, size_t nbytes_src, H5O_loc_t *dst_oloc,
H5G_loc_t *dst_root_loc, void *buf_dst, size_t ref_count,
H5O_copy_t *cpy_info);
@ -284,7 +284,7 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
H5O__copy_expand_ref_object2(H5O_loc_t *src_oloc, hid_t tid_src, H5T_t *dt_src, const void *buf_src,
H5O__copy_expand_ref_object2(H5O_loc_t *src_oloc, hid_t tid_src, const H5T_t *dt_src, const void *buf_src,
size_t nbytes_src, H5O_loc_t *dst_oloc, H5G_loc_t *dst_root_loc, void *buf_dst,
size_t ref_count, H5O_copy_t *cpy_info)
{
@ -423,7 +423,7 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
H5O_copy_expand_ref(H5F_t *file_src, hid_t tid_src, H5T_t *dt_src, void *buf_src, size_t nbytes_src,
H5O_copy_expand_ref(H5F_t *file_src, hid_t tid_src, const H5T_t *dt_src, void *buf_src, size_t nbytes_src,
H5F_t *file_dst, void *buf_dst, H5O_copy_t *cpy_info)
{
H5O_loc_t dst_oloc; /* Copied object object location */

View File

@ -994,7 +994,7 @@ H5_DLL herr_t H5O_are_mdc_flushes_disabled(H5O_loc_t *oloc, hbool_t *are_disable
H5_DLL herr_t H5O_copy_header_map(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */,
H5O_copy_t *cpy_info, hbool_t inc_depth, H5O_type_t *obj_type,
void **udata);
H5_DLL herr_t H5O_copy_expand_ref(H5F_t *file_src, hid_t tid_src, H5T_t *dt_src, void *buf_src,
H5_DLL herr_t H5O_copy_expand_ref(H5F_t *file_src, hid_t tid_src, const H5T_t *dt_src, void *buf_src,
size_t nbytes_src, H5F_t *file_dst, void *buf_dst, H5O_copy_t *cpy_info);
/* Debugging routines */

View File

@ -10273,7 +10273,7 @@ done:
Specify a hyperslab to combine with the current hyperslab selection, and
store the result in the new hyperslab selection.
USAGE
herr_t H5S_combine_hyperslab(new_space, old_space, op, start, stride, count, block)
herr_t H5S_combine_hyperslab(old_space, op, start, stride, count, block, new_space)
H5S_t *old_space; IN: The old space the selection is performed on
H5S_seloper_t op; IN: Operation to perform on current selection
const hsize_t start[]; IN: Offset of start of hyperslab
@ -10297,7 +10297,7 @@ done:
REVISION LOG
--------------------------------------------------------------------------*/
herr_t
H5S_combine_hyperslab(H5S_t *old_space, H5S_seloper_t op, const hsize_t start[], const hsize_t *stride,
H5S_combine_hyperslab(const H5S_t *old_space, H5S_seloper_t op, const hsize_t start[], const hsize_t *stride,
const hsize_t count[], const hsize_t *block, H5S_t **new_space)
{
unsigned u; /* Local index variable */

View File

@ -276,7 +276,7 @@ H5_DLL herr_t H5S_select_elements(H5S_t *space, H5S_seloper_t op, size_t num_ele
/* Operations on hyperslab selections */
H5_DLL herr_t H5S_select_hyperslab(H5S_t *space, H5S_seloper_t op, const hsize_t start[],
const hsize_t *stride, const hsize_t count[], const hsize_t *block);
H5_DLL herr_t H5S_combine_hyperslab(H5S_t *old_space, H5S_seloper_t op, const hsize_t start[],
H5_DLL herr_t H5S_combine_hyperslab(const H5S_t *old_space, H5S_seloper_t op, const hsize_t start[],
const hsize_t *stride, const hsize_t count[], const hsize_t *block,
H5S_t **new_space);
H5_DLL herr_t H5S_hyper_add_span_element(H5S_t *space, unsigned rank, const hsize_t *coords);

View File

@ -196,7 +196,7 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti
/* long command line option */
int i;
const char ch = '=';
char * arg = &argv[opt_ind][2];
char * arg = HDstrdup(&argv[opt_ind][2]);
size_t arg_len = 0;
opt_arg = strchr(&argv[opt_ind][2], ch);
@ -253,6 +253,8 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti
opt_ind++;
sp = 1;
HDfree(arg);
}
else {
register char *cp; /* pointer into current token */