From e996578f73b411c79d8efc7c42ce9dc27842018b Mon Sep 17 00:00:00 2001 From: Augustin Degomme Date: Tue, 6 Apr 2021 18:42:02 +0200 Subject: [PATCH] fix for potentially empty names --- src/smpi/include/smpi_datatype.hpp | 2 +- src/smpi/include/smpi_file.hpp | 2 +- src/smpi/include/smpi_win.hpp | 2 +- src/smpi/mpi/smpi_comm.cpp | 5 ++++- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/smpi/include/smpi_datatype.hpp b/src/smpi/include/smpi_datatype.hpp index 06a106bbd3..19ad3abd14 100644 --- a/src/smpi/include/smpi_datatype.hpp +++ b/src/smpi/include/smpi_datatype.hpp @@ -127,7 +127,7 @@ public: Datatype(const Datatype&) = delete; Datatype& operator=(const Datatype&) = delete; ~Datatype() override; - std::string name() const {return name_;} + std::string name() const {return name_.empty() ? std::string("MPI_Datatype") : name_;} size_t size() const { return size_; } MPI_Aint lb() const { return lb_; } MPI_Aint ub() const { return ub_; } diff --git a/src/smpi/include/smpi_file.hpp b/src/smpi/include/smpi_file.hpp index dc95b2c4fc..dfd995c760 100644 --- a/src/smpi/include/smpi_file.hpp +++ b/src/smpi/include/smpi_file.hpp @@ -42,7 +42,7 @@ class File : public F2C{ int get_position_shared(MPI_Offset* offset) const; int flags() const; MPI_Comm comm() const; - std::string name() const {return file_ ? std::string("MPI_File:" + file_->get_path()): std::string("MPI_File");} + std::string name() const {return file_ ? std::string("MPI_File: ")+ std::string(file_->get_path()): std::string("MPI_File");} int sync(); int seek(MPI_Offset offset, int whence); diff --git a/src/smpi/include/smpi_win.hpp b/src/smpi/include/smpi_win.hpp index e638736948..090e89838e 100644 --- a/src/smpi/include/smpi_win.hpp +++ b/src/smpi/include/smpi_win.hpp @@ -54,7 +54,7 @@ public: int attach (void *base, MPI_Aint size); int detach (const void *base); void get_name(char* name, int* length) const; - std::string name() const {return name_;} + std::string name() const {return name_.empty() ? std::string("MPI_Win") : name_;} void get_group( MPI_Group* group); void set_name(const char* name); int rank() const; diff --git a/src/smpi/mpi/smpi_comm.cpp b/src/smpi/mpi/smpi_comm.cpp index ce496d29e4..bde50b6e60 100644 --- a/src/smpi/mpi/smpi_comm.cpp +++ b/src/smpi/mpi/smpi_comm.cpp @@ -183,7 +183,10 @@ std::string Comm::name() const int size; char name[MPI_MAX_NAME_STRING]; this->get_name(name, &size); - return std::string(name); + if (name[0]=='\0') + return std::string("MPI_Comm"); + else + return std::string(name); } -- 2.20.1