diff --git a/ompi/mca/coll/base/coll_base_allgather.c b/ompi/mca/coll/base/coll_base_allgather.c index 48162a26869..d3e27884106 100644 --- a/ompi/mca/coll/base/coll_base_allgather.c +++ b/ompi/mca/coll/base/coll_base_allgather.c @@ -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 @@ -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; @@ -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; diff --git a/ompi/mca/coll/han/coll_han_alltoall.c b/ompi/mca/coll/han/coll_han_alltoall.c index c2f4b58e32b..8c1a601c546 100644 --- a/ompi/mca/coll/han/coll_han_alltoall.c +++ b/ompi/mca/coll/han/coll_han_alltoall.c @@ -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, @@ -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; - -} \ No newline at end of file +} diff --git a/ompi/mca/coll/xhc/coll_xhc_module.c b/ompi/mca/coll/xhc/coll_xhc_module.c index 879e521f662..56fc563f8e6 100644 --- a/ompi/mca/coll/xhc/coll_xhc_module.c +++ b/ompi/mca/coll/xhc/coll_xhc_module.c @@ -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 @@ -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" @@ -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) { diff --git a/ompi/mca/hook/comm_method/hook_comm_method_fns.c b/ompi/mca/hook/comm_method/hook_comm_method_fns.c index df17f9691ea..b1ab8c200b3 100644 --- a/ompi/mca/hook/comm_method/hook_comm_method_fns.c +++ b/ompi/mca/hook/comm_method/hook_comm_method_fns.c @@ -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 @@ -15,6 +16,7 @@ #include #endif +#include "opal/util/string_copy.h" #include "ompi/communicator/communicator.h" #include "ompi/mca/pml/pml.h" #include "opal/mca/btl/btl.h" @@ -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); } } } @@ -695,7 +697,7 @@ ompi_report_comm_methods(int called_from_location) p = str; for (k=0; kreq_type) { /* parse message */ @@ -242,8 +242,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; /* Set up persistent sends */ req->persist_reqs = (ompi_request_t**) malloc(sizeof(ompi_request_t*)*(req->real_parts)); @@ -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; @@ -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; @@ -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 */ @@ -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; @@ -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 */ @@ -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) { diff --git a/opal/datatype/opal_copy_functions_heterogeneous.c b/opal/datatype/opal_copy_functions_heterogeneous.c index 245de3a9af2..fa654b20138 100644 --- a/opal/datatype/opal_copy_functions_heterogeneous.c +++ b/opal/datatype/opal_copy_functions_heterogeneous.c @@ -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 @@ -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) { diff --git a/opal/datatype/opal_datatype_copy.c b/opal/datatype/opal_datatype_copy.c index 6ff864ce9ef..81b621a9d6a 100644 --- a/opal/datatype/opal_datatype_copy.c +++ b/opal/datatype/opal_datatype_copy.c @@ -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 @@ -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) { copy_type = MCA_ACCELERATOR_TRANSFER_HTOD; } res = opal_accelerator.mem_copy(dst_dev, src_dev, @@ -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, diff --git a/opal/mca/btl/smcuda/btl_smcuda_component.c b/opal/mca/btl/smcuda/btl_smcuda_component.c index 4249b955bb2..a3662e2db0e 100644 --- a/opal/mca/btl/smcuda/btl_smcuda_component.c +++ b/opal/mca/btl/smcuda/btl_smcuda_component.c @@ -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 @@ -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; diff --git a/opal/util/output.c b/opal/util/output.c index ede0200cbae..a1d1259a71c 100644 --- a/opal/util/output.c +++ b/opal/util/output.c @@ -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 @@ -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;