Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warnings fixes #1680

Merged
merged 1 commit into from
Apr 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/H5Cmpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,11 @@ H5C_clear_coll_entries(H5C_t *cache_ptr, hbool_t partial)
H5C_cache_entry_t *entry_ptr = NULL;
herr_t ret_value = SUCCEED;

#if H5C_DO_SANITY_CHECKS
FUNC_ENTER_NOAPI_NOINIT
#else
FUNC_ENTER_NOAPI_NOINIT_NOERR
#endif

entry_ptr = cache_ptr->coll_tail_ptr;
clear_cnt = (partial ? cache_ptr->coll_list_len / 2 : cache_ptr->coll_list_len);
Expand All @@ -919,7 +923,7 @@ H5C_clear_coll_entries(H5C_t *cache_ptr, hbool_t partial)
entry_ptr = prev_ptr;
} /* end while */

#ifdef H5C_DO_SANITY_CHECKS
#if H5C_DO_SANITY_CHECKS
done:
#endif /* H5C_DO_SANITY_CHECKS */
FUNC_LEAVE_NOAPI(ret_value)
Expand Down
7 changes: 3 additions & 4 deletions src/H5Dchunk.c
Original file line number Diff line number Diff line change
Expand Up @@ -8124,8 +8124,8 @@ H5D__chunk_iter(const H5D_t *dset, H5D_chunk_iter_op_t op, void *op_data)
/* Compose chunked index info struct */
idx_info.f = dset->oloc.file;
idx_info.pline = &dset->shared->dcpl_cache.pline;
idx_info.layout = &dset->shared->layout.u.chunk;
idx_info.storage = &dset->shared->layout.storage.u.chunk;
idx_info.layout = &layout->u.chunk;
idx_info.storage = &layout->storage.u.chunk;

/* If the dataset is not written, return without errors */
if (H5F_addr_defined(idx_info.storage->idx_addr)) {
Expand All @@ -8136,8 +8136,7 @@ H5D__chunk_iter(const H5D_t *dset, H5D_chunk_iter_op_t op, void *op_data)
ud.op_data = op_data;

/* Iterate over the allocated chunks calling the iterator callback */
if ((ret_value =
(dset->shared->layout.storage.u.chunk.ops->iterate)(&idx_info, H5D__chunk_iter_cb, &ud)) < 0)
if ((ret_value = (layout->storage.u.chunk.ops->iterate)(&idx_info, H5D__chunk_iter_cb, &ud)) < 0)
HERROR(H5E_DATASET, H5E_CANTNEXT, "chunk iteration failed");
} /* end if H5F_addr_defined */

