Skip to content

Commit 72c952d

Browse files
authored
Merge pull request open-mpi#12743 from jsquyres/pr/gcc-14-compiler-warning-fixes
gcc 14 and clang 18 compiler warning fixes
2 parents 39a8583 + 6e81b00 commit 72c952d

File tree

9 files changed

+44
-28
lines changed

9 files changed

+44
-28
lines changed

ompi/mca/coll/base/coll_base_allgather.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* reserved.
1515
* Copyright (c) 2014-2016 Research Organization for Information Science
1616
* and Technology (RIST). All rights reserved.
17+
* Copyright (c) 2024 Jeffrey M. Squyres. All rights reserved.
1718
* $COPYRIGHT$
1819
*
1920
* Additional copyrights may follow
@@ -776,7 +777,7 @@ int ompi_coll_base_allgather_intra_k_bruck(const void *sbuf, size_t scount,
776777
int recvcount, distance;
777778
ptrdiff_t rlb, rextent;
778779
ptrdiff_t rsize, rgap = 0;
779-
ompi_request_t **reqs;
780+
ompi_request_t **reqs = NULL;
780781
int num_reqs, max_reqs = 0;
781782

782783
char *tmpsend = NULL;
@@ -937,7 +938,7 @@ int ompi_coll_base_allgather_direct_messaging(const void *sbuf, size_t scount,
937938
int line = -1, rank, comm_size, err = MPI_SUCCESS;
938939
ptrdiff_t rlb, rextent;
939940
ptrdiff_t incr;
940-
ompi_request_t **reqs;
941+
ompi_request_t **reqs = NULL;
941942
int max_reqs = 0, reqs_needed = 0;
942943
int peer_rank = 0;
943944

ompi/mca/coll/han/coll_han_alltoall.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,8 @@ int mca_coll_han_alltoall_using_smsc(
207207
/* all ranks will pull from the other ranks' sbuf */
208208
gather_buf_in[0] = (void*)sbuf;
209209
}
210-
gather_buf_in[1] = *(void**)&send_needs_bounce;
211-
gather_buf_in[2] = *(void**)&ii_push_data;
210+
gather_buf_in[1] = (void*)(intptr_t)send_needs_bounce;
211+
gather_buf_in[2] = (void*)(intptr_t)ii_push_data;
212212

213213
rc = low_comm->c_coll->coll_allgather(gather_buf_in, nptrs_gather, MPI_AINT,
214214
gather_buf_out, nptrs_gather, MPI_AINT, low_comm,
@@ -385,5 +385,4 @@ int mca_coll_han_alltoall_using_smsc(
385385
OPAL_OUTPUT_VERBOSE((40, mca_coll_han_component.han_output,
386386
"Alltoall Complete with %d\n",rc));
387387
return rc;
388-
389-
}
388+
}

ompi/mca/coll/xhc/coll_xhc_module.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*
22
* Copyright (c) 2021-2023 Computer Architecture and VLSI Systems (CARV)
33
* Laboratory, ICS Forth. All rights reserved.
4+
* Copyright (c) 2024 Jeffrey M. Squyres. All rights reserved.
45
* $COPYRIGHT$
56
*
67
* Additional copyrights may follow
@@ -523,7 +524,7 @@ static int xhc_module_create_hierarchy(xhc_module_t *module,
523524
continue;
524525
}
525526

526-
int member_id;
527+
int member_id = -1;
527528
int members = 0;
528529

529530
// 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,
560561
}
561562
}
562563

