From b40355806ce53b6c29201309e63b5389d417aecd Mon Sep 17 00:00:00 2001 From: Joshua Gerrard Date: Thu, 24 Nov 2016 21:25:30 +0000 Subject: [PATCH 1/2] Fixed -Werror=unused-result warnings in comm_cid.c by adding error checking Signed-off-by: Joshua Gerrard Signed-off-by: Jeff Squyres (cherry picked from commit 7cf5de12b9873449693f61fbe641689beb79e64e) --- ompi/communicator/comm_cid.c | 41 ++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/ompi/communicator/comm_cid.c b/ompi/communicator/comm_cid.c index d91a427c93b..bae39f91ce9 100644 --- a/ompi/communicator/comm_cid.c +++ b/ompi/communicator/comm_cid.c @@ -840,6 +840,9 @@ static int ompi_comm_allreduce_pmix_reduce_complete (ompi_comm_request_t *reques opal_pmix_pdata_t pdat; opal_buffer_t sbuf; int rc; + int bytes_written; + const int output_id = 0; + const int verbosity_level = 1; OBJ_CONSTRUCT(&sbuf, opal_buffer_t); @@ -858,16 +861,36 @@ static int ompi_comm_allreduce_pmix_reduce_complete (ompi_comm_request_t *reques opal_dss.unload(&sbuf, (void**)&info.data.bo.bytes, &info.data.bo.size); OBJ_DESTRUCT(&sbuf); - if (cid_context->send_first) { - (void)asprintf(&info.key, "%s:%s:send:%d", cid_context->port_string, cid_context->pmix_tag, - cid_context->iter); - (void)asprintf(&pdat.value.key, "%s:%s:recv:%d", cid_context->port_string, cid_context->pmix_tag, - cid_context->iter); + bytes_written = asprintf(&info.key, + cid_context->send_first ? "%s:%s:send:%d" + : "%s:%s:recv:%d", + cid_context->port_string, + cid_context->pmix_tag, + cid_context->iter); + + if (bytes_written == -1) { + opal_output_verbose (verbosity_level, output_id, "writing info.key failed\n"); } else { - (void)asprintf(&info.key, "%s:%s:recv:%d", cid_context->port_string, cid_context->pmix_tag, - cid_context->iter); - (void)asprintf(&pdat.value.key, "%s:%s:send:%d", cid_context->port_string, cid_context->pmix_tag, - cid_context->iter); + bytes_written = asprintf(&pdat.value.key, + cid_context->send_first ? "%s:%s:recv:%d" + : "%s:%s:send:%d", + cid_context->port_string, + cid_context->pmix_tag, + cid_context->iter); + + if (bytes_written == -1) { + opal_output_verbose (verbosity_level, output_id, "writing pdat.value.key failed\n"); + } + } + + if (bytes_written == -1) { + // write with separate calls, + // just in case the args are the cause of failure + opal_output_verbose (verbosity_level, output_id, "send first: %d\n", cid_context->send_first); + opal_output_verbose (verbosity_level, output_id, "port string: %s\n", cid_context->port_string); + opal_output_verbose (verbosity_level, output_id, "pmix tag: %s\n", cid_context->pmix_tag); + opal_output_verbose (verbosity_level, output_id, "iter: %d\n", cid_context->iter); + return OMPI_ERR_OUT_OF_RESOURCE; } /* this macro is not actually non-blocking. if a non-blocking version becomes available this function From 79c4a7805f8686b31ea8b60e668a92a2ad3a70f0 Mon Sep 17 00:00:00 2001 From: Joshua Gerrard Date: Thu, 1 Dec 2016 19:52:39 +0000 Subject: [PATCH 2/2] Swapped use of fprintf for opal_output_verbose Signed-off-by: Joshua Gerrard Signed-off-by: Jeff Squyres (cherry picked from commit d5a45bc12ef637dcccd28dd4b26a631a524ae8ba) --- ompi/communicator/comm_cid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ompi/communicator/comm_cid.c b/ompi/communicator/comm_cid.c index bae39f91ce9..debbed45953 100644 --- a/ompi/communicator/comm_cid.c +++ b/ompi/communicator/comm_cid.c @@ -848,7 +848,7 @@ static int ompi_comm_allreduce_pmix_reduce_complete (ompi_comm_request_t *reques if (OPAL_SUCCESS != (rc = opal_dss.pack(&sbuf, context->tmpbuf, (int32_t)context->count, OPAL_INT))) { OBJ_DESTRUCT(&sbuf); - fprintf (stderr, "pack failed. rc %d\n", rc); + opal_output_verbose (verbosity_level, output_id, "pack failed. rc %d\n", rc); return rc; }