From ae6ff056d17715d89dbd9aea7430d7d0d98ac1fd Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Wed, 15 Sep 2004 20:55:29 +0000 Subject: [PATCH] Don't bother trying to use the fancy schmancy ERRHANDLER macros when invoking an errhandler in MPI_INIT when we don't yet have a communicator to invoke them on. Instead, remove some of the logic from the ERRHANDLER macros and just invoke the back-end function directly in MPI_INIT. This commit was SVN r2692. --- src/errhandler/errhandler.h | 6 +++--- src/mpi/c/init.c | 19 +++++++++++++++---- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/errhandler/errhandler.h b/src/errhandler/errhandler.h index 66c5069bc5..39f720d53b 100644 --- a/src/errhandler/errhandler.h +++ b/src/errhandler/errhandler.h @@ -124,7 +124,7 @@ extern ompi_pointer_array_t *ompi_errhandler_f_to_c_table; * parallel invocation to OMPI_ERRHANDLER_CHECK() and OMPI_ERRHANDLER_RETURN(). */ #define OMPI_ERRHANDLER_INVOKE(mpi_object, err_code, message) \ - ompi_errhandler_invoke((mpi_object) != NULL ? (mpi_object)->error_handler : NULL, \ + ompi_errhandler_invoke((mpi_object)->error_handler, \ (mpi_object), \ (int)(mpi_object)->errhandler_type, \ (err_code < 0 ? (ompi_errcode_get_mpi_code(err_code)) : err_code), \ @@ -146,7 +146,7 @@ extern ompi_pointer_array_t *ompi_errhandler_f_to_c_table; #define OMPI_ERRHANDLER_CHECK(rc, mpi_object, err_code, message) \ if (rc != OMPI_SUCCESS) { \ int __mpi_err_code = (err_code < 0 ? (ompi_errcode_get_mpi_code(err_code)) : err_code); \ - ompi_errhandler_invoke((mpi_object) != NULL ? (mpi_object)->error_handler : NULL, \ + ompi_errhandler_invoke((mpi_object)->error_handler, \ (mpi_object), \ (int) (mpi_object)->errhandler_type, \ (__mpi_err_code), \ @@ -172,7 +172,7 @@ extern ompi_pointer_array_t *ompi_errhandler_f_to_c_table; #define OMPI_ERRHANDLER_RETURN(rc, mpi_object, err_code, message) \ if (rc != OMPI_SUCCESS) { \ int __mpi_err_code = (err_code < 0 ? (ompi_errcode_get_mpi_code(err_code)) : err_code); \ - ompi_errhandler_invoke((mpi_object != NULL) ? (mpi_object)->error_handler : NULL, \ + ompi_errhandler_invoke((mpi_object)->error_handler, \ (mpi_object), \ (int)(mpi_object)->errhandler_type, \ (__mpi_err_code), \ diff --git a/src/mpi/c/init.c b/src/mpi/c/init.c index c8d3792d94..e0914e8ef8 100644 --- a/src/mpi/c/init.c +++ b/src/mpi/c/init.c @@ -30,13 +30,13 @@ int MPI_Init(int *argc, char ***argv) int provided; char *env; int required = MPI_THREAD_SINGLE; - MPI_Comm null = NULL; /* Ensure that we were not already initialized or finalized */ if (ompi_mpi_finalized) { - /* JMS show_help */ - return OMPI_ERRHANDLER_INVOKE(null, MPI_ERR_OTHER, FUNC_NAME); + /* JMS show_help */ + return ompi_errhandler_invoke(NULL, NULL, OMPI_ERRHANDLER_TYPE_COMM, + MPI_ERR_OTHER, FUNC_NAME); } else if (ompi_mpi_initialized) { /* JMS show_help */ return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_OTHER, FUNC_NAME); @@ -62,5 +62,16 @@ int MPI_Init(int *argc, char ***argv) } else { err = ompi_mpi_init(0, NULL, required, &provided); } - OMPI_ERRHANDLER_RETURN(err, null, err, FUNC_NAME); + + /* Since we don't have a communicator to invoke an errorhandler on + here, don't use the fancy-schmancy ERRHANDLER macros; they're + really designed for real communicator objects. Just use the + back-end function directly. */ + + if (MPI_SUCCESS != err) { + return ompi_errhandler_invoke(NULL, NULL, OMPI_ERRHANDLER_TYPE_COMM, + err < 0 ? ompi_errcode_get_mpi_code(err) : + err, FUNC_NAME); + } + return MPI_SUCCESS; }