From 8f1a61343753ad7df098cfd47855dcc65c9b6b83 Mon Sep 17 00:00:00 2001 From: "Samuel K. Gutierrez" Date: Sun, 5 Feb 2023 04:16:29 -0700 Subject: [PATCH] Silence compiler warnings in examples. Signed-off-by: Samuel K. Gutierrez (cherry picked from commit 83ddaf9f4091bb8245f1490cbec35e8a59f14ebc) --- examples/dmodex.c | 10 ++++++++-- examples/nodeid.c | 7 ++++--- examples/pset.c | 3 ++- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/examples/dmodex.c b/examples/dmodex.c index 9d4043921c..6dac1963e9 100644 --- a/examples/dmodex.c +++ b/examples/dmodex.c @@ -17,6 +17,7 @@ * Copyright (c) 2015 Mellanox Technologies, Inc. All rights reserved. * Copyright (c) 2019-2022 IBM Corporation. All rights reserved. * Copyright (c) 2021-2022 Nanook Consulting All rights reserved. + * Copyright (c) 2023 Triad National Security, LLC. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -38,7 +39,7 @@ static pmix_proc_t myproc; int main(int argc, char **argv) { - int rc; + int rc, np; pmix_value_t value; pmix_value_t *val = NULL; char tmp[1024]; @@ -144,7 +145,12 @@ int main(int argc, char **argv) } PMIX_ARGV_FREE(peers); - snprintf(proc.nspace, PMIX_MAX_NSLEN, "%s", myproc.nspace); + np = snprintf(proc.nspace, PMIX_MAX_NSLEN, "%s", myproc.nspace); + if (np >= PMIX_MAX_NSLEN) { + fprintf(stderr, "Client ns %s rank %d: snprintf failed\n", myproc.nspace, myproc.rank); + exit(0); + } + PMIX_INFO_LOAD(&timeout, PMIX_TIMEOUT, &tlimit, PMIX_INT); /* get the committed data - ask for someone who doesn't exist as well */ for (n = 0; n < nprocs; n++) { diff --git a/examples/nodeid.c b/examples/nodeid.c index 9bcffc6c81..da4a5a126a 100644 --- a/examples/nodeid.c +++ b/examples/nodeid.c @@ -16,6 +16,7 @@ * Copyright (c) 2013-2019 Intel, Inc. All rights reserved. * Copyright (c) 2015 Mellanox Technologies, Inc. All rights reserved. * Copyright (c) 2021-2022 Nanook Consulting. All rights reserved. + * Copyright (c) 2023 Triad National Security, LLC. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -77,18 +78,18 @@ int main(int argc, char **argv) proc.rank = n; rc = PMIx_Get(&proc, PMIX_NODEID, NULL, 0, &val); if (PMIX_SUCCESS != rc) { - fprintf(stderr, "[%s:%u] PMIx_Get failed for nodeid on rank %u: %s\n", + fprintf(stderr, "[%s:%u] PMIx_Get failed for nodeid on rank %zd: %s\n", myproc.nspace, myproc.rank, n, PMIx_Error_string(rc)); break; } PMIX_VALUE_GET_NUMBER(rc, val, nodeid, uint32_t); if (PMIX_SUCCESS != rc) { - fprintf(stderr, "[%s:%u] Got bad nodeid for rank %u: %s\n", + fprintf(stderr, "[%s:%u] Got bad nodeid for rank %zd: %s\n", myproc.nspace, myproc.rank, n, PMIx_Error_string(rc)); goto done; } if (0 == myproc.rank) { - fprintf(stderr, "[%s:%u] Peer %u is running on node %u\n", + fprintf(stderr, "[%s:%u] Peer %zd is running on node %u\n", myproc.nspace, myproc.rank, n, nodeid); } PMIX_VALUE_RELEASE(val); diff --git a/examples/pset.c b/examples/pset.c index ea9c35fcc6..9bf5eb2cf1 100644 --- a/examples/pset.c +++ b/examples/pset.c @@ -16,6 +16,7 @@ * Copyright (c) 2013-2018 Intel, Inc. All rights reserved. * Copyright (c) 2015 Mellanox Technologies, Inc. All rights reserved. * Copyright (c) 2021-2022 Nanook Consulting. All rights reserved. + * Copyright (c) 2023 Triad National Security, LLC. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -76,7 +77,7 @@ int main(int argc, char **argv) myproc.nspace, myproc.rank, PMIx_Data_type_string(val->type)); goto done; } - fprintf(stderr, "Client %s:%d PMIx_Get returned %d members\n", myproc.nspace, myproc.rank, + fprintf(stderr, "Client %s:%d PMIx_Get returned %zd members\n", myproc.nspace, myproc.rank, val->data.darray->size); pptr = (pmix_proc_t*)val->data.darray->array; for (n=0; n < val->data.darray->size; n++) {