[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCHv3 1/9] refresh iov_* functions
From: |
Michael Tokarev |
Subject: |
Re: [Qemu-devel] [PATCHv3 1/9] refresh iov_* functions |
Date: |
Tue, 13 Mar 2012 22:28:04 +0400 |
User-agent: |
Mozilla/5.0 (X11; Linux i686 on x86_64; rv:8.0) Gecko/20120216 Icedove/8.0 |
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
- [Qemu-devel] [PATCHv3 0/9] cleanup/consolidate some iovec functions, Michael Tokarev, 2012/03/12
- [Qemu-devel] [PATCHv3 2/9] consolidate qemu_iovec_memset{, _skip}() into single function and use existing iov_memset(), Michael Tokarev, 2012/03/12
- [Qemu-devel] [PATCHv3 1/9] refresh iov_* functions, Michael Tokarev, 2012/03/12
- [Qemu-devel] [PATCHv3 4/9] consolidate qemu_iovec_copy() and qemu_iovec_concat() and make them consistent, Michael Tokarev, 2012/03/12
- [Qemu-devel] [PATCHv3 5/9] change qemu_iovec_to_buf() to match other to, from_buf functions, Michael Tokarev, 2012/03/12
- [Qemu-devel] [PATCHv3 8/9] cleanup qemu_co_sendv(), qemu_co_recvv() and friends, Michael Tokarev, 2012/03/12
- [Qemu-devel] [PATCHv3 7/9] export qemu_sendv_recvv() and use it in qemu_sendv() and qemu_recvv(), Michael Tokarev, 2012/03/12
- [Qemu-devel] [PATCHv3 3/9] allow qemu_iovec_from_buffer() to specify offset from which to start copying, Michael Tokarev, 2012/03/12