diff options
author | Sean McBride <sean@rogue-research.com> | 2021-02-22 17:37:12 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-22 17:37:12 (GMT) |
commit | 5ed255a607d604b45e92b06548682ae9b716535d (patch) | |
tree | 3dcf8239efca99143e561743c2ae997ce9ceca09 | |
parent | 99669024ff93df3ade5b8a1e6eee8bef6df57161 (diff) | |
download | hdf5-5ed255a607d604b45e92b06548682ae9b716535d.zip hdf5-5ed255a607d604b45e92b06548682ae9b716535d.tar.gz hdf5-5ed255a607d604b45e92b06548682ae9b716535d.tar.bz2 |
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.
-rw-r--r-- | examples/h5_ref_compat.c | 4 | ||||
-rw-r--r-- | examples/h5_ref_extern.c | 4 | ||||
-rw-r--r-- | src/H5Dchunk.c | 24 | ||||
-rw-r--r-- | src/H5Gtest.c | 8 | ||||
-rw-r--r-- | src/H5Idbg.c | 8 | ||||
-rw-r--r-- | src/H5Ocopy_ref.c | 6 | ||||
-rw-r--r-- | src/H5Oprivate.h | 2 | ||||
-rw-r--r-- | src/H5Shyper.c | 4 | ||||
-rw-r--r-- | src/H5Sprivate.h | 2 | ||||
-rw-r--r-- | tools/lib/h5tools_utils.c | 4 |
10 files changed, 34 insertions, 32 deletions
diff --git a/examples/h5_ref_compat.c b/examples/h5_ref_compat.c index 82ef525..cce755b 100644 --- a/examples/h5_ref_compat.c +++ b/examples/h5_ref_compat.c @@ -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]); diff --git a/examples/h5_ref_extern.c b/examples/h5_ref_extern.c index a46f676..691d235 100644 --- a/examples/h5_ref_extern.c +++ b/examples/h5_ref_extern.c @@ -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]); diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index bd3b1ed..9d47a4a 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -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 = diff --git a/src/H5Gtest.c b/src/H5Gtest.c index 5f45c8c..9f0dca2 100644 --- a/src/H5Gtest.c +++ b/src/H5Gtest.c @@ -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 diff --git a/src/H5Idbg.c b/src/H5Idbg.c index ea58d59..8894230 100644 --- a/src/H5Idbg.c +++ b/src/H5Idbg.c @@ -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 diff --git a/src/H5Ocopy_ref.c b/src/H5Ocopy_ref.c index f2372c1..f1f8aaf 100644 --- a/src/H5Ocopy_ref.c +++ b/src/H5Ocopy_ref.c @@ -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 */ diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h index b6bd3fe..5b4c11b 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -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 */ diff --git a/src/H5Shyper.c b/src/H5Shyper.c index 8777661..e12ff93 100644 --- a/src/H5Shyper.c +++ b/src/H5Shyper.c @@ -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 */ diff --git a/src/H5Sprivate.h b/src/H5Sprivate.h index f5e4f2c..738d9ae 100644 --- a/src/H5Sprivate.h +++ b/src/H5Sprivate.h @@ -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); diff --git a/tools/lib/h5tools_utils.c b/tools/lib/h5tools_utils.c index 70b715a..bee6262 100644 --- a/tools/lib/h5tools_utils.c +++ b/tools/lib/h5tools_utils.c @@ -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 */ |