From f6de2ab540fe1bc9c0ede1591d28ff2d4dfddd0e Mon Sep 17 00:00:00 2001 From: Augustin Degomme Date: Sun, 18 Aug 2019 23:33:50 +0200 Subject: [PATCH] Don't return an error when a key is not found in an MPI_Info. --- src/smpi/bindings/smpi_pmpi_info.cpp | 10 ++++++++-- src/smpi/internals/smpi_actor.cpp | 3 +++ src/smpi/mpi/smpi_info.cpp | 8 ++------ 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/smpi/bindings/smpi_pmpi_info.cpp b/src/smpi/bindings/smpi_pmpi_info.cpp index 82634cfe77..0a694f22b1 100644 --- a/src/smpi/bindings/smpi_pmpi_info.cpp +++ b/src/smpi/bindings/smpi_pmpi_info.cpp @@ -34,8 +34,10 @@ int PMPI_Info_free( MPI_Info *info){ int PMPI_Info_get(MPI_Info info, const char *key,int valuelen, char *value, int *flag){ *flag=false; - if (info == nullptr || key == nullptr || valuelen <0) + if (info == nullptr || valuelen <0) return MPI_ERR_ARG; + if (key == nullptr) + return MPI_ERR_INFO_KEY; if (value == nullptr) return MPI_ERR_INFO_VALUE; return info->get(key, valuelen, value, flag); @@ -68,8 +70,12 @@ int PMPI_Info_get_nthkey( MPI_Info info, int n, char *key){ int PMPI_Info_get_valuelen( MPI_Info info, const char *key, int *valuelen, int *flag){ *flag=false; - if (info == nullptr || key == nullptr || valuelen==nullptr) + if (info == nullptr) return MPI_ERR_ARG; + if (key == nullptr) + return MPI_ERR_INFO_KEY; + if (valuelen == nullptr) + return MPI_ERR_INFO_VALUE; return info->get_valuelen(key, valuelen, flag); } diff --git a/src/smpi/internals/smpi_actor.cpp b/src/smpi/internals/smpi_actor.cpp index bb5d5af73d..c918f1acb5 100644 --- a/src/smpi/internals/smpi_actor.cpp +++ b/src/smpi/internals/smpi_actor.cpp @@ -6,6 +6,7 @@ #include "src/smpi/include/smpi_actor.hpp" #include "mc/mc.h" #include "smpi_comm.hpp" +#include "smpi_info.hpp" #include "src/mc/mc_replay.hpp" #include "src/simix/smx_private.hpp" @@ -180,6 +181,8 @@ MPI_Comm ActorExt::comm_self() MPI_Info ActorExt::info_env() { + if (info_env_==MPI_INFO_NULL) + info_env_=new Info(); return info_env_; } diff --git a/src/smpi/mpi/smpi_info.cpp b/src/smpi/mpi/smpi_info.cpp index 73a323e7b9..c20ae58755 100644 --- a/src/smpi/mpi/smpi_info.cpp +++ b/src/smpi/mpi/smpi_info.cpp @@ -31,10 +31,8 @@ int Info::get(const char *key, int valuelen, char *value, int *flag){ memcpy(value, tmpvalue.c_str(), (tmpvalue.length() + 1 < static_cast(valuelen)) ? tmpvalue.length() + 1 : valuelen); *flag=true; - return MPI_SUCCESS; - } else { - return MPI_ERR_INFO_KEY; } + return MPI_SUCCESS; } int Info::remove(const char *key){ @@ -67,10 +65,8 @@ int Info::get_valuelen(const char *key, int *valuelen, int *flag){ if (val != map_.end()) { *valuelen = val->second.length(); *flag=true; - return MPI_SUCCESS; - } else { - return MPI_ERR_INFO_KEY; } + return MPI_SUCCESS; } Info* Info::f2c(int id){ -- 2.20.1