From patchwork Wed Mar 27 16:36:30 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 231750 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 16E8E2C009F for ; Thu, 28 Mar 2013 03:40:27 +1100 (EST) Received: from localhost ([::1]:58110 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UKtOg-0002yq-SB for incoming@patchwork.ozlabs.org; Wed, 27 Mar 2013 12:40:22 -0400 Received: from eggs.gnu.org ([208.118.235.92]:45659) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UKtLG-0006OU-8O for qemu-devel@nongnu.org; Wed, 27 Mar 2013 12:36:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UKtLC-0002tW-No for qemu-devel@nongnu.org; Wed, 27 Mar 2013 12:36:50 -0400 Received: from mail-ea0-x22c.google.com ([2a00:1450:4013:c01::22c]:53430) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UKtLC-0002st-Ff for qemu-devel@nongnu.org; Wed, 27 Mar 2013 12:36:46 -0400 Received: by mail-ea0-f172.google.com with SMTP id z7so1856402eaf.3 for ; Wed, 27 Mar 2013 09:36:45 -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=uD6lxkuAOKaC41g5V3AptQjIz1L8Z8g5xrAvBLfolAk=; b=mVmoQ520KrVQV88okj5XkA+IE+2W1chAouqb72cN6oOyAjnVpaZ2cok8LradR4L7pD 5XVTfFIl2NbWg4reiy21RA4LRVXpi17TrYXfby1KXk7lJtYBA7Re8lUMWSRB4hy+rik4 e9fv4dfUb7XnrdjhmsJRxi7m4Yqxe6XmTJrbE2bmkja5vGqAz1vg5Z0fp1qT4qzWlHko wvqIDymsnYSzcMc6doklgC0pdBStv2T9or3F/OHDvVFtAgxz4gbO50wZyxFprVO5iLhK hDhUrVEVAf2ed9boGjqPFKq3dbozyNbTHZ/oLDVQqMIcIL+QKGWSDFW6+nIazeeNzEGY N5DA== X-Received: by 10.15.111.202 with SMTP id cj50mr17240887eeb.6.1364402205611; Wed, 27 Mar 2013 09:36:45 -0700 (PDT) Received: from playground.lan (93-34-176-20.ip50.fastwebnet.it. [93.34.176.20]) by mx.google.com with ESMTPS id d47sm32366397eem.9.2013.03.27.09.36.43 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 27 Mar 2013 09:36:44 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Wed, 27 Mar 2013 17:36:30 +0100 Message-Id: <1364402192-18169-5-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1364402192-18169-1-git-send-email-pbonzini@redhat.com> References: <1364402192-18169-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::22c 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. Signed-off-by: Paolo Bonzini Reviewed-by: Juan Quintela --- 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;