diff --git a/src/posix/platform/hdlc_interface.cpp b/src/posix/platform/hdlc_interface.cpp index 4a3aa2a30..27c59b6e3 100644 --- a/src/posix/platform/hdlc_interface.cpp +++ b/src/posix/platform/hdlc_interface.cpp @@ -235,16 +235,18 @@ otError HdlcInterface::Write(const uint8_t *aFrame, uint16_t aLength) { ssize_t rval = write(mSockFd, aFrame, aLength); - if (rval > 0) + if (rval == aLength) + { + break; + } + else if (rval > 0) { aLength -= static_cast(rval); aFrame += static_cast(rval); - continue; } - - if ((rval < 0) && (errno != EAGAIN) && (errno != EWOULDBLOCK) && (errno != EINTR)) + else if (rval < 0) { - DieNow(OT_EXIT_ERROR_ERRNO); + VerifyOrDie((errno == EAGAIN) || (errno == EWOULDBLOCK) || (errno == EINTR), OT_EXIT_ERROR_ERRNO); } SuccessOrExit(error = WaitForWritable());