From 472e5635c732b5757fcef8b6c1d747c618f20529 Mon Sep 17 00:00:00 2001 From: Nathan Hjelm Date: Tue, 2 Jun 2015 08:57:07 -0600 Subject: [PATCH 1/3] topo/base: fix coverity issue CID 1295340 Unchecked return value (CHECKED_RETURN) Check the return code of mca_base_framework_open. If the call fails for some reason the component array will not be properly defined. This will cause issues in mca_topo_base_find_available. Signed-off-by: Nathan Hjelm --- ompi/mca/topo/base/topo_base_lazy_init.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ompi/mca/topo/base/topo_base_lazy_init.c b/ompi/mca/topo/base/topo_base_lazy_init.c index 04db474670..42dc376f75 100644 --- a/ompi/mca/topo/base/topo_base_lazy_init.c +++ b/ompi/mca/topo/base/topo_base_lazy_init.c @@ -1,3 +1,4 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana * University Research and Technology @@ -11,6 +12,8 @@ * All rights reserved. * Copyright (c) 2009 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2012-2015 Inria. All rights reserved. + * Copyright (c) 2015 Los Alamos National Security, LLC. All rights + * reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -39,7 +42,12 @@ int mca_topo_base_lazy_init(void) /** * Register and open all available components, giving them a chance to access the MCA parameters. */ - mca_base_framework_open (&ompi_topo_base_framework, MCA_BASE_REGISTER_DEFAULT); + + err = mca_base_framework_open (&ompi_topo_base_framework, MCA_BASE_REGISTER_DEFAULT); + if (OMPI_SUCCESS != err) { + return err; + } + if (OMPI_SUCCESS != (err = mca_topo_base_find_available(OPAL_ENABLE_PROGRESS_THREADS, OMPI_ENABLE_THREAD_MULTIPLE))) { From 632f829eb7352edbea76239130fdfd2c7cb2e7ff Mon Sep 17 00:00:00 2001 From: Nathan Hjelm Date: Tue, 2 Jun 2015 09:04:10 -0600 Subject: [PATCH 2/3] mpit: fix coverity issues CID 1047284 Uninitialized scalar variable (UNINIT) CID 1047285 Uninitialized scalar variable (UNINIT) CID 1047286 Uninitialized scalar variable (UNINIT) If a performance variable session has no handles we should be returning MPI_SUCCESS for MPI_T_pvar_start, MPI_T_pvar_stop, and MPI_T_pvar_reset. The code was returning an unitialized value. This commit also updates the error code to return the proper error on failure. Signed-off-by: Nathan Hjelm --- ompi/mpi/tool/mpit_common.c | 7 ++++++- ompi/mpi/tool/pvar_reset.c | 4 ++-- ompi/mpi/tool/pvar_start.c | 2 +- ompi/mpi/tool/pvar_stop.c | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/ompi/mpi/tool/mpit_common.c b/ompi/mpi/tool/mpit_common.c index 015a8faa5f..785b8c0d83 100644 --- a/ompi/mpi/tool/mpit_common.c +++ b/ompi/mpi/tool/mpit_common.c @@ -1,6 +1,6 @@ /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* - * Copyright (c) 2012-2013 Los Alamos National Security, LLC. All rights + * Copyright (c) 2012-2015 Los Alamos National Security, LLC. All rights * reserved. * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. @@ -80,6 +80,11 @@ int ompit_var_type_to_datatype (mca_base_var_type_t type, MPI_Datatype *datatype int ompit_opal_to_mpit_error (int rc) { + if (rc >= 0) { + /* Already an MPI error (always >= 0) */ + return rc; + } + switch (rc) { case OPAL_SUCCESS: return MPI_SUCCESS; diff --git a/ompi/mpi/tool/pvar_reset.c b/ompi/mpi/tool/pvar_reset.c index 1091db0dcc..cf05f58ea8 100644 --- a/ompi/mpi/tool/pvar_reset.c +++ b/ompi/mpi/tool/pvar_reset.c @@ -1,6 +1,6 @@ /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* - * Copyright (c) 2012-2013 Los Alamos National Security, LLC. All rights + * Copyright (c) 2012-2015 Los Alamos National Security, LLC. All rights * reserved. * Copyright (c) 2014 Cisco Systems, Inc. All rights reserved. * $COPYRIGHT$ @@ -23,7 +23,7 @@ int MPI_T_pvar_reset(MPI_T_pvar_session session, MPI_T_pvar_handle handle) { - int ret; + int ret = MPI_SUCCESS; if (!mpit_is_initialized ()) { return MPI_T_ERR_NOT_INITIALIZED; diff --git a/ompi/mpi/tool/pvar_start.c b/ompi/mpi/tool/pvar_start.c index 0f8e71f814..667c3cc486 100644 --- a/ompi/mpi/tool/pvar_start.c +++ b/ompi/mpi/tool/pvar_start.c @@ -32,7 +32,7 @@ static int pvar_handle_start (mca_base_pvar_handle_t *handle) int MPI_T_pvar_start(MPI_T_pvar_session session, MPI_T_pvar_handle handle) { - int ret; + int ret = MPI_SUCCESS; if (!mpit_is_initialized ()) { return MPI_T_ERR_NOT_INITIALIZED; diff --git a/ompi/mpi/tool/pvar_stop.c b/ompi/mpi/tool/pvar_stop.c index 9caf60f046..0866ac46a0 100644 --- a/ompi/mpi/tool/pvar_stop.c +++ b/ompi/mpi/tool/pvar_stop.c @@ -32,7 +32,7 @@ static int pvar_handle_stop (mca_base_pvar_handle_t *handle) int MPI_T_pvar_stop(MPI_T_pvar_session session, MPI_T_pvar_handle handle) { - int ret; + int ret = MPI_SUCCESS; if (!mpit_is_initialized ()) { return MPI_T_ERR_NOT_INITIALIZED; From 69a0e1dd08c1666118bcef6788ef523f8ce8facb Mon Sep 17 00:00:00 2001 From: Nathan Hjelm Date: Tue, 2 Jun 2015 09:40:26 -0600 Subject: [PATCH 3/3] comm: fix coverity issues CID 1269683 Unchecked return value (CHECKED_RETURN) CID 1269684 Unchecked return value (CHECKED_RETURN) Use ompi_comm_rank instead of MPI_Comm_rank here. There is no reason to be using the MPI interface over the internal interface. This should clear up these issues. Signed-off-by: Nathan Hjelm --- ompi/communicator/comm_helpers.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ompi/communicator/comm_helpers.c b/ompi/communicator/comm_helpers.c index 0f0eb65321..247883fa09 100644 --- a/ompi/communicator/comm_helpers.c +++ b/ompi/communicator/comm_helpers.c @@ -1,3 +1,4 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* * Copyright (c) 2006 The Trustees of Indiana University and Indiana * University Research and Technology @@ -6,6 +7,8 @@ * rights reserved. * Copyright (c) 2014 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2015 Los Alamos National Security, LLC. All rights + * reserved. * * Author(s): Torsten Hoefler * @@ -27,7 +30,7 @@ int ompi_comm_neighbors_count(MPI_Comm comm, int *indegree, int *outdegree, int *weighted = 0; } else if (OMPI_COMM_IS_GRAPH(comm)) { int rank, nneighbors; - MPI_Comm_rank(comm, &rank); + rank = ompi_comm_rank ((ompi_communicator_t *) comm); res = MPI_Graph_neighbors_count(comm, rank, &nneighbors); if (MPI_SUCCESS != res) { return res; @@ -70,8 +73,7 @@ int ompi_comm_neighbors(MPI_Comm comm, int maxindegree, int sources[], int sourc sources[index] = destinations[index] = speer; index++; } } else if (OMPI_COMM_IS_GRAPH(comm)) { - int rank; - MPI_Comm_rank(comm, &rank); + int rank = ompi_comm_rank ((ompi_communicator_t *) comm); res = MPI_Graph_neighbors(comm, rank, maxindegree, sources); if (MPI_SUCCESS != res) { return res;