On 13.03.2012 21:44, Paolo Bonzini wrote: > Il 12/03/2012 20:14, Michael Tokarev ha scritto: >> + for (i = 0, done = 0; done < bytes && i < iov_cnt; i++) { >> + if (offset < iov[i].iov_len) { >> + size_t len = MIN(iov[i].iov_len - offset, bytes - done); >> + memcpy(iov[i].iov_base + offset, buf + done, len); >> + done += len; >> + offset = 0; >> + } else { >> + offset -= iov[i].iov_len; >> } >> - iovec_off += iov[i].iov_len; >> } >> - return buf_off; >> + assert(offset == 0); > > This needs to be assert(offset == 0 || done == 0).
Nope. All these functions actually allow to specify very large value for `bytes' (and I suggested using -1 for it to mean "up to the end"). Only offset must be within the iovec. >> + return done; > > Otherwise looks good, but I must say I do not like changing the API > *and* the implementation in the same patch. It seems like a > bisectability nightmare (and reviewing nightmare, too). I do prefer > your new code though. I changed it all to be the same and actually verified. Sure I can split it into two patches -- that should be easy, will do that in a moment... Just like I did with qemu_sendv_recvv(). The whole thing is just trivial but.. ;) Thank you for the review! > Paolo /mjt