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

gcc 14 and clang 18 compiler warning fixes #12743

Merged
merged 9 commits into from
Sep 2, 2024
5 changes: 3 additions & 2 deletions ompi/mca/coll/base/coll_base_allgather.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* reserved.
* Copyright (c) 2014-2016 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2024 Jeffrey M. Squyres. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -776,7 +777,7 @@ int ompi_coll_base_allgather_intra_k_bruck(const void *sbuf, size_t scount,
int recvcount, distance;
ptrdiff_t rlb, rextent;
ptrdiff_t rsize, rgap = 0;
ompi_request_t **reqs;
ompi_request_t **reqs = NULL;
int num_reqs, max_reqs = 0;

char *tmpsend = NULL;
Expand Down Expand Up @@ -937,7 +938,7 @@ int ompi_coll_base_allgather_direct_messaging(const void *sbuf, size_t scount,
int line = -1, rank, comm_size, err = MPI_SUCCESS;
ptrdiff_t rlb, rextent;
ptrdiff_t incr;
ompi_request_t **reqs;
ompi_request_t **reqs = NULL;
int max_reqs = 0, reqs_needed = 0;
int peer_rank = 0;

Expand Down
7 changes: 3 additions & 4 deletions ompi/mca/coll/han/coll_han_alltoall.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ int mca_coll_han_alltoall_using_smsc(
/* all ranks will pull from the other ranks' sbuf */
gather_buf_in[0] = (void*)sbuf;
}
gather_buf_in[1] = *(void**)&send_needs_bounce;
gather_buf_in[2] = *(void**)&ii_push_data;
gather_buf_in[1] = (void*)(intptr_t)send_needs_bounce;
gather_buf_in[2] = (void*)(intptr_t)ii_push_data;

rc = low_comm->c_coll->coll_allgather(gather_buf_in, nptrs_gather, MPI_AINT,
gather_buf_out, nptrs_gather, MPI_AINT, low_comm,
Expand Down Expand Up @@ -385,5 +385,4 @@ int mca_coll_han_alltoall_using_smsc(
OPAL_OUTPUT_VERBOSE((40, mca_coll_han_component.han_output,
"Alltoall Complete with %d\n",rc));
return rc;

}
}
5 changes: 4 additions & 1 deletion ompi/mca/coll/xhc/coll_xhc_module.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* Copyright (c) 2021-2023 Computer Architecture and VLSI Systems (CARV)
* Laboratory, ICS Forth. All rights reserved.
* Copyright (c) 2024 Jeffrey M. Squyres. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -523,7 +524,7 @@ static int xhc_module_create_hierarchy(xhc_module_t *module,
continue;
}

int member_id;
int member_id = -1;
int members = 0;

// If working with rank list, set the ranks from the list as "local"
Expand Down Expand Up @@ -560,6 +561,8 @@ static int xhc_module_create_hierarchy(xhc_module_t *module,
}
}

assert(member_id != -1);

/* If split or max ranks was specified, math partition the locality
* and remove the previously added locality mapping to some ranks */
if(my_def->split > 1) {
Expand Down
14 changes: 8 additions & 6 deletions ompi/mca/hook/comm_method/hook_comm_method_fns.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2016-2022 IBM Corporation. All rights reserved.
* Copyright (c) 2024 Jeffrey M. Squyres. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand All @@ -15,6 +16,7 @@
#include <dlfcn.h>
#endif

#include "opal/util/string_copy.h"
#include "ompi/communicator/communicator.h"
#include "ompi/mca/pml/pml.h"
#include "opal/mca/btl/btl.h"
Expand Down Expand Up @@ -105,21 +107,21 @@ comm_method_string(MPI_Comm comm, int rank, int *comm_mode) {
if (comm_mode) { *comm_mode = MODE_IS_BTL; }
btl = lookup_btl_name_for_send(comm, rank);
if (NULL == btl) {
strncpy(string, "n/a", COMM_METHOD_STRING_SIZE);
opal_string_copy(string, "n/a", COMM_METHOD_STRING_SIZE);
} else {
strncpy(string, btl, COMM_METHOD_STRING_SIZE);
opal_string_copy(string, btl, COMM_METHOD_STRING_SIZE);
}
}
else if (p && 0==strncmp("cm", p, 3)) { // MTL
if (comm_mode) { *comm_mode = MODE_IS_MTL; }
strncpy(string, lookup_mtl_name(), COMM_METHOD_STRING_SIZE);
opal_string_copy(string, lookup_mtl_name(), COMM_METHOD_STRING_SIZE);
} else { // PML
if (comm_mode) { *comm_mode = MODE_IS_PML; }
if (p) {
strncpy(string, p, COMM_METHOD_STRING_SIZE);
opal_string_copy(string, p, COMM_METHOD_STRING_SIZE);
}
else {
strncpy(string, "n/a", COMM_METHOD_STRING_SIZE);
opal_string_copy(string, "n/a", COMM_METHOD_STRING_SIZE);
}
}
}
Expand Down Expand Up @@ -695,7 +697,7 @@ ompi_report_comm_methods(int called_from_location)
p = str;
for (k=0; k<nleaderranks; ++k) {
char *method_string;
char ucx_label[10];
char ucx_label[20];

method_string = comm_method_to_string(method[i * nleaderranks + k]);
if (0 == strncmp(method_string, UCX_TAG, strlen(UCX_TAG))) {
Expand Down
22 changes: 11 additions & 11 deletions ompi/mca/part/persist/part_persist.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,16 +234,16 @@ mca_part_persist_progress(void)

if(done) {
size_t dt_size_;
int32_t dt_size;
uint32_t dt_size;

if(MCA_PART_PERSIST_REQUEST_PSEND == req->req_type) {
/* parse message */
req->world_peer = req->setup_info[1].world_rank;

err = opal_datatype_type_size(&(req->req_datatype->super), &dt_size_);
if(OMPI_SUCCESS != err) return OMPI_ERROR;
dt_size = (dt_size_ > (size_t) INT_MAX) ? MPI_UNDEFINED : (int) dt_size_;
int32_t bytes = req->real_count * dt_size;
dt_size = (dt_size_ > (size_t) UINT_MAX) ? MPI_UNDEFINED : (uint32_t) dt_size_;
uint32_t bytes = req->real_count * dt_size;

/* Set up persistent sends */
req->persist_reqs = (ompi_request_t**) malloc(sizeof(ompi_request_t*)*(req->real_parts));
Expand All @@ -263,8 +263,8 @@ mca_part_persist_progress(void)

err = opal_datatype_type_size(&(req->req_datatype->super), &dt_size_);
if(OMPI_SUCCESS != err) return OMPI_ERROR;
dt_size = (dt_size_ > (size_t) INT_MAX) ? MPI_UNDEFINED : (int) dt_size_;
int32_t bytes = req->real_count * dt_size;
dt_size = (dt_size_ > (size_t) UINT_MAX) ? MPI_UNDEFINED : (uint32_t) dt_size_;
uint32_t bytes = req->real_count * dt_size;



Expand Down Expand Up @@ -350,7 +350,7 @@ mca_part_persist_precv_init(void *buf,
{
int err = OMPI_SUCCESS;
size_t dt_size_;
int dt_size;
uint32_t dt_size;
mca_part_persist_list_t* new_progress_elem = NULL;

mca_part_persist_precv_request_t *recvreq;
Expand Down Expand Up @@ -382,7 +382,7 @@ mca_part_persist_precv_init(void *buf,
/* Compute total number of bytes */
err = opal_datatype_type_size(&(req->req_datatype->super), &dt_size_);
if(OMPI_SUCCESS != err) return OMPI_ERROR;
dt_size = (dt_size_ > (size_t) INT_MAX) ? MPI_UNDEFINED : (int) dt_size_;
dt_size = (dt_size_ > (size_t) UINT_MAX) ? MPI_UNDEFINED : (uint32_t) dt_size_;
req->req_bytes = parts * count * dt_size;

/* Set ompi request initial values */
Expand Down Expand Up @@ -417,7 +417,7 @@ mca_part_persist_psend_init(const void* buf,
{
int err = OMPI_SUCCESS;
size_t dt_size_;
int dt_size;
uint32_t dt_size;
mca_part_persist_list_t* new_progress_elem = NULL;
mca_part_persist_psend_request_t *sendreq;

Expand All @@ -442,7 +442,7 @@ mca_part_persist_psend_init(const void* buf,
/* Determine total bytes to send. */
err = opal_datatype_type_size(&(req->req_datatype->super), &dt_size_);
if(OMPI_SUCCESS != err) return OMPI_ERROR;
dt_size = (dt_size_ > (size_t) INT_MAX) ? MPI_UNDEFINED : (int) dt_size_;
dt_size = (dt_size_ > (size_t) UINT_MAX) ? MPI_UNDEFINED : (uint32_t) dt_size_;
req->req_bytes = parts * count * dt_size;

/* non-blocking send set-up data */
Expand Down Expand Up @@ -504,11 +504,11 @@ mca_part_persist_start(size_t count, ompi_request_t** requests)
{
if(MCA_PART_PERSIST_REQUEST_PSEND == req->req_type) {
req->done_count = 0;
memset((void*)req->flags,0,sizeof(int32_t)*req->real_parts);
memset((void*)req->flags,0,sizeof(uint32_t)*req->real_parts);
} else {
req->done_count = 0;
err = req->persist_reqs[0]->req_start(req->real_parts, req->persist_reqs);
memset((void*)req->flags,0,sizeof(int32_t)*req->real_parts);
memset((void*)req->flags,0,sizeof(uint32_t)*req->real_parts);
}
} else {
if(MCA_PART_PERSIST_REQUEST_PSEND == req->req_type) {
Expand Down
3 changes: 2 additions & 1 deletion opal/datatype/opal_copy_functions_heterogeneous.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* and Technology (RIST). All rights reserved.
* Copyright (c) 2018 FUJITSU LIMITED. All rights reserved.
* Copyright (c) 2021 IBM Corporation. All rights reserved.
* Copyright (c) 2024 Jeffrey M. Squyres. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -492,7 +493,7 @@ f128_to_f80(unsigned char *f80_buf_to, const unsigned char *f128_buf_from, ssize
*/
static inline
size_t
alignment_of_long_double() {
alignment_of_long_double(void) {
static size_t val = 0;

if (val == 0) {
Expand Down
5 changes: 3 additions & 2 deletions opal/datatype/opal_datatype_copy.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* and Technology (RIST). All rights reserved.
* Copyright (c) 2022 Amazon.com, Inc. or its affiliates. All Rights reserved.
* Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved.
* Copyright (c) 2024 Jeffrey M. Squyres. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -76,7 +77,7 @@ static void *opal_datatype_accelerator_memcpy(void *dest, const void *src, size_
else if (0 >= dst_type && 0 < src_type) {
copy_type = MCA_ACCELERATOR_TRANSFER_DTOH;
}
else if (0 < dst_type && 0 >= dst_type) {
else if (0 < dst_type && 0 >= src_type) {
jsquyres marked this conversation as resolved.
Show resolved Hide resolved
copy_type = MCA_ACCELERATOR_TRANSFER_HTOD;
}
res = opal_accelerator.mem_copy(dst_dev, src_dev,
Expand Down Expand Up @@ -109,7 +110,7 @@ static void *opal_datatype_accelerator_memmove(void *dest, const void *src, size
else if (0 >= dst_type && 0 < src_type) {
copy_type = MCA_ACCELERATOR_TRANSFER_DTOH;
}
else if (0 < dst_type && 0 >= dst_type) {
else if (0 < dst_type && 0 >= src_type) {
copy_type = MCA_ACCELERATOR_TRANSFER_HTOD;
}
res = opal_accelerator.mem_move(dst_dev, src_dev,
Expand Down
3 changes: 2 additions & 1 deletion opal/mca/btl/smcuda/btl_smcuda_component.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
* Copyright (c) 2023 Triad National Security, LLC. All rights
* reserved.
* Copyright (c) 2024 Advanced Micro Devices, Inc. All Rights reserved.
* Copyright (c) 2024 Jeffrey M. Squyres. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -417,7 +418,7 @@ static int get_mpool_res_size(int32_t max_procs, size_t *out_res_size)
* mpool_sm_component.c when sizeof(mca_common_sm_module_t) is
* added.
*/
if (((double) size) * max_procs > LONG_MAX - 4096) {
if (((double) size) * max_procs > (double) (LONG_MAX - 4096)) {
return OPAL_ERR_VALUE_OUT_OF_BOUNDS;
}
size *= (size_t) max_procs;
Expand Down
8 changes: 8 additions & 0 deletions opal/util/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
* reserved.
* Copyright (c) 2019 Triad National Security, LLC. All rights
* reserved.
* Copyright (c) 2024 Jeffrey M. Squyres. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -574,6 +575,13 @@ static int do_open(int output_id, opal_output_stream_t *lds)
opal_output_init();
}

/* Bozo check */

if (output_id >= OPAL_OUTPUT_MAX_STREAMS ||
output_id < -1) {
return OPAL_ERR_BAD_PARAM;
}

str = getenv("OPAL_OUTPUT_REDIRECT");
if (NULL != str && 0 == strcasecmp(str, "file")) {
redirect_to_file = true;
Expand Down
Loading