Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Move check for MPI_BOTTOM one level up.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 16 Nov 2017 08:34:05 +0000 (09:34 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 16 Nov 2017 08:34:19 +0000 (09:34 +0100)
It seems more logical, and I hope that it will silence scan-build about null pointer
dereference.

src/smpi/bindings/smpi_pmpi_type.cpp
src/smpi/mpi/smpi_datatype.cpp

index ec5cc1b..69b7eaa 100644 (file)
@@ -338,7 +338,7 @@ int PMPI_Pack(void* inbuf, int incount, MPI_Datatype type, void* outbuf, int out
     return MPI_ERR_TYPE;
   if(comm==MPI_COMM_NULL)
     return MPI_ERR_COMM;
-  return type->pack(inbuf, incount, outbuf,outcount,position, comm);
+  return type->pack(inbuf == MPI_BOTTOM ? nullptr : inbuf, incount, outbuf, outcount, position, comm);
 }
 
 int PMPI_Pack_size(int incount, MPI_Datatype datatype, MPI_Comm comm, int* size) {
index 2457c8f..4237217 100644 (file)
@@ -251,8 +251,7 @@ void Datatype::set_name(char* name){
 int Datatype::pack(void* inbuf, int incount, void* outbuf, int outcount, int* position,MPI_Comm comm){
   if (outcount - *position < incount*static_cast<int>(size_))
     return MPI_ERR_BUFFER;
-  Datatype::copy(inbuf == MPI_BOTTOM ? nullptr : inbuf, incount, this, static_cast<char*>(outbuf) + *position, outcount,
-                 MPI_CHAR);
+  Datatype::copy(inbuf, incount, this, static_cast<char*>(outbuf) + *position, outcount, MPI_CHAR);
   *position += incount * size_;
   return MPI_SUCCESS;
 }