Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use std::vector.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Mon, 26 Oct 2020 23:20:01 +0000 (00:20 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 27 Oct 2020 22:43:08 +0000 (23:43 +0100)
src/smpi/bindings/smpi_pmpi.cpp

index 66346e8..658d06e 100644 (file)
@@ -209,9 +209,8 @@ int PMPI_Error_class(int errorcode, int* errorclass) {
 
 int PMPI_Error_string(int errorcode, char* string, int* resultlen)
 {
-  static const char* smpi_error_string[] = {FOREACH_ERROR(GENERATE_STRING)};
-  constexpr int nerrors                  = (sizeof smpi_error_string) / (sizeof smpi_error_string[0]);
-  if (errorcode < 0 || errorcode >= nerrors || string == nullptr)
+  static const std::vector<const char*> smpi_error_string = {FOREACH_ERROR(GENERATE_STRING)};
+  if (errorcode < 0 || static_cast<size_t>(errorcode) >= smpi_error_string.size() || string == nullptr)
     return MPI_ERR_ARG;
 
   int len    = snprintf(string, MPI_MAX_ERROR_STRING, "%s", smpi_error_string[errorcode]);