Skip to content

Commit 3bec944

Browse files
authored
Merge pull request #12789 from jsquyres/pr/v5.0.x/gcc-14-complier-warning-fixes
v5.0.x: gcc 14 and clang 18 compiler warning fixes
2 parents a0cb00c + 3d9b62e commit 3bec944

File tree

4 files changed

+29
-18
lines changed

4 files changed

+29
-18
lines changed

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
}
@@ -691,7 +693,7 @@ ompi_report_comm_methods(int called_from_location)
691693
p = str;
692694
for (k=0; k<nleaderranks; ++k) {
693695
char *method_string;
694-
char ucx_label[10];
696+
char ucx_label[20];
695697

696698
method_string = comm_method_to_string(method[i * nleaderranks + k]);
697699
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));
@@ -261,8 +261,8 @@ mca_part_persist_progress(void)
261261

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

267267
/* Set up persistent sends */
268268
req->persist_reqs = (ompi_request_t**) malloc(sizeof(ompi_request_t*)*(req->real_parts));
@@ -337,7 +337,7 @@ mca_part_persist_precv_init(void *buf,
337337
{
338338
int err = OMPI_SUCCESS;
339339
size_t dt_size_;
340-
int dt_size;
340+
uint32_t dt_size;
341341
mca_part_persist_list_t* new_progress_elem = NULL;
342342

343343
mca_part_persist_precv_request_t *recvreq;
@@ -369,7 +369,7 @@ mca_part_persist_precv_init(void *buf,
369369
/* Compute total number of bytes */
370370
err = opal_datatype_type_size(&(req->req_datatype->super), &dt_size_);
371371
if(OMPI_SUCCESS != err) return OMPI_ERROR;
372-
dt_size = (dt_size_ > (size_t) INT_MAX) ? MPI_UNDEFINED : (int) dt_size_;
372+
dt_size = (dt_size_ > (size_t) UINT_MAX) ? MPI_UNDEFINED : (uint32_t) dt_size_;
373373
req->req_bytes = parts * count * dt_size;
374374

375375

@@ -405,7 +405,7 @@ mca_part_persist_psend_init(const void* buf,
405405
{
406406
int err = OMPI_SUCCESS;
407407
size_t dt_size_;
408-
int dt_size;
408+
uint32_t dt_size;
409409
mca_part_persist_list_t* new_progress_elem = NULL;
410410
mca_part_persist_psend_request_t *sendreq;
411411

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

436436

@@ -494,11 +494,11 @@ mca_part_persist_start(size_t count, ompi_request_t** requests)
494494
{
495495
if(MCA_PART_PERSIST_REQUEST_PSEND == req->req_type) {
496496
req->done_count = 0;
497-
memset((void*)req->flags,0,sizeof(int32_t)*req->real_parts);
497+
memset((void*)req->flags,0,sizeof(uint32_t)*req->real_parts);
498498
} else {
499499
req->done_count = 0;
500500
err = req->persist_reqs[0]->req_start(req->real_parts, req->persist_reqs);
501-
memset((void*)req->flags,0,sizeof(int32_t)*req->real_parts);
501+
memset((void*)req->flags,0,sizeof(uint32_t)*req->real_parts);
502502
}
503503
} else {
504504
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/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)