From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:38682) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S6kFH-0003Nm-7q for qemu-devel@nongnu.org; Sun, 11 Mar 2012 10:59:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S6kFF-0004sv-DE for qemu-devel@nongnu.org; Sun, 11 Mar 2012 10:59:38 -0400 Received: from mail-we0-f173.google.com ([74.125.82.173]:64173) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S6kFF-0004sm-49 for qemu-devel@nongnu.org; Sun, 11 Mar 2012 10:59:37 -0400 Received: by werp12 with SMTP id p12so3034288wer.4 for ; Sun, 11 Mar 2012 07:59:35 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <4F5CBDD3.1010101@redhat.com> Date: Sun, 11 Mar 2012 15:59:31 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <1331430564-32745-1-git-send-email-mjt@msgid.tls.msk.ru> <1331430564-32745-4-git-send-email-mjt@msgid.tls.msk.ru> In-Reply-To: <1331430564-32745-4-git-send-email-mjt@msgid.tls.msk.ru> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCHv2 3/7] consolidate qemu_iovec_copy() and qemu_iovec_concat() and make them consistent List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Michael Tokarev Cc: qemu-devel@nongnu.org Il 11/03/2012 02:49, Michael Tokarev ha scritto: > qemu_iovec_concat() is currently a wrapper for qemu_iovec_copy(), > use the former (with extra "0" arg) in a few places where it is used. > > Change skip argument of qemu_iovec_copy() from uint64_t to size_t, > since size of qiov itself is size_t, so there's no way to skip larger > sizes. Rename it to soffset, to make it clear that the offset > is applied to src. > > Also change the only usage of uint64_t in hw/9pfs/virtio-9p.c, in > v9fs_init_qiov_from_pdu() - all callers of it actually uses size_t > too, not uint64_t. > > Semantic change in the meaning of `count' (now renamed to `sbytes') > argument. Initial comment said that src is copied to dst until > _total_ size is less than specified, so it might be interpreted > as maximum size of the _dst_ vector. Actual meaning of if was > that total amount of skipped and copied bytes should not exceed > `count'. Make it just the amount of bytes to _copy_, without > counting skipped bytes. This makes it consistent with other > iovec functions, and also matches actual _usage_ of this function. > > Order of argumens is already good: > qemu_iovec_memset(QEMUIOVector *qiov, size_t offset, int c, size_t bytes) > vs: > qemu_iovec_concat(QEMUIOVector *dst, QEMUIOVector *src, size_t soffset, size_t sbytes) > (note soffset is after _src_ not dst, since it applies to src; > for memset it applies to qiov). > > Note that in many places where this function is used, the previous > call is qemu_iovec_reset(), which means many callers actually want > copy (replacing dst content), not concat. So we may want to add a > paramere to allow resetting dst in one go. Yes, this initially left me a bit confused. Let's add a new function qemu_iovec_copy that does reset+concat. Paolo