From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:39607) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TGHge-0006SH-Bi for qemu-devel@nongnu.org; Mon, 24 Sep 2012 19:03:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TGHgd-0005aO-3B for qemu-devel@nongnu.org; Mon, 24 Sep 2012 19:03:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:64605) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TGHgc-0005aF-Rm for qemu-devel@nongnu.org; Mon, 24 Sep 2012 19:03:35 -0400 Date: Tue, 25 Sep 2012 01:04:50 +0200 From: "Michael S. Tsirkin" Message-ID: <0a5b42d30237d61a9c1d14c599ddd62f7b98db3d.1348527749.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Subject: [Qemu-devel] [PATCH 07/14] virtio-net: first s/g is always at start of buf List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, Jason Wang , Anthony Liguori , stefanha@linux.vnet.ibm.com, aurelien@aurel32.net We know offset is 0, assert that. Signed-off-by: Michael S. Tsirkin --- hw/virtio-net.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hw/virtio-net.c b/hw/virtio-net.c index 3a0d1a7..6e6f5f3 100644 --- a/hw/virtio-net.c +++ b/hw/virtio-net.c @@ -630,6 +630,7 @@ static ssize_t virtio_net_receive(NetClientState *nc, const uint8_t *buf, size_t } if (i == 0) { + assert(offset == 0); if (n->mergeable_rx_bufs) { mhdr_cnt = iov_cpy(mhdr_sg, ARRAY_SIZE(mhdr_sg), sg, elem.in_num, @@ -637,8 +638,8 @@ static ssize_t virtio_net_receive(NetClientState *nc, const uint8_t *buf, size_t sizeof(mhdr.num_buffers)); } - receive_header(n, sg, elem.in_num, buf + offset, size - offset); - offset += n->host_hdr_len; + receive_header(n, sg, elem.in_num, buf, size); + offset = n->host_hdr_len; total += n->guest_hdr_len; guest_offset = n->guest_hdr_len; } else { -- MST