- if(incount<0){
- return MPI_ERR_COUNT;
- } else if(inbuf==nullptr || outbuf==nullptr || outcount < 0){
- return MPI_ERR_ARG;
- } else if (type == MPI_DATATYPE_NULL || not type->is_valid()){
- return MPI_ERR_TYPE;
- } else if(comm==MPI_COMM_NULL){
- return MPI_ERR_COMM;
- } else {
- return type->pack(inbuf == MPI_BOTTOM ? nullptr : inbuf, incount, outbuf, outcount, position, comm);
- }
+ CHECK_NEGATIVE(2, MPI_ERR_COUNT, incount)
+ CHECK_NEGATIVE(5, MPI_ERR_COUNT, outcount)
+ CHECK_BUFFER(1, inbuf, incount)
+ CHECK_BUFFER(4, outbuf, outcount)
+ CHECK_TYPE(6, type)
+ CHECK_COMM(7)
+ return type->pack(inbuf == MPI_BOTTOM ? nullptr : inbuf, incount, outbuf, outcount, position, comm);