564+
assert(member_id != -1);
565+
563566
/* If split or max ranks was specified, math partition the locality
564567
* and remove the previously added locality mapping to some ranks */
565568
if(my_def->split > 1) {

ompi/mca/hook/comm_method/hook_comm_method_fns.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
* Copyright (c) 2016-2022 IBM Corporation. All rights reserved.
3+
* Copyright (c) 2024 Jeffrey M. Squyres. All rights reserved.
34
* $COPYRIGHT$
45
*
56
* Additional copyrights may follow
@@ -15,6 +16,7 @@
1516
#include <dlfcn.h>
1617
#endif
1718

19+
#include "opal/util/string_copy.h"
1820
#include "ompi/communicator/communicator.h"
1921
#include "ompi/mca/pml/pml.h"
2022
#include "opal/mca/btl/btl.h"
@@ -105,21 +107,21 @@ comm_method_string(MPI_Comm comm, int rank, int *comm_mode) {
105107
if (comm_mode) { *comm_mode = MODE_IS_BTL; }
106108
btl = lookup_btl_name_for_send(comm, rank);
107109
if (NULL == btl) {
108-
strncpy(string, "n/a", COMM_METHOD_STRING_SIZE);
110+
opal_string_copy(string, "n/a", COMM_METHOD_STRING_SIZE);
109111
} else {
110-
strncpy(string, btl, COMM_METHOD_STRING_SIZE);
112+
opal_string_copy(string, btl, COMM_METHOD_STRING_SIZE);
111113
}
112114
}
113115
else if (p && 0==strncmp("cm", p, 3)) { // MTL
114116
if (comm_mode) { *comm_mode = MODE_IS_MTL; }
115-
strncpy(string, lookup_mtl_name(), COMM_METHOD_STRING_SIZE);
117+
opal_string_copy(string, lookup_mtl_name(), COMM_METHOD_STRING_SIZE);
116118
} else { // PML
117119
if (comm_mode) { *comm_mode = MODE_IS_PML; }
118120
if (p) {
119-
strncpy(string, p, COMM_METHOD_STRING_SIZE);
121+
opal_string_copy(string, p, COMM_METHOD_STRING_SIZE);
120122
}
121123
else {
122-
strncpy(string, "n/a", COMM_METHOD_STRING_SIZE);
124+
opal_string_copy(string, "n/a", COMM_METHOD_STRING_SIZE);
123125
}
124126
}
125127
}
@@ -695,7 +697,7 @@ ompi_report_comm_methods(int called_from_location)
695697
p = str;
696698
for (k=0; k<nleaderranks; ++k) {
697699
char *method_string;
698-
char ucx_label[10];
700+
char ucx_label[20];
699701

700702
method_string = comm_method_to_string(method[i * nleaderranks + k]);
701703
if (0 == strncmp(method_string, UCX_TAG, strlen(UCX_TAG))) {

ompi/mca/part/persist/part_persist.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -234,16 +234,16 @@ mca_part_persist_progress(void)
234234

235235
if(done) {
236236
size_t dt_size_;
237-
int32_t dt_size;
237+
uint32_t dt_size;
238238

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

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

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

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

269269

270270

@@ -350,7 +350,7 @@ mca_part_persist_precv_init(void *buf,
350350
{
351351
int err = OMPI_SUCCESS;
352352
size_t dt_size_;
353-
int dt_size;
353+
uint32_t dt_size;
354354
mca_part_persist_list_t* new_progress_elem = NULL;
355355

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

388388
/* Set ompi request initial values */
@@ -417,7 +417,7 @@ mca_part_persist_psend_init(const void* buf,
417417
{
418418
int err = OMPI_SUCCESS;
419419
size_t dt_size_;
420-
int dt_size;
420+
uint32_t dt_size;
421421
mca_part_persist_list_t* new_progress_elem = NULL;
422422
mca_part_persist_psend_request_t *sendreq;
423423

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

448448
/* non-blocking send set-up data */
@@ -504,11 +504,11 @@ mca_part_persist_start(size_t count, ompi_request_t** requests)
504504
{
505505
if(MCA_PART_PERSIST_REQUEST_PSEND == req->req_type) {
506506
req->done_count = 0;
507-
memset((void*)req->flags,0,sizeof(int32_t)*req->real_parts);
507+
memset((void*)req->flags,0,sizeof(uint32_t)*req->real_parts);
508508
} else {
509509
req->done_count = 0;
510510
err = req->persist_reqs[0]->req_start(req->real_parts, req->persist_reqs);
511-
memset((void*)req->flags,0,sizeof(int32_t)*req->real_parts);
511+
memset((void*)req->flags,0,sizeof(uint32_t)*req->real_parts);
512512
}
513513
} else {
514514
if(MCA_PART_PERSIST_REQUEST_PSEND == req->req_type) {

opal/datatype/opal_copy_functions_heterogeneous.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* and Technology (RIST). All rights reserved.
99
* Copyright (c) 2018 FUJITSU LIMITED. All rights reserved.
1010
* Copyright (c) 2021 IBM Corporation. All rights reserved.
11+
* Copyright (c) 2024 Jeffrey M. Squyres. All rights reserved.
1112
* $COPYRIGHT$
1213
*
1314
* Additional copyrights may follow
@@ -492,7 +493,7 @@ f128_to_f80(unsigned char *f80_buf_to, const unsigned char *f128_buf_from, ssize
492493
*/
493494
static inline
494495
size_t
495-
alignment_of_long_double() {
496+
alignment_of_long_double(void) {
496497
static size_t val = 0;
497498

498499
if (val == 0) {

opal/datatype/opal_datatype_copy.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
* and Technology (RIST). All rights reserved.
1818
* Copyright (c) 2022 Amazon.com, Inc. or its affiliates. All Rights reserved.
1919
* Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved.
20+
* Copyright (c) 2024 Jeffrey M. Squyres. All rights reserved.
2021
* $COPYRIGHT$
2122
*
2223
* Additional copyrights may follow
@@ -76,7 +77,7 @@ static void *opal_datatype_accelerator_memcpy(void *dest, const void *src, size_
7677
else if (0 >= dst_type && 0 < src_type) {
7778
copy_type = MCA_ACCELERATOR_TRANSFER_DTOH;
7879
}
79-
else if (0 < dst_type && 0 >= dst_type) {
80+
else if (0 < dst_type && 0 >= src_type) {
8081
copy_type = MCA_ACCELERATOR_TRANSFER_HTOD;
8182
}
8283
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
109110
else if (0 >= dst_type && 0 < src_type) {
110111
copy_type = MCA_ACCELERATOR_TRANSFER_DTOH;
111112
}
112-
else if (0 < dst_type && 0 >= dst_type) {
113+
else if (0 < dst_type && 0 >= src_type) {
113114
copy_type = MCA_ACCELERATOR_TRANSFER_HTOD;
114115
}
115116
res = opal_accelerator.mem_move(dst_dev, src_dev,

opal/mca/btl/smcuda/btl_smcuda_component.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
* Copyright (c) 2023 Triad National Security, LLC. All rights
2222
* reserved.
2323
* Copyright (c) 2024 Advanced Micro Devices, Inc. All Rights reserved.
24+
* Copyright (c) 2024 Jeffrey M. Squyres. All rights reserved.
2425
* $COPYRIGHT$
2526
*
2627
* Additional copyrights may follow
@@ -417,7 +418,7 @@ static int get_mpool_res_size(int32_t max_procs, size_t *out_res_size)
417418
* mpool_sm_component.c when sizeof(mca_common_sm_module_t) is
418419
* added.
419420
*/
420-
if (((double) size) * max_procs > LONG_MAX - 4096) {
421+
if (((double) size) * max_procs > (double) (LONG_MAX - 4096)) {
421422
return OPAL_ERR_VALUE_OUT_OF_BOUNDS;
422423
}
423424
size *= (size_t) max_procs;

opal/util/output.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
* reserved.
2323
* Copyright (c) 2019 Triad National Security, LLC. All rights
2424
* reserved.
25+
* Copyright (c) 2024 Jeffrey M. Squyres. All rights reserved.
2526
* $COPYRIGHT$
2627
*
2728
* Additional copyrights may follow
@@ -574,6 +575,13 @@ static int do_open(int output_id, opal_output_stream_t *lds)
574575
opal_output_init();
575576
}
576577

578+
/* Bozo check */
579+
580+
if (output_id >= OPAL_OUTPUT_MAX_STREAMS ||
581+
output_id < -1) {
582+
return OPAL_ERR_BAD_PARAM;
583+
}
584+
577585
str = getenv("OPAL_OUTPUT_REDIRECT");
578586
if (NULL != str && 0 == strcasecmp(str, "file")) {
579587
redirect_to_file = true;

0 commit comments

Comments
 (0)