diff --git a/ompi/mpi/c/comm_get_name.c b/ompi/mpi/c/comm_get_name.c index e635b768505..ddb4875819f 100644 --- a/ompi/mpi/c/comm_get_name.c +++ b/ompi/mpi/c/comm_get_name.c @@ -2,7 +2,7 @@ * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2005 The University of Tennessee and The University + * Copyright (c) 2004-2022 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, @@ -52,7 +52,11 @@ int MPI_Comm_get_name(MPI_Comm comm, char *name, int *length) if ( MPI_PARAM_CHECK ) { OMPI_ERR_INIT_FINALIZE(FUNC_NAME); - if ( ompi_comm_invalid ( comm ) ) + /* Do not use ompi_comm_invalid, it prevent returning + * the name for the predefined MPI_COMM_NULL. + */ + if ((NULL == comm) || + (OMPI_COMM_IS_FREED(comm)) || (OMPI_COMM_IS_INVALID(comm)) ) return OMPI_ERRHANDLER_INVOKE ( MPI_COMM_WORLD, MPI_ERR_COMM, FUNC_NAME); diff --git a/ompi/mpi/c/type_get_name.c b/ompi/mpi/c/type_get_name.c index b38697a1bc1..e6b8d8a97d5 100644 --- a/ompi/mpi/c/type_get_name.c +++ b/ompi/mpi/c/type_get_name.c @@ -51,7 +51,7 @@ int MPI_Type_get_name(MPI_Datatype type, char *type_name, int *resultlen) if ( MPI_PARAM_CHECK ) { OMPI_ERR_INIT_FINALIZE(FUNC_NAME); - if (NULL == type || MPI_DATATYPE_NULL == type) { + if (NULL == type) { return OMPI_ERRHANDLER_NOHANDLE_INVOKE(MPI_ERR_TYPE, FUNC_NAME ); } else if (NULL == type_name || NULL == resultlen) { diff --git a/ompi/mpi/c/win_get_name.c b/ompi/mpi/c/win_get_name.c index 6d745c05a5f..375a31641b7 100644 --- a/ompi/mpi/c/win_get_name.c +++ b/ompi/mpi/c/win_get_name.c @@ -2,7 +2,7 @@ * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2020 The University of Tennessee and The University + * Copyright (c) 2004-2022 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, @@ -44,7 +44,12 @@ int MPI_Win_get_name(MPI_Win win, char *win_name, int *resultlen) if (MPI_PARAM_CHECK) { OMPI_ERR_INIT_FINALIZE(FUNC_NAME); - if (ompi_win_invalid(win)) { + /* Do not use ompi_comm_invalid, it prevent returning + * the name for the predefined MPI_COMM_NULL. + */ + if (NULL == win || + (OMPI_WIN_INVALID & win->w_flags) || + (OMPI_WIN_FREED & win->w_flags)) { return OMPI_ERRHANDLER_NOHANDLE_INVOKE(MPI_ERR_WIN, FUNC_NAME); } else if (NULL == win_name || NULL == resultlen) { return OMPI_ERRHANDLER_INVOKE(win, MPI_ERR_ARG, FUNC_NAME); diff --git a/ompi/win/win.c b/ompi/win/win.c index 70e70c978e8..4113165d1f0 100644 --- a/ompi/win/win.c +++ b/ompi/win/win.c @@ -3,7 +3,7 @@ * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. - * Copyright (c) 2004-2017 The University of Tennessee and The University + * Copyright (c) 2004-2022 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, @@ -124,7 +124,6 @@ int ompi_win_init (void) /* Setup MPI_WIN_NULL */ OBJ_CONSTRUCT(&ompi_mpi_win_null.win, ompi_win_t); - ompi_mpi_win_null.win.w_flags = OMPI_WIN_INVALID; ompi_mpi_win_null.win.w_group = &ompi_mpi_group_null.group; OBJ_RETAIN(&ompi_mpi_group_null); ompi_win_set_name(&ompi_mpi_win_null.win, "MPI_WIN_NULL");