diff options
author | jhendersonHDF <jhenderson@hdfgroup.org> | 2022-05-03 17:02:01 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-03 17:02:01 (GMT) |
commit | 5f00066eacdf2b2ddb3cf92635bea99eb1aee85e (patch) | |
tree | d7dc19a5e765e1f03933f3244ac622e362e33c2f /src | |
parent | 47e3d5e79522d8030a5a455521524a80cd9ef064 (diff) | |
download | hdf5-5f00066eacdf2b2ddb3cf92635bea99eb1aee85e.zip hdf5-5f00066eacdf2b2ddb3cf92635bea99eb1aee85e.tar.gz hdf5-5f00066eacdf2b2ddb3cf92635bea99eb1aee85e.tar.bz2 |
Hdf5 1 12 Miscellaneous warnings fixes (#1718)
* Fixes const issues in the version 2 B-trees (#1172)
The operations that were changed are fundamentally not const since the
shadow operation can modify the node structure when SWMR is in use.
* Quiets const warning in H5RS code (#1181)
* Avoid calling H5Ropen_object with a misaligned H5R_ref_t: copy the (#1171)
* Avoid calling H5Ropen_object with a misaligned H5R_ref_t: copy the
raw H5R_ref_t bytes to a heap buffer that's known to have the right
alignment.
* Committing clang-format changes
* Use an automatic H5R_ref_t instead of malloc'ing one. Go ahead and
initialize the H5R_ref_t to all-0s so that arbitrary stack content
doesn't foul things up. Bail out with an error if `size` exceeds
`sizeof(H5R_ref_t)`.
* Committing clang-format changes
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
* Miscellaneous warnings fixes
Co-authored-by: Dana Robinson <43805+derobins@users.noreply.github.com>
Co-authored-by: David Young <dyoung@hdfgroup.org>
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/H5B2int.c | 33 | ||||
-rw-r--r-- | src/H5B2pkg.h | 12 | ||||
-rw-r--r-- | src/H5Dchunk.c | 7 | ||||
-rw-r--r-- | src/H5Dmpio.c | 14 | ||||
-rw-r--r-- | src/H5FDhdfs.c | 4 | ||||
-rw-r--r-- | src/H5Gname.c | 2 | ||||
-rw-r--r-- | src/H5RS.c | 12 | ||||
-rw-r--r-- | src/H5Tref.c | 9 | ||||
-rw-r--r-- | src/H5trace.c | 15 |
9 files changed, 61 insertions, 47 deletions
diff --git a/src/H5B2int.c b/src/H5B2int.c index 610da6c..ab43a5a 100644 --- a/src/H5B2int.c +++ b/src/H5B2int.c @@ -52,9 +52,9 @@ /********************/ /* Local Prototypes */ /********************/ -static herr_t H5B2__update_child_flush_depends(H5B2_hdr_t *hdr, unsigned depth, - const H5B2_node_ptr_t *node_ptrs, unsigned start_idx, - unsigned end_idx, void *old_parent, void *new_parent); +static herr_t H5B2__update_child_flush_depends(H5B2_hdr_t *hdr, unsigned depth, H5B2_node_ptr_t *node_ptrs, + unsigned start_idx, unsigned end_idx, void *old_parent, + void *new_parent); /*********************/ /* Package Variables */ @@ -1617,7 +1617,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5B2__iterate_node(H5B2_hdr_t *hdr, uint16_t depth, const H5B2_node_ptr_t *curr_node, void *parent, +H5B2__iterate_node(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node, void *parent, H5B2_operator_t op, void *op_data) { const H5AC_class_t *curr_node_class = NULL; /* Pointer to current node's class info */ @@ -1642,8 +1642,7 @@ H5B2__iterate_node(H5B2_hdr_t *hdr, uint16_t depth, const H5B2_node_ptr_t *curr_ /* Lock the current B-tree node */ if (NULL == - (internal = H5B2__protect_internal(hdr, parent, (H5B2_node_ptr_t *)curr_node, depth, FALSE, - H5AC__READ_ONLY_FLAG))) /* Casting away const OK -QAK */ + (internal = H5B2__protect_internal(hdr, parent, curr_node, depth, FALSE, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree internal node") /* Set up information about current node */ @@ -1739,8 +1738,8 @@ done: *------------------------------------------------------------------------- */ herr_t -H5B2__delete_node(H5B2_hdr_t *hdr, uint16_t depth, const H5B2_node_ptr_t *curr_node, void *parent, - H5B2_remove_t op, void *op_data) +H5B2__delete_node(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node, void *parent, H5B2_remove_t op, + void *op_data) { const H5AC_class_t *curr_node_class = NULL; /* Pointer to current node's class info */ void * node = NULL; /* Pointers to current node */ @@ -1759,8 +1758,7 @@ H5B2__delete_node(H5B2_hdr_t *hdr, uint16_t depth, const H5B2_node_ptr_t *curr_n /* Lock the current B-tree node */ if (NULL == - (internal = H5B2__protect_internal(hdr, parent, (H5B2_node_ptr_t *)curr_node, depth, FALSE, - H5AC__NO_FLAGS_SET))) /* Casting away const OK -QAK */ + (internal = H5B2__protect_internal(hdr, parent, curr_node, depth, FALSE, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree internal node") /* Set up information about current node */ @@ -1824,7 +1822,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5B2__node_size(H5B2_hdr_t *hdr, uint16_t depth, const H5B2_node_ptr_t *curr_node, void *parent, +H5B2__node_size(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node, void *parent, hsize_t *btree_size) { H5B2_internal_t *internal = NULL; /* Pointer to internal node */ @@ -1839,8 +1837,8 @@ H5B2__node_size(H5B2_hdr_t *hdr, uint16_t depth, const H5B2_node_ptr_t *curr_nod HDassert(depth > 0); /* Lock the current B-tree node */ - if (NULL == (internal = H5B2__protect_internal(hdr, parent, (H5B2_node_ptr_t *)curr_node, depth, FALSE, - H5AC__READ_ONLY_FLAG))) /* Casting away const OK -QAK */ + if (NULL == + (internal = H5B2__protect_internal(hdr, parent, curr_node, depth, FALSE, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree internal node") /* Recursively descend into child nodes, if we are above the "twig" level in the B-tree */ @@ -1910,7 +1908,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5B2__update_flush_depend(H5B2_hdr_t *hdr, unsigned depth, const H5B2_node_ptr_t *node_ptr, void *old_parent, +H5B2__update_flush_depend(H5B2_hdr_t *hdr, unsigned depth, H5B2_node_ptr_t *node_ptr, void *old_parent, void *new_parent) { const H5AC_class_t *child_class; /* Pointer to child node's class info */ @@ -1941,9 +1939,8 @@ H5B2__update_flush_depend(H5B2_hdr_t *hdr, unsigned depth, const H5B2_node_ptr_t H5B2_internal_t *child_int; /* Protect child */ - if (NULL == (child_int = H5B2__protect_internal( - hdr, new_parent, (H5B2_node_ptr_t *)node_ptr, (uint16_t)(depth - 1), FALSE, - H5AC__NO_FLAGS_SET))) /* Casting away const OK -QAK */ + if (NULL == (child_int = H5B2__protect_internal(hdr, new_parent, node_ptr, (uint16_t)(depth - 1), + FALSE, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree internal node") child_class = H5AC_BT2_INT; child = child_int; @@ -2010,7 +2007,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5B2__update_child_flush_depends(H5B2_hdr_t *hdr, unsigned depth, const H5B2_node_ptr_t *node_ptrs, +H5B2__update_child_flush_depends(H5B2_hdr_t *hdr, unsigned depth, H5B2_node_ptr_t *node_ptrs, unsigned start_idx, unsigned end_idx, void *old_parent, void *new_parent) { unsigned u; /* Local index variable */ diff --git a/src/H5B2pkg.h b/src/H5B2pkg.h index 8d620cc..66d04fa 100644 --- a/src/H5B2pkg.h +++ b/src/H5B2pkg.h @@ -321,7 +321,7 @@ extern const H5B2_class_t *const H5B2_client_class_g[H5B2_NUM_BTREE_ID]; /* Generic routines */ H5_DLL herr_t H5B2__create_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry); -H5_DLL herr_t H5B2__update_flush_depend(H5B2_hdr_t *hdr, unsigned depth, const H5B2_node_ptr_t *node_ptr, +H5_DLL herr_t H5B2__update_flush_depend(H5B2_hdr_t *hdr, unsigned depth, H5B2_node_ptr_t *node_ptr, void *old_parent, void *new_parent); H5_DLL herr_t H5B2__destroy_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry); @@ -390,9 +390,9 @@ H5_DLL herr_t H5B2__update_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, void *op_data); /* Routines for iterating over nodes/records */ -H5_DLL herr_t H5B2__iterate_node(H5B2_hdr_t *hdr, uint16_t depth, const H5B2_node_ptr_t *curr_node, - void *parent, H5B2_operator_t op, void *op_data); -H5_DLL herr_t H5B2__node_size(H5B2_hdr_t *hdr, uint16_t depth, const H5B2_node_ptr_t *curr_node, void *parent, +H5_DLL herr_t H5B2__iterate_node(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node, void *parent, + H5B2_operator_t op, void *op_data); +H5_DLL herr_t H5B2__node_size(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node, void *parent, hsize_t *op_data); /* Routines for locating records */ @@ -423,8 +423,8 @@ H5_DLL herr_t H5B2__remove_leaf_by_idx(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_no void *op_data); /* Routines for deleting nodes */ -H5_DLL herr_t H5B2__delete_node(H5B2_hdr_t *hdr, uint16_t depth, const H5B2_node_ptr_t *curr_node, - void *parent, H5B2_remove_t op, void *op_data); +H5_DLL herr_t H5B2__delete_node(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node, void *parent, + H5B2_remove_t op, void *op_data); /* Debugging routines for dumping file structures */ H5_DLL herr_t H5B2__hdr_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index e6bf26c..ef1a447 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -5190,14 +5190,11 @@ done: static int H5D__chunk_cmp_coll_fill_info(const void *_entry1, const void *_entry2) { - const struct chunk_coll_fill_info *entry1; - const struct chunk_coll_fill_info *entry2; + const struct chunk_coll_fill_info *entry1 = (const struct chunk_coll_fill_info *)_entry1; + const struct chunk_coll_fill_info *entry2 = (const struct chunk_coll_fill_info *)_entry2; FUNC_ENTER_STATIC_NOERR - entry1 = (const struct chunk_coll_fill_info *)_entry1; - entry2 = (const struct chunk_coll_fill_info *)_entry2; - FUNC_LEAVE_NOAPI(H5F_addr_cmp(entry1->addr, entry2->addr)) } /* end H5D__chunk_cmp_coll_fill_info() */ #endif /* H5_HAVE_PARALLEL */ diff --git a/src/H5Dmpio.c b/src/H5Dmpio.c index 4f52127..7f018c4 100644 --- a/src/H5Dmpio.c +++ b/src/H5Dmpio.c @@ -2577,9 +2577,9 @@ H5D__cmp_filtered_collective_io_info_entry(const void *filtered_collective_io_in { const H5D_filtered_collective_io_info_t *entry1; const H5D_filtered_collective_io_info_t *entry2; - haddr_t addr1 = HADDR_UNDEF; - haddr_t addr2 = HADDR_UNDEF; - int ret_value; + haddr_t addr1 = HADDR_UNDEF; + haddr_t addr2 = HADDR_UNDEF; + int ret_value = 0; FUNC_ENTER_STATIC_NOERR @@ -2631,7 +2631,7 @@ H5D__cmp_chunk_redistribute_info(const void *_entry1, const void *_entry2) const H5D_chunk_redistribute_info_t *entry2; hsize_t chunk_index1; hsize_t chunk_index2; - int ret_value; + int ret_value = 0; FUNC_ENTER_STATIC_NOERR @@ -2672,9 +2672,9 @@ H5D__cmp_chunk_redistribute_info_orig_owner(const void *_entry1, const void *_en { const H5D_chunk_redistribute_info_t *entry1; const H5D_chunk_redistribute_info_t *entry2; - int owner1 = -1; - int owner2 = -1; - int ret_value; + int owner1 = -1; + int owner2 = -1; + int ret_value = 0; FUNC_ENTER_STATIC_NOERR diff --git a/src/H5FDhdfs.c b/src/H5FDhdfs.c index 9a5aae0..b00ef7c 100644 --- a/src/H5FDhdfs.c +++ b/src/H5FDhdfs.c @@ -1730,7 +1730,7 @@ H5FD_hdfs_init(void) } herr_t -H5Pget_fapl_hdfs(hid_t fapl_id, H5FD_hdfs_fapl_t *fa_out) +H5Pget_fapl_hdfs(hid_t H5_ATTR_UNUSED fapl_id, H5FD_hdfs_fapl_t H5_ATTR_UNUSED *fa_out) { herr_t ret_value = FAIL; @@ -1744,7 +1744,7 @@ done: } herr_t -H5Pset_fapl_hdfs(hid_t fapl_id, H5FD_hdfs_fapl_t *fa) +H5Pset_fapl_hdfs(hid_t H5_ATTR_UNUSED fapl_id, H5FD_hdfs_fapl_t H5_ATTR_UNUSED *fa) { herr_t ret_value = FAIL; diff --git a/src/H5Gname.c b/src/H5Gname.c index cc8eaf4..c2b50c5 100644 --- a/src/H5Gname.c +++ b/src/H5Gname.c @@ -307,7 +307,7 @@ H5G__build_fullpath(const char *prefix, const char *name) /* Build full path */ HDstrncpy(full_path, prefix, orig_path_len + 1); if (need_sep) - HDstrncat(full_path, "/", (size_t)1); + HDstrcat(full_path, "/"); HDstrncat(full_path, name, name_len); /* Create reference counted string for path */ @@ -174,8 +174,16 @@ H5RS_wrap(const char *s) if (NULL == (ret_value = H5FL_MALLOC(H5RS_str_t))) HGOTO_ERROR(H5E_RS, H5E_CANTALLOC, NULL, "memory allocation failed") - /* Set the internal fields */ - ret_value->s = (char *)s; + /* Set the internal fields + * + * We ignore warnings about storing a const char pointer in the struct + * since we never modify or free the string when the wrapped struct + * field is set to TRUE. + */ + H5_GCC_DIAG_OFF("cast-qual") + ret_value->s = (char *)s; + H5_GCC_DIAG_ON("cast-qual") + ret_value->wrapped = 1; ret_value->n = 1; diff --git a/src/H5Tref.c b/src/H5Tref.c index 8af326e..7e12ac6 100644 --- a/src/H5Tref.c +++ b/src/H5Tref.c @@ -709,6 +709,14 @@ done: * *------------------------------------------------------------------------- */ +/* + * It is the correct thing to do to have the reference buffer + * be const-qualified here, but the VOL "blob specific" routine + * needs a non-const pointer since an operation might modify + * the "blob". Disable this warning here (at least temporarily) + * for this reason. + */ +H5_GCC_DIAG_OFF("cast-qual") static herr_t H5T__ref_disk_isnull(const H5VL_object_t *src_file, const void *src_buf, hbool_t *isnull) { @@ -742,6 +750,7 @@ H5T__ref_disk_isnull(const H5VL_object_t *src_file, const void *src_buf, hbool_t done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__ref_disk_isnull() */ +H5_GCC_DIAG_ON("cast-qual") /*------------------------------------------------------------------------- * Function: H5T__ref_disk_setnull diff --git a/src/H5trace.c b/src/H5trace.c index d13d8ef..8d70254 100644 --- a/src/H5trace.c +++ b/src/H5trace.c @@ -120,8 +120,8 @@ H5_trace(const double *returning, const char *func, const char *type, ...) void * vp = NULL; FILE * out = H5_debug_g.trace; static hbool_t is_first_invocation = TRUE; - H5_timer_t function_timer = {{0}, {0}, {0}, FALSE}; - H5_timevals_t function_times; + H5_timer_t function_timer; + H5_timevals_t function_times = {0.0, 0.0, 0.0}; static H5_timer_t running_timer; H5_timevals_t running_times; static int current_depth = 0; @@ -133,6 +133,10 @@ H5_trace(const double *returning, const char *func, const char *type, ...) return 0.0F; /*tracing is off*/ HDva_start(ap, type); + /* Initialize the timer for this function */ + if (H5_debug_g.ttimes) + H5_timer_init(&function_timer); + if (H5_debug_g.ttop) { if (returning) { if (current_depth > 1) { @@ -156,11 +160,10 @@ H5_trace(const double *returning, const char *func, const char *type, ...) H5_timer_init(&running_timer); H5_timer_start(&running_timer); } /* end if */ - if (H5_debug_g.ttimes) { - /* start the timer for this function */ - H5_timer_init(&function_timer); + + /* Start the timer for this function */ + if (H5_debug_g.ttimes) H5_timer_start(&function_timer); - } /* end if */ /* Print the first part of the line. This is the indication of the * nesting depth followed by the function name and either start of |