From patchwork Wed Apr 17 09:46:50 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 237188 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 46D2E2C015A for ; Wed, 17 Apr 2013 19:47:47 +1000 (EST) Received: from localhost ([::1]:32820 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1USOxt-0006Qv-E9 for incoming@patchwork.ozlabs.org; Wed, 17 Apr 2013 05:47:45 -0400 Received: from eggs.gnu.org ([208.118.235.92]:39327) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1USOxI-0006NN-Nw for qemu-devel@nongnu.org; Wed, 17 Apr 2013 05:47:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1USOxH-0002Dn-Go for qemu-devel@nongnu.org; Wed, 17 Apr 2013 05:47:08 -0400 Received: from mail-ea0-x231.google.com ([2a00:1450:4013:c01::231]:52176) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1USOxH-0002Dh-Ax for qemu-devel@nongnu.org; Wed, 17 Apr 2013 05:47:07 -0400 Received: by mail-ea0-f177.google.com with SMTP id q14so627239eaj.22 for ; Wed, 17 Apr 2013 02:47:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=xmEkweNgvaSaT1YoAHtPbcVWdgTR+mQw+WXQ9FvtUHY=; b=K3+iPFeDzNciJeL9ejUy12x1sZ6BoeYesq3oEkfo1QK8UQQYWyHGdm+2AvgYrITOYi 6GzI8i2NGILjiLhIaoufrfuT8xLbB/dDgw0++jtvfjU7PS7zVHWSrxuWsLe77kTrj0W5 OPlpTtM+L7EGoiV4dajSvivkGE4H/kW224/6Z/V3sIJm4mJvL7iKh3+8r6lbGI/WD1hR dQ3oolfDvDQtPw6D3nF6Hm4j1+nzlFUEx1M8QhfxCsKaQEIuQJtwz18emmnpKWGwMl/x 60S+4vIPtNTv397z8yBUq0TrMkpJ27nv8cmHsfdjMf+V9v73btdfOJtbBI+Pt6jSSm0G 6PTA== X-Received: by 10.14.107.69 with SMTP id n45mr16477469eeg.23.1366192026610; Wed, 17 Apr 2013 02:47:06 -0700 (PDT) Received: from playground.lan (93-34-176-20.ip50.fastwebnet.it. [93.34.176.20]) by mx.google.com with ESMTPS id w51sm7697038eev.13.2013.04.17.02.47.04 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 17 Apr 2013 02:47:05 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Wed, 17 Apr 2013 11:46:50 +0200 Message-Id: <1366192012-14872-5-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1366192012-14872-1-git-send-email-pbonzini@redhat.com> References: <1366192012-14872-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4013:c01::231 Cc: owasserm@redhat.com, quintela@redhat.com Subject: [Qemu-devel] [PATCH 4/6] iov: reorganize iov_send_recv, part 3 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org "si" and "ei" are merged in a single variable. Reviewed-by: Juan Quintela Reviewed-by: Orit Wassermann Signed-off-by: Paolo Bonzini --- util/iov.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/util/iov.c b/util/iov.c index 110d18e..f14ff0b 100644 --- a/util/iov.c +++ b/util/iov.c @@ -146,7 +146,7 @@ ssize_t iov_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt, { ssize_t ret; size_t orig_len, tail; - unsigned si, ei; /* start and end indexes */ + unsigned niov; if (bytes == 0) { /* Catch the do-nothing case early, as otherwise we will pass an @@ -158,15 +158,15 @@ ssize_t iov_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt, /* Find the start position, skipping `offset' bytes: * first, skip all full-sized vector elements, */ - for (si = 0; si < iov_cnt && offset >= iov[si].iov_len; ++si) { - offset -= iov[si].iov_len; + for (niov = 0; niov < iov_cnt && offset >= iov[niov].iov_len; ++niov) { + offset -= iov[niov].iov_len; } - /* si == iov_cnt would only be valid if bytes == 0, which + /* niov == iov_cnt would only be valid if bytes == 0, which * we already ruled out above. */ - assert(si < iov_cnt); - iov += si; - iov_cnt -= si; + assert(niov < iov_cnt); + iov += niov; + iov_cnt -= niov; if (offset) { /* second, skip `offset' bytes from the (now) first element, @@ -177,23 +177,23 @@ ssize_t iov_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt, /* Find the end position skipping `bytes' bytes: */ /* first, skip all full-sized elements */ tail = bytes; - for (ei = 0; ei < iov_cnt && iov[ei].iov_len <= tail; ++ei) { - tail -= iov[ei].iov_len; + for (niov = 0; niov < iov_cnt && iov[niov].iov_len <= tail; ++niov) { + tail -= iov[niov].iov_len; } if (tail) { /* second, fixup the last element, and remember the original * length */ - assert(ei < iov_cnt); - assert(iov[ei].iov_len > tail); - orig_len = iov[ei].iov_len; - iov[ei++].iov_len = tail; + assert(niov < iov_cnt); + assert(iov[niov].iov_len > tail); + orig_len = iov[niov].iov_len; + iov[niov++].iov_len = tail; } - ret = do_send_recv(sockfd, iov, ei, do_send); + ret = do_send_recv(sockfd, iov, niov, do_send); /* Undo the changes above */ if (tail) { - iov[ei-1].iov_len = orig_len; + iov[niov-1].iov_len = orig_len; } if (offset) { iov[0].iov_base -= offset;