Expand Down
12 changes: 7 additions & 5 deletions src/H5Dcontig.c
Original file line number Diff line number Diff line change
Expand Up @@ -605,23 +605,25 @@ H5D__contig_io_init(H5D_io_info_t *io_info, const H5D_type_info_t H5_ATTR_UNUSED
static htri_t
H5D__contig_may_use_select_io(const H5D_io_info_t *io_info, H5D_io_op_type_t op_type)
{
const H5D_t *dataset = io_info->dset; /* Local pointer to dataset info */
htri_t ret_value = FAIL; /* Return value */
const H5D_t *dataset = NULL; /* Local pointer to dataset info */
htri_t ret_value = FAIL; /* Return value */

FUNC_ENTER_STATIC

/* Sanity check */
HDassert(io_info);
HDassert(dataset);
HDassert(io_info->dset);
HDassert(op_type == H5D_IO_OP_READ || op_type == H5D_IO_OP_WRITE);

dataset = io_info->dset;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be immediately before the HDassert(dataset) line, otherwise that assert will always be tripped.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was building in release so missed this one! Just fixed the assertion and pushed.


/* Don't use selection I/O if it's globally disabled, if there is a type
* conversion, or if it's not a contiguous dataset, or if the sieve buffer
* exists (write) or is dirty (read) */
if (!H5_use_selection_io_g || io_info->io_ops.single_read != H5D__select_read ||
io_info->layout_ops.readvv != H5D__contig_readvv ||
(op_type == H5D_IO_OP_READ && io_info->dset->shared->cache.contig.sieve_dirty) ||
(op_type == H5D_IO_OP_WRITE && io_info->dset->shared->cache.contig.sieve_buf))
(op_type == H5D_IO_OP_READ && dataset->shared->cache.contig.sieve_dirty) ||
(op_type == H5D_IO_OP_WRITE && dataset->shared->cache.contig.sieve_buf))
ret_value = FALSE;
else {
hbool_t page_buf_enabled;
Expand Down
10 changes: 6 additions & 4 deletions src/H5Dmpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -3467,8 +3467,9 @@ H5D__mpio_redistribute_shared_chunks(H5D_filtered_collective_io_info_t *chunk_li
static herr_t
H5D__mpio_redistribute_shared_chunks_int(H5D_filtered_collective_io_info_t *chunk_list,
size_t *num_chunks_assigned_map, hbool_t all_ranks_involved,
const H5D_io_info_t *io_info, const H5D_chunk_map_t *fm,
int mpi_rank, int mpi_size)
const H5D_io_info_t * io_info,
const H5D_chunk_map_t H5_ATTR_NDEBUG_UNUSED *fm, int mpi_rank,
int mpi_size)
{
MPI_Datatype struct_type;
MPI_Datatype packed_type;
Expand Down Expand Up @@ -3797,7 +3798,8 @@ H5D__mpio_redistribute_shared_chunks_int(H5D_filtered_collective_io_info_t *chun
static herr_t
H5D__mpio_share_chunk_modification_data(H5D_filtered_collective_io_info_t *chunk_list,
size_t *chunk_list_num_entries, H5D_io_info_t *io_info,
const H5D_type_info_t *type_info, int mpi_rank, int mpi_size,
const H5D_type_info_t *type_info, int mpi_rank,
int H5_ATTR_NDEBUG_UNUSED mpi_size,
H5D_filtered_collective_io_info_t **chunk_hash_table,
unsigned char ***chunk_msg_bufs, int *chunk_msg_bufs_len)
{
Expand Down Expand Up @@ -4547,7 +4549,7 @@ H5D__mpio_collective_filtered_chunk_update(H5D_filtered_collective_io_info_t *ch
H5D_filtered_collective_io_info_t *chunk_hash_table,
unsigned char **chunk_msg_bufs, int chunk_msg_bufs_len,
const H5D_io_info_t *io_info, const H5D_type_info_t *type_info,
int mpi_rank, int mpi_size)
int H5_ATTR_NDEBUG_UNUSED mpi_rank, int mpi_size)
{
H5D_fill_buf_info_t fb_info;
H5D_chunk_info_t * chunk_info = NULL;
Expand Down
6 changes: 4 additions & 2 deletions src/H5FD.c
Original file line number Diff line number Diff line change
Expand Up @@ -2261,8 +2261,10 @@ H5FDget_vfd_handle(H5FD_t *file, hid_t fapl_id, void **file_handle /*out*/)
HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get file handle for file driver")

done:
if (FAIL == ret_value)
*file_handle = NULL;
if (FAIL == ret_value) {
if (file_handle)
*file_handle = NULL;
}

FUNC_LEAVE_API(ret_value)
} /* end H5FDget_vfd_handle() */
Expand Down
2 changes: 1 addition & 1 deletion src/H5FDmpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1865,7 +1865,7 @@ H5FD__mpio_vector_build_types(uint32_t count, H5FD_mem_t types[], haddr_t addrs[
if (!sub_types) {
HDassert(!sub_types_created);

if (NULL == (sub_types = (int *)HDmalloc((size_t)count * sizeof(MPI_Datatype))))
if (NULL == (sub_types = HDmalloc((size_t)count * sizeof(MPI_Datatype))))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sub_types is an MPI_Datatype *, not an int *

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no need to cast the allocated pointers in C anyways.

HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "can't alloc sub types array")
if (NULL == (sub_types_created = (uint8_t *)HDcalloc((size_t)count, 1))) {
H5MM_free(sub_types);
Expand Down
10 changes: 3 additions & 7 deletions src/H5FDsec2.c
Original file line number Diff line number Diff line change
Expand Up @@ -1075,17 +1075,13 @@ H5FD__sec2_delete(const char *filename, hid_t H5_ATTR_UNUSED fapl_id)
*-------------------------------------------------------------------------
*/
static herr_t
H5FD__sec2_ctl(H5FD_t *_file, uint64_t op_code, uint64_t flags, const void H5_ATTR_UNUSED *input,
void H5_ATTR_UNUSED **output)
H5FD__sec2_ctl(H5FD_t H5_ATTR_UNUSED *_file, uint64_t op_code, uint64_t flags,
const void H5_ATTR_UNUSED *input, void H5_ATTR_UNUSED **output)
{
H5FD_sec2_t *file = (H5FD_sec2_t *)_file;
herr_t ret_value = SUCCEED;
herr_t ret_value = SUCCEED;

FUNC_ENTER_STATIC

/* Sanity checks */
HDassert(file);

switch (op_code) {
/* Unknown op code */
default:
Expand Down
2 changes: 1 addition & 1 deletion src/H5Oint.c
Original file line number Diff line number Diff line change
Expand Up @@ -3014,7 +3014,7 @@ H5O_get_proxy(const H5O_t *oh)
*-------------------------------------------------------------------------
*/
herr_t
H5O__free(H5O_t *oh, hbool_t force)
H5O__free(H5O_t *oh, hbool_t H5_ATTR_NDEBUG_UNUSED force)
{
unsigned u; /* Local index variable */
herr_t ret_value = SUCCEED; /* Return value */
Expand Down
2 changes: 1 addition & 1 deletion src/H5Pfapl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1636,7 +1636,7 @@ H5Pget_driver_config_str(hid_t fapl_id, char *config_buf, size_t buf_size)
size_t config_str_len = HDstrlen(config_str);

if (config_buf) {
HDstrncpy(config_buf, config_str, MIN(config_str_len + 1, buf_size));
HDstrncpy(config_buf, config_str, buf_size);
if (config_str_len >= buf_size)
config_buf[buf_size - 1] = '\0';
}
Expand Down
4 changes: 2 additions & 2 deletions src/H5Tref.c
Original file line number Diff line number Diff line change
Expand Up @@ -638,8 +638,8 @@ H5T__ref_mem_read(H5VL_object_t H5_ATTR_UNUSED *src_file, const void *src_buf, s
*/
static herr_t
H5T__ref_mem_write(H5VL_object_t *src_file, const void *src_buf, size_t src_size, H5R_type_t src_type,
H5VL_object_t H5_ATTR_UNUSED *dst_file, void *dst_buf, size_t dst_size,
void H5_ATTR_UNUSED *bg_buf)
H5VL_object_t H5_ATTR_UNUSED *dst_file, void *dst_buf,
size_t H5_ATTR_NDEBUG_UNUSED dst_size, void H5_ATTR_UNUSED *bg_buf)
{
H5F_t * src_f = NULL;
hid_t file_id = H5I_INVALID_HID;
Expand Down
2 changes: 1 addition & 1 deletion test/cache_image.c
Original file line number Diff line number Diff line change
Expand Up @@ -7510,7 +7510,7 @@ get_free_sections_test(hbool_t single_file_vfd)
*-------------------------------------------------------------------------
*/
static unsigned
evict_on_close_test(hbool_t single_file_vfd)
evict_on_close_test(hbool_t H5_ATTR_PARALLEL_UNUSED single_file_vfd)
{
#ifndef H5_HAVE_PARALLEL
const char *fcn_name = "evict_on_close_test()";
Expand Down
6 changes: 3 additions & 3 deletions test/dt_arith.c
Original file line number Diff line number Diff line change
Expand Up @@ -2694,18 +2694,18 @@ my_isnan(dtype_t type, void *val)
if (FLT_FLOAT == type) {
float x = 0.0;
HDmemcpy(&x, val, sizeof(float));
retval = (x != x);
retval = !H5_FLT_ABS_EQUAL(x, x);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't compare floats, doubles, long doubles using != here. Use library macro to compare with an epsilon value instead.

}
else if (FLT_DOUBLE == type) {
double x = 0.0;
HDmemcpy(&x, val, sizeof(double));
retval = (x != x);
retval = !H5_DBL_ABS_EQUAL(x, x);
#if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE
}
else if (FLT_LDOUBLE == type) {
long double x = 0.0L;
HDmemcpy(&x, val, sizeof(long double));
retval = (x != x);
retval = !H5_LDBL_ABS_EQUAL(x, x);
#endif
}
else {
Expand Down
Loading