From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:34010) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S7WS9-00085k-Cd for qemu-devel@nongnu.org; Tue, 13 Mar 2012 14:28:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S7WS7-0004Aq-JX for qemu-devel@nongnu.org; Tue, 13 Mar 2012 14:28:08 -0400 Received: from isrv.corpit.ru ([86.62.121.231]:54632) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S7WS7-0004Ad-CD for qemu-devel@nongnu.org; Tue, 13 Mar 2012 14:28:07 -0400 Message-ID: <4F5F91B4.8040201@msgid.tls.msk.ru> Date: Tue, 13 Mar 2012 22:28:04 +0400 From: Michael Tokarev MIME-Version: 1.0 References: <1331579663-29950-1-git-send-email-mjt@msgid.tls.msk.ru> <1331579663-29950-2-git-send-email-mjt@msgid.tls.msk.ru> <4F5F878E.4080408@redhat.com> In-Reply-To: <4F5F878E.4080408@redhat.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCHv3 1/9] refresh iov_* functions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: qemu-devel@nongnu.org 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