- if (comm == MPI_COMM_NULL)
- return MPI_ERR_COMM;
- if ((sendbuf == nullptr && sendcount > 0) || (recvbuf == nullptr))
- return MPI_ERR_BUFFER;
- if (((sendbuf != MPI_IN_PLACE) && (sendtype == MPI_DATATYPE_NULL)) || (recvtype == MPI_DATATYPE_NULL))
- return MPI_ERR_TYPE;
- if ((sendbuf != MPI_IN_PLACE) && (sendcount < 0))
- return MPI_ERR_COUNT;
- if (recvcounts == nullptr || displs == nullptr)
- return MPI_ERR_ARG;
- if (request == nullptr)
- return MPI_ERR_ARG;
-
- for (int i = 0; i < comm->size(); i++) { // copy data to avoid bad free
- if (recvcounts[i] < 0)
- return MPI_ERR_COUNT;
+ CHECK_COMM(8)
+ CHECK_BUFFER(1, sendbuf, sendcount)
+ if(sendbuf != MPI_IN_PLACE)
+ CHECK_TYPE(3, sendtype)
+ CHECK_TYPE(6, recvtype)
+ CHECK_NULL(5, MPI_ERR_COUNT, recvcounts)
+ CHECK_NULL(6, MPI_ERR_ARG, displs)
+ if(sendbuf != MPI_IN_PLACE)
+ CHECK_COUNT(2, sendcount)
+ CHECK_REQUEST(9)
+ for (int i = 0; i < comm->size(); i++) {
+ CHECK_COUNT(5, recvcounts[i])
+ CHECK_BUFFER(4, recvbuf, recvcounts[i])