From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:40645) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S7VmK-000300-QZ for qemu-devel@nongnu.org; Tue, 13 Mar 2012 13:45:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S7VmG-0002wm-6T for qemu-devel@nongnu.org; Tue, 13 Mar 2012 13:44:56 -0400 Received: from mail-ee0-f45.google.com ([74.125.83.45]:52373) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S7VmF-0002wS-Tf for qemu-devel@nongnu.org; Tue, 13 Mar 2012 13:44:52 -0400 Received: by eeit10 with SMTP id t10so534740eei.4 for ; Tue, 13 Mar 2012 10:44:49 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <4F5F878E.4080408@redhat.com> Date: Tue, 13 Mar 2012 18:44:46 +0100 From: Paolo Bonzini 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> In-Reply-To: <1331579663-29950-2-git-send-email-mjt@msgid.tls.msk.ru> 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: Michael Tokarev Cc: qemu-devel@nongnu.org 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). > + 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. Paolo